• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyCFunction_New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AUD_initPython

PyObject* AUD_initPython()
{
	PyObject* module = PyInit_aud();
	PyModule_AddObject(module, "device", (PyObject*)PyCFunction_New(meth_getcdevice, NULL));
	PyModule_AddObject(module, "_sound_from_pointer", (PyObject*)PyCFunction_New(meth_sound_from_pointer, NULL));
	PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module);

	return module;
}
开发者ID:HVisionSensing,项目名称:blendocv,代码行数:9,代码来源:AUD_C-API.cpp


示例2: init_mergesort

void init_mergesort(void) {
    import_array();
    import_ufunc();
	m = Py_InitModule3("_mergesort", module_methods, "mergesort module for parallel mergesort");
	PyObject * mergefunc = PyCFunction_New(module_methods, NULL);
	PyObject * argmergefunc = PyCFunction_New(module_methods + 1, NULL);
	PyObject * permutefunc = PyCFunction_New(module_methods + 2, NULL);
	PyObject * reorderdtypefunc = PyCFunction_New(module_methods + 3, NULL);
	PyModule_AddObject(m, "merge", mergefunc);
	PyModule_AddObject(m, "argmerge", argmergefunc);
	PyModule_AddObject(m, "permute", permutefunc);
	PyModule_AddObject(m, "reorderdtype", reorderdtypefunc);
}
开发者ID:StevenLOL,项目名称:sharedmem,代码行数:13,代码来源:_mergesort.c


示例3: SIP_MLNAME_CAST

// Decorate the method now the arguments have been parsed.
static PyObject *decorate(Chimera::Signature *parsed_sig, PyObject *res_obj,
        const char *context)
{
    // Parse any result type.
    if (res_obj)
    {
        parsed_sig->result = Chimera::parse(res_obj);

        if (!parsed_sig->result)
        {
            Chimera::raiseParseException(res_obj, context);
            delete parsed_sig;
            return 0;
        }
    }

    // Wrap the parsed signature in a Python object.
    PyObject *sig_obj = Chimera::Signature::toPyObject(parsed_sig);

    if (!sig_obj)
        return 0;

    // Create the decorator function itself.  We stash the arguments in "self".
    // This may be an abuse, but it seems to be Ok.
    static PyMethodDef deco_method = {
        SIP_MLNAME_CAST("_deco"), decorator, METH_O, 0
    };

    PyObject *obj = PyCFunction_New(&deco_method, sig_obj);
    Py_DECREF(sig_obj);

    return obj;
}
开发者ID:EntityFXCode,项目名称:arsenalsuite,代码行数:34,代码来源:qpycore_pyqtslot.cpp


示例4: init_scope

void init_scope(void) {
  PyMethodDef *def;

  PyObject *module=Py_InitModule("_scope", ModuleMethods);
  PyObject *moduleDict=PyModule_GetDict(module);
  PyObject *classDict=PyDict_New();
  PyObject *className = PyString_FromString("Scopeable");
  PyObject *scopeableClass = PyClass_New(NULL, classDict, className);
  PyDict_SetItemString(moduleDict, "Scopeable", scopeableClass);
  Py_DECREF(classDict);
  Py_DECREF(className);
  Py_DECREF(scopeableClass);

  for (def = ScopeableMethods; def->ml_name != NULL; def++) {
    PyObject *func=PyCFunction_New(def, NULL);
    PyObject *method= PyMethod_New(func, NULL, scopeableClass);
    PyDict_SetItemString(classDict, def->ml_name, method);
    /* 
     * this would normally happen in PyClass_New() if the classDict
     * were already populated; but I'm passing it an empty dict
     */
    if (!strncmp(def->ml_name, "__getattr__", strlen("__getattr__"))) {
      ((PyClassObject *)scopeableClass)->cl_getattr=method;
    }
    Py_DECREF(func);
    Py_DECREF(method);
  }
}
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:28,代码来源:_scope.c


示例5: PyCFunction_New

	PyObject * function_python::create_function_adapter( const function_adapter_interface_ptr & _adapter, bool _native )
	{
		uint32_t arity = _adapter->getArity();
		
		PyMethodDef * method;
		
		if( _native == true )
		{
			method = &m_method_native;
		}
		else
		{
			if( arity > 0 )
			{
				method = &m_method_args;
			}
			else
			{
				method = &m_method_noargs;
			}
		}

		py_function_type * py_self = (py_function_type *)PyType_GenericAlloc( &m_function_type, 0 );

		stdex::intrusive_ptr_setup( py_self->iadapter, _adapter );

		PyObject * py_func = PyCFunction_New( method, (PyObject*)py_self );
		Py_DECREF( (PyObject *)py_self );

		return py_func;
	}
开发者ID:irov,项目名称:pybind,代码行数:31,代码来源:function_python.cpp


示例6: PyCFunction_New

//-------------------------------------------------------------------------------------
void EntityMailbox::onInstallScript(PyObject* mod)
{
	static PyMethodDef __unpickle__Method = {"Mailbox", (PyCFunction)&EntityMailbox::__unpickle__, METH_VARARGS, 0};
	PyObject* pyFunc = PyCFunction_New(&__unpickle__Method, NULL);
	script::Pickler::registerUnpickleFunc(pyFunc, "Mailbox");
	Py_DECREF(pyFunc);
}
开发者ID:guozanhua,项目名称:kbengine,代码行数:8,代码来源:entity_mailbox.cpp


示例7: Py_BuildValue

static PyObject *ffi_callback(FFIObject *self, PyObject *args, PyObject *kwds)
{
    PyObject *c_decl, *python_callable = Py_None, *error = Py_None;
    PyObject *res, *onerror = Py_None;
    static char *keywords[] = {"cdecl", "python_callable", "error",
                               "onerror", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", keywords,
                                     &c_decl, &python_callable, &error,
                                     &onerror))
        return NULL;

    c_decl = (PyObject *)_ffi_type(self, c_decl, ACCEPT_STRING | ACCEPT_CTYPE |
                                                 CONSIDER_FN_AS_FNPTR);
    if (c_decl == NULL)
        return NULL;

    args = Py_BuildValue("(OOOO)", c_decl, python_callable, error, onerror);
    if (args == NULL)
        return NULL;

    if (python_callable != Py_None) {
        res = b_callback(NULL, args);
    }
    else {
        static PyMethodDef md = {"callback_decorator",
                                 (PyCFunction)_ffi_callback_decorator, METH_O};
        res = PyCFunction_New(&md, args);
    }
    Py_DECREF(args);
    return res;
}
开发者ID:RBPI,项目名称:real-python-test,代码行数:32,代码来源:ffi_obj.c


示例8: Py_FindMethodInChain

PyObject *
Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, const char *name)
{
    if (name[0] == '_' && name[1] == '_') {
        if (strcmp(name, "__methods__") == 0) {
            if (PyErr_WarnPy3k("__methods__ not supported in 3.x",
                               1) < 0)
                return NULL;
            return listmethodchain(chain);
        }
        if (strcmp(name, "__doc__") == 0) {
            const char *doc = self->ob_type->tp_doc;
            if (doc != NULL)
                return PyString_FromString(doc);
        }
    }
    while (chain != NULL) {
        PyMethodDef *ml = chain->methods;
        for (; ml->ml_name != NULL; ml++) {
            if (name[0] == ml->ml_name[0] &&
                strcmp(name+1, ml->ml_name+1) == 0)
                /* XXX */
                return PyCFunction_New(ml, self);
        }
        chain = chain->link;
    }
    PyErr_SetString(PyExc_AttributeError, name);
    return NULL;
}
开发者ID:0xcc,项目名称:python-read,代码行数:29,代码来源:methodobject.c


示例9: init_Missing

void
init_Missing(void)
{
  PyObject *m, *d;

  if(! ((vname=PyString_FromString("V"))
	&& (Missing_dot_Value=PyString_FromString("Missing.Value"))
	&& (empty_string=PyString_FromString(""))
	)) return;

  /* Create the module and add the functions */
  m = Py_InitModule4("_Missing", Module_Level__methods,
		     Missing_module_documentation,
		     (PyObject*)NULL,PYTHON_API_VERSION);

  /* Add some symbolic constants to the module */
  d = PyModule_GetDict(m);

  PyExtensionClass_Export(d,"Missing",MissingType);

  theValue = PyObject_CallObject((PyObject*)&MissingType, NULL);
  notMissing = PyObject_CallObject((PyObject*)&MissingType, NULL);
  reduce=PyCFunction_New(reduce_ml, theValue);

  PyDict_SetItemString(d, "Value", theValue);
  PyDict_SetItemString(d, "V", theValue);
  PyDict_SetItemString(d, "MV", theValue);
  PyDict_SetItemString(d, "notMissing", notMissing);
}
开发者ID:jean,项目名称:Missing,代码行数:29,代码来源:_Missing.c


示例10: PyCFunction_New

//-------------------------------------------------------------------------------------
void FixedArray::onInstallScript(PyObject* mod)
{
	static PyMethodDef __unpickle__Method = {"FixedArray", (PyCFunction)&FixedArray::__unpickle__, METH_VARARGS, 0};
	PyObject* pyFunc = PyCFunction_New(&__unpickle__Method, NULL);
	script::Pickler::registerUnpickleFunc(pyFunc, "FixedArray");
	Py_DECREF(pyFunc);
}
开发者ID:waluoo,项目名称:kbengine,代码行数:8,代码来源:fixedarray.cpp


示例11: rpcErrorClass

PyObject *
rpcErrorClass(void)
{
	PyObject	*klass,
			*dict,
			*func,
			*meth;
	PyMethodDef	*method;

	dict = PyDict_New();
	if (dict == NULL)
		return (NULL);
	klass = PyErr_NewException("xmlrpc.error", NULL, dict);
	if (klass == NULL)
		return (NULL);
	for (method = rpcErrorMethods; method->ml_name != NULL; method++) {
		func = PyCFunction_New(method, NULL);
		if (func == NULL)
			return (NULL);
		meth = PyMethod_New(func, NULL, klass);
		if (meth == NULL)
			return (NULL);
		if (PyDict_SetItemString(dict, method->ml_name, meth))
			return (NULL);
		Py_DECREF(meth);
		Py_DECREF(func);
	}
	return (klass);
}
开发者ID:Zemanta,项目名称:py-xmlrpc,代码行数:29,代码来源:rpcError.c


示例12: PyErr_SetString

static PyObject *ffi_new_allocator(FFIObject *self, PyObject *args,
                                   PyObject *kwds)
{
    PyObject *allocator, *result;
    PyObject *my_alloc = Py_None, *my_free = Py_None;
    int should_clear_after_alloc = 1;
    static char *keywords[] = {"alloc", "free", "should_clear_after_alloc",
                               NULL};
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOi:new_allocator", keywords,
                                     &my_alloc, &my_free,
                                     &should_clear_after_alloc))
        return NULL;

    if (my_alloc == Py_None && my_free != Py_None) {
        PyErr_SetString(PyExc_TypeError, "cannot pass 'free' without 'alloc'");
        return NULL;
    }

    allocator = PyTuple_Pack(4,
                             (PyObject *)self,
                             my_alloc,
                             my_free,
                             PyBool_FromLong(should_clear_after_alloc));
    if (allocator == NULL)
        return NULL;

    {
        static PyMethodDef md = {"allocator",
                                 (PyCFunction)_ffi_new_with_allocator,
                                 METH_VARARGS | METH_KEYWORDS};
        result = PyCFunction_New(&md, allocator);
    }
    Py_DECREF(allocator);
    return result;
}
开发者ID:tharvik,项目名称:cffi,代码行数:35,代码来源:ffi_obj.c


示例13: atkrole_export_funcs

/**
 * Exports the different atk_role* functions into the module.
 */
void
atkrole_export_funcs (PyObject *module)
{
    int i = 0;
    PyObject *func;

    static PyMethodDef methods[] = { 
        { "atk_role_get_name", _role_get_name, METH_VARARGS,
          "atk_role_get_name (role) -> string\n\n"
          "Gets the description string describing the AtkRole role." },
        { "atk_role_get_localized_name", _role_get_localized_name,
          METH_VARARGS,
          "atk_role_get_localized_name (role) -> string\n\n"
          "Gets the localized description string describing the AtkRole role."
        },
        { "atk_role_for_name", _role_for_name, METH_VARARGS,
          "atk_role_for_name (name) -> int\n\n"
          "Get the AtkRole type corresponding to a role name." },
        { "atk_role_register", _role_register, METH_VARARGS,
          "atk_role_register (name) -> int\n\n"
          "Registers the role specified by name." },
        { NULL, NULL, 0, NULL }
    };

    while (methods[i].ml_name != NULL)
    {
        func = PyCFunction_New (&methods[i], NULL);
        PyObject_SetAttrString (module, methods[i].ml_name, func);
        i++;
    }
}
开发者ID:prim,项目名称:ocempgui,代码行数:34,代码来源:papi_atkrole.c


示例14: PyInit_gpu

PyObject *GPU_initPython(void)
{
	PyObject *module = PyInit_gpu();
	PyModule_AddObject(module, "export_shader", (PyObject *)PyCFunction_New(meth_export_shader, NULL));
	PyDict_SetItemString(PyImport_GetModuleDict(), "gpu", module);

	return module;
}
开发者ID:244xiao,项目名称:blender,代码行数:8,代码来源:gpu.c


示例15: BPY_atexit_register

void BPY_atexit_register(void)
{
	/* atexit module owns this new function reference */
	BLI_assert(func_bpy_atregister == NULL);

	func_bpy_atregister= (PyObject *)PyCFunction_New(&meth_bpy_atexit, NULL);
	atexit_func_call("register", func_bpy_atregister);
}
开发者ID:mik0001,项目名称:Blender,代码行数:8,代码来源:bpy_interface_atexit.c


示例16: BPY_rna_id_collection_module

int BPY_rna_id_collection_module(PyObject *mod_par)
{
	static PyMethodDef user_map = {
	    "user_map", (PyCFunction)bpy_user_map, METH_VARARGS | METH_KEYWORDS, bpy_user_map_doc};

	PyModule_AddObject(mod_par, "_rna_id_collection_user_map", PyCFunction_New(&user_map, NULL));

	return 0;
}
开发者ID:diekev,项目名称:blender,代码行数:9,代码来源:bpy_rna_id_collection.c


示例17: method_get

static PyObject *
method_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
{
	PyObject *res;

	if (descr_check((PyDescrObject *)descr, obj, &res))
		return res;
	return PyCFunction_New(descr->d_method, obj);
}
开发者ID:develersrl,项目名称:dspython,代码行数:9,代码来源:descrobject.c


示例18: PyCFunction_New

//-------------------------------------------------------------------------------------
void ScriptVector2::onInstallScript(PyObject* mod)
{
	static PyMethodDef __unpickle__Method = {"Vector2", (PyCFunction)&ScriptVector2::__unpickle__, METH_VARARGS, 0};
	PyObject* pyFunc = PyCFunction_New(&__unpickle__Method, NULL);
	script::Pickler::registerUnpickleFunc(pyFunc, "Vector2");
	Py_DECREF(pyFunc);
	ScriptVector2::_scriptType.tp_as_number = &ScriptVector2::numberMethods;
	// ScriptVector2::_scriptType.tp_reserved = tp_compare;
	ScriptVector2::_scriptType.tp_name = "Vector2";
}
开发者ID:1564143452,项目名称:kbengine,代码行数:11,代码来源:vector2.cpp


示例19: start

int start(int argc, wchar_t **argv)
{
	int rc;
	PyObject *mod;
	PySys_SetArgvEx(argc, argv, 0);

	mod = PyImport_ImportModule("sys");
	if (mod) {
		PyObject_SetAttrString(mod,
				       method[0].ml_name,
				       PyCFunction_New(&method[0], NULL));
		PyObject_SetAttrString(mod,
				       method[1].ml_name,
				       PyCFunction_New(&method[1], NULL));
	}

	rc = run_script();
	fini();
	return rc;
}
开发者ID:ABI-Software,项目名称:py2exe,代码行数:20,代码来源:start.c


示例20: LDAPadd_methods

void
LDAPadd_methods( PyObject* d, PyMethodDef* methods ) 
{
    PyMethodDef *meth;

    for( meth = methods; meth->ml_meth; meth++ ) {
        PyObject *f = PyCFunction_New( meth, NULL );
        PyDict_SetItemString( d, meth->ml_name, f );
        Py_DECREF(f);
    }
}
开发者ID:18600597055,项目名称:hue,代码行数:11,代码来源:common.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyCObject_AsVoidPtr函数代码示例发布时间:2022-05-30
下一篇:
C++ PyCFunction_Check函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap