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

C++ Py_InitModule3函数代码示例

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

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



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

示例1: inittradesocket

PyMODINIT_FUNC inittradesocket(void)
{
	Py_InitModule3("tradesocket", tradesocket_methods, tradesocket__doc__);
}
开发者ID:DeadWisdom,项目名称:Sovereign,代码行数:4,代码来源:tradesocket.c


示例2: initwave2d_cfunc

PyMODINIT_FUNC initwave2d_cfunc() {
	Py_InitModule3("wave2d_cfunc", wave2d_cfunc_methods, module_doc);
	import_array();
}
开发者ID:wbkifun,项目名称:my_stuff,代码行数:4,代码来源:wave2d-cfunc-sse-openmp.c


示例3: initRadialVelocity

//initialise the module
PyMODINIT_FUNC 
initRadialVelocity(void)
{
    (void) Py_InitModule3("RadialVelocity", RadialVelocityMethods, "Radial vel docstring...");
    import_array(); //must be present for numpy stuff
}
开发者ID:OxES,项目名称:MyFuncs,代码行数:7,代码来源:RadialVelocity.c


示例4: initguiQt

PyMODINIT_FUNC
initguiQt(void) {
	PyEval_InitThreads(); /* Start the interpreter's thread-awareness */

	if(PyType_Ready(&QtGuiObject_Type) < 0) {
		Py_FatalError("Can't initialize QtGuiObject type");
		return;
	}

	PyObject* m = Py_InitModule3("guiQt", module_methods, module_doc);
	if(!m) {
		Py_FatalError("Can't initialize guiQt module");
		return;		
	}
	
	bool fail = false;

	if(PyModule_AddObject(m, "QtGuiObject", (PyObject*) &QtGuiObject_Type) != 0)
		fail = true;

	iterControlTypes([&](const std::string& controlType, ControlBuilderFunc builderFunc) {
		struct PythonWrapper {
			std::string controlType;
			ControlBuilderFunc builderFunc;
			PyObject* operator()(PyObject* args, PyObject* kw) {
				PyObject* control = NULL;
				if(!PyArg_ParseTuple(args, ("O:buildControl" + controlType).c_str(), &control))
					return NULL;
				if(!PyType_IsSubtype(Py_TYPE(control), &QtGuiObject_Type)) {
					PyErr_Format(PyExc_ValueError, "guiQt.buildControl%s: we expect a QtGuiObject", controlType.c_str());
					return NULL;
				}
				PyQtGuiObject* guiObject = (PyQtGuiObject*) control;
				bool res = builderFunc(guiObject);
				if(!res)
					// XXX: handle somehow? ...
					printf("guiQt.buildControl%s: warning, returned error\n", controlType.c_str());

				Py_INCREF(control);
				return control;
			}
		};
		PythonWrapper wrapper;
		wrapper.controlType = controlType;
		wrapper.builderFunc = builderFunc;
		PyObject* funcObj = (PyObject*) newFunctionWrapper(wrapper);
		if(!funcObj) {
			fail = true;
			return;
		}
		if(PyModule_AddObject(m, ("builControl" + controlType).c_str(), funcObj) != 0)
			fail = true;
	});

	if(fail) {
		if(PyErr_Occurred())
			PyErr_Print();
		
		Py_FatalError("guiQt module init error");
	}
}
开发者ID:albertz,项目名称:music-player,代码行数:61,代码来源:PythonInterface.cpp


示例5: init_svgview

PyMODINIT_FUNC init_svgview() {
  Py_InitModule3("_svgview", _viewer_methods, "");
  rsvg_init();
  g_thread_init(NULL);
  gdk_threads_init();
}
开发者ID:chinnurtb,项目名称:cassius,代码行数:6,代码来源:_svgview.c


示例6: init_phono4py

PyMODINIT_FUNC init_phono4py(void)
{
  Py_InitModule3("_phono4py", functions, "C-extension for phono4py\n\n...\n");
  return;
}
开发者ID:arbegla,项目名称:phonopy,代码行数:5,代码来源:_phono4py.c


示例7: initEfiCompressor

PyMODINIT_FUNC
initEfiCompressor(VOID) {
  Py_InitModule3("EfiCompressor", EfiCompressor_Funcs, "EFI Compression Algorithm Extension Module");
}
开发者ID:AbnerChang,项目名称:edk2-staging,代码行数:4,代码来源:EfiCompressor.c


示例8: initangie_c

/* Init module function */
void initangie_c(void)
{
    //printf("ANGIE [optimized, c] module was initialized!\n");
    Py_InitModule3("angie_c", angie_c_funcs,
                   "ANGIE");
}
开发者ID:JacekPierzchlewski,项目名称:PaTeS,代码行数:7,代码来源:angie_c.c


示例9: init_laplacian

PyMODINIT_FUNC init_laplacian(void)
{
	Py_InitModule3("_laplacian", _functions, "Second degree Laplacian edge detection accelerator module.");

}
开发者ID:AndrejScak,项目名称:arsoapi,代码行数:5,代码来源:_laplacian.c


示例10: init_ExtensionClass

PyMODINIT_FUNC
init_ExtensionClass(void)
{
  PyObject *m, *s;

  if (pickle_setup() < 0)
    return;

#define DEFINE_STRING(S) \
  if(! (str ## S = PyString_FromString(# S))) return

  DEFINE_STRING(__of__);
  DEFINE_STRING(__get__);
  DEFINE_STRING(__class_init__);
  DEFINE_STRING(__init__);
  DEFINE_STRING(__bases__);
  DEFINE_STRING(__mro__);
  DEFINE_STRING(__new__);
#undef DEFINE_STRING

  PyExtensionClassCAPI = &TrueExtensionClassCAPI;

  ExtensionClassType.ob_type = &PyType_Type;
  ExtensionClassType.tp_base = &PyType_Type;
  ExtensionClassType.tp_basicsize = PyType_Type.tp_basicsize;
  ExtensionClassType.tp_traverse = PyType_Type.tp_traverse;
  ExtensionClassType.tp_clear = PyType_Type.tp_clear;
  
  /* Initialize types: */
  if (PyType_Ready(&ExtensionClassType) < 0)
    return;

  BaseType.ob_type = &ExtensionClassType;
  BaseType.tp_base = &PyBaseObject_Type;
  BaseType.tp_basicsize = PyBaseObject_Type.tp_basicsize;
  BaseType.tp_new = PyType_GenericNew;

  if (PyType_Ready(&BaseType) < 0)
    return;

  NoInstanceDictionaryBaseType.ob_type = &ExtensionClassType;
  NoInstanceDictionaryBaseType.tp_base = &BaseType;
  NoInstanceDictionaryBaseType.tp_basicsize = BaseType.tp_basicsize;
  NoInstanceDictionaryBaseType.tp_new = PyType_GenericNew;

  if (PyType_Ready(&NoInstanceDictionaryBaseType) < 0)
    return;
  
  /* Create the module and add the functions */
  m = Py_InitModule3("_ExtensionClass", ec_methods,
                     _extensionclass_module_documentation);

  if (m == NULL)
    return;

  s = PyCObject_FromVoidPtr(PyExtensionClassCAPI, NULL);
  if (PyModule_AddObject(m, "CAPI2", s) < 0)
    return;
        
  /* Add types: */
  if (PyModule_AddObject(m, "ExtensionClass", 
                         (PyObject *)&ExtensionClassType) < 0)
    return;
  if (PyModule_AddObject(m, "Base", (PyObject *)&BaseType) < 0)
    return;
  if (PyModule_AddObject(m, "NoInstanceDictionaryBase", 
                         (PyObject *)&NoInstanceDictionaryBaseType) < 0)
    return;
}
开发者ID:goschtl,项目名称:zope,代码行数:69,代码来源:_ExtensionClass.c


示例11: initedit_distance

 void initedit_distance(void) {
      PyObject *m = Py_InitModule3(module_name, module_methods,
                                   module_docstring);
      if (m == NULL)
           return;
 }
开发者ID:scrapinghub,项目名称:page_finder,代码行数:6,代码来源:edit_distance.c


示例12: main

int main(int argc, char *argv[]) {
	std::cout << "C++: This is process: " <<  getpid() << std::endl;

	
    PyObject *pName, *pModule, *pFunc; //, *pDict, ;
    PyObject *pValue; // *pArgs,
    // int i;

	std::string module("python6");
	std::string function("run_now");

	// Initilize Python
    Py_Initialize();
    
	/* NameObjectType.tp_new = PyType_GenericNew;
	if (PyType_Ready(&NameObjectType) < 0) {
		PyErr_Print();
		fprintf(stderr, "Type not ready - PyType_Ready\n");
		return 1;
	} */

 
	PyTypeObject* type_object = create_type_object();
	if (PyType_Ready(type_object) < 0) {
		PyErr_Print();
		fprintf(stderr, "Type not ready - PyType_Ready\n");
		free_type_object(type_object);
		return 1;
	}

	PyObject* m = Py_InitModule3("name", NULL, "XXX");
	if (!m) {
		PyErr_Print();
		fprintf(stderr, "Failed to load initilize module - Py_InitModule3\n");
		free_type_object(type_object);
		return 1;
	}

	/*Py_INCREF(&NameObjectType);
	PyModule_AddObject(m, "Name", (PyObject *)&NameObjectType);*/

	Py_INCREF(type_object);
	PyModule_AddObject(m, "Name", (PyObject*)type_object);
	
	
    // Load module python2.py
    pName = PyString_FromString(module.c_str()); 					// Error checking of pName left out
    pModule = PyImport_Import(pName);
    Py_DECREF(pName);
    if (!pModule) {
		PyErr_Print();
		fprintf(stderr, "Failed to load \"%s\"\n", argv[1]);
		free_type_object(type_object);
		return 1;
	}

	// Get the python fuction to call
    pFunc = PyObject_GetAttrString(pModule, function.c_str()); 		// pFunc is a new reference 
    if (!pFunc || !PyCallable_Check(pFunc)) {
        if (PyErr_Occurred())
            PyErr_Print();
        fprintf(stderr, "Cannot find function \"%s\"\n", argv[2]);
	    Py_XDECREF(pFunc);
	    Py_DECREF(pModule);
		free_type_object(type_object);
        return 1;
    }

    // Make the call to the python function
    pValue = PyObject_CallObject(pFunc, NULL);
    if (!pValue) {
        PyErr_Print();
        fprintf(stderr,"Call failed\n");
        Py_DECREF(pFunc);
        Py_DECREF(pModule);
		free_type_object(type_object);
        return 1;
    }

	// Show the result of the python call
    printf("Result of call: %ld\n", PyInt_AsLong(pValue)); 
    
    // Decrease counters for python garbage collection
    Py_DECREF(pValue);
    Py_XDECREF(pFunc);
    Py_DECREF(pModule);
    
	std::cout << "Before Py_Finalize()" << std::endl;
	
    // Clean up python
    Py_Finalize();
    
	free_type_object(type_object);
    
	std::cout << "Freeing the allocated memory" << std::endl;
		
    return 0;
}
开发者ID:colmsjo,项目名称:TradeServer,代码行数:98,代码来源:python6.cpp


示例13: initmpatch

PyMODINIT_FUNC
initmpatch(void)
{
	Py_InitModule3("mpatch", methods, mpatch_doc);
	mpatch_Error = PyErr_NewException("mpatch.mpatchError", NULL, NULL);
}
开发者ID:Distrotech,项目名称:mercurial,代码行数:6,代码来源:mpatch.c


示例14: init_spglib

PyMODINIT_FUNC init_spglib(void)
{
  Py_InitModule3("_spglib", functions, "C-extension for spglib\n\n...\n");
  return;
}
开发者ID:arbegla,项目名称:phonopy,代码行数:5,代码来源:_spglib.c


示例15: initdefault_encoding_utf8

PyMODINIT_FUNC
initdefault_encoding_utf8(void) 
{
    PyUnicode_SetDefaultEncoding("utf-8");
    Py_InitModule3("default_encoding_utf8", methods, "Forces the default encoding to utf-8");
}
开发者ID:OndrejSlamecka,项目名称:setroubleshoot,代码行数:6,代码来源:default_encoding.c


示例16: init_perlin

void
init_perlin(void)
{
	Py_InitModule3("_perlin", perlin_functions, module_doc);
}
开发者ID:caseman,项目名称:noise,代码行数:5,代码来源:_perlin.c


示例17: initred

PyMODINIT_FUNC initred(void) {
    Py_InitModule3("red", methods, NULL);
}
开发者ID:asottile,项目名称:go-python-module-example,代码行数:3,代码来源:red.c


示例18: initctrans

PyMODINIT_FUNC initctrans(void)  {
	(void) Py_InitModule3("ctrans", _ctransMethods, _ctransDoc);
	import_array();  // Must be present for NumPy.  Called first after above line.
}
开发者ID:buzmakov,项目名称:scikit-xray,代码行数:4,代码来源:ctrans.c


示例19: initdecoders

PyMODINIT_FUNC
initdecoders(void)
{
    PyObject* m;

    decoders_FlacDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_FlacDecoderType) < 0)
        return;

    decoders_OggFlacDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_OggFlacDecoderType) < 0)
        return;

    decoders_SHNDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_SHNDecoderType) < 0)
        return;

    decoders_ALACDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_ALACDecoderType) < 0)
        return;

    decoders_WavPackDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_WavPackDecoderType) < 0)
        return;

    #ifdef HAS_VORBIS
    decoders_VorbisDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_VorbisDecoderType) < 0)
        return;
    #endif

    #ifdef HAS_MP3
    decoders_MP3DecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_MP3DecoderType) < 0)
        return;
    #endif

    #ifdef HAS_OPUS
    decoders_OpusDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_OpusDecoderType) < 0)
        return;
    #endif

    decoders_TTADecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_TTADecoderType) < 0)
        return;

    decoders_CPPMDecoderType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_CPPMDecoderType) < 0)
        return;

    decoders_DVDA_Title_Type.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_DVDA_Title_Type) < 0)
        return;

    decoders_Sine_Mono_Type.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_Sine_Mono_Type) < 0)
        return;

    decoders_Sine_Stereo_Type.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_Sine_Stereo_Type) < 0)
        return;

    decoders_Sine_Simple_Type.tp_new = PyType_GenericNew;
    if (PyType_Ready(&decoders_Sine_Simple_Type) < 0)
        return;

    m = Py_InitModule3("decoders", module_methods,
                       "Low-level audio format decoders");

    Py_INCREF(&decoders_FlacDecoderType);
    PyModule_AddObject(m, "FlacDecoder",
                       (PyObject *)&decoders_FlacDecoderType);

    Py_INCREF(&decoders_OggFlacDecoderType);
    PyModule_AddObject(m, "OggFlacDecoder",
                       (PyObject *)&decoders_OggFlacDecoderType);

    Py_INCREF(&decoders_SHNDecoderType);
    PyModule_AddObject(m, "SHNDecoder",
                       (PyObject *)&decoders_SHNDecoderType);

    Py_INCREF(&decoders_ALACDecoderType);
    PyModule_AddObject(m, "ALACDecoder",
                       (PyObject *)&decoders_ALACDecoderType);

    Py_INCREF(&decoders_WavPackDecoderType);
    PyModule_AddObject(m, "WavPackDecoder",
                       (PyObject *)&decoders_WavPackDecoderType);

    #ifdef HAS_VORBIS
    Py_INCREF(&decoders_VorbisDecoderType);
    PyModule_AddObject(m, "VorbisDecoder",
                       (PyObject *)&decoders_VorbisDecoderType);
    #endif

    #ifdef HAS_MP3
    Py_INCREF(&decoders_MP3DecoderType);
    PyModule_AddObject(m, "MP3Decoder",
                       (PyObject *)&decoders_MP3DecoderType);
//.........这里部分代码省略.........
开发者ID:PengYingChuan,项目名称:python-audio-tools,代码行数:101,代码来源:decoders.c


示例20: initalsacontrol

PyMODINIT_FUNC
initalsacontrol(void)
{
	PyObject *d, *d1, *l1, *o;
	int i;

	if (PyType_Ready(&pyalsacontrol_type) < 0)
		return;

	module = Py_InitModule3("alsacontrol", pyalsacontrolparse_methods, "libasound control wrapper");
	if (module == NULL)
		return;

#if 0
	buildin = PyImport_AddModule("__buildin__");
	if (buildin == NULL)
		return;
	if (PyObject_SetAttrString(module, "__buildins__", buildin) < 0)
		return;
#endif

	Py_INCREF(&pyalsacontrol_type);
	PyModule_AddObject(module, "Control", (PyObject *)&pyalsacontrol_type);

	d = PyModule_GetDict(module);

	/* ---- */

	d1 = PyDict_New();

#define add_space1(pname, name) { \
	o = PyInt_FromLong(SND_CTL_ELEM_IFACE_##name); \
	PyDict_SetItemString(d1, pname, o); \
	Py_DECREF(o); }
	
	add_space1("CARD", CARD);
	add_space1("HWDEP", HWDEP);
	add_space1("MIXER", MIXER);
	add_space1("PCM", PCM);
	add_space1("RAWMIDI", RAWMIDI);
	add_space1("TIMER", TIMER);
	add_space1("SEQUENCER", SEQUENCER);
	add_space1("LAST", LAST);

	PyDict_SetItemString(d, "interface_id", d1);
	Py_DECREF(d1);

	/* ---- */

	l1 = PyList_New(0);

	for (i = 0; i <= SND_CTL_ELEM_IFACE_LAST; i++) {
		o = PyString_FromString(snd_ctl_elem_iface_name(i));
		PyList_Append(l1, o);
		Py_DECREF(o);
	}

	PyDict_SetItemString(d, "interface_name", l1);
	Py_DECREF(l1);

	/* ---- */

	d1 = PyDict_New();
	
#define add_space5(pname, name) { \
	o = PyInt_FromLong(SND_CTL_##name); \
	PyDict_SetItemString(d1, pname, o); \
	Py_DECREF(o); }
	
	add_space5("NONBLOCK", NONBLOCK);
	add_space5("ASYNC", ASYNC);
	add_space5("READONLY", READONLY);

	PyDict_SetItemString(d, "open_mode", d1);
	Py_DECREF(d1);

	/* ---- */

	if (PyErr_Occurred())
		Py_FatalError("Cannot initialize module alsacontrol");
}
开发者ID:physacco,项目名称:pyalsa,代码行数:81,代码来源:alsacontrol.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Py_SetProgramName函数代码示例发布时间:2022-05-30
下一篇:
C++ Py_InitModule函数代码示例发布时间: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