PyMODINIT_FUNC SIP_MODULE_ENTRY() #endif { static PyMethodDef sip_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static PyModuleDef sip_module_def = { PyModuleDef_HEAD_INIT, "PyQt5.QtWebSockets", NULL, -1, sip_methods, NULL, NULL, NULL, NULL }; #endif PyObject *sipModule, *sipModuleDict; PyObject *sip_sipmod, *sip_capiobj; /* Initialise the module and get it's dictionary. */ #if PY_MAJOR_VERSION >= 3 sipModule = PyModule_Create(&sip_module_def); #elif PY_VERSION_HEX >= 0x02050000 sipModule = Py_InitModule(sipName_PyQt5_QtWebSockets, sip_methods); #else sipModule = Py_InitModule(const_cast<char *>(sipName_PyQt5_QtWebSockets), sip_methods); #endif if (sipModule == NULL) SIP_MODULE_RETURN(NULL); sipModuleDict = PyModule_GetDict(sipModule); /* Get the SIP module's API. */ #if PY_VERSION_HEX >= 0x02050000 sip_sipmod = PyImport_ImportModule(SIP_MODULE_NAME); #else sip_sipmod = PyImport_ImportModule(const_cast<char *>(SIP_MODULE_NAME)); #endif if (sip_sipmod == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } sip_capiobj = PyDict_GetItemString(PyModule_GetDict(sip_sipmod), "_C_API"); Py_DECREF(sip_sipmod); #if defined(SIP_USE_PYCAPSULE) if (sip_capiobj == NULL || !PyCapsule_CheckExact(sip_capiobj)) #else if (sip_capiobj == NULL || !PyCObject_Check(sip_capiobj)) #endif { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #if defined(SIP_USE_PYCAPSULE) sipAPI_QtWebSockets = reinterpret_cast<const sipAPIDef *>(PyCapsule_GetPointer(sip_capiobj, SIP_MODULE_NAME "._C_API")); #else sipAPI_QtWebSockets = reinterpret_cast<const sipAPIDef *>(PyCObject_AsVoidPtr(sip_capiobj)); #endif #if defined(SIP_USE_PYCAPSULE) if (sipAPI_QtWebSockets == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #endif /* Export the module and publish it's API. */ if (sipExportModule(&sipModuleAPI_QtWebSockets,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,0) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } sip_QtWebSockets_qt_metaobject = (sip_qt_metaobject_func)sipImportSymbol("qtcore_qt_metaobject"); sip_QtWebSockets_qt_metacall = (sip_qt_metacall_func)sipImportSymbol("qtcore_qt_metacall"); sip_QtWebSockets_qt_metacast = (sip_qt_metacast_func)sipImportSymbol("qtcore_qt_metacast"); if (!sip_QtWebSockets_qt_metacast) Py_FatalError("Unable to import qtcore_qt_metacast"); /* Initialise the module now all its dependencies have been set up. */ if (sipInitModule(&sipModuleAPI_QtWebSockets,sipModuleDict) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } /* Get the APIs of the modules that this one is dependent on. */ sipModuleAPI_QtWebSockets_QtCore = sipModuleAPI_QtWebSockets.em_imports[0].im_module; sipModuleAPI_QtWebSockets_QtNetwork = sipModuleAPI_QtWebSockets.em_imports[1].im_module; SIP_MODULE_RETURN(sipModule); }
PyMODINIT_FUNC SIP_MODULE_ENTRY() #endif { static PyMethodDef sip_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static PyModuleDef sip_module_def = { PyModuleDef_HEAD_INIT, "MyMath", NULL, -1, sip_methods, NULL, NULL, NULL, NULL }; #endif PyObject *sipModule, *sipModuleDict; PyObject *sip_sipmod, *sip_capiobj; /* Initialise the module and get it's dictionary. */ #if PY_MAJOR_VERSION >= 3 sipModule = PyModule_Create(&sip_module_def); #elif PY_VERSION_HEX >= 0x02050000 sipModule = Py_InitModule(sipName_MyMath, sip_methods); #else sipModule = Py_InitModule(const_cast<char *>(sipName_MyMath), sip_methods); #endif if (sipModule == NULL) SIP_MODULE_RETURN(NULL); sipModuleDict = PyModule_GetDict(sipModule); /* Get the SIP module's API. */ #if PY_VERSION_HEX >= 0x02050000 sip_sipmod = PyImport_ImportModule(SIP_MODULE_NAME); #else sip_sipmod = PyImport_ImportModule(const_cast<char *>(SIP_MODULE_NAME)); #endif if (sip_sipmod == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } sip_capiobj = PyDict_GetItemString(PyModule_GetDict(sip_sipmod), "_C_API"); Py_DECREF(sip_sipmod); #if defined(SIP_USE_PYCAPSULE) if (sip_capiobj == NULL || !PyCapsule_CheckExact(sip_capiobj)) #else if (sip_capiobj == NULL || !PyCObject_Check(sip_capiobj)) #endif { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #if defined(SIP_USE_PYCAPSULE) sipAPI_MyMath = reinterpret_cast<const sipAPIDef *>(PyCapsule_GetPointer(sip_capiobj, SIP_MODULE_NAME "._C_API")); #else sipAPI_MyMath = reinterpret_cast<const sipAPIDef *>(PyCObject_AsVoidPtr(sip_capiobj)); #endif #if defined(SIP_USE_PYCAPSULE) if (sipAPI_MyMath == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #endif /* Export the module and publish it's API. */ if (sipExportModule(&sipModuleAPI_MyMath,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,0) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } /* Initialise the module now all its dependencies have been set up. */ if (sipInitModule(&sipModuleAPI_MyMath,sipModuleDict) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } SIP_MODULE_RETURN(sipModule); }