当前位置: 首页>>代码示例>>C++>>正文


C++ PyCObject_Check函数代码示例

本文整理汇总了C++中PyCObject_Check函数的典型用法代码示例。如果您正苦于以下问题:C++ PyCObject_Check函数的具体用法?C++ PyCObject_Check怎么用?C++ PyCObject_Check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PyCObject_Check函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PyBool_FromLong

static PyObject *authGSSServerHasDelegated(PyObject *self, PyObject *args)
{
    gss_server_state *state;
    PyObject *pystate;

    if (!PyArg_ParseTuple(args, "O", &pystate))
        return NULL;

    if (!PyCObject_Check(pystate)) {
        PyErr_SetString(PyExc_TypeError, "Expected a context object");
        return NULL;
    }

    state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
    if (state == NULL)
        return NULL;

    return PyBool_FromLong(authenticate_gss_server_has_delegated(state));
}
开发者ID:prashanthpai,项目名称:PyKerberos,代码行数:19,代码来源:kerberos.c

示例2: Py_BuildValue

static PyObject *authGSSClientResponseConf(PyObject *self, PyObject *args)
{
    gss_client_state *state;
    PyObject *pystate;

    if (!PyArg_ParseTuple(args, "O", &pystate))
        return NULL;

    if (!PyCObject_Check(pystate)) {
        PyErr_SetString(PyExc_TypeError, "Expected a context object");
        return NULL;
    }

    state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
    if (state == NULL)
        return NULL;

    return Py_BuildValue("i", state->responseConf);
}
开发者ID:prashanthpai,项目名称:PyKerberos,代码行数:19,代码来源:kerberos.c

示例3: pythonTrace

  int pythonTrace(PyObject* mobj, PyFrameObject *mframe, int mwhat, PyObject *marg) {
    // DBG("Python trace\n");
    IvrPython* pIvrPython = 0; //getIvrPythonPointer();
    if (mobj != NULL){
      if (PyCObject_Check(mobj)) {
	  pIvrPython = (IvrPython*)PyCObject_AsVoidPtr(mobj);
	  //	  Py_DECREF(mobj);
      }
    }

    if (pIvrPython) {
      AmEventQueue* evq = pIvrPython->getScriptEventQueue();
      if (evq)
	evq->processEvents();
    } else {
      ERROR("IvrPython pointer not found in Trace!\n");
      return 1;
    }
    return 0; 
  }
开发者ID:BackupTheBerlios,项目名称:semsivr,代码行数:20,代码来源:IvrPython.cpp

示例4: pf_init

static PyObject *
pf_init(PyObject *self, PyObject *args)
{
    PyObject *pyobj, *pyarray, *py_posparams;
    double period_tolerance;
    struct s_param *params;
    struct pfHandle *pfh;
    double pos_params[N_PARAMS];

    if(!PyArg_ParseTuple(
	   args,"OdOO",&pyobj,&period_tolerance,&py_posparams, &pyarray))
    {
	return NULL;
    }
    if(!PyCObject_Check(pyobj))
    {
	PyErr_SetString(PyExc_ValueError,"Not a valid handle");
	return NULL;
    }

    pfh = (struct pfHandle *)PyCObject_AsVoidPtr(pyobj);

    if(!parse_posparams(py_posparams, pos_params))
    {
	return NULL;
    }

    int len=0;
    params = parse_params(pyarray,&len);
    if(!params)
    {
	return NULL;
    }

    /*finally all args are assembled */
    pfh->pfo->vtbl->init(pfh->pfo,period_tolerance,pos_params,params,len);
    free(params);

    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:Bookaa,项目名称:gnofract4d.simplify,代码行数:41,代码来源:fract4dmodule_gmp.cpp

示例5: mlabraw_oldeval

PyObject * mlabraw_oldeval(PyObject *, PyObject *args)
{
  //XXX how large should this be?
  const int  BUFSIZE=10000;
  char buffer[BUFSIZE];
  char *lStr;
  char *retStr = buffer;
  PyObject *ret;
  PyObject *lHandle;

  if (! PyArg_ParseTuple(args, "Os:eval", &lHandle, &lStr)) return NULL;
  if (! PyCObject_Check(lHandle)) {
    PyErr_SetString(PyExc_TypeError, "Invalid object passed as mlabraw session handle");
    return NULL;
  }
  engOutputBuffer((Engine *)PyCObject_AsVoidPtr(lHandle), retStr, BUFSIZE-1);
  if (engEvalString((Engine *)PyCObject_AsVoidPtr(lHandle), lStr) != 0) {
    PyErr_SetString(mlabraw_error,
                   "Unable to evaluate string in MATLAB(TM) workspace");
    return NULL;
  }
  // skip the prompt if there is one
  if (strncmp(">> ", retStr, 3) == 0) {
    retStr += 3;
  }
  else {
    //XXX I think there is no prompt under windoze
//     printf("###DEBUG: matlab output doesn't start with \">> \"!\n"
//            "It starts with: '%s'\n"
//            "The command was: '%s'\n", retStr, lStr);
  }
  // "??? " is how an error message begins in matlab
  // obviously there is no proper way to test whether a command was
  // succesful... AAARGH
  if (strncmp("??? ", retStr, 4) == 0) {
    PyErr_SetString(mlabraw_error, retStr + 4); // skip "??? "
    return NULL;
  }
  ret = (PyObject *)PyString_FromString(retStr);
  return ret;
}
开发者ID:ericjsolis,项目名称:danapeerlab,代码行数:41,代码来源:mlabraw.cpp

示例6: pyglib_init

void
pyglib_init(void)
{
    PyObject *glib, *cobject;
    
    glib = PyImport_ImportModule("glib");
    if (!glib) {
	if (PyErr_Occurred()) {
	    PyObject *type, *value, *traceback;
	    PyObject *py_orig_exc;
	    PyErr_Fetch(&type, &value, &traceback);
	    py_orig_exc = PyObject_Repr(value);
	    Py_XDECREF(type);
	    Py_XDECREF(value);
	    Py_XDECREF(traceback);
	    PyErr_Format(PyExc_ImportError,
			 "could not import glib (error was: %s)",
			 _PyUnicode_AsString(py_orig_exc));
	    Py_DECREF(py_orig_exc);
        } else {
	    PyErr_SetString(PyExc_ImportError,
			    "could not import glib (no error given)");
	}
	return;
    }
    
    cobject = PyObject_GetAttrString(glib, "_PyGLib_API");
    if (cobject && PyCObject_Check(cobject))
	_PyGLib_API = (struct _PyGLib_Functions *) PyCObject_AsVoidPtr(cobject);
    else {
	PyErr_SetString(PyExc_ImportError,
			"could not import glib (could not find _PyGLib_API object)");
	Py_DECREF(glib);
	return;
    }

    _PyGMainContext_Type = (PyTypeObject*)PyObject_GetAttrString(glib, "MainContext");
    _PyGOptionGroup_Type = (PyTypeObject*)PyObject_GetAttrString(glib, "OptionGroup");
    _PyGOptionContext_Type = (PyTypeObject*)PyObject_GetAttrString(glib, "OptionContext");
}
开发者ID:tizenorg,项目名称:platform.upstream.pygobject2,代码行数:40,代码来源:pyglib.c

示例7: do_get_time_by_index

static PyObject *
do_get_time_by_index (PyObject *self, PyObject *args, PyObject *kwds)
{
    NsLibrary      *lib;
    PyObject       *cobj;
    PyObject       *iobj, *id_obj, *idx_obj;
    uint32          file_id;
    uint32          entity_id;
    uint32          index;
    double          timepoint;
    ns_RESULT       res;

    if (!PyArg_ParseTuple (args, "OOOO", &cobj, &iobj, &id_obj, &idx_obj))
    {
        PyErr_SetString (PyExc_StandardError, "Could not parse arguments");
        return NULL;
    }

    if (!PyCObject_Check (cobj) || !PyInt_Check (iobj) ||
            !PyInt_Check (id_obj) || !PyInt_Check (idx_obj))
    {
        PyErr_SetString (PyExc_TypeError, "Wrong argument type(s)");
        return NULL;
    }

    lib = PyCObject_AsVoidPtr (cobj);
    file_id = (uint32) PyInt_AsUnsignedLongMask (iobj);
    entity_id = (uint32) PyInt_AsUnsignedLongMask (id_obj);
    index = (uint32) PyInt_AsUnsignedLongMask (idx_obj);

    res = lib->GetTimeByIndex (file_id,
                               entity_id,
                               index,
                               &timepoint);

    if (check_result_is_error (res, lib))
        return NULL;

    return Py_BuildValue ("d", timepoint);
}
开发者ID:jthorniley,项目名称:python-neuroshare,代码行数:40,代码来源:nspy_glue.c

示例8: PyArg_ParseTuple

static PyObject *pattern_get_class(PyObject *self,      PyObject *args)
{
  int ok=true;
  int int1;
  PyObject *result = NULL;
  PyObject *O,*l1,*l2;
  CChamp *I;
  ListPat *pat;
  ListAtom *at;
  ListBond *bd;
  int a,b;
  int n_atom,n_bond;
  ok = PyArg_ParseTuple(args,"Oi",&O,&int1);
  ok = PyCObject_Check(O);
  if(ok) {
    I = PyCObject_AsVoidPtr(O);
    pat = I->Pat+int1;
    
    n_atom = ListLen(I->Atom,pat->atom);
    at = I->Atom + pat->atom;
    l1 = PyList_New(n_atom);
    for(a=0;a<n_atom;a++) {
      PyList_SetItem(l1,a,PyInt_FromLong(at->class));
      at = I->Atom + at->link;
    }

    n_bond = ListLen(I->Bond,pat->bond);
    l2 = PyList_New(n_bond);
    bd = I->Bond + pat->bond;
    for(b=0;b<n_bond;b++) {
      PyList_SetItem(l2,b,PyInt_FromLong(bd->class));
      bd = I->Bond + bd->link;
    }

    result = PyList_New(2);
    PyList_SetItem(result,0,l1);
    PyList_SetItem(result,1,l2);
  }
  return(RetObj(ok,result));
}
开发者ID:dprada,项目名称:pymol-open-source,代码行数:40,代码来源:champ_module.c

示例9: Py_BuildValue

static PyObject *authGSSServerTargetName(PyObject *self, PyObject *args)
{
    gss_server_state *state;
    PyObject *pystate;
    
    if (! PyArg_ParseTuple(args, "O", &pystate)) {
        return NULL;
    }
    
    if (! PyCObject_Check(pystate)) {
        PyErr_SetString(PyExc_TypeError, "Expected a context object");
        return NULL;
    }
    
    state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);

    if (state == NULL) {
        return NULL;
    }
    
    return Py_BuildValue("s", state->targetname);
}
开发者ID:veerakumar123,项目名称:tomcat,代码行数:22,代码来源:kerberos.c

示例10: pf_calc

static PyObject *
pf_calc(PyObject *self, PyObject *args)
{
    PyObject *pyobj, *pyret;
    double params[4];
    struct pfHandle *pfh; 
    int nIters, x=0,y=0,aa=0;
    int outIters=0, outFate=-777;
    double outDist=0.0;
    int outSolid=0;
    int fDirectColorFlag=0;
    double colors[4] = {0.0, 0.0, 0.0, 0.0};

    if(!PyArg_ParseTuple(args,"O(dddd)i|iii",
			 &pyobj,
			 &params[0],&params[1],&params[2],&params[3],
			 &nIters,&x,&y,&aa))
    {
	return NULL;
    }
    if(!PyCObject_Check(pyobj))
    {
	PyErr_SetString(PyExc_ValueError,"Not a valid handle");
	return NULL;
    }

    pfh = (struct pfHandle *)PyCObject_AsVoidPtr(pyobj);
#ifdef DEBUG_THREADS
    printf("%p : PF : CALC\n",pfh);
#endif
    pfh->pfo->vtbl->calc(pfh->pfo,params,
			 nIters, -1,
			 x,y,aa,
			 &outIters,&outFate,&outDist,&outSolid,
			 &fDirectColorFlag, &colors[0]);
    assert(outFate != -777);
    pyret = Py_BuildValue("iidi",outIters,outFate,outDist,outSolid);
    return pyret; // Python can handle errors if this is NULL
}
开发者ID:Bookaa,项目名称:gnofract4d.simplify,代码行数:39,代码来源:fract4dmodule_gmp.cpp

示例11: authGSSClientInit

static PyObject* authGSSClientInit(PyObject* self, PyObject* args, PyObject* keywds)
{
    const char *service = NULL;
    const char *principal = NULL;
    gss_client_state *state;
    PyObject *pystate;
    gss_server_state *delegatestate = NULL;
    PyObject *pydelegatestate;
    static char *kwlist[] = {
        "service", "principal", "gssflags", "delegated", NULL
    };
    long int gss_flags = GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG;
    int result = 0;

    if (! PyArg_ParseTupleAndKeywords(
        args, keywds, "s|slO", kwlist,
        &service, &principal, &gss_flags, &pydelegatestate
    )) {
        return NULL;
    }

    state = (gss_client_state *) malloc(sizeof(gss_client_state));
    pystate = PyCObject_FromVoidPtr(state, NULL);

    if (PyCObject_Check(pydelegatestate)) {
        delegatestate = PyCObject_AsVoidPtr(pydelegatestate);
    }

    result = authenticate_gss_client_init(
        service, principal, gss_flags, delegatestate, state
    );

    if (result == AUTH_GSS_ERROR) {
        return NULL;
    }

    return Py_BuildValue("(iO)", result, pystate);
}
开发者ID:veerakumar123,项目名称:tomcat,代码行数:38,代码来源:kerberos.c

示例12: Py_BuildValue

static PyObject *authGSSImpersonationCleanCtx(PyObject *self, PyObject *args)
{
    gss_impers_state *state;
    PyObject *pystate;
    int result = 0;

    if (!PyArg_ParseTuple(args, "O", &pystate))
        return NULL;

    if (!PyCObject_Check(pystate)) {
        PyErr_SetString(PyExc_TypeError, "Expected a context object");
        return NULL;
    }

    state = (gss_impers_state *)PyCObject_AsVoidPtr(pystate);
    if (state != NULL)
    {
        result = authenticate_gss_impers_cleanctx(state);

    }

    return Py_BuildValue("i", result);
}
开发者ID:may-day,项目名称:s4u2p,代码行数:23,代码来源:s4u2p.c

示例13: _get_array_interface

static int
_get_array_interface(PyObject *obj,
		     PyObject **cobj_p,
		     PyArrayInterface **inter_p)
{
    if (!(*cobj_p = PyObject_GetAttrString(obj, "__array_struct__"))) {
	if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
		PyErr_Clear();
		PyErr_SetString(PyExc_ValueError,
				"no C-struct array interface");
	    }
	return 0;
    }

    if (!PyCObject_Check(*cobj_p) ||  /* conditional 'or's */
	!(*inter_p = PyCObject_AsVoidPtr(*cobj_p)) ||
	(*inter_p)->two != 2) {
	Py_DECREF(*cobj_p);
	PyErr_SetString(PyExc_ValueError, "invalid array interface");
	return 0;
    }
    return 1;
}
开发者ID:Abstak,项目名称:Mastermind_Python,代码行数:23,代码来源:_arraysurfarray.c

示例14: IvrDialogBase_new

// Constructor
static PyObject* IvrDialogBase_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
  static char *kwlist[] = {"ivr_dlg", NULL};
  IvrDialogBase *self;

  self = (IvrDialogBase *)type->tp_alloc(type, 0);
  if (self != NULL) {
	
    PyObject* o_dlg = NULL;
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &o_dlg)){
	    
      Py_DECREF(self);
      return NULL;
    }
    
    if (!PyCObject_Check(o_dlg)){
	    
      Py_DECREF(self);
      return NULL;
    }
	
    self->p_dlg = (IvrDialog*)PyCObject_AsVoidPtr(o_dlg);
	
    // initialize self.dialog
    self->dialog = IvrSipDialog_FromPtr(&self->p_dlg->dlg);

    if(!self->dialog){
      PyErr_Print();
      ERROR("IvrDialogBase: while creating IvrSipDialog instance\n");
      Py_DECREF(self);
      return NULL;
    }
  }

  DBG("IvrDialogBase_new\n");
  return (PyObject *)self;
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:38,代码来源:IvrDialogBase.cpp

示例15: headerNew

/* TODO: permit keyring check + retrofits on copy/load */
static PyObject *hdr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
{
    PyObject *obj = NULL;
    rpmfdObject *fdo = NULL;
    Header h = NULL;
    char *kwlist[] = { "obj", NULL };

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &obj)) {
	return NULL;
    }

    if (obj == NULL) {
	h = headerNew();
    } else if (PyCObject_Check(obj)) {
	h = PyCObject_AsVoidPtr(obj);
    } else if (hdrObject_Check(obj)) {
	h = headerCopy(((hdrObject*) obj)->h);
    } else if (PyBytes_Check(obj)) {
	h = headerCopyLoad(PyBytes_AsString(obj));
    } else if (rpmfdFromPyObject(obj, &fdo)) {
	Py_BEGIN_ALLOW_THREADS;
	h = headerRead(rpmfdGetFd(fdo), HEADER_MAGIC_YES);
	Py_END_ALLOW_THREADS;
	Py_XDECREF(fdo);
    } else {
    	PyErr_SetString(PyExc_TypeError, "header, blob or file expected");
	return NULL;
    }

    if (h == NULL) {
	PyErr_SetString(pyrpmError, "bad header");
	return NULL;
    }
    
    return hdr_Wrap(subtype, h);
}
开发者ID:kaltsi,项目名称:rpm,代码行数:37,代码来源:header-py.c


注:本文中的PyCObject_Check函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。