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


C++ PyCObject_FromVoidPtrAndDesc函数代码示例

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


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

示例1: __Pyx_ExportFunction

static int __Pyx_ExportFunction(char *n, void *f, char *s) {
	PyObject *d = 0;
	PyObject *p = 0;
	d = PyObject_GetAttrString(__pyx_m, "__pyx_capi__");
	if (!d) {
		PyErr_Clear();
		d = PyDict_New();
		if (!d)
			goto bad;
		Py_INCREF(d);
		if (PyModule_AddObject(__pyx_m, "__pyx_capi__", d) < 0)
			goto bad;
	}
	p = PyCObject_FromVoidPtrAndDesc(f, s, 0);
	if (!p)
		goto bad;
	if (PyDict_SetItemString(d, n, p) < 0)
		goto bad;
	Py_DECREF(p);
	Py_DECREF(d);
	return 0;
bad:
	Py_XDECREF(p);
	Py_XDECREF(d);
	return -1;
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:26,代码来源:l_capi.c

示例2: SWIG_Python_NewPointerObj

/* Create a new pointer object */
static PyObject *
SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
  PyObject *robj;
  if (!ptr) {
    Py_INCREF(Py_None);
    return Py_None;
  }
#ifdef SWIG_COBJECT_TYPES
  robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL);
#else
  {
    char result[1024];
    SWIG_Python_PointerStr(result, ptr, type->name, 1024);
    robj = PyString_FromString(result);
  }
#endif
  if (!robj || (robj == Py_None)) return robj;
  if (type->clientdata) {
    PyObject *inst;
    PyObject *args = Py_BuildValue((char*)"(O)", robj);
    Py_DECREF(robj);
    inst = PyObject_CallObject((PyObject *) type->clientdata, args);
    Py_DECREF(args);
    if (inst) {
      if (own) {
        PyObject_SetAttrString(inst,(char*)"thisown",Py_True);
      }
      robj = inst;
    }
  }
  return robj;
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:33,代码来源:wrap_LOCA_TimeDependent.C

示例3: INITFUNC

INITFUNC (void)
{
    PyObject *m;
    PyObject *d;

    nysets_heapdefs[0].type = &NyMutBitSet_Type;
    nysets_heapdefs[1].type = &NyCplBitSet_Type;
    nysets_heapdefs[2].type = &NyNodeSet_Type;

    m = Py_InitModule(MODNAME, module_methods);
    if (!m)
      goto Error;
    d = PyModule_GetDict(m);
    if (fsb_dx_nybitset_init(m) == -1)
      goto Error;
    if (fsb_dx_nynodeset_init(m) == -1)
      goto Error;
    if (PyDict_SetItemString(d, "__doc__", PyString_FromString(sets_doc)) == -1)
      goto Error;
    if (PyDict_SetItemString(d,
			 "_NyHeapDefs_",
			 PyCObject_FromVoidPtrAndDesc(
						      &nysets_heapdefs,
						      "NyHeapDef[] v1.0",
						      0)
			 ) == -1)
      goto Error;
    return;
  Error:
    if (PyErr_Occurred() == NULL)
      PyErr_SetString(PyExc_ImportError, "module initialization failed");
}
开发者ID:15580056814,项目名称:hue,代码行数:32,代码来源:sets.c

示例4: symbolic

static PyObject* symbolic(PyObject *self, PyObject *args)
{
    spmatrix *A;
    double info[UMFPACK_INFO];
    void *symbolic;

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

    if (!SpMatrix_Check(A)) PY_ERR_TYPE("A must be a sparse matrix");
    if (SP_NCOLS(A) == 0 || SP_NROWS(A) == 0) {
        PyErr_SetString(PyExc_ValueError, "A must have at least one "
            "row and column");
        return NULL;
    }

    switch (SP_ID(A)){
        case DOUBLE:
            UMFD(symbolic)(SP_NROWS(A), SP_NCOLS(A), SP_COL(A),
                SP_ROW(A), SP_VAL(A), &symbolic, NULL, info);
            if (info[UMFPACK_STATUS] == UMFPACK_OK)
#if PY_MAJOR_VERSION >= 3
                return (PyObject *) PyCapsule_New( (void *) symbolic, 
                    "UMFPACK SYM D FACTOR", 
                    (PyCapsule_Destructor) &free_umfpack_d_symbolic);  
#else
                return (PyObject *) PyCObject_FromVoidPtrAndDesc(
                    (void *) symbolic, "UMFPACK SYM D FACTOR",
                    free_umfpack_d_symbolic);
#endif
            else
                UMFD(free_symbolic)(&symbolic);
            break;

        case COMPLEX:
            UMFZ(symbolic)(SP_NROWS(A), SP_NCOLS(A), SP_COL(A),
                SP_ROW(A), SP_VAL(A), NULL, &symbolic, NULL, info);
            if (info[UMFPACK_STATUS] == UMFPACK_OK)
#if PY_MAJOR_VERSION >= 3
                return (PyObject *) PyCapsule_New(
                    (void *) symbolic, "UMFPACK SYM Z FACTOR",
                    (PyCapsule_Destructor) &free_umfpack_z_symbolic);
#else
                return (PyObject *) PyCObject_FromVoidPtrAndDesc(
                    (void *) symbolic, "UMFPACK SYM Z FACTOR",
                    free_umfpack_z_symbolic);
#endif
            else
开发者ID:MGKhKhD,项目名称:cvxopt,代码行数:47,代码来源:umfpack.c

示例5: Py_INCREF

PyObject *wrap_xmlNodeSetPtr(xmlNodeSetPtr nset) {
  PyObject *ret;

  if (nset == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) nset, (char *) "xmlNodeSetPtr", NULL);
  return (ret);
}
开发者ID:adrianobalani,项目名称:AssinaturaDigitalNFE,代码行数:10,代码来源:wrap_objs.c

示例6: Py_INCREF

PyObject *wrap_xmlSecTransformId(xmlSecTransformId transformId) {
  PyObject *ret;

  if (transformId == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) transformId,
				     (char *) "xmlSecTransformId", NULL);
  return (ret);
}
开发者ID:badbole,项目名称:sh,代码行数:11,代码来源:transforms.c

示例7: put_handle

static PyObject *
put_handle (hive_h *h)
{
  assert (h);
#ifndef HAVE_PYCAPSULE_NEW
  return
    PyCObject_FromVoidPtrAndDesc ((void *) h, (char *) "hive_h", NULL);
#else
  return PyCapsule_New ((void *) h, "hive_h", NULL);
#endif
}
开发者ID:coriolis,项目名称:hivex,代码行数:11,代码来源:hivex-py.c

示例8: Py_INCREF

PyObject *wrap_xmlSecKeyDataStorePtr(xmlSecKeyDataStorePtr store) {
  PyObject *ret;

  if (store == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) store,
				     (char *) "xmlSecKeyDataStorePtr", NULL);
  return (ret);
}
开发者ID:dnet,项目名称:pyxmlsec,代码行数:11,代码来源:keysdata.c

示例9: Py_INCREF

PyObject *wrap_xmlSecBufferPtr(xmlSecBufferPtr buf) {
  PyObject *ret;

  if (buf == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) buf,
				     (char *) "xmlSecBufferPtr", NULL);
  return (ret);
}
开发者ID:DeltaOS,项目名称:pyxmlsec,代码行数:11,代码来源:buffer.c

示例10: Py_INCREF

PyObject *wrap_xmlSecPtrListId(xmlSecPtrListId listId) {
  PyObject *ret;

  if (listId == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) listId,
				     (char *) "xmlSecPtrListId", NULL);
  return (ret);
}
开发者ID:DeltaOS,项目名称:pyxmlsec,代码行数:11,代码来源:list.c

示例11: Py_INCREF

PyObject *wrap_xmlSecKeysMngrPtr(xmlSecKeysMngrPtr mngr) {
  PyObject *ret;

  if (mngr == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) mngr,
				     (char *) "xmlSecKeysMngrPtr", NULL);
  return (ret);
}
开发者ID:dnet,项目名称:pyxmlsec,代码行数:11,代码来源:keysmngr.c

示例12: Py_INCREF

PyObject *wrap_xmlSecBase64CtxPtr(xmlSecBase64CtxPtr ctx) {
  PyObject *ret;

  if (ctx == NULL) {
    Py_INCREF(Py_None);
    return (Py_None);
  }
  ret = PyCObject_FromVoidPtrAndDesc((void *) ctx,
				     (char *) "xmlSecBase64CtxPtr", NULL);
  return (ret);
}
开发者ID:dnet,项目名称:pyxmlsec,代码行数:11,代码来源:base64.c

示例13: initpointless

PyMODINIT_FUNC
initpointless(void)
{
	if (sizeof(Word_t) != sizeof(void*)) {
		PyErr_SetString(PyExc_ValueError, "word size mismatch");
		return;
	}

	PyObject* module_pointless = 0;

	if ((module_pointless = Py_InitModule4("pointless", pointless_methods, "Pointless Python API", 0, PYTHON_API_VERSION)) == 0)
		return;

	struct {
		PyTypeObject* type;
		const char* name;
	} types[13] = {
		{&PyPointlessType,               "Pointless"               },
		{&PyPointlessVectorType,         "PointlessVector"         },
		{&PyPointlessVectorIterType,     "PointlessVectorIter"     },
		{&PyPointlessBitvectorType,      "PointlessBitvector"      },
		{&PyPointlessBitvectorIterType,  "PointlessBitvectorIter"  },
		{&PyPointlessSetType,            "PointlessSet"            },
		{&PyPointlessSetIterType,        "PointlessSetIter"        },
		{&PyPointlessMapType,            "PointlessMap"            },
		{&PyPointlessMapKeyIterType,     "PointlessMapKeyIter"     },
		{&PyPointlessMapValueIterType,   "PointlessMapValueIter"   },
		{&PyPointlessMapItemIterType,    "PointlessMapItemIter"    },
		{&PyPointlessPrimVectorType,     "PointlessPrimVector"     },
		{&PyPointlessPrimVectorIterType, "PointlessPrimVectorIter" }
	};

	int i;

	for (i = 0; i < 13; i++) {
		if (PyType_Ready(types[i].type) < 0)
			return;

		Py_INCREF((PyObject*)types[i].type);

		if (PyModule_AddObject(module_pointless, types[i].name, (PyObject*)types[i].type) != 0)
			return;
	}

	PyObject* c_api = PyCObject_FromVoidPtrAndDesc(&CAPI, (void*)POINTLESS_API_MAGIC, NULL);

	if (c_api == 0)
		return;

	if (PyModule_AddObject(module_pointless, "pointless_CAPI", c_api) != 0)
		return;
}
开发者ID:dohop,项目名称:py-pointless,代码行数:52,代码来源:pointless_ext.c

示例14: instantiate

//////////////////////
////  Functions
//////////////////////
static PyObject * instantiate(PyObject * self, PyObject *argtuple) {
  assert(PyTuple_Check(argtuple));
  if (3 != PyTuple_Size(argtuple)){ 
     PyErr_Format(PyExc_TypeError, "Wrong number of arguments, expected 3, got %i", (int)PyTuple_Size(argtuple));
     return NULL;
  }
  __struct_compiled_op_23bd09edf362672f31013a9d03547767* struct_ptr = new __struct_compiled_op_23bd09edf362672f31013a9d03547767();
  if (struct_ptr->init( PyTuple_GET_ITEM(argtuple, 0),PyTuple_GET_ITEM(argtuple, 1),PyTuple_GET_ITEM(argtuple, 2) ) != 0) {
    delete struct_ptr;
    return NULL;
  }
  PyObject* thunk = PyCObject_FromVoidPtrAndDesc((void*)(&__struct_compiled_op_23bd09edf362672f31013a9d03547767_executor), struct_ptr, __struct_compiled_op_23bd09edf362672f31013a9d03547767_destructor);
  return thunk; }
开发者ID:ejake,项目名称:tensor-factorization,代码行数:16,代码来源:mod.cpp

示例15: instantiate

//////////////////////
////  Functions
//////////////////////
static PyObject * instantiate(PyObject * self, PyObject *argtuple) {
  assert(PyTuple_Check(argtuple));
  if (3 != PyTuple_Size(argtuple)){ 
     PyErr_Format(PyExc_TypeError, "Wrong number of arguments, expected 3, got %i", (int)PyTuple_Size(argtuple));
     return NULL;
  }
  __struct_compiled_op_ddde6ae9a09770eed554831e9a1050c2* struct_ptr = new __struct_compiled_op_ddde6ae9a09770eed554831e9a1050c2();
  if (struct_ptr->init( PyTuple_GET_ITEM(argtuple, 0),PyTuple_GET_ITEM(argtuple, 1),PyTuple_GET_ITEM(argtuple, 2) ) != 0) {
    delete struct_ptr;
    return NULL;
  }
  PyObject* thunk = PyCObject_FromVoidPtrAndDesc((void*)(&__struct_compiled_op_ddde6ae9a09770eed554831e9a1050c2_executor), struct_ptr, __struct_compiled_op_ddde6ae9a09770eed554831e9a1050c2_destructor);
  return thunk; }
开发者ID:liyong3forever,项目名称:Theano-LSTM,代码行数:16,代码来源:mod.cpp


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