void image_init(PyObject *m) { Py_INCREF(&ImageType); PyModule_AddObject(m, "Image", (PyObject *)&ImageType); }
void initofx(void) { PyObject *mod = Py_InitModule("ofx", PyOFX_Methods); PyModule_AddIntConstant(mod, "TypeImageEffectHost", ofx::TypeImageEffectHost); PyModule_AddIntConstant(mod, "TypeImageEffect", ofx::TypeImageEffect); PyModule_AddIntConstant(mod, "TypeImageEffectInstance", ofx::TypeImageEffectInstance); PyModule_AddIntConstant(mod, "TypeParameter", ofx::TypeParameter); PyModule_AddIntConstant(mod, "TypeParameterInstance", ofx::TypeParameterInstance); PyModule_AddIntConstant(mod, "TypeClip", ofx::TypeClip); PyModule_AddIntConstant(mod, "TypeImage", ofx::TypeImage); PyModule_AddIntConstant(mod, "BitDepthNone", ofx::BitDepthNone); PyModule_AddIntConstant(mod, "BitDepthByte", ofx::BitDepthByte); PyModule_AddIntConstant(mod, "BitDepthShort", ofx::BitDepthShort); PyModule_AddIntConstant(mod, "BitDepthFloat", ofx::BitDepthFloat); #ifdef OFX_API_1_3 PyModule_AddIntConstant(mod, "BitDepthHalf", ofx::BitDepthHalf); #endif PyModule_AddIntConstant(mod, "ImageComponentNone", ofx::ImageComponentNone); #ifdef OFX_API_1_2 PyModule_AddIntConstant(mod, "ImageComponentRGB", ofx::ImageComponentRGB); #endif PyModule_AddIntConstant(mod, "ImageComponentRGBA", ofx::ImageComponentRGBA); PyModule_AddIntConstant(mod, "ImageComponentAlpha", ofx::ImageComponentAlpha); PyModule_AddIntConstant(mod, "ImageComponentYUVA", ofx::ImageComponentYUVA); PyModule_AddIntConstant(mod, "ImageFieldNone", ofx::ImageFieldNone); PyModule_AddIntConstant(mod, "ImageFieldBoth", ofx::ImageFieldBoth); PyModule_AddIntConstant(mod, "ImageFieldLower", ofx::ImageFieldLower); PyModule_AddIntConstant(mod, "ImageFieldUpper", ofx::ImageFieldUpper); PyModule_AddIntConstant(mod, "ImageFieldExtractBoth", ofx::ImageFieldExtractBoth); PyModule_AddIntConstant(mod, "ImageFieldExtractSingle", ofx::ImageFieldExtractSingle); PyModule_AddIntConstant(mod, "ImageFieldExtractDoubled", ofx::ImageFieldExtractDoubled); PyModule_AddIntConstant(mod, "ImageFieldOrderNone", ofx::ImageFieldOrderNone); PyModule_AddIntConstant(mod, "ImageFieldOrderLower", ofx::ImageFieldOrderLower); PyModule_AddIntConstant(mod, "ImageFieldOrderUpper", ofx::ImageFieldOrderUpper); PyModule_AddIntConstant(mod, "ImageOpaque", ofx::ImageOpaque); PyModule_AddIntConstant(mod, "ImagePreMultiplied", ofx::ImagePreMultiplied); PyModule_AddIntConstant(mod, "ImageUnPreMultiplied", ofx::ImageUnPreMultiplied); PyModule_AddIntConstant(mod, "ImageEffectContextGenerator", ofx::ImageEffectContextGenerator); PyModule_AddIntConstant(mod, "ImageEffectContextFilter", ofx::ImageEffectContextFilter); PyModule_AddIntConstant(mod, "ImageEffectContextTransition", ofx::ImageEffectContextTransition); PyModule_AddIntConstant(mod, "ImageEffectContextPaint", ofx::ImageEffectContextPaint); PyModule_AddIntConstant(mod, "ImageEffectContextGeneral", ofx::ImageEffectContextGeneral); PyModule_AddIntConstant(mod, "ImageEffectContextRetimer", ofx::ImageEffectContextRetimer); PyModule_AddIntConstant(mod, "RenderThreadUnsafe", ofx::RenderThreadUnsafe); PyModule_AddIntConstant(mod, "RenderThreadInstanceSafe", ofx::RenderThreadInstanceSafe); PyModule_AddIntConstant(mod, "RenderThreadFullySafe", ofx::RenderThreadFullySafe); PyModule_AddIntConstant(mod, "ParamTypeInteger", ofx::ParamTypeInteger); PyModule_AddIntConstant(mod, "ParamTypeDouble", ofx::ParamTypeDouble); PyModule_AddIntConstant(mod, "ParamTypeBoolean", ofx::ParamTypeBoolean); PyModule_AddIntConstant(mod, "ParamTypeChoice", ofx::ParamTypeChoice); PyModule_AddIntConstant(mod, "ParamTypeRGBA", ofx::ParamTypeRGBA); PyModule_AddIntConstant(mod, "ParamTypeRGB", ofx::ParamTypeRGB); PyModule_AddIntConstant(mod, "ParamTypeDouble2D", ofx::ParamTypeDouble2D); PyModule_AddIntConstant(mod, "ParamTypeInteger2D", ofx::ParamTypeInteger2D); PyModule_AddIntConstant(mod, "ParamTypeDouble3D", ofx::ParamTypeDouble3D); PyModule_AddIntConstant(mod, "ParamTypeInteger3D", ofx::ParamTypeInteger3D); PyModule_AddIntConstant(mod, "ParamTypeString", ofx::ParamTypeString); PyModule_AddIntConstant(mod, "ParamTypeCustom", ofx::ParamTypeCustom); PyModule_AddIntConstant(mod, "ParamTypeGroup", ofx::ParamTypeGroup); PyModule_AddIntConstant(mod, "ParamTypePage", ofx::ParamTypePage); PyModule_AddIntConstant(mod, "ParamTypePushButton", ofx::ParamTypePushButton); #ifdef OFX_API_1_2 PyModule_AddIntConstant(mod, "ParamTypeParametric", ofx::ParamTypeParametric); #endif PyModule_AddIntConstant(mod, "ParamInvalidateValueChange", ofx::ParamInvalidateValueChange); PyModule_AddIntConstant(mod, "ParamInvalidateValueChangeToEnd", ofx::ParamInvalidateValueChangeToEnd); PyModule_AddIntConstant(mod, "ParamInvalidateAll", ofx::ParamInvalidateAll); PyModule_AddIntConstant(mod, "StringParamSingleLine", ofx::StringParamSingleLine); PyModule_AddIntConstant(mod, "StringParamMultiLine", ofx::StringParamMultiLine); PyModule_AddIntConstant(mod, "StringParamFilePath", ofx::StringParamFilePath); PyModule_AddIntConstant(mod, "StringParamDirectoryPath", ofx::StringParamDirectoryPath); PyModule_AddIntConstant(mod, "StringParamLabel", ofx::StringParamLabel); #ifdef OFX_API_1_3 PyModule_AddIntConstant(mod, "StringParamRichText", ofx::StringParamRichText); #endif PyModule_AddIntConstant(mod, "DoubleParamPlain", ofx::DoubleParamPlain); PyModule_AddIntConstant(mod, "DoubleParamAngle", ofx::DoubleParamAngle); PyModule_AddIntConstant(mod, "DoubleParamScale", ofx::DoubleParamScale); PyModule_AddIntConstant(mod, "DoubleParamTime", ofx::DoubleParamTime); PyModule_AddIntConstant(mod, "DoubleParamAbsoluteTime", ofx::DoubleParamAbsoluteTime); PyModule_AddIntConstant(mod, "DoubleParamNormalisedX", ofx::DoubleParamNormalisedX); PyModule_AddIntConstant(mod, "DoubleParamNormalisedXAbsolute", ofx::DoubleParamNormalisedXAbsolute); PyModule_AddIntConstant(mod, "DoubleParamNormalisedY", ofx::DoubleParamNormalisedY); PyModule_AddIntConstant(mod, "DoubleParamNormalisedYAbsolute", ofx::DoubleParamNormalisedYAbsolute); PyModule_AddIntConstant(mod, "DoubleParamNormalisedXY", ofx::DoubleParamNormalisedXY); PyModule_AddIntConstant(mod, "DoubleParamNormalisedXYAbsolute", ofx::DoubleParamNormalisedXYAbsolute); #ifdef OFX_API_1_2 PyModule_AddIntConstant(mod, "DoubleParamX", ofx::DoubleParamX); PyModule_AddIntConstant(mod, "DoubleParamXAbsolute", ofx::DoubleParamXAbsolute); PyModule_AddIntConstant(mod, "DoubleParamY", ofx::DoubleParamY); PyModule_AddIntConstant(mod, "DoubleParamYAbsolute", ofx::DoubleParamYAbsolute); PyModule_AddIntConstant(mod, "DoubleParamXY", ofx::DoubleParamXY); PyModule_AddIntConstant(mod, "DoubleParamXYAbsolute", ofx::DoubleParamXYAbsolute); #endif #ifdef OFX_API_1_2 PyModule_AddIntConstant(mod, "CoordinatesCanonical", ofx::CoordinatesCanonical); PyModule_AddIntConstant(mod, "CoordinatesNormalised", ofx::CoordinatesNormalised); #endif PyModule_AddIntConstant(mod, "KeyDirectionPrev", ofx::KeyDirectionPrev); PyModule_AddIntConstant(mod, "KeyDirectionExact", ofx::KeyDirectionExact); PyModule_AddIntConstant(mod, "KeyDirectionNext", ofx::KeyDirectionNext); PyModule_AddIntConstant(mod, "MessageTypeFatal", ofx::MessageTypeFatal); PyModule_AddIntConstant(mod, "MessageTypeError", ofx::MessageTypeError); PyModule_AddIntConstant(mod, "MessageTypeMessage", ofx::MessageTypeMessage); PyModule_AddIntConstant(mod, "MessageTypeLog", ofx::MessageTypeLog); PyModule_AddIntConstant(mod, "MessageTypeQuestion", ofx::MessageTypeQuestion); #ifdef OFX_API_1_2 PyModule_AddIntConstant(mod, "MessageTypeWarning", ofx::MessageTypeWarning); #endif PyModule_AddIntConstant(mod, "ChangeUserEdited", ofx::ChangeUserEdited); PyModule_AddIntConstant(mod, "ChangePluginEdited", ofx::ChangePluginEdited); PyModule_AddIntConstant(mod, "ChangeTime", ofx::ChangeTime); PyModule_AddIntConstant(mod, "ActionLoad", ofx::ActionLoad); PyModule_AddIntConstant(mod, "ActionInteractLoseFocus", ofx::ActionInteractLoseFocus); PyModule_AddIntConstant(mod, "ActionInteractGainFocus", ofx::ActionInteractGainFocus); PyModule_AddIntConstant(mod, "ActionInteractKeyRepeat", ofx::ActionInteractKeyRepeat); PyModule_AddIntConstant(mod, "ActionInteractKeyUp", ofx::ActionInteractKeyUp); PyModule_AddIntConstant(mod, "ActionInteractKeyDown", ofx::ActionInteractKeyDown); PyModule_AddIntConstant(mod, "ActionInteractPenUp", ofx::ActionInteractPenUp); PyModule_AddIntConstant(mod, "ActionInteractPenDown", ofx::ActionInteractPenDown); PyModule_AddIntConstant(mod, "ActionInteractPenMotion", ofx::ActionInteractPenMotion); PyModule_AddIntConstant(mod, "ActionInteractDraw", ofx::ActionInteractDraw); PyModule_AddIntConstant(mod, "ActionImageEffectGetTimeDomain", ofx::ActionImageEffectGetTimeDomain); PyModule_AddIntConstant(mod, "ActionImageEffectGetClipPreferences", ofx::ActionImageEffectGetClipPreferences); PyModule_AddIntConstant(mod, "ActionImageEffectEndSequenceRender", ofx::ActionImageEffectEndSequenceRender); PyModule_AddIntConstant(mod, "ActionImageEffectBeginSequenceRender", ofx::ActionImageEffectBeginSequenceRender); PyModule_AddIntConstant(mod, "ActionImageEffectRender", ofx::ActionImageEffectRender); PyModule_AddIntConstant(mod, "ActionImageEffectIsIdentity", ofx::ActionImageEffectIsIdentity); PyModule_AddIntConstant(mod, "ActionImageEffectGetFramesNeeded", ofx::ActionImageEffectGetFramesNeeded); PyModule_AddIntConstant(mod, "ActionImageEffectGetRoI", ofx::ActionImageEffectGetRoI); PyModule_AddIntConstant(mod, "ActionImageEffectGetRoD", ofx::ActionImageEffectGetRoD); PyModule_AddIntConstant(mod, "ActionImageEffectDescribeInContext", ofx::ActionImageEffectDescribeInContext); PyModule_AddIntConstant(mod, "ActionEndInstanceEdit", ofx::ActionEndInstanceEdit); PyModule_AddIntConstant(mod, "ActionBeginInstanceEdit", ofx::ActionBeginInstanceEdit); PyModule_AddIntConstant(mod, "ActionUnload", ofx::ActionUnload); PyModule_AddIntConstant(mod, "ActionDescribe", ofx::ActionDescribe); PyModule_AddIntConstant(mod, "ActionCreateInstance", ofx::ActionCreateInstance); PyModule_AddIntConstant(mod, "ActionDestroyInstance", ofx::ActionDestroyInstance); PyModule_AddIntConstant(mod, "ActionInstanceChanged", ofx::ActionInstanceChanged); PyModule_AddIntConstant(mod, "ActionBeginInstanceChanged", ofx::ActionBeginInstanceChanged); PyModule_AddIntConstant(mod, "ActionEndInstanceChanged", ofx::ActionEndInstanceChanged); PyModule_AddIntConstant(mod, "ActionPurgeCaches", ofx::ActionPurgeCaches); PyModule_AddIntConstant(mod, "ActionSyncPrivateData", ofx::ActionSyncPrivateData); #ifdef OFX_API_1_3 PyModule_AddIntConstant(mod, "ActionOpenGLContextAttached", ofx::ActionOpenGLContextAttached); PyModule_AddIntConstant(mod, "ActionOpenGLContextDetached", ofx::ActionOpenGLContextAttached); #endif PyModule_AddIntConstant(mod, "SequentialRenderNotNeeded", ofx::SequentialRenderNotNeeded); PyModule_AddIntConstant(mod, "SequentialRenderRequired", ofx::SequentialRenderRequired); PyModule_AddIntConstant(mod, "SequentialRenderUnknown", ofx::SequentialRenderUnknown); PyModule_AddIntConstant(mod, "SequentialRenderAlways", ofx::SequentialRenderAlways); #ifdef OFX_API_1_2 PyModule_AddIntConstant(mod, "SequentialRenderIfPossible", ofx::SequentialRenderIfPossible); PyModule_AddIntConstant(mod, "SequentialRenderSometimes", ofx::SequentialRenderSometimes); #endif PyModule_AddIntConstant(mod, "StatOK", kOfxStatOK); PyModule_AddIntConstant(mod, "StatFailed", kOfxStatFailed); PyModule_AddIntConstant(mod, "StatErrFatal", kOfxStatErrFatal); PyModule_AddIntConstant(mod, "StatErrUnknown", kOfxStatErrUnknown); PyModule_AddIntConstant(mod, "StatErrMissingHostFeature", kOfxStatErrMissingHostFeature); PyModule_AddIntConstant(mod, "StatErrUnsupported", kOfxStatErrUnsupported); PyModule_AddIntConstant(mod, "StatErrExists", kOfxStatErrExists); PyModule_AddIntConstant(mod, "StatErrFormat", kOfxStatErrFormat); PyModule_AddIntConstant(mod, "StatErrMemory", kOfxStatErrMemory); PyModule_AddIntConstant(mod, "StatErrBadHandle", kOfxStatErrBadHandle); PyModule_AddIntConstant(mod, "StatErrBadIndex", kOfxStatErrBadIndex); PyModule_AddIntConstant(mod, "StatErrValue", kOfxStatErrValue); PyModule_AddIntConstant(mod, "StatErrImageFormat", kOfxStatErrImageFormat); PyModule_AddIntConstant(mod, "StatReplyYes", kOfxStatReplyYes); PyModule_AddIntConstant(mod, "StatReplyNo", kOfxStatReplyNo); PyModule_AddIntConstant(mod, "StatReplyDefault", kOfxStatReplyDefault); #ifdef OFX_API_1_3 PyModule_AddIntConstant(mod, "StatGLOutOfMemory", kOfxStatGLOutOfMemory); PyModule_AddIntConstant(mod, "StatGLRenderFailed", kOfxStatGLRenderFailed); #endif PyModule_AddStringConstant(mod, "PageSkipRow", kOfxParamPageSkipRow); PyModule_AddStringConstant(mod, "PageSkipColumn", kOfxParamPageSkipColumn); PyModule_AddIntConstant(mod, "MajorVersion", ofx::MajorVersion); PyModule_AddIntConstant(mod, "MinorVersion", ofx::MinorVersion); PyModule_AddIntConstant(mod, "PatchVersion", ofx::PatchVersion); PyModule_AddStringConstant(mod, "Version", ofx::Version); INIT_TYPE(PyOFXActionArgumentsType, "ofx.ActionArguments", PyOFXActionArguments); PyOFXActionArgumentsType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE; PyOFXActionArgumentsType.tp_new = PyOFXActionArguments_New; PyOFXActionArgumentsType.tp_init = PyOFXActionArguments_Init; PyOFXActionArgumentsType.tp_dealloc = PyOFXActionArguments_Delete; PyOFXActionArgumentsType.tp_setattro = PyOFXActionArguments_SetAttr; //PyObject_GenericSetAttr; PyOFXActionArgumentsType.tp_getattro = PyOFXActionArguments_GetAttr; //PyObject_GenericGetAttr; if (PyType_Ready(&PyOFXActionArgumentsType) < 0) { std::cerr << "Failed to intiialize ofx.ActionArguments class" << std::endl; Py_DECREF(mod); return; } INIT_TYPE(PyOFXRectIType, "ofx.RectI", PyOFXRectI); PyOFXRectIType.tp_flags = Py_TPFLAGS_DEFAULT; PyOFXRectIType.tp_new = PyOFXRectI_New; PyOFXRectIType.tp_init = PyOFXRectI_Init; PyOFXRectIType.tp_dealloc = PyOFXRectI_Delete; PyOFXRectIType.tp_getset = PyOFXRectI_GetSeters; if (PyType_Ready(&PyOFXRectIType) < 0) { std::cerr << "Failed to intiialize ofx.RectI class" << std::endl; Py_DECREF(mod); return; } INIT_TYPE(PyOFXRectDType, "ofx.RectD", PyOFXRectD); PyOFXRectDType.tp_flags = Py_TPFLAGS_DEFAULT; PyOFXRectDType.tp_new = PyOFXRectD_New; PyOFXRectDType.tp_init = PyOFXRectD_Init; PyOFXRectDType.tp_dealloc = PyOFXRectD_Delete; PyOFXRectDType.tp_getset = PyOFXRectD_GetSeters; if (PyType_Ready(&PyOFXRectDType) < 0) { std::cerr << "Failed to intiialize ofx.RectD class" << std::endl; Py_DECREF(mod); return; } INIT_TYPE(PyOFXRangeIType, "ofx.RangeI", PyOFXRangeI); PyOFXRangeIType.tp_flags = Py_TPFLAGS_DEFAULT; PyOFXRangeIType.tp_new = PyOFXRangeI_New; PyOFXRangeIType.tp_init = PyOFXRangeI_Init; PyOFXRangeIType.tp_dealloc = PyOFXRangeI_Delete; PyOFXRangeIType.tp_getset = PyOFXRangeI_GetSeters; if (PyType_Ready(&PyOFXRangeIType) < 0) { std::cerr << "Failed to intiialize ofx.RangeI class" << std::endl; Py_DECREF(mod); return; } INIT_TYPE(PyOFXRangeDType, "ofx.RangeD", PyOFXRangeD); PyOFXRangeDType.tp_flags = Py_TPFLAGS_DEFAULT; PyOFXRangeDType.tp_new = PyOFXRangeD_New; PyOFXRangeDType.tp_init = PyOFXRangeD_Init; PyOFXRangeDType.tp_dealloc = PyOFXRangeD_Delete; PyOFXRangeDType.tp_getset = PyOFXRangeD_GetSeters; if (PyType_Ready(&PyOFXRangeDType) < 0) { std::cerr << "Failed to intiialize ofx.RangeD class" << std::endl; Py_DECREF(mod); return; } Py_INCREF(&PyOFXActionArgumentsType); PyModule_AddObject(mod, "ActionArguments", (PyObject*)&PyOFXActionArgumentsType); Py_INCREF(&PyOFXRectIType); PyModule_AddObject(mod, "RectI", (PyObject*)&PyOFXRectIType); Py_INCREF(&PyOFXRectDType); PyModule_AddObject(mod, "RectD", (PyObject*)&PyOFXRectDType); Py_INCREF(&PyOFXRangeIType); PyModule_AddObject(mod, "RangeI", (PyObject*)&PyOFXRangeIType); Py_INCREF(&PyOFXRangeDType); PyModule_AddObject(mod, "RangeD", (PyObject*)&PyOFXRangeDType); Py_INCREF(&PyOFXRangeDType); PyModule_AddObject(mod, "FrameRange", (PyObject*)&PyOFXRangeDType); if (!PyOFX_InitException(mod)) { std::cerr << "Failed to intiialize exception classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitHandle(mod)) { std::cerr << "Failed to intiialize handle classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitPixel(mod)) { std::cerr << "Failed to intiialize pixel classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitMessage(mod)) { std::cerr << "Failed to intiialize message classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitMemory(mod)) { std::cerr << "Failed to intiialize memory classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitProgress(mod)) { std::cerr << "Failed to intiialize progress classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitTimeLine(mod)) { std::cerr << "Failed to intiialize timeline classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitProperty(mod)) { std::cerr << "Failed to intiialize property classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitParameter(mod)) { std::cerr << "Failed to intiialize parameter classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitParameterSet(mod)) { std::cerr << "Failed to intiialize parameterset classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitHost(mod)) { std::cerr << "Failed to intiialize host classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitImage(mod)) { std::cerr << "Failed to intiialize image classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitClip(mod)) { std::cerr << "Failed to intiialize clip classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitInteract(mod)) { std::cerr << "Failed to intiialize interact classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitImageEffect(mod)) { std::cerr << "Failed to intiialize imageeffect classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitPlugin(mod)) { std::cerr << "Failed to intiialize plugin classes" << std::endl; Py_DECREF(mod); return; } if (!PyOFX_InitTest(mod)) { std::cerr << "Failed to intiialize test classes" << std::endl; Py_DECREF(mod); return; } }
PyMODINIT_FUNC init_zope_interface_coptimizations(void) { PyObject *m; #define DEFINE_STRING(S) \ if(! (str ## S = PyString_FromString(# S))) return DEFINE_STRING(__dict__); DEFINE_STRING(__implemented__); DEFINE_STRING(__provides__); DEFINE_STRING(__class__); DEFINE_STRING(__providedBy__); DEFINE_STRING(extends); DEFINE_STRING(_implied); DEFINE_STRING(_implements); DEFINE_STRING(_cls); DEFINE_STRING(__conform__); DEFINE_STRING(_call_conform); DEFINE_STRING(_uncached_lookup); DEFINE_STRING(_uncached_lookupAll); DEFINE_STRING(_uncached_subscriptions); DEFINE_STRING(_registry); DEFINE_STRING(_generation); DEFINE_STRING(ro); DEFINE_STRING(changed); #undef DEFINE_STRING adapter_hooks = PyList_New(0); if (adapter_hooks == NULL) return; /* Initialize types: */ SpecType.tp_new = PyBaseObject_Type.tp_new; if (PyType_Ready(&SpecType) < 0) return; OSDType.tp_new = PyBaseObject_Type.tp_new; if (PyType_Ready(&OSDType) < 0) return; CPBType.tp_new = PyBaseObject_Type.tp_new; if (PyType_Ready(&CPBType) < 0) return; InterfaceBase.tp_new = PyBaseObject_Type.tp_new; if (PyType_Ready(&InterfaceBase) < 0) return; LookupBase.tp_new = PyBaseObject_Type.tp_new; if (PyType_Ready(&LookupBase) < 0) return; VerifyingBase.tp_new = PyBaseObject_Type.tp_new; if (PyType_Ready(&VerifyingBase) < 0) return; /* Create the module and add the functions */ m = Py_InitModule3("_zope_interface_coptimizations", m_methods, "C optimizations for zope.interface\n\n" "$Id: _zope_interface_coptimizations.c 106268 2009-12-08 08:29:06Z wosc $"); if (m == NULL) return; /* Add types: */ if (PyModule_AddObject(m, "SpecificationBase", OBJECT(&SpecType)) < 0) return; if (PyModule_AddObject(m, "ObjectSpecificationDescriptor", (PyObject *)&OSDType) < 0) return; if (PyModule_AddObject(m, "ClassProvidesBase", OBJECT(&CPBType)) < 0) return; if (PyModule_AddObject(m, "InterfaceBase", OBJECT(&InterfaceBase)) < 0) return; if (PyModule_AddObject(m, "LookupBase", OBJECT(&LookupBase)) < 0) return; if (PyModule_AddObject(m, "VerifyingBase", OBJECT(&VerifyingBase)) < 0) return; if (PyModule_AddObject(m, "adapter_hooks", adapter_hooks) < 0) return; }
PyMODINIT_FUNC init_billiard(void) { PyObject *module, *temp, *value; /* Initialize module */ module = Py_InitModule("_billiard", Billiard_module_methods); if (!module) return; /* Get copy of objects from pickle */ temp = PyImport_ImportModule(PICKLE_MODULE); if (!temp) return; Billiard_pickle_dumps = PyObject_GetAttrString(temp, "dumps"); Billiard_pickle_loads = PyObject_GetAttrString(temp, "loads"); Billiard_pickle_protocol = PyObject_GetAttrString(temp, "HIGHEST_PROTOCOL"); Py_XDECREF(temp); /* Get copy of BufferTooShort */ temp = PyImport_ImportModule("billiard"); if (!temp) return; Billiard_BufferTooShort = PyObject_GetAttrString(temp, "BufferTooShort"); Py_XDECREF(temp); /* Add connection type to module */ if (PyType_Ready(&BilliardConnectionType) < 0) return; Py_INCREF(&BilliardConnectionType); PyModule_AddObject(module, "Connection", (PyObject*)&BilliardConnectionType); #if defined(MS_WINDOWS) || \ (defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED)) /* Add SemLock type to module */ if (PyType_Ready(&BilliardSemLockType) < 0) return; Py_INCREF(&BilliardSemLockType); PyDict_SetItemString(BilliardSemLockType.tp_dict, "SEM_VALUE_MAX", Py_BuildValue("i", SEM_VALUE_MAX)); PyModule_AddObject(module, "SemLock", (PyObject*)&BilliardSemLockType); #endif #ifdef MS_WINDOWS /* Add PipeConnection to module */ if (PyType_Ready(&BilliardPipeConnectionType) < 0) return; Py_INCREF(&BilliardPipeConnectionType); PyModule_AddObject(module, "PipeConnection", (PyObject*)&BilliardPipeConnectionType); /* Initialize win32 class and add to multiprocessing */ temp = create_win32_namespace(); if (!temp) return; PyModule_AddObject(module, "win32", temp); /* Initialize the event handle used to signal Ctrl-C */ sigint_event = CreateEvent(NULL, TRUE, FALSE, NULL); if (!sigint_event) { PyErr_SetFromWindowsErr(0); return; } if (!SetConsoleCtrlHandler(ProcessingCtrlHandler, TRUE)) { PyErr_SetFromWindowsErr(0); return; } #endif /* Add configuration macros */ temp = PyDict_New(); if (!temp) return; #define ADD_FLAG(name) \ value = Py_BuildValue("i", name); \ if (value == NULL) { Py_DECREF(temp); return; } \ if (PyDict_SetItemString(temp, #name, value) < 0) { \ Py_DECREF(temp); Py_DECREF(value); return; } \ Py_DECREF(value) #if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED) ADD_FLAG(HAVE_SEM_OPEN); #endif #ifdef HAVE_SEM_TIMEDWAIT ADD_FLAG(HAVE_SEM_TIMEDWAIT); #endif #ifdef HAVE_FD_TRANSFER ADD_FLAG(HAVE_FD_TRANSFER); #endif #ifdef HAVE_BROKEN_SEM_GETVALUE ADD_FLAG(HAVE_BROKEN_SEM_GETVALUE); #endif #ifdef HAVE_BROKEN_SEM_UNLINK ADD_FLAG(HAVE_BROKEN_SEM_UNLINK); #endif if (PyModule_AddObject(module, "flags", temp) < 0) return; }
void _pygi_info_register_types (PyObject *m) { #define _PyGI_REGISTER_TYPE(m, type, cname, base) \ Py_TYPE(&type) = &PyType_Type; \ type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); \ type.tp_weaklistoffset = offsetof(PyGIBaseInfo, inst_weakreflist); \ type.tp_methods = _PyGI##cname##_methods; \ type.tp_base = &base; \ if (PyType_Ready(&type)) \ return; \ if (PyModule_AddObject(m, #cname, (PyObject *)&type)) \ return Py_TYPE(&PyGIBaseInfo_Type) = &PyType_Type; PyGIBaseInfo_Type.tp_dealloc = (destructor) _base_info_dealloc; PyGIBaseInfo_Type.tp_repr = (reprfunc) _base_info_repr; PyGIBaseInfo_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC); PyGIBaseInfo_Type.tp_traverse = (traverseproc) _base_info_traverse; PyGIBaseInfo_Type.tp_weaklistoffset = offsetof(PyGIBaseInfo, inst_weakreflist); PyGIBaseInfo_Type.tp_methods = _PyGIBaseInfo_methods; PyGIBaseInfo_Type.tp_richcompare = (richcmpfunc)_base_info_richcompare; if (PyType_Ready(&PyGIBaseInfo_Type)) return; if (PyModule_AddObject(m, "BaseInfo", (PyObject *)&PyGIBaseInfo_Type)) return; _PyGI_REGISTER_TYPE (m, PyGIUnresolvedInfo_Type, UnresolvedInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGICallableInfo_Type, CallableInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGICallbackInfo_Type, CallbackInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIFunctionInfo_Type, FunctionInfo, PyGICallableInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIRegisteredTypeInfo_Type, RegisteredTypeInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIStructInfo_Type, StructInfo, PyGIRegisteredTypeInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIEnumInfo_Type, EnumInfo, PyGIRegisteredTypeInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIObjectInfo_Type, ObjectInfo, PyGIRegisteredTypeInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIInterfaceInfo_Type, InterfaceInfo, PyGIRegisteredTypeInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIConstantInfo_Type, ConstantInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIValueInfo_Type, ValueInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIFieldInfo_Type, FieldInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIVFuncInfo_Type, VFuncInfo, PyGICallableInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIUnionInfo_Type, UnionInfo, PyGIRegisteredTypeInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIBoxedInfo_Type, BoxedInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIErrorDomainInfo_Type, ErrorDomainInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGISignalInfo_Type, SignalInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIPropertyInfo_Type, PropertyInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGIArgInfo_Type, ArgInfo, PyGIBaseInfo_Type); _PyGI_REGISTER_TYPE (m, PyGITypeInfo_Type, TypeInfo, PyGIBaseInfo_Type); #undef _PyGI_REGISTER_TYPE }
EnumModule::EnumModule(PyObject *parent, char* name) { module =Py_InitModule(name, enum_methods); Py_INCREF(module); PyModule_AddObject(parent, name, module); }
PyMODINIT_FUNC INIT_MODULE(_psycopg)(void) { #if PY_VERSION_HEX < 0x03020000 static void *PSYCOPG_API[PSYCOPG_API_pointers]; PyObject *c_api_object; #endif PyObject *module = NULL, *dict; #ifdef PSYCOPG_DEBUG if (getenv("PSYCOPG_DEBUG")) psycopg_debug_enabled = 1; #endif Dprintf("initpsycopg: initializing psycopg %s", PSYCOPG_VERSION); /* initialize all the new types and then the module */ Py_TYPE(&connectionType) = &PyType_Type; Py_TYPE(&cursorType) = &PyType_Type; Py_TYPE(&typecastType) = &PyType_Type; Py_TYPE(&qstringType) = &PyType_Type; Py_TYPE(&binaryType) = &PyType_Type; Py_TYPE(&isqlquoteType) = &PyType_Type; Py_TYPE(&pbooleanType) = &PyType_Type; Py_TYPE(&pintType) = &PyType_Type; Py_TYPE(&pfloatType) = &PyType_Type; Py_TYPE(&pdecimalType) = &PyType_Type; Py_TYPE(&asisType) = &PyType_Type; Py_TYPE(&listType) = &PyType_Type; Py_TYPE(&chunkType) = &PyType_Type; Py_TYPE(&NotifyType) = &PyType_Type; Py_TYPE(&XidType) = &PyType_Type; if (PyType_Ready(&connectionType) == -1) goto exit; if (PyType_Ready(&cursorType) == -1) goto exit; if (PyType_Ready(&typecastType) == -1) goto exit; if (PyType_Ready(&qstringType) == -1) goto exit; if (PyType_Ready(&binaryType) == -1) goto exit; if (PyType_Ready(&isqlquoteType) == -1) goto exit; if (PyType_Ready(&pbooleanType) == -1) goto exit; if (PyType_Ready(&pintType) == -1) goto exit; if (PyType_Ready(&pfloatType) == -1) goto exit; if (PyType_Ready(&pdecimalType) == -1) goto exit; if (PyType_Ready(&asisType) == -1) goto exit; if (PyType_Ready(&listType) == -1) goto exit; if (PyType_Ready(&chunkType) == -1) goto exit; if (PyType_Ready(&NotifyType) == -1) goto exit; if (PyType_Ready(&XidType) == -1) goto exit; #ifdef PSYCOPG_EXTENSIONS Py_TYPE(&lobjectType) = &PyType_Type; if (PyType_Ready(&lobjectType) == -1) goto exit; #endif /* import mx.DateTime module, if necessary */ #ifdef HAVE_MXDATETIME Py_TYPE(&mxdatetimeType) = &PyType_Type; if (PyType_Ready(&mxdatetimeType) == -1) goto exit; if (0 != mxDateTime_ImportModuleAndAPI()) { PyErr_Clear(); /* only fail if the mx typacaster should have been the default */ #ifdef PSYCOPG_DEFAULT_MXDATETIME PyErr_SetString(PyExc_ImportError, "can't import mx.DateTime module (requested as default adapter)"); goto exit; #endif } #endif /* import python builtin datetime module, if available */ pyDateTimeModuleP = PyImport_ImportModule("datetime"); if (pyDateTimeModuleP == NULL) { Dprintf("initpsycopg: can't import datetime module"); PyErr_SetString(PyExc_ImportError, "can't import datetime module"); goto exit; } /* Initialize the PyDateTimeAPI everywhere is used */ PyDateTime_IMPORT; if (psyco_adapter_datetime_init()) { goto exit; } Py_TYPE(&pydatetimeType) = &PyType_Type; if (PyType_Ready(&pydatetimeType) == -1) goto exit; /* import psycopg2.tz anyway (TODO: replace with C-level module?) */ pyPsycopgTzModule = PyImport_ImportModule("psycopg2.tz"); if (pyPsycopgTzModule == NULL) { Dprintf("initpsycopg: can't import psycopg2.tz module"); PyErr_SetString(PyExc_ImportError, "can't import psycopg2.tz module"); goto exit; } pyPsycopgTzLOCAL = PyObject_GetAttrString(pyPsycopgTzModule, "LOCAL"); pyPsycopgTzFixedOffsetTimezone = PyObject_GetAttrString(pyPsycopgTzModule, "FixedOffsetTimezone"); /* initialize the module and grab module's dictionary */ #if PY_MAJOR_VERSION < 3 module = Py_InitModule("_psycopg", psycopgMethods); #else module = PyModule_Create(&psycopgmodule); #endif if (!module) { goto exit; } dict = PyModule_GetDict(module); /* initialize all the module's exported functions */ /* PyBoxer_API[PyBoxer_Fake_NUM] = (void *)PyBoxer_Fake; */ /* Create a CObject containing the API pointer array's address */ /* If anybody asks for a PyCapsule we'll deal with it. */ #if PY_VERSION_HEX < 0x03020000 c_api_object = PyCObject_FromVoidPtr((void *)PSYCOPG_API, NULL); if (c_api_object != NULL) PyModule_AddObject(module, "_C_API", c_api_object); #endif /* other mixed initializations of module-level variables */ if (!(psycoEncodings = PyDict_New())) { goto exit; } if (0 != psyco_encodings_fill(psycoEncodings)) { goto exit; } psyco_null = Bytes_FromString("NULL"); if (!(psyco_DescriptionType = psyco_make_description_type())) { goto exit; } /* set some module's parameters */ PyModule_AddStringConstant(module, "__version__", PSYCOPG_VERSION); PyModule_AddStringConstant(module, "__doc__", "psycopg PostgreSQL driver"); PyModule_AddObject(module, "apilevel", Text_FromUTF8(APILEVEL)); PyModule_AddObject(module, "threadsafety", PyInt_FromLong(THREADSAFETY)); PyModule_AddObject(module, "paramstyle", Text_FromUTF8(PARAMSTYLE)); /* put new types in module dictionary */ PyModule_AddObject(module, "connection", (PyObject*)&connectionType); PyModule_AddObject(module, "cursor", (PyObject*)&cursorType); PyModule_AddObject(module, "ISQLQuote", (PyObject*)&isqlquoteType); PyModule_AddObject(module, "Notify", (PyObject*)&NotifyType); PyModule_AddObject(module, "Xid", (PyObject*)&XidType); #ifdef PSYCOPG_EXTENSIONS PyModule_AddObject(module, "lobject", (PyObject*)&lobjectType); #endif /* encodings dictionary in module dictionary */ PyModule_AddObject(module, "encodings", psycoEncodings); #ifdef HAVE_MXDATETIME /* If we can't find mx.DateTime objects at runtime, * remove them from the module (and, as consequence, from the adapters). */ if (0 != psyco_adapter_mxdatetime_init()) { PyDict_DelItemString(dict, "DateFromMx"); PyDict_DelItemString(dict, "TimeFromMx"); PyDict_DelItemString(dict, "TimestampFromMx"); PyDict_DelItemString(dict, "IntervalFromMx"); } #endif /* initialize default set of typecasters */ if (0 != typecast_init(dict)) { goto exit; } /* initialize microprotocols layer */ microprotocols_init(dict); if (0 != psyco_adapters_init(dict)) { goto exit; } /* create a standard set of exceptions and add them to the module's dict */ if (0 != psyco_errors_init()) { goto exit; } psyco_errors_fill(dict); /* Solve win32 build issue about non-constant initializer element */ cursorType.tp_alloc = PyType_GenericAlloc; binaryType.tp_alloc = PyType_GenericAlloc; isqlquoteType.tp_alloc = PyType_GenericAlloc; pbooleanType.tp_alloc = PyType_GenericAlloc; pintType.tp_alloc = PyType_GenericAlloc; pfloatType.tp_alloc = PyType_GenericAlloc; pdecimalType.tp_alloc = PyType_GenericAlloc; connectionType.tp_alloc = PyType_GenericAlloc; asisType.tp_alloc = PyType_GenericAlloc; qstringType.tp_alloc = PyType_GenericAlloc; listType.tp_alloc = PyType_GenericAlloc; chunkType.tp_alloc = PyType_GenericAlloc; pydatetimeType.tp_alloc = PyType_GenericAlloc; NotifyType.tp_alloc = PyType_GenericAlloc; XidType.tp_alloc = PyType_GenericAlloc; #ifdef PSYCOPG_EXTENSIONS lobjectType.tp_alloc = PyType_GenericAlloc; #endif #ifdef HAVE_MXDATETIME mxdatetimeType.tp_alloc = PyType_GenericAlloc; #endif Dprintf("initpsycopg: module initialization complete"); exit: #if PY_MAJOR_VERSION > 2 return module; #else return; #endif }
PyMODINIT_FUNC init_GPIO(void) #endif { PyObject *module = NULL; #if PY_MAJOR_VERSION > 2 if ((module = PyModule_Create(&rpigpiomodule)) == NULL) goto exit; #else if ((module = Py_InitModule("_GPIO", rpi_gpio_methods)) == NULL) goto exit; #endif WrongDirectionException = PyErr_NewException("RPIO.Exceptions.WrongDirectionException", NULL, NULL); PyModule_AddObject(module, "WrongDirectionException", WrongDirectionException); InvalidModeException = PyErr_NewException("RPIO.Exceptions.InvalidModeException", NULL, NULL); PyModule_AddObject(module, "InvalidModeException", InvalidModeException); InvalidDirectionException = PyErr_NewException("RPIO.Exceptions.InvalidDirectionException", NULL, NULL); PyModule_AddObject(module, "InvalidDirectionException", InvalidDirectionException); InvalidChannelException = PyErr_NewException("RPIO.Exceptions.InvalidChannelException", NULL, NULL); PyModule_AddObject(module, "InvalidChannelException", InvalidChannelException); InvalidPullException = PyErr_NewException("RPIO.Exceptions.InvalidPullException", NULL, NULL); PyModule_AddObject(module, "InvalidPullException", InvalidPullException); ModeNotSetException = PyErr_NewException("RPIO.Exceptions.ModeNotSetException", NULL, NULL); PyModule_AddObject(module, "ModeNotSetException", ModeNotSetException); high = Py_BuildValue("i", HIGH); PyModule_AddObject(module, "HIGH", high); low = Py_BuildValue("i", LOW); PyModule_AddObject(module, "LOW", low); output = Py_BuildValue("i", OUTPUT); PyModule_AddObject(module, "OUT", output); input = Py_BuildValue("i", INPUT); PyModule_AddObject(module, "IN", input); alt0 = Py_BuildValue("i", ALT0); PyModule_AddObject(module, "ALT0", alt0); board = Py_BuildValue("i", BOARD); PyModule_AddObject(module, "BOARD", board); bcm = Py_BuildValue("i", BCM); PyModule_AddObject(module, "BCM", bcm); pud_off = Py_BuildValue("i", PUD_OFF); PyModule_AddObject(module, "PUD_OFF", pud_off); pud_up = Py_BuildValue("i", PUD_UP); PyModule_AddObject(module, "PUD_UP", pud_up); pud_down = Py_BuildValue("i", PUD_DOWN); PyModule_AddObject(module, "PUD_DOWN", pud_down); // detect board revision and set up accordingly cache_rpi_revision(); switch (revision_int) { case 1: pin_to_gpio = &pin_to_gpio_rev1; gpio_to_pin = &gpio_to_pin_rev1; break; case 2: pin_to_gpio = &pin_to_gpio_rev2; gpio_to_pin = &gpio_to_pin_rev2; break; case 3: pin_to_gpio = &pin_to_gpio_rev3; gpio_to_pin = &gpio_to_pin_rev3; break; default: PyErr_SetString(PyExc_SystemError, "This module can only be run on a Raspberry Pi!"); #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } rpi_revision = Py_BuildValue("i", revision_int); PyModule_AddObject(module, "RPI_REVISION", rpi_revision); rpi_revision_hex = Py_BuildValue("s", revision_hex); PyModule_AddObject(module, "RPI_REVISION_HEX", rpi_revision_hex); version = Py_BuildValue("s", "0.10.1/0.4.2a"); PyModule_AddObject(module, "VERSION_GPIO", version); // set up mmaped areas if (module_setup() != SETUP_OK ) { #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } if (Py_AtExit(cleanup) != 0) { cleanup(); #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } exit: #if PY_MAJOR_VERSION > 2 return module; #else return; #endif }
//-------------------MODULE INITIALIZATION-------------------------------- int StrokeShader_Init(PyObject *module) { if (module == NULL) return -1; if (PyType_Ready(&StrokeShader_Type) < 0) return -1; Py_INCREF(&StrokeShader_Type); PyModule_AddObject(module, "StrokeShader", (PyObject *)&StrokeShader_Type); if (PyType_Ready(&BackboneStretcherShader_Type) < 0) return -1; Py_INCREF(&BackboneStretcherShader_Type); PyModule_AddObject(module, "BackboneStretcherShader", (PyObject *)&BackboneStretcherShader_Type); if (PyType_Ready(&BezierCurveShader_Type) < 0) return -1; Py_INCREF(&BezierCurveShader_Type); PyModule_AddObject(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type); if (PyType_Ready(&BlenderTextureShader_Type) < 0) return -1; Py_INCREF(&BlenderTextureShader_Type); PyModule_AddObject(module, "BlenderTextureShader", (PyObject *)&BlenderTextureShader_Type); if (PyType_Ready(&CalligraphicShader_Type) < 0) return -1; Py_INCREF(&CalligraphicShader_Type); PyModule_AddObject(module, "CalligraphicShader", (PyObject *)&CalligraphicShader_Type); if (PyType_Ready(&ColorNoiseShader_Type) < 0) return -1; Py_INCREF(&ColorNoiseShader_Type); PyModule_AddObject(module, "ColorNoiseShader", (PyObject *)&ColorNoiseShader_Type); if (PyType_Ready(&ConstantColorShader_Type) < 0) return -1; Py_INCREF(&ConstantColorShader_Type); PyModule_AddObject(module, "ConstantColorShader", (PyObject *)&ConstantColorShader_Type); if (PyType_Ready(&ConstantThicknessShader_Type) < 0) return -1; Py_INCREF(&ConstantThicknessShader_Type); PyModule_AddObject(module, "ConstantThicknessShader", (PyObject *)&ConstantThicknessShader_Type); if (PyType_Ready(&ConstrainedIncreasingThicknessShader_Type) < 0) return -1; Py_INCREF(&ConstrainedIncreasingThicknessShader_Type); PyModule_AddObject(module, "ConstrainedIncreasingThicknessShader", (PyObject *)&ConstrainedIncreasingThicknessShader_Type); if (PyType_Ready(&GuidingLinesShader_Type) < 0) return -1; Py_INCREF(&GuidingLinesShader_Type); PyModule_AddObject(module, "GuidingLinesShader", (PyObject *)&GuidingLinesShader_Type); if (PyType_Ready(&IncreasingColorShader_Type) < 0) return -1; Py_INCREF(&IncreasingColorShader_Type); PyModule_AddObject(module, "IncreasingColorShader", (PyObject *)&IncreasingColorShader_Type); if (PyType_Ready(&IncreasingThicknessShader_Type) < 0) return -1; Py_INCREF(&IncreasingThicknessShader_Type); PyModule_AddObject(module, "IncreasingThicknessShader", (PyObject *)&IncreasingThicknessShader_Type); if (PyType_Ready(&PolygonalizationShader_Type) < 0) return -1; Py_INCREF(&PolygonalizationShader_Type); PyModule_AddObject(module, "PolygonalizationShader", (PyObject *)&PolygonalizationShader_Type); if (PyType_Ready(&SamplingShader_Type) < 0) return -1; Py_INCREF(&SamplingShader_Type); PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type); if (PyType_Ready(&SmoothingShader_Type) < 0) return -1; Py_INCREF(&SmoothingShader_Type); PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type); if (PyType_Ready(&SpatialNoiseShader_Type) < 0) return -1; Py_INCREF(&SpatialNoiseShader_Type); PyModule_AddObject(module, "SpatialNoiseShader", (PyObject *)&SpatialNoiseShader_Type); if (PyType_Ready(&StrokeTextureStepShader_Type) < 0) return -1; Py_INCREF(&StrokeTextureStepShader_Type); PyModule_AddObject(module, "StrokeTextureStepShader", (PyObject *)&StrokeTextureStepShader_Type); if (PyType_Ready(&ThicknessNoiseShader_Type) < 0) return -1; Py_INCREF(&ThicknessNoiseShader_Type); PyModule_AddObject(module, "ThicknessNoiseShader", (PyObject *)&ThicknessNoiseShader_Type); if (PyType_Ready(&TipRemoverShader_Type) < 0) return -1; Py_INCREF(&TipRemoverShader_Type); PyModule_AddObject(module, "TipRemoverShader", (PyObject *)&TipRemoverShader_Type); return 0; }
void PartExport initPart() { std::stringstream str; str << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE; App::Application::Config()["OCC_VERSION"] = str.str(); // This is highly experimental and we should keep an eye on it // if we have mysterious crashes // The argument must be 'Standard_False' to avoid FPE caused by // Python's cmath module. //#if defined(FC_OS_LINUX) OSD::SetSignal(Standard_False); //#endif PyObject* partModule = Py_InitModule3("Part", Part_methods, module_part_doc); /* mod name, table ptr */ Base::Console().Log("Loading Part module... done\n"); // Add Types to module Base::Interpreter().addType(&Part::TopoShapePy ::Type,partModule,"Shape"); Base::Interpreter().addType(&Part::TopoShapeVertexPy ::Type,partModule,"Vertex"); Base::Interpreter().addType(&Part::TopoShapeWirePy ::Type,partModule,"Wire"); Base::Interpreter().addType(&Part::TopoShapeEdgePy ::Type,partModule,"Edge"); Base::Interpreter().addType(&Part::TopoShapeSolidPy ::Type,partModule,"Solid"); Base::Interpreter().addType(&Part::TopoShapeFacePy ::Type,partModule,"Face"); Base::Interpreter().addType(&Part::TopoShapeCompoundPy ::Type,partModule,"Compound"); Base::Interpreter().addType(&Part::TopoShapeCompSolidPy ::Type,partModule,"CompSolid"); Base::Interpreter().addType(&Part::TopoShapeShellPy ::Type,partModule,"Shell"); Base::Interpreter().addType(&Part::LinePy ::Type,partModule,"Line"); Base::Interpreter().addType(&Part::PointPy ::Type,partModule,"Point"); Base::Interpreter().addType(&Part::CirclePy ::Type,partModule,"Circle"); Base::Interpreter().addType(&Part::EllipsePy ::Type,partModule,"Ellipse"); Base::Interpreter().addType(&Part::HyperbolaPy ::Type,partModule,"Hyperbola"); Base::Interpreter().addType(&Part::ParabolaPy ::Type,partModule,"Parabola"); Base::Interpreter().addType(&Part::ArcPy ::Type,partModule,"Arc"); Base::Interpreter().addType(&Part::ArcOfCirclePy ::Type,partModule,"ArcOfCircle"); Base::Interpreter().addType(&Part::BezierCurvePy ::Type,partModule,"BezierCurve"); Base::Interpreter().addType(&Part::BSplineCurvePy ::Type,partModule,"BSplineCurve"); Base::Interpreter().addType(&Part::OffsetCurvePy ::Type,partModule,"OffsetCurve"); Base::Interpreter().addType(&Part::PlanePy ::Type,partModule,"Plane"); Base::Interpreter().addType(&Part::CylinderPy ::Type,partModule,"Cylinder"); Base::Interpreter().addType(&Part::ConePy ::Type,partModule,"Cone"); Base::Interpreter().addType(&Part::SpherePy ::Type,partModule,"Sphere"); Base::Interpreter().addType(&Part::ToroidPy ::Type,partModule,"Toroid"); Base::Interpreter().addType(&Part::BezierSurfacePy ::Type,partModule,"BezierSurface"); Base::Interpreter().addType(&Part::BSplineSurfacePy ::Type,partModule,"BSplineSurface"); Base::Interpreter().addType(&Part::OffsetSurfacePy ::Type,partModule,"OffsetSurface"); Base::Interpreter().addType(&Part::SurfaceOfExtrusionPy ::Type,partModule,"SurfaceOfExtrusion"); Base::Interpreter().addType(&Part::SurfaceOfRevolutionPy::Type,partModule,"SurfaceOfRevolution"); Base::Interpreter().addType(&Part::RectangularTrimmedSurfacePy ::Type,partModule,"RectangularTrimmedSurface"); Base::Interpreter().addType(&Part::PartFeaturePy ::Type,partModule,"Feature"); PyObject* brepModule = Py_InitModule3("BRepOffsetAPI", 0, "BrepOffsetAPI"); Py_INCREF(brepModule); PyModule_AddObject(partModule, "BRepOffsetAPI", brepModule); Base::Interpreter().addType(&Part::BRepOffsetAPI_MakePipeShellPy::Type,brepModule,"MakePipeShell"); Part::TopoShape ::init(); Part::PropertyPartShape ::init(); Part::PropertyGeometryList ::init(); Part::PropertyShapeHistory ::init(); Part::PropertyFilletEdges ::init(); Part::Feature ::init(); Part::FeatureExt ::init(); Part::FeaturePython ::init(); Part::FeatureGeometrySet ::init(); Part::CustomFeature ::init(); Part::CustomFeaturePython ::init(); Part::Primitive ::init(); Part::Box ::init(); Part::Spline ::init(); Part::Boolean ::init(); Part::Common ::init(); Part::MultiCommon ::init(); Part::Cut ::init(); Part::Fuse ::init(); Part::MultiFuse ::init(); Part::Section ::init(); Part::FilletBase ::init(); Part::Fillet ::init(); Part::Chamfer ::init(); Part::Compound ::init(); Part::Extrusion ::init(); Part::Revolution ::init(); Part::Mirroring ::init(); Part::ImportStep ::init(); Part::ImportIges ::init(); Part::ImportBrep ::init(); Part::CurveNet ::init(); Part::Polygon ::init(); Part::Circle ::init(); Part::Ellipse ::init(); Part::Vertex ::init(); Part::Line ::init(); Part::Ellipsoid ::init(); Part::Plane ::init(); Part::Sphere ::init(); Part::Cylinder ::init(); Part::Prism ::init(); Part::Cone ::init(); Part::Torus ::init(); Part::Helix ::init(); Part::Spiral ::init(); Part::Wedge ::init(); Part::Part2DObject ::init(); Part::Part2DObjectPython ::init(); Part::RuledSurface ::init(); Part::Loft ::init(); Part::Sweep ::init(); Part::Offset ::init(); Part::Thickness ::init(); // Geometry types Part::Geometry ::init(); Part::GeomPoint ::init(); Part::GeomCurve ::init(); Part::GeomBezierCurve ::init(); Part::GeomBSplineCurve ::init(); Part::GeomCircle ::init(); Part::GeomArcOfCircle ::init(); Part::GeomEllipse ::init(); Part::GeomHyperbola ::init(); Part::GeomParabola ::init(); Part::GeomLine ::init(); Part::GeomLineSegment ::init(); Part::GeomOffsetCurve ::init(); Part::GeomTrimmedCurve ::init(); Part::GeomSurface ::init(); Part::GeomBezierSurface ::init(); Part::GeomBSplineSurface ::init(); Part::GeomCylinder ::init(); Part::GeomCone ::init(); Part::GeomSphere ::init(); Part::GeomToroid ::init(); Part::GeomPlane ::init(); Part::GeomOffsetSurface ::init(); Part::GeomTrimmedSurface ::init(); Part::GeomSurfaceOfRevolution ::init(); Part::GeomSurfaceOfExtrusion ::init(); IGESControl_Controller::Init(); STEPControl_Controller::Init(); // set the user-defined units Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); int unit = hGrp->GetInt("Unit", 0); switch (unit) { case 1: Interface_Static::SetCVal("write.iges.unit","M"); Interface_Static::SetCVal("write.step.unit","M"); break; case 2: Interface_Static::SetCVal("write.iges.unit","IN"); Interface_Static::SetCVal("write.step.unit","IN"); break; default: Interface_Static::SetCVal("write.iges.unit","MM"); Interface_Static::SetCVal("write.step.unit","MM"); break; } }
void PythonContext::GlobalInit() { // must happen on the UI thread if(qApp->thread() != QThread::currentThread()) { qFatal("PythonContext::GlobalInit MUST be called from the UI thread"); return; } // for the exception signal qRegisterMetaType<QList<QString>>("QList<QString>"); PyImport_AppendInittab("_renderdoc", &PyInit_renderdoc); PyImport_AppendInittab("_qrenderdoc", &PyInit_qrenderdoc); #if defined(STATIC_QRENDERDOC) // add the location where our libs will be for statically-linked python installs { QDir bin = QFileInfo(QCoreApplication::applicationFilePath()).absoluteDir(); QString pylibs = QDir::cleanPath(bin.absoluteFilePath(lit("../share/renderdoc/pylibs"))); pylibs.toWCharArray(python_home); Py_SetPythonHome(python_home); } #endif Py_SetProgramName(program_name); Py_Initialize(); PyEval_InitThreads(); OutputRedirectorType.tp_name = "renderdoc_output_redirector"; OutputRedirectorType.tp_basicsize = sizeof(OutputRedirector); OutputRedirectorType.tp_flags = Py_TPFLAGS_DEFAULT; OutputRedirectorType.tp_doc = "Output redirector, to be able to catch output to stdout and stderr"; OutputRedirectorType.tp_new = PyType_GenericNew; OutputRedirectorType.tp_dealloc = &PythonContext::outstream_del; OutputRedirectorType.tp_methods = OutputRedirector_methods; OutputRedirector_methods[0].ml_meth = &PythonContext::outstream_write; OutputRedirector_methods[1].ml_meth = &PythonContext::outstream_flush; PyObject *main_module = PyImport_AddModule("__main__"); PyModule_AddObject(main_module, "renderdoc", PyImport_ImportModule("_renderdoc")); PyModule_AddObject(main_module, "qrenderdoc", PyImport_ImportModule("_qrenderdoc")); main_dict = PyModule_GetDict(main_module); // replace sys.stdout and sys.stderr with our own objects. These have a 'this' pointer of NULL, // which then indicates they need to forward to a global object // import sys PyDict_SetItemString(main_dict, "sys", PyImport_ImportModule("sys")); PyObject *rlcompleter = PyImport_ImportModule("rlcompleter"); if(rlcompleter) { PyDict_SetItemString(main_dict, "rlcompleter", rlcompleter); } else { // ignore a failed import PyErr_Clear(); } // sysobj = sys PyObject *sysobj = PyDict_GetItemString(main_dict, "sys"); // sysobj.stdout = renderdoc_output_redirector() // sysobj.stderr = renderdoc_output_redirector() if(PyType_Ready(&OutputRedirectorType) >= 0) { // for compatibility with earlier versions of python that took a char * instead of const char * char noparams[1] = ""; PyObject *redirector = PyObject_CallFunction((PyObject *)&OutputRedirectorType, noparams); PyObject_SetAttrString(sysobj, "stdout", redirector); OutputRedirector *output = (OutputRedirector *)redirector; output->isStdError = 0; output->context = NULL; redirector = PyObject_CallFunction((PyObject *)&OutputRedirectorType, noparams); PyObject_SetAttrString(sysobj, "stderr", redirector); output = (OutputRedirector *)redirector; output->isStdError = 1; output->context = NULL; } // if we need to append to sys.path to locate PySide2, do that now #if defined(PYSIDE2_SYS_PATH) { PyObject *syspath = PyObject_GetAttrString(sysobj, "path"); #ifndef STRINGIZE #define STRINGIZE2(a) #a #define STRINGIZE(a) STRINGIZE2(a) #endif PyObject *str = PyUnicode_FromString(STRINGIZE(PYSIDE2_SYS_PATH)); PyList_Append(syspath, str); Py_DecRef(str); Py_DecRef(syspath); } #endif // set up PySide #if PYSIDE2_ENABLED { Shiboken::AutoDecRef core(Shiboken::Module::import("PySide2.QtCore")); if(!core.isNull()) SbkPySide2_QtCoreTypes = Shiboken::Module::getTypes(core); else qCritical() << "Failed to load PySide2.QtCore"; Shiboken::AutoDecRef gui(Shiboken::Module::import("PySide2.QtGui")); if(!gui.isNull()) SbkPySide2_QtGuiTypes = Shiboken::Module::getTypes(gui); else qCritical() << "Failed to load PySide2.QtGui"; Shiboken::AutoDecRef widgets(Shiboken::Module::import("PySide2.QtWidgets")); if(!widgets.isNull()) SbkPySide2_QtWidgetsTypes = Shiboken::Module::getTypes(widgets); else qCritical() << "Failed to load PySide2.QtWidgets"; } #endif // release GIL so that python work can now happen on any thread PyEval_SaveThread(); }
initpyodbc(void) #endif { ErrorInit(); if (PyType_Ready(&ConnectionType) < 0 || PyType_Ready(&CursorType) < 0 || PyType_Ready(&RowType) < 0 || PyType_Ready(&CnxnInfoType) < 0) return MODRETURN(0); Object module; #if PY_MAJOR_VERSION >= 3 module.Attach(PyModule_Create(&moduledef)); #else module.Attach(Py_InitModule4("pyodbc", pyodbc_methods, module_doc, NULL, PYTHON_API_VERSION)); #endif pModule = module.Get(); if (!module || !import_types() || !CreateExceptions()) return MODRETURN(0); init_locale_info(); const char* szVersion = TOSTRING(PYODBC_VERSION); PyModule_AddStringConstant(module, "version", (char*)szVersion); PyModule_AddIntConstant(module, "threadsafety", 1); PyModule_AddStringConstant(module, "apilevel", "2.0"); PyModule_AddStringConstant(module, "paramstyle", "qmark"); PyModule_AddObject(module, "pooling", Py_True); Py_INCREF(Py_True); PyModule_AddObject(module, "lowercase", Py_False); Py_INCREF(Py_False); PyModule_AddObject(module, "Connection", (PyObject*)&ConnectionType); Py_INCREF((PyObject*)&ConnectionType); PyModule_AddObject(module, "Cursor", (PyObject*)&CursorType); Py_INCREF((PyObject*)&CursorType); PyModule_AddObject(module, "Row", (PyObject*)&RowType); Py_INCREF((PyObject*)&RowType); // Add the SQL_XXX defines from ODBC. for (unsigned int i = 0; i < _countof(aConstants); i++) PyModule_AddIntConstant(module, (char*)aConstants[i].szName, aConstants[i].value); PyModule_AddObject(module, "Date", (PyObject*)PyDateTimeAPI->DateType); Py_INCREF((PyObject*)PyDateTimeAPI->DateType); PyModule_AddObject(module, "Time", (PyObject*)PyDateTimeAPI->TimeType); Py_INCREF((PyObject*)PyDateTimeAPI->TimeType); PyModule_AddObject(module, "Timestamp", (PyObject*)PyDateTimeAPI->DateTimeType); Py_INCREF((PyObject*)PyDateTimeAPI->DateTimeType); PyModule_AddObject(module, "DATETIME", (PyObject*)PyDateTimeAPI->DateTimeType); Py_INCREF((PyObject*)PyDateTimeAPI->DateTimeType); PyModule_AddObject(module, "STRING", (PyObject*)&PyString_Type); Py_INCREF((PyObject*)&PyString_Type); PyModule_AddObject(module, "NUMBER", (PyObject*)&PyFloat_Type); Py_INCREF((PyObject*)&PyFloat_Type); PyModule_AddObject(module, "ROWID", (PyObject*)&PyInt_Type); Py_INCREF((PyObject*)&PyInt_Type); PyObject* binary_type; #if PY_VERSION_HEX >= 0x02060000 binary_type = (PyObject*)&PyByteArray_Type; #else binary_type = (PyObject*)&PyBuffer_Type; #endif PyModule_AddObject(module, "BINARY", binary_type); Py_INCREF(binary_type); PyModule_AddObject(module, "Binary", binary_type); Py_INCREF(binary_type); I(null_binary != 0); // must be initialized first PyModule_AddObject(module, "BinaryNull", null_binary); PyModule_AddIntConstant(module, "UNICODE_SIZE", sizeof(Py_UNICODE)); PyModule_AddIntConstant(module, "SQLWCHAR_SIZE", sizeof(SQLWCHAR)); if (!PyErr_Occurred()) { module.Detach(); } else { ErrorCleanup(); } return MODRETURN(pModule); }
PyMODINIT_FUNC PyInit__io(void) { PyObject *m = PyModule_Create(&_PyIO_Module); _PyIO_State *state = NULL; if (m == NULL) return NULL; state = IO_MOD_STATE(m); state->initialized = 0; /* put os in the module state */ state->os_module = PyImport_ImportModule("os"); if (state->os_module == NULL) goto fail; #define ADD_TYPE(type, name) \ if (PyType_Ready(type) < 0) \ goto fail; \ Py_INCREF(type); \ if (PyModule_AddObject(m, name, (PyObject *)type) < 0) { \ Py_DECREF(type); \ goto fail; \ } /* DEFAULT_BUFFER_SIZE */ if (PyModule_AddIntMacro(m, DEFAULT_BUFFER_SIZE) < 0) goto fail; /* UnsupportedOperation inherits from ValueError and IOError */ state->unsupported_operation = PyObject_CallFunction( (PyObject *)&PyType_Type, "s(OO){}", "UnsupportedOperation", PyExc_ValueError, PyExc_IOError); if (state->unsupported_operation == NULL) goto fail; Py_INCREF(state->unsupported_operation); if (PyModule_AddObject(m, "UnsupportedOperation", state->unsupported_operation) < 0) goto fail; /* BlockingIOError */ _PyExc_BlockingIOError.tp_base = (PyTypeObject *) PyExc_IOError; ADD_TYPE(&_PyExc_BlockingIOError, "BlockingIOError"); /* Concrete base types of the IO ABCs. (the ABCs themselves are declared through inheritance in io.py) */ ADD_TYPE(&PyIOBase_Type, "_IOBase"); ADD_TYPE(&PyRawIOBase_Type, "_RawIOBase"); ADD_TYPE(&PyBufferedIOBase_Type, "_BufferedIOBase"); ADD_TYPE(&PyTextIOBase_Type, "_TextIOBase"); /* Implementation of concrete IO objects. */ /* FileIO */ PyFileIO_Type.tp_base = &PyRawIOBase_Type; ADD_TYPE(&PyFileIO_Type, "FileIO"); /* BytesIO */ PyBytesIO_Type.tp_base = &PyBufferedIOBase_Type; ADD_TYPE(&PyBytesIO_Type, "BytesIO"); if (PyType_Ready(&_PyBytesIOBuffer_Type) < 0) goto fail; /* StringIO */ PyStringIO_Type.tp_base = &PyTextIOBase_Type; ADD_TYPE(&PyStringIO_Type, "StringIO"); /* BufferedReader */ PyBufferedReader_Type.tp_base = &PyBufferedIOBase_Type; ADD_TYPE(&PyBufferedReader_Type, "BufferedReader"); /* BufferedWriter */ PyBufferedWriter_Type.tp_base = &PyBufferedIOBase_Type; ADD_TYPE(&PyBufferedWriter_Type, "BufferedWriter"); /* BufferedRWPair */ PyBufferedRWPair_Type.tp_base = &PyBufferedIOBase_Type; ADD_TYPE(&PyBufferedRWPair_Type, "BufferedRWPair"); /* BufferedRandom */ PyBufferedRandom_Type.tp_base = &PyBufferedIOBase_Type; ADD_TYPE(&PyBufferedRandom_Type, "BufferedRandom"); /* TextIOWrapper */ PyTextIOWrapper_Type.tp_base = &PyTextIOBase_Type; ADD_TYPE(&PyTextIOWrapper_Type, "TextIOWrapper"); /* IncrementalNewlineDecoder */ ADD_TYPE(&PyIncrementalNewlineDecoder_Type, "IncrementalNewlineDecoder"); /* Interned strings */ if (!(_PyIO_str_close = PyUnicode_InternFromString("close"))) goto fail; if (!(_PyIO_str_closed = PyUnicode_InternFromString("closed"))) goto fail; if (!(_PyIO_str_decode = PyUnicode_InternFromString("decode"))) goto fail; if (!(_PyIO_str_encode = PyUnicode_InternFromString("encode"))) goto fail; if (!(_PyIO_str_fileno = PyUnicode_InternFromString("fileno"))) goto fail; if (!(_PyIO_str_flush = PyUnicode_InternFromString("flush"))) goto fail; if (!(_PyIO_str_getstate = PyUnicode_InternFromString("getstate"))) goto fail; if (!(_PyIO_str_isatty = PyUnicode_InternFromString("isatty"))) goto fail; if (!(_PyIO_str_newlines = PyUnicode_InternFromString("newlines"))) goto fail; if (!(_PyIO_str_nl = PyUnicode_InternFromString("\n"))) goto fail; if (!(_PyIO_str_read = PyUnicode_InternFromString("read"))) goto fail; if (!(_PyIO_str_read1 = PyUnicode_InternFromString("read1"))) goto fail; if (!(_PyIO_str_readable = PyUnicode_InternFromString("readable"))) goto fail; if (!(_PyIO_str_readinto = PyUnicode_InternFromString("readinto"))) goto fail; if (!(_PyIO_str_readline = PyUnicode_InternFromString("readline"))) goto fail; if (!(_PyIO_str_reset = PyUnicode_InternFromString("reset"))) goto fail; if (!(_PyIO_str_seek = PyUnicode_InternFromString("seek"))) goto fail; if (!(_PyIO_str_seekable = PyUnicode_InternFromString("seekable"))) goto fail; if (!(_PyIO_str_setstate = PyUnicode_InternFromString("setstate"))) goto fail; if (!(_PyIO_str_tell = PyUnicode_InternFromString("tell"))) goto fail; if (!(_PyIO_str_truncate = PyUnicode_InternFromString("truncate"))) goto fail; if (!(_PyIO_str_write = PyUnicode_InternFromString("write"))) goto fail; if (!(_PyIO_str_writable = PyUnicode_InternFromString("writable"))) goto fail; if (!(_PyIO_empty_str = PyUnicode_FromStringAndSize(NULL, 0))) goto fail; if (!(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0))) goto fail; if (!(_PyIO_zero = PyLong_FromLong(0L))) goto fail; state->initialized = 1; return m; fail: Py_XDECREF(state->os_module); Py_XDECREF(state->unsupported_operation); Py_DECREF(m); return NULL; }
PyMODINIT_FUNC initGPIO(void) #endif { PyObject *module = NULL; #if PY_MAJOR_VERSION > 2 if ((module = PyModule_Create(&rpigpiomodule)) == NULL) goto exit; #else if ((module = Py_InitModule("Ox.GPIO", rpi_gpio_methods)) == NULL) goto exit; #endif WrongDirectionException = PyErr_NewException("Ox.GPIO.WrongDirectionException", NULL, NULL); PyModule_AddObject(module, "WrongDirectionException", WrongDirectionException); InvalidModeException = PyErr_NewException("Ox.GPIO.InvalidModeException", NULL, NULL); PyModule_AddObject(module, "InvalidModeException", InvalidModeException); InvalidDirectionException = PyErr_NewException("Ox.GPIO.InvalidDirectionException", NULL, NULL); PyModule_AddObject(module, "InvalidDirectionException", InvalidDirectionException); InvalidChannelException = PyErr_NewException("Ox.GPIO.InvalidChannelException", NULL, NULL); PyModule_AddObject(module, "InvalidChannelException", InvalidChannelException); InvalidPullException = PyErr_NewException("Ox.GPIO.InvalidPullException", NULL, NULL); PyModule_AddObject(module, "InvalidPullException", InvalidPullException); ModeNotSetException = PyErr_NewException("Ox.GPIO.ModeNotSetException", NULL, NULL); PyModule_AddObject(module, "ModeNotSetException", ModeNotSetException); SetupException = PyErr_NewException("Ox.GPIO.SetupException", NULL, NULL); PyModule_AddObject(module, "SetupException", SetupException); high = Py_BuildValue("i", HIGH); PyModule_AddObject(module, "HIGH", high); low = Py_BuildValue("i", LOW); PyModule_AddObject(module, "LOW", low); output = Py_BuildValue("i", OUTPUT); PyModule_AddObject(module, "OUT", output); input = Py_BuildValue("i", INPUT); PyModule_AddObject(module, "IN", input); version = Py_BuildValue("s", "0.4.1a"); PyModule_AddObject(module, "VERSION", version); // set up mmaped areas if (module_setup() != SETUP_OK ) { #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } if (Py_AtExit(gpio_close) != 0) { gpio_close(); #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } exit: #if PY_MAJOR_VERSION > 2 return module; #else return; #endif }
void initossaudiodev(void) { PyObject *m; m = Py_InitModule("ossaudiodev", ossaudiodev_methods); if (m == NULL) return; OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", NULL, NULL); if (OSSAudioError) { /* Each call to PyModule_AddObject decrefs it; compensate: */ Py_INCREF(OSSAudioError); Py_INCREF(OSSAudioError); PyModule_AddObject(m, "error", OSSAudioError); PyModule_AddObject(m, "OSSAudioError", OSSAudioError); } /* Build 'control_labels' and 'control_names' lists and add them to the module. */ if (build_namelists(m) == -1) /* XXX what to do here? */ return; /* Expose the audio format numbers -- essential! */ _EXPORT_INT(m, AFMT_QUERY); _EXPORT_INT(m, AFMT_MU_LAW); _EXPORT_INT(m, AFMT_A_LAW); _EXPORT_INT(m, AFMT_IMA_ADPCM); _EXPORT_INT(m, AFMT_U8); _EXPORT_INT(m, AFMT_S16_LE); _EXPORT_INT(m, AFMT_S16_BE); _EXPORT_INT(m, AFMT_S8); _EXPORT_INT(m, AFMT_U16_LE); _EXPORT_INT(m, AFMT_U16_BE); _EXPORT_INT(m, AFMT_MPEG); #ifdef AFMT_AC3 _EXPORT_INT(m, AFMT_AC3); #endif #ifdef AFMT_S16_NE _EXPORT_INT(m, AFMT_S16_NE); #endif #ifdef AFMT_U16_NE _EXPORT_INT(m, AFMT_U16_NE); #endif #ifdef AFMT_S32_LE _EXPORT_INT(m, AFMT_S32_LE); #endif #ifdef AFMT_S32_BE _EXPORT_INT(m, AFMT_S32_BE); #endif #ifdef AFMT_MPEG _EXPORT_INT(m, AFMT_MPEG); #endif /* Expose the sound mixer device numbers. */ _EXPORT_INT(m, SOUND_MIXER_NRDEVICES); _EXPORT_INT(m, SOUND_MIXER_VOLUME); _EXPORT_INT(m, SOUND_MIXER_BASS); _EXPORT_INT(m, SOUND_MIXER_TREBLE); _EXPORT_INT(m, SOUND_MIXER_SYNTH); _EXPORT_INT(m, SOUND_MIXER_PCM); _EXPORT_INT(m, SOUND_MIXER_SPEAKER); _EXPORT_INT(m, SOUND_MIXER_LINE); _EXPORT_INT(m, SOUND_MIXER_MIC); _EXPORT_INT(m, SOUND_MIXER_CD); _EXPORT_INT(m, SOUND_MIXER_IMIX); _EXPORT_INT(m, SOUND_MIXER_ALTPCM); _EXPORT_INT(m, SOUND_MIXER_RECLEV); _EXPORT_INT(m, SOUND_MIXER_IGAIN); _EXPORT_INT(m, SOUND_MIXER_OGAIN); _EXPORT_INT(m, SOUND_MIXER_LINE1); _EXPORT_INT(m, SOUND_MIXER_LINE2); _EXPORT_INT(m, SOUND_MIXER_LINE3); #ifdef SOUND_MIXER_DIGITAL1 _EXPORT_INT(m, SOUND_MIXER_DIGITAL1); #endif #ifdef SOUND_MIXER_DIGITAL2 _EXPORT_INT(m, SOUND_MIXER_DIGITAL2); #endif #ifdef SOUND_MIXER_DIGITAL3 _EXPORT_INT(m, SOUND_MIXER_DIGITAL3); #endif #ifdef SOUND_MIXER_PHONEIN _EXPORT_INT(m, SOUND_MIXER_PHONEIN); #endif #ifdef SOUND_MIXER_PHONEOUT _EXPORT_INT(m, SOUND_MIXER_PHONEOUT); #endif #ifdef SOUND_MIXER_VIDEO _EXPORT_INT(m, SOUND_MIXER_VIDEO); #endif #ifdef SOUND_MIXER_RADIO _EXPORT_INT(m, SOUND_MIXER_RADIO); #endif #ifdef SOUND_MIXER_MONITOR _EXPORT_INT(m, SOUND_MIXER_MONITOR); #endif /* Expose all the ioctl numbers for masochists who like to do this stuff directly. */ _EXPORT_INT(m, SNDCTL_COPR_HALT); _EXPORT_INT(m, SNDCTL_COPR_LOAD); _EXPORT_INT(m, SNDCTL_COPR_RCODE); _EXPORT_INT(m, SNDCTL_COPR_RCVMSG); _EXPORT_INT(m, SNDCTL_COPR_RDATA); _EXPORT_INT(m, SNDCTL_COPR_RESET); _EXPORT_INT(m, SNDCTL_COPR_RUN); _EXPORT_INT(m, SNDCTL_COPR_SENDMSG); _EXPORT_INT(m, SNDCTL_COPR_WCODE); _EXPORT_INT(m, SNDCTL_COPR_WDATA); #ifdef SNDCTL_DSP_BIND_CHANNEL _EXPORT_INT(m, SNDCTL_DSP_BIND_CHANNEL); #endif _EXPORT_INT(m, SNDCTL_DSP_CHANNELS); _EXPORT_INT(m, SNDCTL_DSP_GETBLKSIZE); _EXPORT_INT(m, SNDCTL_DSP_GETCAPS); #ifdef SNDCTL_DSP_GETCHANNELMASK _EXPORT_INT(m, SNDCTL_DSP_GETCHANNELMASK); #endif _EXPORT_INT(m, SNDCTL_DSP_GETFMTS); _EXPORT_INT(m, SNDCTL_DSP_GETIPTR); _EXPORT_INT(m, SNDCTL_DSP_GETISPACE); #ifdef SNDCTL_DSP_GETODELAY _EXPORT_INT(m, SNDCTL_DSP_GETODELAY); #endif _EXPORT_INT(m, SNDCTL_DSP_GETOPTR); _EXPORT_INT(m, SNDCTL_DSP_GETOSPACE); #ifdef SNDCTL_DSP_GETSPDIF _EXPORT_INT(m, SNDCTL_DSP_GETSPDIF); #endif _EXPORT_INT(m, SNDCTL_DSP_GETTRIGGER); _EXPORT_INT(m, SNDCTL_DSP_MAPINBUF); _EXPORT_INT(m, SNDCTL_DSP_MAPOUTBUF); _EXPORT_INT(m, SNDCTL_DSP_NONBLOCK); _EXPORT_INT(m, SNDCTL_DSP_POST); #ifdef SNDCTL_DSP_PROFILE _EXPORT_INT(m, SNDCTL_DSP_PROFILE); #endif _EXPORT_INT(m, SNDCTL_DSP_RESET); _EXPORT_INT(m, SNDCTL_DSP_SAMPLESIZE); _EXPORT_INT(m, SNDCTL_DSP_SETDUPLEX); _EXPORT_INT(m, SNDCTL_DSP_SETFMT); _EXPORT_INT(m, SNDCTL_DSP_SETFRAGMENT); #ifdef SNDCTL_DSP_SETSPDIF _EXPORT_INT(m, SNDCTL_DSP_SETSPDIF); #endif _EXPORT_INT(m, SNDCTL_DSP_SETSYNCRO); _EXPORT_INT(m, SNDCTL_DSP_SETTRIGGER); _EXPORT_INT(m, SNDCTL_DSP_SPEED); _EXPORT_INT(m, SNDCTL_DSP_STEREO); _EXPORT_INT(m, SNDCTL_DSP_SUBDIVIDE); _EXPORT_INT(m, SNDCTL_DSP_SYNC); _EXPORT_INT(m, SNDCTL_FM_4OP_ENABLE); _EXPORT_INT(m, SNDCTL_FM_LOAD_INSTR); _EXPORT_INT(m, SNDCTL_MIDI_INFO); _EXPORT_INT(m, SNDCTL_MIDI_MPUCMD); _EXPORT_INT(m, SNDCTL_MIDI_MPUMODE); _EXPORT_INT(m, SNDCTL_MIDI_PRETIME); _EXPORT_INT(m, SNDCTL_SEQ_CTRLRATE); _EXPORT_INT(m, SNDCTL_SEQ_GETINCOUNT); _EXPORT_INT(m, SNDCTL_SEQ_GETOUTCOUNT); #ifdef SNDCTL_SEQ_GETTIME _EXPORT_INT(m, SNDCTL_SEQ_GETTIME); #endif _EXPORT_INT(m, SNDCTL_SEQ_NRMIDIS); _EXPORT_INT(m, SNDCTL_SEQ_NRSYNTHS); _EXPORT_INT(m, SNDCTL_SEQ_OUTOFBAND); _EXPORT_INT(m, SNDCTL_SEQ_PANIC); _EXPORT_INT(m, SNDCTL_SEQ_PERCMODE); _EXPORT_INT(m, SNDCTL_SEQ_RESET); _EXPORT_INT(m, SNDCTL_SEQ_RESETSAMPLES); _EXPORT_INT(m, SNDCTL_SEQ_SYNC); _EXPORT_INT(m, SNDCTL_SEQ_TESTMIDI); _EXPORT_INT(m, SNDCTL_SEQ_THRESHOLD); #ifdef SNDCTL_SYNTH_CONTROL _EXPORT_INT(m, SNDCTL_SYNTH_CONTROL); #endif #ifdef SNDCTL_SYNTH_ID _EXPORT_INT(m, SNDCTL_SYNTH_ID); #endif _EXPORT_INT(m, SNDCTL_SYNTH_INFO); _EXPORT_INT(m, SNDCTL_SYNTH_MEMAVL); #ifdef SNDCTL_SYNTH_REMOVESAMPLE _EXPORT_INT(m, SNDCTL_SYNTH_REMOVESAMPLE); #endif _EXPORT_INT(m, SNDCTL_TMR_CONTINUE); _EXPORT_INT(m, SNDCTL_TMR_METRONOME); _EXPORT_INT(m, SNDCTL_TMR_SELECT); _EXPORT_INT(m, SNDCTL_TMR_SOURCE); _EXPORT_INT(m, SNDCTL_TMR_START); _EXPORT_INT(m, SNDCTL_TMR_STOP); _EXPORT_INT(m, SNDCTL_TMR_TEMPO); _EXPORT_INT(m, SNDCTL_TMR_TIMEBASE); }
PyMODINIT_FUNC initumath(void) #endif { PyObject *m, *d, *s, *s2, *c_api; int UFUNC_FLOATING_POINT_SUPPORT = 1; #ifdef NO_UFUNC_FLOATING_POINT_SUPPORT UFUNC_FLOATING_POINT_SUPPORT = 0; #endif /* Create the module and add the functions */ #if defined(NPY_PY3K) m = PyModule_Create(&moduledef); #else m = Py_InitModule("umath", methods); #endif if (!m) { return RETVAL; } /* Import the array */ if (_import_array() < 0) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "umath failed: Could not import array core."); } return RETVAL; } /* Initialize the types */ if (PyType_Ready(&PyUFunc_Type) < 0) return RETVAL; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); c_api = NpyCapsule_FromVoidPtr((void *)PyUFunc_API, NULL); if (PyErr_Occurred()) { goto err; } PyDict_SetItemString(d, "_UFUNC_API", c_api); Py_DECREF(c_api); if (PyErr_Occurred()) { goto err; } s = PyString_FromString("0.4.0"); PyDict_SetItemString(d, "__version__", s); Py_DECREF(s); /* Load the ufunc operators into the array module's namespace */ InitOperators(d); InitOtherOperators(d); PyDict_SetItemString(d, "pi", s = PyFloat_FromDouble(NPY_PI)); Py_DECREF(s); PyDict_SetItemString(d, "e", s = PyFloat_FromDouble(NPY_E)); Py_DECREF(s); PyDict_SetItemString(d, "euler_gamma", s = PyFloat_FromDouble(NPY_EULER)); Py_DECREF(s); #define ADDCONST(str) PyModule_AddIntConstant(m, #str, UFUNC_##str) #define ADDSCONST(str) PyModule_AddStringConstant(m, "UFUNC_" #str, UFUNC_##str) ADDCONST(ERR_IGNORE); ADDCONST(ERR_WARN); ADDCONST(ERR_CALL); ADDCONST(ERR_RAISE); ADDCONST(ERR_PRINT); ADDCONST(ERR_LOG); ADDCONST(ERR_DEFAULT); ADDCONST(SHIFT_DIVIDEBYZERO); ADDCONST(SHIFT_OVERFLOW); ADDCONST(SHIFT_UNDERFLOW); ADDCONST(SHIFT_INVALID); ADDCONST(FPE_DIVIDEBYZERO); ADDCONST(FPE_OVERFLOW); ADDCONST(FPE_UNDERFLOW); ADDCONST(FPE_INVALID); ADDCONST(FLOATING_POINT_SUPPORT); ADDSCONST(PYVALS_NAME); #undef ADDCONST #undef ADDSCONST PyModule_AddIntConstant(m, "UFUNC_BUFSIZE_DEFAULT", (long)NPY_BUFSIZE); PyModule_AddObject(m, "PINF", PyFloat_FromDouble(NPY_INFINITY)); PyModule_AddObject(m, "NINF", PyFloat_FromDouble(-NPY_INFINITY)); PyModule_AddObject(m, "PZERO", PyFloat_FromDouble(NPY_PZERO)); PyModule_AddObject(m, "NZERO", PyFloat_FromDouble(NPY_NZERO)); PyModule_AddObject(m, "NAN", PyFloat_FromDouble(NPY_NAN)); s = PyDict_GetItemString(d, "conjugate"); s2 = PyDict_GetItemString(d, "remainder"); /* Setup the array object's numerical structures with appropriate ufuncs in d*/ PyArray_SetNumericOps(d); PyDict_SetItemString(d, "conj", s); PyDict_SetItemString(d, "mod", s2); if (!intern_strings()) { goto err; } return RETVAL; err: /* Check for errors */ if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load umath module."); } return RETVAL; }
void add_class(PyObject * module, PyTypeObject * type, const char * classname) { Py_INCREF(type); PyModule_AddObject(module, classname, (PyObject *)type); }
static PyObject* create_module (void) { PyBobLearnLinearMachine_Type.tp_new = PyType_GenericNew; if (PyType_Ready(&PyBobLearnLinearMachine_Type) < 0) return 0; PyBobLearnLinearPCATrainer_Type.tp_new = PyType_GenericNew; if (PyType_Ready(&PyBobLearnLinearPCATrainer_Type) < 0) return 0; PyBobLearnLinearFisherLDATrainer_Type.tp_new = PyType_GenericNew; if (PyType_Ready(&PyBobLearnLinearFisherLDATrainer_Type) < 0) return 0; PyBobLearnLinearCGLogRegTrainer_Type.tp_new = PyType_GenericNew; if (PyType_Ready(&PyBobLearnLinearCGLogRegTrainer_Type) < 0) return 0; PyBobLearnLinearWhiteningTrainer_Type.tp_new = PyType_GenericNew; if (PyType_Ready(&PyBobLearnLinearWhiteningTrainer_Type) < 0) return 0; PyBobLearnLinearWCCNTrainer_Type.tp_new = PyType_GenericNew; if (PyType_Ready(&PyBobLearnLinearWCCNTrainer_Type) < 0) return 0; # if PY_VERSION_HEX >= 0x03000000 PyObject* m = PyModule_Create(&module_definition); # else PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr); # endif if (!m) return 0; auto m_ = make_safe(m); /* register the types to python */ Py_INCREF(&PyBobLearnLinearMachine_Type); if (PyModule_AddObject(m, "Machine", (PyObject *)&PyBobLearnLinearMachine_Type) < 0) return 0; Py_INCREF(&PyBobLearnLinearPCATrainer_Type); if (PyModule_AddObject(m, "PCATrainer", (PyObject *)&PyBobLearnLinearPCATrainer_Type) < 0) return 0; Py_INCREF(&PyBobLearnLinearFisherLDATrainer_Type); if (PyModule_AddObject(m, "FisherLDATrainer", (PyObject *)&PyBobLearnLinearFisherLDATrainer_Type) < 0) return 0; Py_INCREF(&PyBobLearnLinearCGLogRegTrainer_Type); if (PyModule_AddObject(m, "CGLogRegTrainer", (PyObject *)&PyBobLearnLinearCGLogRegTrainer_Type) < 0) return 0; Py_INCREF(&PyBobLearnLinearWhiteningTrainer_Type); if (PyModule_AddObject(m, "WhiteningTrainer", (PyObject *)&PyBobLearnLinearWhiteningTrainer_Type) < 0) return 0; Py_INCREF(&PyBobLearnLinearWCCNTrainer_Type); if (PyModule_AddObject(m, "WCCNTrainer", (PyObject *)&PyBobLearnLinearWCCNTrainer_Type) < 0) return 0; if (!init_BobLearnLinearBIC(m)) return 0; static void* PyBobLearnLinear_API[PyBobLearnLinear_API_pointers]; /* exhaustive list of C APIs */ /************** * Versioning * **************/ PyBobLearnLinear_API[PyBobLearnLinear_APIVersion_NUM] = (void *)&PyBobLearnLinear_APIVersion; /****************************************** * Bindings for bob.learn.linear.Machine * ******************************************/ PyBobLearnLinear_API[PyBobLearnLinearMachine_Type_NUM] = (void *)&PyBobLearnLinearMachine_Type; PyBobLearnLinear_API[PyBobLearnLinearMachine_Check_NUM] = (void *)&PyBobLearnLinearMachine_Check; PyBobLearnLinear_API[PyBobLearnLinearMachine_NewFromSize_NUM] = (void *)&PyBobLearnLinearMachine_NewFromSize; /********************************************* * Bindings for bob.learn.linear.PCATrainer * *********************************************/ PyBobLearnLinear_API[PyBobLearnLinearPCATrainer_Type_NUM] = (void *)&PyBobLearnLinearPCATrainer_Type; PyBobLearnLinear_API[PyBobLearnLinearPCATrainer_Check_NUM] = (void *)&PyBobLearnLinearPCATrainer_Check; /*************************************************** * Bindings for bob.learn.linear.FisherLDATrainer * ***************************************************/ PyBobLearnLinear_API[PyBobLearnLinearFisherLDATrainer_Type_NUM] = (void *)&PyBobLearnLinearFisherLDATrainer_Type; PyBobLearnLinear_API[PyBobLearnLinearFisherLDATrainer_Check_NUM] = (void *)&PyBobLearnLinearFisherLDATrainer_Check; /************************************************** * Bindings for bob.learn.linear.CGLogRegTrainer * **************************************************/ PyBobLearnLinear_API[PyBobLearnLinearCGLogRegTrainer_Type_NUM] = (void *)&PyBobLearnLinearCGLogRegTrainer_Type; PyBobLearnLinear_API[PyBobLearnLinearCGLogRegTrainer_Check_NUM] = (void *)&PyBobLearnLinearCGLogRegTrainer_Check; /*************************************************** * Bindings for bob.learn.linear.WhiteningTrainer * ***************************************************/ PyBobLearnLinear_API[PyBobLearnLinearWhiteningTrainer_Type_NUM] = (void *)&PyBobLearnLinearWhiteningTrainer_Type; PyBobLearnLinear_API[PyBobLearnLinearWhiteningTrainer_Check_NUM] = (void *)&PyBobLearnLinearWhiteningTrainer_Check; /*************************************************** * Bindings for bob.learn.linear.WCCNTrainer * ***************************************************/ PyBobLearnLinear_API[PyBobLearnLinearWCCNTrainer_Type_NUM] = (void *)&PyBobLearnLinearWCCNTrainer_Type; PyBobLearnLinear_API[PyBobLearnLinearWCCNTrainer_Check_NUM] = (void *)&PyBobLearnLinearWCCNTrainer_Check; #if PY_VERSION_HEX >= 0x02070000 /* defines the PyCapsule */ PyObject* c_api_object = PyCapsule_New((void *)PyBobLearnLinear_API, BOB_EXT_MODULE_PREFIX "." BOB_EXT_MODULE_NAME "._C_API", 0); #else PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyBobLearnLinear_API, 0); #endif if (c_api_object) PyModule_AddObject(m, "_C_API", c_api_object); /* imports dependencies */ if (import_bob_blitz() < 0) return 0; if (import_bob_core_logging() < 0) return 0; if (import_bob_io_base() < 0) return 0; if (import_bob_learn_activation() < 0) return 0; return Py_BuildValue("O", m); }
static PyObject *moduleinit(void) { static apr_pool_t *pool; PyObject *mod; if (PyType_Ready(&Repository_Type) < 0) return NULL; if (PyType_Ready(&FileSystem_Type) < 0) return NULL; if (PyType_Ready(&FileSystemRoot_Type) < 0) return NULL; if (PyType_Ready(&Stream_Type) < 0) return NULL; apr_initialize(); pool = Pool(NULL); if (pool == NULL) return NULL; svn_fs_initialize(pool); #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "repos", /* m_name */ "Local repository management.", /* m_doc */ -1, /* m_size */ repos_module_methods, /* m_methods */ NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear*/ NULL, /* m_free */ }; mod = PyModule_Create(&moduledef); #else mod = Py_InitModule3("repos", repos_module_methods, "Local repository management"); #endif if (mod == NULL) return NULL; PyModule_AddIntConstant(mod, "LOAD_UUID_DEFAULT", svn_repos_load_uuid_default); PyModule_AddIntConstant(mod, "LOAD_UUID_IGNORE", svn_repos_load_uuid_ignore); PyModule_AddIntConstant(mod, "LOAD_UUID_FORCE", svn_repos_load_uuid_force); PyModule_AddIntConstant(mod, "PATH_CHANGE_MODIFY", svn_fs_path_change_modify); PyModule_AddIntConstant(mod, "PATH_CHANGE_ADD", svn_fs_path_change_add); PyModule_AddIntConstant(mod, "PATH_CHANGE_DELETE", svn_fs_path_change_delete); PyModule_AddIntConstant(mod, "PATH_CHANGE_REPLACE", svn_fs_path_change_replace); #if ONLY_SINCE_SVN(1, 6) PyModule_AddIntConstant(mod, "CHECKSUM_MD5", svn_checksum_md5); PyModule_AddIntConstant(mod, "CHECKSUM_SHA1", svn_checksum_sha1); #else PyModule_AddIntConstant(mod, "CHECKSUM_MD5", 0); #endif PyModule_AddObject(mod, "Repository", (PyObject *)&Repository_Type); Py_INCREF(&Repository_Type); PyModule_AddObject(mod, "Stream", (PyObject *)&Stream_Type); Py_INCREF(&Stream_Type); return mod; }
PyObject *uwsgi_pyimport_by_filename(char *name, char *filename) { #ifdef UWSGI_PYPY uwsgi_log("import by filename is currently not supported on PyPy !!!\n"); return NULL; #else FILE *pyfile; struct _node *py_file_node = NULL; PyObject *py_compiled_node, *py_file_module; int is_a_package = 0; struct stat pystat; char *real_filename = filename; if (!uwsgi_check_scheme(filename)) { pyfile = fopen(filename, "r"); if (!pyfile) { uwsgi_log("failed to open python file %s\n", filename); return NULL; } if (fstat(fileno(pyfile), &pystat)) { fclose(pyfile); uwsgi_error("fstat()"); return NULL; } if (S_ISDIR(pystat.st_mode)) { is_a_package = 1; fclose(pyfile); real_filename = uwsgi_concat2(filename, "/__init__.py"); pyfile = fopen(real_filename, "r"); if (!pyfile) { uwsgi_error_open(real_filename); free(real_filename); return NULL; } } py_file_node = PyParser_SimpleParseFile(pyfile, real_filename, Py_file_input); if (!py_file_node) { PyErr_Print(); uwsgi_log("failed to parse file %s\n", real_filename); if (is_a_package) free(real_filename); fclose(pyfile); return NULL; } fclose(pyfile); } else { int pycontent_size = 0; char *pycontent = uwsgi_open_and_read(filename, &pycontent_size, 1, NULL); if (pycontent) { py_file_node = PyParser_SimpleParseString(pycontent, Py_file_input); if (!py_file_node) { PyErr_Print(); uwsgi_log("failed to parse url %s\n", real_filename); return NULL; } } } py_compiled_node = (PyObject *) PyNode_Compile(py_file_node, real_filename); if (!py_compiled_node) { PyErr_Print(); uwsgi_log("failed to compile python file %s\n", real_filename); return NULL; } if (is_a_package) { py_file_module = PyImport_AddModule(name); if (py_file_module) { PyModule_AddObject(py_file_module, "__path__", Py_BuildValue("[O]", PyString_FromString(filename))); } free(real_filename); } py_file_module = PyImport_ExecCodeModule(name, py_compiled_node); if (!py_file_module) { PyErr_Print(); return NULL; } Py_DECREF(py_compiled_node); return py_file_module; #endif }
PyObject * AerospikeException_New(void) { static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "aerospike.exception", /* m_name */ "Exception objects", /* m_doc */ -1, /* m_size */ NULL, /* m_methods */ NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL, /* m_free */ }; module = PyModule_Create(&moduledef); struct exceptions exceptions_array; memset(&exceptions_array, 0, sizeof(exceptions_array)); struct server_exceptions_struct server_array = { {&exceptions_array.InvalidRequest, &exceptions_array.ServerFull, &exceptions_array.NoXDR, &exceptions_array.UnsupportedFeature, &exceptions_array.DeviceOverload, &exceptions_array.NamespaceNotFound, &exceptions_array.ForbiddenError, &exceptions_array.QueryError, &exceptions_array.ClusterError}, {"InvalidRequest", "ServerFull", "NoXDR", "UnsupportedFeature", "DeviceOverload", "NamespaceNotFound", "ForbiddenError", "QueryError", "ClusterError"}, {AEROSPIKE_ERR_REQUEST_INVALID, AEROSPIKE_ERR_SERVER_FULL, AEROSPIKE_ERR_NO_XDR, AEROSPIKE_ERR_UNSUPPORTED_FEATURE, AEROSPIKE_ERR_DEVICE_OVERLOAD, AEROSPIKE_ERR_NAMESPACE_NOT_FOUND, AEROSPIKE_ERR_FAIL_FORBIDDEN, AEROSPIKE_ERR_QUERY, AEROSPIKE_ERR_CLUSTER} }; struct record_exceptions_struct record_array = { {&exceptions_array.RecordKeyMismatch, &exceptions_array.RecordNotFound, &exceptions_array.RecordGenerationError, &exceptions_array.RecordExistsError, &exceptions_array.RecordTooBig, &exceptions_array.RecordBusy, &exceptions_array.BinNameError, &exceptions_array.BinExistsError, &exceptions_array.BinNotFound, &exceptions_array.BinIncompatibleType}, {"RecordKeyMismatch", "RecordNotFound", "RecordGenerationError", "RecordExistsError", "RecordTooBig", "RecordBusy", "BinNameError", "BinExistsError", "BinNotFound", "BinIncompatibleType"}, {AEROSPIKE_ERR_RECORD_KEY_MISMATCH, AEROSPIKE_ERR_RECORD_NOT_FOUND, AEROSPIKE_ERR_RECORD_GENERATION, AEROSPIKE_ERR_RECORD_EXISTS, AEROSPIKE_ERR_RECORD_TOO_BIG, AEROSPIKE_ERR_RECORD_BUSY, AEROSPIKE_ERR_BIN_NAME, AEROSPIKE_ERR_BIN_EXISTS, AEROSPIKE_ERR_BIN_NOT_FOUND, AEROSPIKE_ERR_BIN_INCOMPATIBLE_TYPE} }; struct index_exceptions_struct index_array = { {&exceptions_array.IndexNotFound, &exceptions_array.IndexFoundError, &exceptions_array.IndexOOM, &exceptions_array.IndexNotReadable, &exceptions_array.IndexNameMaxLen, &exceptions_array.IndexNameMaxCount}, {"IndexNotFound", "IndexFoundError", "IndexOOM", "IndexNotReadable", "IndexNameMaxLen", "IndexNameMaxCount"}, {AEROSPIKE_ERR_INDEX_NOT_FOUND, AEROSPIKE_ERR_INDEX_FOUND, AEROSPIKE_ERR_INDEX_OOM, AEROSPIKE_ERR_INDEX_NOT_READABLE, AEROSPIKE_ERR_INDEX_NAME_MAXLEN, AEROSPIKE_ERR_INDEX_MAXCOUNT} }; struct admin_exceptions_struct admin_array = { {&exceptions_array.SecurityNotSupported, &exceptions_array.SecurityNotEnabled, &exceptions_array.SecuritySchemeNotSupported, &exceptions_array.InvalidCommand, &exceptions_array.InvalidField, &exceptions_array.IllegalState, &exceptions_array.InvalidUser, &exceptions_array.UserExistsError, &exceptions_array.InvalidPassword, &exceptions_array.ExpiredPassword, &exceptions_array.ForbiddenPassword, &exceptions_array.InvalidCredential, &exceptions_array.InvalidRole, &exceptions_array.RoleExistsError, &exceptions_array.RoleViolation, &exceptions_array.InvalidPrivilege, &exceptions_array.NotAuthenticated}, {"SecurityNotSupported", "SecurityNotEnabled", "SecuritySchemeNotSupported", "InvalidCommand", "InvalidField", "IllegalState", "InvalidUser", "UserExistsError", "InvalidPassword", "ExpiredPassword", "ForbiddenPassword", "InvalidCredential", "InvalidRole", "RoleExistsError", "RoleViolation", "InvalidPrivilege", "NotAuthenticated"}, {AEROSPIKE_SECURITY_NOT_SUPPORTED, AEROSPIKE_SECURITY_NOT_ENABLED, AEROSPIKE_SECURITY_SCHEME_NOT_SUPPORTED, AEROSPIKE_INVALID_COMMAND, AEROSPIKE_INVALID_FIELD, AEROSPIKE_ILLEGAL_STATE, AEROSPIKE_INVALID_USER, AEROSPIKE_USER_ALREADY_EXISTS, AEROSPIKE_INVALID_PASSWORD, AEROSPIKE_EXPIRED_PASSWORD, AEROSPIKE_FORBIDDEN_PASSWORD, AEROSPIKE_INVALID_CREDENTIAL, AEROSPIKE_INVALID_ROLE, AEROSPIKE_ROLE_ALREADY_EXISTS, AEROSPIKE_ROLE_VIOLATION, AEROSPIKE_INVALID_PRIVILEGE, AEROSPIKE_NOT_AUTHENTICATED} }; struct ldt_exceptions_struct ldt_array = { {&exceptions_array.LargeItemNotFound, &exceptions_array.LDTInternalError, &exceptions_array.LDTNotFound, &exceptions_array.LDTUniqueKeyError, &exceptions_array.LDTInsertError, &exceptions_array.LDTSearchError, &exceptions_array.LDTDeleteError, &exceptions_array.LDTInputParamError, &exceptions_array.LDTTypeMismatch, &exceptions_array.LDTBinNameNull, &exceptions_array.LDTBinNameNotString, &exceptions_array.LDTBinNameTooLong, &exceptions_array.LDTTooManyOpenSubrecs, &exceptions_array.LDTTopRecNotFound, &exceptions_array.LDTSubRecNotFound, &exceptions_array.LDTBinNotFound, &exceptions_array.LDTBinExistsError, &exceptions_array.LDTBinDamaged, &exceptions_array.LDTSubrecPoolDamaged, &exceptions_array.LDTSubrecDamaged, &exceptions_array.LDTSubrecOpenError, &exceptions_array.LDTSubrecUpdateError, &exceptions_array.LDTSubrecCreateError, &exceptions_array.LDTSubrecDeleteError, &exceptions_array.LDTSubrecCloseError, &exceptions_array.LDTToprecUpdateError, &exceptions_array.LDTToprecCreateError, &exceptions_array.LDTFilterFunctionBad, &exceptions_array.LDTFilterFunctionNotFound, &exceptions_array.LDTKeyFunctionBad, &exceptions_array.LDTKeyFunctionNotFound, &exceptions_array.LDTTransFunctionBad, &exceptions_array.LDTTransFunctionNotFound, &exceptions_array.LDTUntransFunctionBad, &exceptions_array.LDTUntransFunctionNotFound, &exceptions_array.LDTUserModuleBad, &exceptions_array.LDTUserModuleNotFound}, {"LargeItemNotFound", "LDTInternalError", "LDTNotFound", "LDTUniqueKeyError", "LDTInsertError", "LDTSearchError", "LDTDeleteError", "LDTInputParamError", "LDTTypeMismatch", "LDTBinNameNull", "LDTBinNameNotString", "LDTBinNameTooLong", "LDTTooManyOpenSubrecs", "LDTTopRecNotFound", "LDTSubRecNotFound", "LDTBinNotFound", "LDTBinExistsError", "LDTBinDamaged", "LDTSubrecPoolDamaged", "LDTSubrecDamaged", "LDTSubrecOpenError", "LDTSubrecUpdateError", "LDTSubrecCreateError", "LDTSubrecDeleteError", "LDTSubrecCloseError", "LDTToprecUpdateError", "LDTToprecCreateError", "LDTFilterFunctionBad", "LDTFilterFunctionNotFound", "LDTKeyFunctionBad", "LDTKeyFunctionNotFound", "LDTTransFunctionBad", "LDTTransFunctionNotFound", "LDTUntransFunctionBad", "LDTUntransFunctionNotFound", "LDTUserModuleBad", "LDTUserModuleNotFound"}, {AEROSPIKE_ERR_LARGE_ITEM_NOT_FOUND, AEROSPIKE_ERR_LDT_INTERNAL, AEROSPIKE_ERR_LDT_NOT_FOUND, AEROSPIKE_ERR_LDT_UNIQUE_KEY, AEROSPIKE_ERR_LDT_INSERT, AEROSPIKE_ERR_LDT_SEARCH, AEROSPIKE_ERR_LDT_DELETE, AEROSPIKE_ERR_LDT_INPUT_PARM, AEROSPIKE_ERR_LDT_TYPE_MISMATCH, AEROSPIKE_ERR_LDT_NULL_BIN_NAME, AEROSPIKE_ERR_LDT_BIN_NAME_NOT_STRING, AEROSPIKE_ERR_LDT_BIN_NAME_TOO_LONG, AEROSPIKE_ERR_LDT_TOO_MANY_OPEN_SUBRECS, AEROSPIKE_ERR_LDT_TOP_REC_NOT_FOUND, AEROSPIKE_ERR_LDT_SUB_REC_NOT_FOUND, AEROSPIKE_ERR_LDT_BIN_DOES_NOT_EXIST, AEROSPIKE_ERR_LDT_BIN_ALREADY_EXISTS, AEROSPIKE_ERR_LDT_BIN_DAMAGED, AEROSPIKE_ERR_LDT_SUBREC_POOL_DAMAGED, AEROSPIKE_ERR_LDT_SUBREC_DAMAGED, AEROSPIKE_ERR_LDT_SUBREC_OPEN, AEROSPIKE_ERR_LDT_SUBREC_UPDATE, AEROSPIKE_ERR_LDT_SUBREC_CREATE, AEROSPIKE_ERR_LDT_SUBREC_DELETE, AEROSPIKE_ERR_LDT_SUBREC_CLOSE, AEROSPIKE_ERR_LDT_TOPREC_UPDATE, AEROSPIKE_ERR_LDT_TOPREC_CREATE, AEROSPIKE_ERR_LDT_FILTER_FUNCTION_BAD, AEROSPIKE_ERR_LDT_FILTER_FUNCTION_NOT_FOUND, AEROSPIKE_ERR_LDT_KEY_FUNCTION_BAD, AEROSPIKE_ERR_LDT_KEY_FUNCTION_NOT_FOUND, AEROSPIKE_ERR_LDT_TRANS_FUNCTION_BAD, AEROSPIKE_ERR_LDT_TRANS_FUNCTION_NOT_FOUND, AEROSPIKE_ERR_LDT_UNTRANS_FUNCTION_BAD, AEROSPIKE_ERR_LDT_UNTRANS_FUNCTION_NOT_FOUND, AEROSPIKE_ERR_LDT_USER_MODULE_BAD, AEROSPIKE_ERR_LDT_USER_MODULE_NOT_FOUND} }; PyObject *py_code = NULL; PyObject *py_dict = PyDict_New(); PyDict_SetItemString(py_dict, "code", Py_None); PyDict_SetItemString(py_dict, "file", Py_None); PyDict_SetItemString(py_dict, "msg", Py_None); PyDict_SetItemString(py_dict, "line", Py_None); exceptions_array.AerospikeError = PyErr_NewException("exception.AerospikeError", NULL, py_dict); Py_INCREF(exceptions_array.AerospikeError); Py_DECREF(py_dict); PyModule_AddObject(module, "AerospikeError", exceptions_array.AerospikeError); PyObject_SetAttrString(exceptions_array.AerospikeError, "code", Py_None); exceptions_array.ClientError = PyErr_NewException("exception.ClientError", exceptions_array.AerospikeError, NULL); Py_INCREF(exceptions_array.ClientError); PyModule_AddObject(module, "ClientError", exceptions_array.ClientError); py_code = PyInt_FromLong(AEROSPIKE_ERR_CLIENT); PyObject_SetAttrString(exceptions_array.ClientError, "code", py_code); Py_DECREF(py_code); exceptions_array.ServerError = PyErr_NewException("exception.ServerError", exceptions_array.AerospikeError, NULL); Py_INCREF(exceptions_array.ServerError); PyModule_AddObject(module, "ServerError", exceptions_array.ServerError); py_code = PyInt_FromLong(AEROSPIKE_ERR_SERVER); PyObject_SetAttrString(exceptions_array.ServerError, "code", py_code); Py_DECREF(py_code); exceptions_array.TimeoutError = PyErr_NewException("exception.TimeoutError", exceptions_array.AerospikeError, NULL); Py_INCREF(exceptions_array.TimeoutError); PyModule_AddObject(module, "TimeoutError", exceptions_array.TimeoutError); py_code = PyInt_FromLong(AEROSPIKE_ERR_TIMEOUT); PyObject_SetAttrString(exceptions_array.TimeoutError, "code", py_code); Py_DECREF(py_code); //Client Exceptions exceptions_array.ParamError = PyErr_NewException("exception.ParamError", exceptions_array.ClientError, NULL); Py_INCREF(exceptions_array.ParamError); PyModule_AddObject(module, "ParamError", exceptions_array.ParamError); py_code = PyInt_FromLong(AEROSPIKE_ERR_PARAM); PyObject_SetAttrString(exceptions_array.ParamError, "code", py_code); Py_DECREF(py_code); exceptions_array.InvalidHostError = PyErr_NewException("exception.InvalidHostError", exceptions_array.ClientError, NULL); Py_INCREF(exceptions_array.InvalidHostError); PyModule_AddObject(module, "InvalidHostError", exceptions_array.InvalidHostError); py_code = PyInt_FromLong(AEROSPIKE_ERR_INVALID_HOST); PyObject_SetAttrString(exceptions_array.InvalidHostError, "code", py_code); Py_DECREF(py_code); //Server Exceptions int count = sizeof(server_array.server_exceptions)/sizeof(server_array.server_exceptions[0]); int i; PyObject **current_exception; for(i=0; i < count; i++) { current_exception = server_array.server_exceptions[i]; char * name = server_array.server_exceptions_name[i]; char prefix[40] = "exception."; *current_exception = PyErr_NewException(strcat(prefix, name), exceptions_array.ServerError, NULL); Py_INCREF(*current_exception); PyModule_AddObject(module, name, *current_exception); PyObject *py_code = PyInt_FromLong(server_array.server_exceptions_codes[i]); PyObject_SetAttrString(*current_exception, "code", py_code); Py_DECREF(py_code); } exceptions_array.ClusterChangeError = PyErr_NewException("exception.ClusterChangeError", exceptions_array.ClusterError, NULL); Py_INCREF(exceptions_array.ClusterChangeError); PyModule_AddObject(module, "ClusterChangeError", exceptions_array.ClusterChangeError); py_code = PyInt_FromLong(AEROSPIKE_ERR_CLUSTER_CHANGE); PyObject_SetAttrString(exceptions_array.ClusterChangeError, "code", py_code); Py_DECREF(py_code); //Record exceptions PyObject *py_record_dict = PyDict_New(); PyDict_SetItemString(py_record_dict, "key", Py_None); PyDict_SetItemString(py_record_dict, "bin", Py_None); exceptions_array.RecordError = PyErr_NewException("exception.RecordError", exceptions_array.ServerError, py_record_dict); Py_INCREF(exceptions_array.RecordError); Py_DECREF(py_record_dict); PyModule_AddObject(module, "RecordError", exceptions_array.RecordError); //int count = sizeof(record_exceptions)/sizeof(record_exceptions[0]); count = sizeof(record_array.record_exceptions)/sizeof(record_array.record_exceptions[0]); for(i=0; i < count; i++) { current_exception = record_array.record_exceptions[i]; char * name = record_array.record_exceptions_name[i]; char prefix[40] = "exception."; *current_exception = PyErr_NewException(strcat(prefix, name), exceptions_array.RecordError, NULL); Py_INCREF(*current_exception); PyModule_AddObject(module, name, *current_exception); PyObject *py_code = PyInt_FromLong(record_array.record_exceptions_codes[i]); PyObject_SetAttrString(*current_exception, "code", py_code); Py_DECREF(py_code); } //Index exceptions PyObject *py_index_dict = PyDict_New(); PyDict_SetItemString(py_index_dict, "name", Py_None); exceptions_array.IndexError = PyErr_NewException("exception.IndexError", exceptions_array.ServerError, py_index_dict); Py_INCREF(exceptions_array.IndexError); Py_DECREF(py_index_dict); PyModule_AddObject(module, "IndexError", exceptions_array.IndexError); count = sizeof(index_array.index_exceptions)/sizeof(index_array.index_exceptions[0]); for(i=0; i < count; i++) { current_exception = index_array.index_exceptions[i]; char * name = index_array.index_exceptions_name[i]; char prefix[40] = "exception."; *current_exception = PyErr_NewException(strcat(prefix, name), exceptions_array.IndexError, NULL); Py_INCREF(*current_exception); PyModule_AddObject(module, name, *current_exception); PyObject *py_code = PyInt_FromLong(index_array.index_exceptions_codes[i]); PyObject_SetAttrString(*current_exception, "code", py_code); Py_DECREF(py_code); } //UDF exceptions PyObject *py_udf_dict = PyDict_New(); PyDict_SetItemString(py_udf_dict, "module", Py_None); PyDict_SetItemString(py_udf_dict, "func", Py_None); exceptions_array.UDFError = PyErr_NewException("exception.UDFError", exceptions_array.ServerError, py_udf_dict); Py_INCREF(exceptions_array.UDFError); Py_DECREF(py_udf_dict); PyModule_AddObject(module, "UDFError", exceptions_array.UDFError); py_code = PyInt_FromLong(AEROSPIKE_ERR_UDF); PyObject_SetAttrString(exceptions_array.UDFError, "code", py_code); Py_DECREF(py_code); exceptions_array.UDFNotFound = PyErr_NewException("exception.UDFNotFound", exceptions_array.UDFError, NULL); Py_INCREF(exceptions_array.UDFNotFound); PyModule_AddObject(module, "UDFNotFound", exceptions_array.UDFNotFound); py_code = PyInt_FromLong(AEROSPIKE_ERR_UDF_NOT_FOUND); PyObject_SetAttrString(exceptions_array.UDFNotFound, "code", py_code); Py_DECREF(py_code); exceptions_array.LuaFileNotFound = PyErr_NewException("exception.LuaFileNotFound", exceptions_array.UDFError, NULL); Py_INCREF(exceptions_array.LuaFileNotFound); PyModule_AddObject(module, "LuaFileNotFound", exceptions_array.LuaFileNotFound); py_code = PyInt_FromLong(AEROSPIKE_ERR_LUA_FILE_NOT_FOUND); PyObject_SetAttrString(exceptions_array.LuaFileNotFound, "code", py_code); Py_DECREF(py_code); //Admin exceptions exceptions_array.AdminError = PyErr_NewException("exception.AdminError", exceptions_array.ServerError, NULL); Py_INCREF(exceptions_array.AdminError); PyModule_AddObject(module, "AdminError", exceptions_array.AdminError); count = sizeof(admin_array.admin_exceptions)/sizeof(admin_array.admin_exceptions[0]); for(i=0; i < count; i++) { current_exception = admin_array.admin_exceptions[i]; char * name = admin_array.admin_exceptions_name[i]; char prefix[40] = "exception."; *current_exception = PyErr_NewException(strcat(prefix, name), exceptions_array.AdminError, NULL); Py_INCREF(*current_exception); PyModule_AddObject(module, name, *current_exception); PyObject *py_code = PyInt_FromLong(admin_array.admin_exceptions_codes[i]); PyObject_SetAttrString(*current_exception, "code", py_code); Py_DECREF(py_code); } //Query exceptions exceptions_array.QueryQueueFull = PyErr_NewException("exception.QueryQueueFull", exceptions_array.QueryError, NULL); Py_INCREF(exceptions_array.QueryQueueFull); PyModule_AddObject(module, "QueryQueueFull", exceptions_array.QueryQueueFull); py_code = PyInt_FromLong(AEROSPIKE_ERR_QUERY_QUEUE_FULL); PyObject_SetAttrString(exceptions_array.QueryQueueFull, "code", py_code); Py_DECREF(py_code); exceptions_array.QueryTimeout = PyErr_NewException("exception.QueryTimeout", exceptions_array.QueryError, NULL); Py_INCREF(exceptions_array.QueryTimeout); PyModule_AddObject(module, "QueryTimeout", exceptions_array.QueryTimeout); py_code = PyInt_FromLong(AEROSPIKE_ERR_QUERY_TIMEOUT); PyObject_SetAttrString(exceptions_array.QueryQueueFull, "code", py_code); Py_DECREF(py_code); //LDT exceptions PyObject *py_ldt_dict = PyDict_New(); PyDict_SetItemString(py_ldt_dict, "key", Py_None); PyDict_SetItemString(py_ldt_dict, "bin", Py_None); exceptions_array.LDTError = PyErr_NewException("exception.LDTError", exceptions_array.ServerError, py_ldt_dict); Py_INCREF(exceptions_array.LDTError); Py_DECREF(py_ldt_dict); PyModule_AddObject(module, "LDTError", exceptions_array.LDTError); count = sizeof(ldt_array.ldt_exceptions)/sizeof(ldt_array.ldt_exceptions[0]); for(i=0; i < count; i++) { current_exception = ldt_array.ldt_exceptions[i]; char * name = ldt_array.ldt_exceptions_name[i]; char prefix[40] = "exception."; *current_exception = PyErr_NewException(strcat(prefix, name), exceptions_array.LDTError, NULL); Py_INCREF(*current_exception); PyModule_AddObject(module, name, *current_exception); PyObject *py_code = PyInt_FromLong(ldt_array.ldt_exceptions_codes[i]); PyObject_SetAttrString(*current_exception, "code", py_code); Py_DECREF(py_code); } return module; }
/* Shared python2/3 module initialization: */ static int initModule(PyObject *m) { PyObject * d; /* * treat error to register rpm cleanup hook as fatal, tracebacks * can and will leave stale locks around if we can't clean up */ if (Py_AtExit(rpm_exithook) == -1) return 0; rpmReadConfigFiles(NULL, NULL); d = PyModule_GetDict(m); pyrpmError = PyErr_NewException("_rpm.error", NULL, NULL); if (pyrpmError != NULL) PyDict_SetItemString(d, "error", pyrpmError); Py_INCREF(&hdr_Type); PyModule_AddObject(m, "hdr", (PyObject *) &hdr_Type); Py_INCREF(&rpmds_Type); PyModule_AddObject(m, "ds", (PyObject *) &rpmds_Type); Py_INCREF(&rpmfd_Type); PyModule_AddObject(m, "fd", (PyObject *) &rpmfd_Type); Py_INCREF(&rpmfi_Type); PyModule_AddObject(m, "fi", (PyObject *) &rpmfi_Type); Py_INCREF(&rpmKeyring_Type); PyModule_AddObject(m, "keyring", (PyObject *) &rpmKeyring_Type); Py_INCREF(&rpmmi_Type); PyModule_AddObject(m, "mi", (PyObject *) &rpmmi_Type); Py_INCREF(&rpmii_Type); PyModule_AddObject(m, "ii", (PyObject *) &rpmii_Type); Py_INCREF(&rpmProblem_Type); PyModule_AddObject(m, "prob", (PyObject *) &rpmProblem_Type); Py_INCREF(&rpmPubkey_Type); PyModule_AddObject(m, "pubkey", (PyObject *) &rpmPubkey_Type); #if 0 Py_INCREF(&rpmtd_Type); PyModule_AddObject(m, "td", (PyObject *) &rpmtd_Type); #endif Py_INCREF(&rpmte_Type); PyModule_AddObject(m, "te", (PyObject *) &rpmte_Type); Py_INCREF(&rpmts_Type); PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type); addRpmTags(m); PyModule_AddStringConstant(m, "__version__", RPMVERSION); #define REGISTER_ENUM(val) PyModule_AddIntConstant(m, #val, val) REGISTER_ENUM(RPMTAG_NOT_FOUND); REGISTER_ENUM(RPMRC_OK); REGISTER_ENUM(RPMRC_NOTFOUND); REGISTER_ENUM(RPMRC_FAIL); REGISTER_ENUM(RPMRC_NOTTRUSTED); REGISTER_ENUM(RPMRC_NOKEY); REGISTER_ENUM(RPMFILE_STATE_NORMAL); REGISTER_ENUM(RPMFILE_STATE_REPLACED); REGISTER_ENUM(RPMFILE_STATE_NOTINSTALLED); REGISTER_ENUM(RPMFILE_STATE_NETSHARED); REGISTER_ENUM(RPMFILE_STATE_WRONGCOLOR); REGISTER_ENUM(RPMFILE_CONFIG); REGISTER_ENUM(RPMFILE_DOC); REGISTER_ENUM(RPMFILE_MISSINGOK); REGISTER_ENUM(RPMFILE_NOREPLACE); REGISTER_ENUM(RPMFILE_GHOST); REGISTER_ENUM(RPMFILE_LICENSE); REGISTER_ENUM(RPMFILE_README); REGISTER_ENUM(RPMFILE_PUBKEY); REGISTER_ENUM(RPMDEP_SENSE_REQUIRES); REGISTER_ENUM(RPMDEP_SENSE_CONFLICTS); REGISTER_ENUM(RPMSENSE_ANY); REGISTER_ENUM(RPMSENSE_LESS); REGISTER_ENUM(RPMSENSE_GREATER); REGISTER_ENUM(RPMSENSE_EQUAL); REGISTER_ENUM(RPMSENSE_POSTTRANS); REGISTER_ENUM(RPMSENSE_PREREQ); REGISTER_ENUM(RPMSENSE_PRETRANS); REGISTER_ENUM(RPMSENSE_INTERP); REGISTER_ENUM(RPMSENSE_SCRIPT_PRE); REGISTER_ENUM(RPMSENSE_SCRIPT_POST); REGISTER_ENUM(RPMSENSE_SCRIPT_PREUN); REGISTER_ENUM(RPMSENSE_SCRIPT_POSTUN); REGISTER_ENUM(RPMSENSE_SCRIPT_VERIFY); REGISTER_ENUM(RPMSENSE_FIND_REQUIRES); REGISTER_ENUM(RPMSENSE_FIND_PROVIDES); REGISTER_ENUM(RPMSENSE_TRIGGERIN); REGISTER_ENUM(RPMSENSE_TRIGGERUN); REGISTER_ENUM(RPMSENSE_TRIGGERPOSTUN); REGISTER_ENUM(RPMSENSE_RPMLIB); REGISTER_ENUM(RPMSENSE_TRIGGERPREIN); REGISTER_ENUM(RPMSENSE_KEYRING); REGISTER_ENUM(RPMSENSE_CONFIG); REGISTER_ENUM(RPMTRANS_FLAG_TEST); REGISTER_ENUM(RPMTRANS_FLAG_BUILD_PROBS); REGISTER_ENUM(RPMTRANS_FLAG_NOSCRIPTS); REGISTER_ENUM(RPMTRANS_FLAG_JUSTDB); REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERS); REGISTER_ENUM(RPMTRANS_FLAG_NODOCS); REGISTER_ENUM(RPMTRANS_FLAG_ALLFILES); REGISTER_ENUM(RPMTRANS_FLAG_KEEPOBSOLETE); REGISTER_ENUM(RPMTRANS_FLAG_NOCONTEXTS); REGISTER_ENUM(RPMTRANS_FLAG_REPACKAGE); REGISTER_ENUM(RPMTRANS_FLAG_REVERSE); REGISTER_ENUM(RPMTRANS_FLAG_NOPRE); REGISTER_ENUM(RPMTRANS_FLAG_NOPOST); REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERPREIN); REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERIN); REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERUN); REGISTER_ENUM(RPMTRANS_FLAG_NOPREUN); REGISTER_ENUM(RPMTRANS_FLAG_NOPOSTUN); REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERPOSTUN); REGISTER_ENUM(RPMTRANS_FLAG_NOPRETRANS); REGISTER_ENUM(RPMTRANS_FLAG_NOPOSTTRANS); REGISTER_ENUM(RPMTRANS_FLAG_NOMD5); REGISTER_ENUM(RPMTRANS_FLAG_NOFILEDIGEST); REGISTER_ENUM(RPMTRANS_FLAG_NOSUGGEST); REGISTER_ENUM(RPMTRANS_FLAG_ADDINDEPS); REGISTER_ENUM(RPMTRANS_FLAG_NOCONFIGS); REGISTER_ENUM(RPMPROB_FILTER_IGNOREOS); REGISTER_ENUM(RPMPROB_FILTER_IGNOREARCH); REGISTER_ENUM(RPMPROB_FILTER_REPLACEPKG); REGISTER_ENUM(RPMPROB_FILTER_FORCERELOCATE); REGISTER_ENUM(RPMPROB_FILTER_REPLACENEWFILES); REGISTER_ENUM(RPMPROB_FILTER_REPLACEOLDFILES); REGISTER_ENUM(RPMPROB_FILTER_OLDPACKAGE); REGISTER_ENUM(RPMPROB_FILTER_DISKSPACE); REGISTER_ENUM(RPMPROB_FILTER_DISKNODES); REGISTER_ENUM(RPMCALLBACK_UNKNOWN); REGISTER_ENUM(RPMCALLBACK_INST_PROGRESS); REGISTER_ENUM(RPMCALLBACK_INST_START); REGISTER_ENUM(RPMCALLBACK_INST_OPEN_FILE); REGISTER_ENUM(RPMCALLBACK_INST_CLOSE_FILE); REGISTER_ENUM(RPMCALLBACK_TRANS_PROGRESS); REGISTER_ENUM(RPMCALLBACK_TRANS_START); REGISTER_ENUM(RPMCALLBACK_TRANS_STOP); REGISTER_ENUM(RPMCALLBACK_UNINST_PROGRESS); REGISTER_ENUM(RPMCALLBACK_UNINST_START); REGISTER_ENUM(RPMCALLBACK_UNINST_STOP); REGISTER_ENUM(RPMCALLBACK_REPACKAGE_PROGRESS); REGISTER_ENUM(RPMCALLBACK_REPACKAGE_START); REGISTER_ENUM(RPMCALLBACK_REPACKAGE_STOP); REGISTER_ENUM(RPMCALLBACK_UNPACK_ERROR); REGISTER_ENUM(RPMCALLBACK_CPIO_ERROR); REGISTER_ENUM(RPMCALLBACK_SCRIPT_ERROR); REGISTER_ENUM(RPMCALLBACK_SCRIPT_START); REGISTER_ENUM(RPMCALLBACK_SCRIPT_STOP); REGISTER_ENUM(RPMCALLBACK_INST_STOP); REGISTER_ENUM(RPMPROB_BADARCH); REGISTER_ENUM(RPMPROB_BADOS); REGISTER_ENUM(RPMPROB_PKG_INSTALLED); REGISTER_ENUM(RPMPROB_BADRELOCATE); REGISTER_ENUM(RPMPROB_REQUIRES); REGISTER_ENUM(RPMPROB_CONFLICT); REGISTER_ENUM(RPMPROB_NEW_FILE_CONFLICT); REGISTER_ENUM(RPMPROB_FILE_CONFLICT); REGISTER_ENUM(RPMPROB_OLDPACKAGE); REGISTER_ENUM(RPMPROB_DISKSPACE); REGISTER_ENUM(RPMPROB_DISKNODES); REGISTER_ENUM(RPMPROB_OBSOLETES); REGISTER_ENUM(VERIFY_DIGEST); REGISTER_ENUM(VERIFY_SIGNATURE); REGISTER_ENUM(RPMLOG_EMERG); REGISTER_ENUM(RPMLOG_ALERT); REGISTER_ENUM(RPMLOG_CRIT); REGISTER_ENUM(RPMLOG_ERR); REGISTER_ENUM(RPMLOG_WARNING); REGISTER_ENUM(RPMLOG_NOTICE); REGISTER_ENUM(RPMLOG_INFO); REGISTER_ENUM(RPMLOG_DEBUG); REGISTER_ENUM(RPMMIRE_DEFAULT); REGISTER_ENUM(RPMMIRE_STRCMP); REGISTER_ENUM(RPMMIRE_REGEX); REGISTER_ENUM(RPMMIRE_GLOB); REGISTER_ENUM(RPMVSF_DEFAULT); REGISTER_ENUM(RPMVSF_NOHDRCHK); REGISTER_ENUM(RPMVSF_NEEDPAYLOAD); REGISTER_ENUM(RPMVSF_NOSHA1HEADER); REGISTER_ENUM(RPMVSF_NOMD5HEADER); REGISTER_ENUM(RPMVSF_NODSAHEADER); REGISTER_ENUM(RPMVSF_NORSAHEADER); REGISTER_ENUM(RPMVSF_NOSHA1); REGISTER_ENUM(RPMVSF_NOMD5); REGISTER_ENUM(RPMVSF_NODSA); REGISTER_ENUM(RPMVSF_NORSA); REGISTER_ENUM(_RPMVSF_NODIGESTS); REGISTER_ENUM(_RPMVSF_NOSIGNATURES); REGISTER_ENUM(_RPMVSF_NOHEADER); REGISTER_ENUM(_RPMVSF_NOPAYLOAD); REGISTER_ENUM(TR_ADDED); REGISTER_ENUM(TR_REMOVED); REGISTER_ENUM(RPMDBI_PACKAGES); REGISTER_ENUM(RPMDBI_LABEL); REGISTER_ENUM(RPMDBI_INSTFILENAMES); REGISTER_ENUM(RPMDBI_NAME); REGISTER_ENUM(RPMDBI_BASENAMES); REGISTER_ENUM(RPMDBI_GROUP); REGISTER_ENUM(RPMDBI_REQUIRENAME); REGISTER_ENUM(RPMDBI_PROVIDENAME); REGISTER_ENUM(RPMDBI_CONFLICTNAME); REGISTER_ENUM(RPMDBI_OBSOLETENAME); REGISTER_ENUM(RPMDBI_TRIGGERNAME); REGISTER_ENUM(RPMDBI_DIRNAMES); REGISTER_ENUM(RPMDBI_INSTALLTID); REGISTER_ENUM(RPMDBI_SIGMD5); REGISTER_ENUM(RPMDBI_SHA1HEADER); REGISTER_ENUM(HEADERCONV_EXPANDFILELIST); REGISTER_ENUM(HEADERCONV_COMPRESSFILELIST); REGISTER_ENUM(HEADERCONV_RETROFIT_V3); return 1; }
void initglue(void) { PyObject *m; m = Py_InitModule3("glue", py_misc_methods, "Python bindings for miscellaneous Samba functions."); if (m == NULL) return; PyModule_AddObject(m, "version", PyString_FromString(SAMBA_VERSION_STRING)); /* "userAccountControl" flags */ PyModule_AddObject(m, "UF_NORMAL_ACCOUNT", PyInt_FromLong(UF_NORMAL_ACCOUNT)); PyModule_AddObject(m, "UF_TEMP_DUPLICATE_ACCOUNT", PyInt_FromLong(UF_TEMP_DUPLICATE_ACCOUNT)); PyModule_AddObject(m, "UF_SERVER_TRUST_ACCOUNT", PyInt_FromLong(UF_SERVER_TRUST_ACCOUNT)); PyModule_AddObject(m, "UF_WORKSTATION_TRUST_ACCOUNT", PyInt_FromLong(UF_WORKSTATION_TRUST_ACCOUNT)); PyModule_AddObject(m, "UF_INTERDOMAIN_TRUST_ACCOUNT", PyInt_FromLong(UF_INTERDOMAIN_TRUST_ACCOUNT)); PyModule_AddObject(m, "UF_PASSWD_NOTREQD", PyInt_FromLong(UF_PASSWD_NOTREQD)); PyModule_AddObject(m, "UF_ACCOUNTDISABLE", PyInt_FromLong(UF_ACCOUNTDISABLE)); /* "groupType" flags */ PyModule_AddObject(m, "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_BUILTIN_LOCAL_GROUP)); PyModule_AddObject(m, "GTYPE_SECURITY_GLOBAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_GLOBAL_GROUP)); PyModule_AddObject(m, "GTYPE_SECURITY_DOMAIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_DOMAIN_LOCAL_GROUP)); PyModule_AddObject(m, "GTYPE_SECURITY_UNIVERSAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_UNIVERSAL_GROUP)); PyModule_AddObject(m, "GTYPE_DISTRIBUTION_GLOBAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_GLOBAL_GROUP)); PyModule_AddObject(m, "GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP)); PyModule_AddObject(m, "GTYPE_DISTRIBUTION_UNIVERSAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_UNIVERSAL_GROUP)); /* "sAMAccountType" flags */ PyModule_AddObject(m, "ATYPE_NORMAL_ACCOUNT", PyInt_FromLong(ATYPE_NORMAL_ACCOUNT)); PyModule_AddObject(m, "ATYPE_WORKSTATION_TRUST", PyInt_FromLong(ATYPE_WORKSTATION_TRUST)); PyModule_AddObject(m, "ATYPE_INTERDOMAIN_TRUST", PyInt_FromLong(ATYPE_INTERDOMAIN_TRUST)); PyModule_AddObject(m, "ATYPE_SECURITY_GLOBAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_GLOBAL_GROUP)); PyModule_AddObject(m, "ATYPE_SECURITY_LOCAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_LOCAL_GROUP)); PyModule_AddObject(m, "ATYPE_SECURITY_UNIVERSAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_UNIVERSAL_GROUP)); PyModule_AddObject(m, "ATYPE_DISTRIBUTION_GLOBAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_GLOBAL_GROUP)); PyModule_AddObject(m, "ATYPE_DISTRIBUTION_LOCAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_LOCAL_GROUP)); PyModule_AddObject(m, "ATYPE_DISTRIBUTION_UNIVERSAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_UNIVERSAL_GROUP)); /* "domainFunctionality", "forestFunctionality" flags in the rootDSE */ PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2000", PyInt_FromLong(DS_DOMAIN_FUNCTION_2000)); PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003_MIXED", PyInt_FromLong(DS_DOMAIN_FUNCTION_2003_MIXED)); PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003", PyInt_FromLong(DS_DOMAIN_FUNCTION_2003)); PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008", PyInt_FromLong(DS_DOMAIN_FUNCTION_2008)); PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008_R2", PyInt_FromLong(DS_DOMAIN_FUNCTION_2008_R2)); /* "domainControllerFunctionality" flags in the rootDSE */ PyModule_AddObject(m, "DS_DC_FUNCTION_2000", PyInt_FromLong(DS_DC_FUNCTION_2000)); PyModule_AddObject(m, "DS_DC_FUNCTION_2003", PyInt_FromLong(DS_DC_FUNCTION_2003)); PyModule_AddObject(m, "DS_DC_FUNCTION_2008", PyInt_FromLong(DS_DC_FUNCTION_2008)); PyModule_AddObject(m, "DS_DC_FUNCTION_2008_R2", PyInt_FromLong(DS_DC_FUNCTION_2008_R2)); /* "LDAP_SERVER_SD_FLAGS_OID" */ PyModule_AddObject(m, "SECINFO_OWNER", PyInt_FromLong(SECINFO_OWNER)); PyModule_AddObject(m, "SECINFO_GROUP", PyInt_FromLong(SECINFO_GROUP)); PyModule_AddObject(m, "SECINFO_DACL", PyInt_FromLong(SECINFO_DACL)); PyModule_AddObject(m, "SECINFO_SACL", PyInt_FromLong(SECINFO_SACL)); /* one of the most annoying things about python scripts is that they don't die when you hit control-C. This fixes that sillyness. As we do all database operations using transactions, this is also safe. In fact, not dying immediately is unsafe as we could end up treating the control-C exception as a different error and try to modify as database incorrectly */ signal(SIGINT, SIG_DFL); }
PyMODINIT_FUNC initnumpy_quaternion(void) { PyObject *m; int quaternionNum; PyObject* numpy = PyImport_ImportModule("numpy"); PyObject* numpy_dict = PyModule_GetDict(numpy); int arg_types[3]; m = Py_InitModule("numpy_quaternion", QuaternionMethods); if (m == NULL) { return; } /* Make sure NumPy is initialized */ import_array(); import_umath(); /* Register the quaternion array scalar type */ #if defined(NPY_PY3K) PyQuaternionArrType_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; #else PyQuaternionArrType_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES; #endif PyQuaternionArrType_Type.tp_new = quaternion_arrtype_new; PyQuaternionArrType_Type.tp_richcompare = gentype_richcompare; PyQuaternionArrType_Type.tp_hash = quaternion_arrtype_hash; PyQuaternionArrType_Type.tp_repr = quaternion_arrtype_repr; PyQuaternionArrType_Type.tp_str = quaternion_arrtype_str; PyQuaternionArrType_Type.tp_base = &PyGenericArrType_Type; if (PyType_Ready(&PyQuaternionArrType_Type) < 0) { PyErr_Print(); PyErr_SetString(PyExc_SystemError, "could not initialize PyQuaternionArrType_Type"); return; } /* The array functions */ PyArray_InitArrFuncs(&_PyQuaternion_ArrFuncs); _PyQuaternion_ArrFuncs.getitem = (PyArray_GetItemFunc*)QUATERNION_getitem; _PyQuaternion_ArrFuncs.setitem = (PyArray_SetItemFunc*)QUATERNION_setitem; _PyQuaternion_ArrFuncs.copyswap = (PyArray_CopySwapFunc*)QUATERNION_copyswap; _PyQuaternion_ArrFuncs.copyswapn = (PyArray_CopySwapNFunc*)QUATERNION_copyswapn; _PyQuaternion_ArrFuncs.compare = (PyArray_CompareFunc*)QUATERNION_compare; _PyQuaternion_ArrFuncs.argmax = (PyArray_ArgFunc*)QUATERNION_argmax; _PyQuaternion_ArrFuncs.nonzero = (PyArray_NonzeroFunc*)QUATERNION_nonzero; _PyQuaternion_ArrFuncs.fillwithscalar = (PyArray_FillWithScalarFunc*)QUATERNION_fillwithscalar; /* The quaternion array descr */ quaternion_descr = PyObject_New(PyArray_Descr, &PyArrayDescr_Type); quaternion_descr->typeobj = &PyQuaternionArrType_Type; quaternion_descr->kind = 'q'; quaternion_descr->type = 'j'; quaternion_descr->byteorder = '='; quaternion_descr->type_num = 0; /* assigned at registration */ quaternion_descr->elsize = 8*4; quaternion_descr->alignment = 8; quaternion_descr->subarray = NULL; quaternion_descr->fields = NULL; quaternion_descr->names = NULL; quaternion_descr->f = &_PyQuaternion_ArrFuncs; Py_INCREF(&PyQuaternionArrType_Type); quaternionNum = PyArray_RegisterDataType(quaternion_descr); if (quaternionNum < 0) return; register_cast_function(NPY_BOOL, quaternionNum, (PyArray_VectorUnaryFunc*)BOOL_to_quaternion); register_cast_function(NPY_BYTE, quaternionNum, (PyArray_VectorUnaryFunc*)BYTE_to_quaternion); register_cast_function(NPY_UBYTE, quaternionNum, (PyArray_VectorUnaryFunc*)UBYTE_to_quaternion); register_cast_function(NPY_SHORT, quaternionNum, (PyArray_VectorUnaryFunc*)SHORT_to_quaternion); register_cast_function(NPY_USHORT, quaternionNum, (PyArray_VectorUnaryFunc*)USHORT_to_quaternion); register_cast_function(NPY_INT, quaternionNum, (PyArray_VectorUnaryFunc*)INT_to_quaternion); register_cast_function(NPY_UINT, quaternionNum, (PyArray_VectorUnaryFunc*)UINT_to_quaternion); register_cast_function(NPY_LONG, quaternionNum, (PyArray_VectorUnaryFunc*)LONG_to_quaternion); register_cast_function(NPY_ULONG, quaternionNum, (PyArray_VectorUnaryFunc*)ULONG_to_quaternion); register_cast_function(NPY_LONGLONG, quaternionNum, (PyArray_VectorUnaryFunc*)LONGLONG_to_quaternion); register_cast_function(NPY_ULONGLONG, quaternionNum, (PyArray_VectorUnaryFunc*)ULONGLONG_to_quaternion); register_cast_function(NPY_FLOAT, quaternionNum, (PyArray_VectorUnaryFunc*)FLOAT_to_quaternion); register_cast_function(NPY_DOUBLE, quaternionNum, (PyArray_VectorUnaryFunc*)DOUBLE_to_quaternion); register_cast_function(NPY_LONGDOUBLE, quaternionNum, (PyArray_VectorUnaryFunc*)LONGDOUBLE_to_quaternion); register_cast_function(NPY_CFLOAT, quaternionNum, (PyArray_VectorUnaryFunc*)CFLOAT_to_quaternion); register_cast_function(NPY_CDOUBLE, quaternionNum, (PyArray_VectorUnaryFunc*)CDOUBLE_to_quaternion); register_cast_function(NPY_CLONGDOUBLE, quaternionNum, (PyArray_VectorUnaryFunc*)CLONGDOUBLE_to_quaternion); #define REGISTER_UFUNC(name)\ PyUFunc_RegisterLoopForType((PyUFuncObject *)PyDict_GetItemString(numpy_dict, #name),\ quaternion_descr->type_num, quaternion_##name##_ufunc, arg_types, NULL) #define REGISTER_SCALAR_UFUNC(name)\ PyUFunc_RegisterLoopForType((PyUFuncObject *)PyDict_GetItemString(numpy_dict, #name),\ quaternion_descr->type_num, quaternion_##name##_scalar_ufunc, arg_types, NULL) /* quat -> bool */ arg_types[0] = quaternion_descr->type_num; arg_types[1] = NPY_BOOL; REGISTER_UFUNC(isnan); REGISTER_UFUNC(isinf); REGISTER_UFUNC(isfinite); /* quat -> double */ arg_types[1] = NPY_DOUBLE; REGISTER_UFUNC(absolute); /* quat -> quat */ arg_types[1] = quaternion_descr->type_num; REGISTER_UFUNC(log); REGISTER_UFUNC(exp); REGISTER_UFUNC(negative); REGISTER_UFUNC(conjugate); /* quat, quat -> bool */ arg_types[2] = NPY_BOOL; REGISTER_UFUNC(equal); REGISTER_UFUNC(not_equal); REGISTER_UFUNC(less); REGISTER_UFUNC(less_equal); /* quat, double -> quat */ arg_types[1] = NPY_DOUBLE; arg_types[2] = quaternion_descr->type_num; REGISTER_SCALAR_UFUNC(multiply); REGISTER_SCALAR_UFUNC(divide); REGISTER_SCALAR_UFUNC(power); /* quat, quat -> quat */ arg_types[1] = quaternion_descr->type_num; REGISTER_UFUNC(add); REGISTER_UFUNC(subtract); REGISTER_UFUNC(multiply); REGISTER_UFUNC(divide); REGISTER_UFUNC(power); REGISTER_UFUNC(copysign); PyModule_AddObject(m, "quaternion", (PyObject *)&PyQuaternionArrType_Type); }
PyMODINIT_FUNC init_testcapi(void) { PyObject *m; m = Py_InitModule("_testcapi", TestMethods); if (m == NULL) return; test_structmembersType.ob_type=&PyType_Type; Py_INCREF(&test_structmembersType); PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType); PyModule_AddObject(m, "CHAR_MAX", PyInt_FromLong(CHAR_MAX)); PyModule_AddObject(m, "CHAR_MIN", PyInt_FromLong(CHAR_MIN)); PyModule_AddObject(m, "UCHAR_MAX", PyInt_FromLong(UCHAR_MAX)); PyModule_AddObject(m, "SHRT_MAX", PyInt_FromLong(SHRT_MAX)); PyModule_AddObject(m, "SHRT_MIN", PyInt_FromLong(SHRT_MIN)); PyModule_AddObject(m, "USHRT_MAX", PyInt_FromLong(USHRT_MAX)); PyModule_AddObject(m, "INT_MAX", PyLong_FromLong(INT_MAX)); PyModule_AddObject(m, "INT_MIN", PyLong_FromLong(INT_MIN)); PyModule_AddObject(m, "UINT_MAX", PyLong_FromUnsignedLong(UINT_MAX)); PyModule_AddObject(m, "LONG_MAX", PyInt_FromLong(LONG_MAX)); PyModule_AddObject(m, "LONG_MIN", PyInt_FromLong(LONG_MIN)); PyModule_AddObject(m, "ULONG_MAX", PyLong_FromUnsignedLong(ULONG_MAX)); PyModule_AddObject(m, "FLT_MAX", PyFloat_FromDouble(FLT_MAX)); PyModule_AddObject(m, "FLT_MIN", PyFloat_FromDouble(FLT_MIN)); PyModule_AddObject(m, "DBL_MAX", PyFloat_FromDouble(DBL_MAX)); PyModule_AddObject(m, "DBL_MIN", PyFloat_FromDouble(DBL_MIN)); PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyInt_FromSsize_t(PY_SSIZE_T_MAX)); PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyInt_FromSsize_t(PY_SSIZE_T_MIN)); TestError = PyErr_NewException("_testcapi.error", NULL, NULL); Py_INCREF(TestError); PyModule_AddObject(m, "error", TestError); }
static int PyGcc_init_gcc_module(struct plugin_name_args *plugin_info) { int i; if (!PyGcc_globals.module) { return 0; } /* Set up int constants for each of the enum plugin_event values: */ #define DEFEVENT(NAME) \ PyModule_AddIntMacro(PyGcc_globals.module, NAME); # include "plugin.def" # undef DEFEVENT PyGcc_globals.argument_dict = PyDict_New(); if (!PyGcc_globals.argument_dict) { return 0; } PyGcc_globals.argument_tuple = PyTuple_New(plugin_info->argc); if (!PyGcc_globals.argument_tuple) { return 0; } /* PySys_SetArgvEx(plugin_info->argc, plugin_info->argv, 0); */ for (i=0; i<plugin_info->argc; i++) { struct plugin_argument *arg = &plugin_info->argv[i]; PyObject *key; PyObject *value; PyObject *pair; key = PyGccString_FromString(arg->key); if (arg->value) { value = PyGccString_FromString(plugin_info->argv[i].value); } else { value = Py_None; } PyDict_SetItem(PyGcc_globals.argument_dict, key, value); // FIXME: ref counts? pair = Py_BuildValue("(s, s)", arg->key, arg->value); if (!pair) { return 1; } PyTuple_SetItem(PyGcc_globals.argument_tuple, i, pair); } PyModule_AddObject(PyGcc_globals.module, "argument_dict", PyGcc_globals.argument_dict); PyModule_AddObject(PyGcc_globals.module, "argument_tuple", PyGcc_globals.argument_tuple); /* Pass properties: */ PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_any); PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_lcf); PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_leh); PyModule_AddIntMacro(PyGcc_globals.module, PROP_cfg); #if (GCC_VERSION >= 4008) /* PROP_referenced_vars went away in GCC 4.8 (in r190067) */ #else PyModule_AddIntMacro(PyGcc_globals.module, PROP_referenced_vars); #endif PyModule_AddIntMacro(PyGcc_globals.module, PROP_ssa); PyModule_AddIntMacro(PyGcc_globals.module, PROP_no_crit_edges); PyModule_AddIntMacro(PyGcc_globals.module, PROP_rtl); PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_lomp); PyModule_AddIntMacro(PyGcc_globals.module, PROP_cfglayout); PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_lcx); PyModule_AddIntMacro(PyGcc_globals.module, GCC_VERSION); /* Success: */ return 1; }
PyMODINIT_FUNC initPyBCM2835(void) { PyObject *m; m = Py_InitModule("PyBCM2835", PyBCM2835Methods); if (m == NULL) return; // Constants PyModule_AddIntConstant(m,"HIGH",1); PyModule_AddIntConstant(m,"LOW",0); PyModule_AddIntConstant(m,"PERI_BASE",BCM2835_PERI_BASE); PyModule_AddIntConstant(m,"GPIO_PADS",BCM2835_GPIO_PADS); PyModule_AddIntConstant(m,"CLOCK_BASE",BCM2835_CLOCK_BASE); PyModule_AddIntConstant(m,"GPIO_BASE",BCM2835_GPIO_BASE); PyModule_AddIntConstant(m,"SPI0_BASE",BCM2835_SPI0_BASE); PyModule_AddIntConstant(m,"GPIO_PWM",BCM2835_GPIO_PWM); PyModule_AddIntConstant(m,"PAGE_SIZE",BCM2835_PAGE_SIZE); PyModule_AddIntConstant(m,"BLOCK_SIZE",BCM2835_BLOCK_SIZE); PyModule_AddIntConstant(m,"GPFSEL0",BCM2835_GPFSEL0); PyModule_AddIntConstant(m,"GPFSEL1",BCM2835_GPFSEL1); PyModule_AddIntConstant(m,"GPFSEL2",BCM2835_GPFSEL2); PyModule_AddIntConstant(m,"GPFSEL3",BCM2835_GPFSEL3); PyModule_AddIntConstant(m,"GPFSEL4",BCM2835_GPFSEL4); PyModule_AddIntConstant(m,"GPFSEL5",BCM2835_GPFSEL5); PyModule_AddIntConstant(m,"GPSET0",BCM2835_GPSET0); PyModule_AddIntConstant(m,"GPSET1",BCM2835_GPSET1); PyModule_AddIntConstant(m,"GPCLR0",BCM2835_GPCLR0); PyModule_AddIntConstant(m,"GPCLR1",BCM2835_GPCLR1); PyModule_AddIntConstant(m,"GPLEV0",BCM2835_GPLEV0); PyModule_AddIntConstant(m,"GPLEV1",BCM2835_GPLEV1); PyModule_AddIntConstant(m,"GPEDS0",BCM2835_GPEDS0); PyModule_AddIntConstant(m,"GPEDS1",BCM2835_GPEDS1); PyModule_AddIntConstant(m,"GPREN0",BCM2835_GPREN0); PyModule_AddIntConstant(m,"GPREN1",BCM2835_GPREN1); PyModule_AddIntConstant(m,"GPFEN0",BCM2835_GPFEN0); PyModule_AddIntConstant(m,"GPFEN1",BCM2835_GPFEN1); PyModule_AddIntConstant(m,"GPAFEN0",BCM2835_GPAFEN0); PyModule_AddIntConstant(m,"GPAFEN1",BCM2835_GPAFEN1); PyModule_AddIntConstant(m,"GPPUD",BCM2835_GPPUD); PyModule_AddIntConstant(m,"GPPUDCLK0",BCM2835_GPPUDCLK0); PyModule_AddIntConstant(m,"GPPUDCLK1",BCM2835_GPPUDCLK1); PyModule_AddIntConstant(m,"BCM2835_PADS_GPIO_0_27",BCM2835_PADS_GPIO_0_27); PyModule_AddIntConstant(m,"BCM2835_PADS_GPIO_28_45",BCM2835_PADS_GPIO_28_45); PyModule_AddIntConstant(m,"BCM2835_PADS_GPIO_46_53",BCM2835_PADS_GPIO_46_53); PyModule_AddIntConstant(m,"BCM2835_PAD_PASSWRD",BCM2835_PAD_PASSWRD); PyModule_AddIntConstant(m,"BCM2835_PAD_SLEW_RATE_UNLIMITED",BCM2835_PAD_SLEW_RATE_UNLIMITED); PyModule_AddIntConstant(m,"BCM2835_PAD_HYSTERESIS_ENABLED",BCM2835_PAD_HYSTERESIS_ENABLED); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_2mA",BCM2835_PAD_DRIVE_2mA); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_4mA",BCM2835_PAD_DRIVE_4mA); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_6mA",BCM2835_PAD_DRIVE_6mA); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_8mA",BCM2835_PAD_DRIVE_8mA); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_10mA",BCM2835_PAD_DRIVE_10mA); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_12mA",BCM2835_PAD_DRIVE_12mA); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_14mA",BCM2835_PAD_DRIVE_14mA); PyModule_AddIntConstant(m,"BCM2835_PAD_DRIVE_16mA",BCM2835_PAD_DRIVE_16mA); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS",BCM2835_SPI0_CS); PyModule_AddIntConstant(m,"BCM2835_SPI0_FIFO",BCM2835_SPI0_FIFO); PyModule_AddIntConstant(m,"BCM2835_SPI0_CLK",BCM2835_SPI0_CLK); PyModule_AddIntConstant(m,"BCM2835_SPI0_DLEN",BCM2835_SPI0_DLEN); PyModule_AddIntConstant(m,"BCM2835_SPI0_LTOH",BCM2835_SPI0_LTOH); PyModule_AddIntConstant(m,"BCM2835_SPI0_DC",BCM2835_SPI0_DC); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_LEN_LONG",BCM2835_SPI0_CS_LEN_LONG); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_DMA_LEN",BCM2835_SPI0_CS_DMA_LEN); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CSPOL2",BCM2835_SPI0_CS_CSPOL2); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CSPOL1",BCM2835_SPI0_CS_CSPOL1); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CSPOL0",BCM2835_SPI0_CS_CSPOL0); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_RXF",BCM2835_SPI0_CS_RXF); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_RXR",BCM2835_SPI0_CS_RXR); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_TXD",BCM2835_SPI0_CS_TXD); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_DONE",BCM2835_SPI0_CS_DONE); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_TE_EN",BCM2835_SPI0_CS_TE_EN); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_LMONO",BCM2835_SPI0_CS_LMONO); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_LEN",BCM2835_SPI0_CS_LEN); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_REN",BCM2835_SPI0_CS_REN); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_ADCS",BCM2835_SPI0_CS_ADCS); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_INTR",BCM2835_SPI0_CS_INTR); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_INTD",BCM2835_SPI0_CS_INTD); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_DMAEN",BCM2835_SPI0_CS_DMAEN); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_TA",BCM2835_SPI0_CS_TA); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CSPOL",BCM2835_SPI0_CS_CSPOL); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CLEAR",BCM2835_SPI0_CS_CLEAR); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CLEAR_RX",BCM2835_SPI0_CS_CLEAR_RX); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CLEAR_TX",BCM2835_SPI0_CS_CLEAR_TX); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CPOL",BCM2835_SPI0_CS_CPOL); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CPHA",BCM2835_SPI0_CS_CPHA); PyModule_AddIntConstant(m,"BCM2835_SPI0_CS_CS",BCM2835_SPI0_CS_CS); //PyModule_AddIntConstant(m,"",); // Function Select PyModule_AddIntConstant(m,"GPIO_FSEL_INPT",BCM2835_GPIO_FSEL_INPT); PyModule_AddIntConstant(m,"GPIO_FSEL_OUTP",BCM2835_GPIO_FSEL_OUTP); PyModule_AddIntConstant(m,"GPIO_FSEL_ALT0",BCM2835_GPIO_FSEL_ALT0); PyModule_AddIntConstant(m,"GPIO_FSEL_ALT1",BCM2835_GPIO_FSEL_ALT1); PyModule_AddIntConstant(m,"GPIO_FSEL_ALT2",BCM2835_GPIO_FSEL_ALT2); PyModule_AddIntConstant(m,"GPIO_FSEL_ALT3",BCM2835_GPIO_FSEL_ALT3); PyModule_AddIntConstant(m,"GPIO_FSEL_ALT4",BCM2835_GPIO_FSEL_ALT4); PyModule_AddIntConstant(m,"GPIO_FSEL_ALT5",BCM2835_GPIO_FSEL_ALT5); PyModule_AddIntConstant(m,"GPIO_FSEL_MASK",BCM2835_GPIO_FSEL_MASK); // PUD Control PyModule_AddIntConstant(m,"BCM2835_GPIO_PUD_OFF",BCM2835_GPIO_PUD_OFF); PyModule_AddIntConstant(m,"BCM2835_GPIO_PUD_DOWN",BCM2835_GPIO_PUD_DOWN); PyModule_AddIntConstant(m,"BCM2835_GPIO_PUD_UP",BCM2835_GPIO_PUD_UP); // Pad Group PyModule_AddIntConstant(m,"BCM2835_PAD_GROUP_GPIO_0_27",BCM2835_PAD_GROUP_GPIO_0_27); PyModule_AddIntConstant(m,"BCM2835_PAD_GROUP_GPIO_28_45",BCM2835_PAD_GROUP_GPIO_28_45); PyModule_AddIntConstant(m,"BCM2835_PAD_GROUP_GPIO_46_53",BCM2835_PAD_GROUP_GPIO_46_53); // RPiGPIOPin PyModule_AddIntConstant(m,"RPI_GPIO_P1_03",RPI_GPIO_P1_03); PyModule_AddIntConstant(m,"RPI_GPIO_P1_05",RPI_GPIO_P1_05); PyModule_AddIntConstant(m,"RPI_GPIO_P1_07",RPI_GPIO_P1_07); PyModule_AddIntConstant(m,"RPI_GPIO_P1_08",RPI_GPIO_P1_08); PyModule_AddIntConstant(m,"RPI_GPIO_P1_10",RPI_GPIO_P1_10); PyModule_AddIntConstant(m,"RPI_GPIO_P1_11",RPI_GPIO_P1_11); PyModule_AddIntConstant(m,"RPI_GPIO_P1_12",RPI_GPIO_P1_12); PyModule_AddIntConstant(m,"RPI_GPIO_P1_13",RPI_GPIO_P1_13); PyModule_AddIntConstant(m,"RPI_GPIO_P1_15",RPI_GPIO_P1_15); PyModule_AddIntConstant(m,"RPI_GPIO_P1_16",RPI_GPIO_P1_16); PyModule_AddIntConstant(m,"RPI_GPIO_P1_18",RPI_GPIO_P1_18); PyModule_AddIntConstant(m,"RPI_GPIO_P1_19",RPI_GPIO_P1_19); PyModule_AddIntConstant(m,"RPI_GPIO_P1_21",RPI_GPIO_P1_21); PyModule_AddIntConstant(m,"RPI_GPIO_P1_22",RPI_GPIO_P1_22); PyModule_AddIntConstant(m,"RPI_GPIO_P1_23",RPI_GPIO_P1_23); PyModule_AddIntConstant(m,"RPI_GPIO_P1_24",RPI_GPIO_P1_24); PyModule_AddIntConstant(m,"RPI_GPIO_P1_26",RPI_GPIO_P1_26); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_03",RPI_V2_GPIO_P1_03); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_05",RPI_V2_GPIO_P1_05); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_07",RPI_V2_GPIO_P1_07); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_08",RPI_V2_GPIO_P1_08); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_10",RPI_V2_GPIO_P1_10); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_11",RPI_V2_GPIO_P1_11); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_12",RPI_V2_GPIO_P1_12); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_13",RPI_V2_GPIO_P1_13); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_15",RPI_V2_GPIO_P1_15); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_16",RPI_V2_GPIO_P1_16); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_18",RPI_V2_GPIO_P1_18); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_19",RPI_V2_GPIO_P1_19); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_21",RPI_V2_GPIO_P1_21); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_22",RPI_V2_GPIO_P1_22); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_23",RPI_V2_GPIO_P1_23); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_24",RPI_V2_GPIO_P1_24); PyModule_AddIntConstant(m,"RPI_V2_GPIO_P1_26",RPI_V2_GPIO_P1_26); // Bit Order PyModule_AddIntConstant(m,"SPI_BIT_ORDER_LSBFIRST",BCM2835_SPI_BIT_ORDER_LSBFIRST); PyModule_AddIntConstant(m,"SPI_BIT_ORDER_MSBFIRST",BCM2835_SPI_BIT_ORDER_MSBFIRST); // SPI Mode PyModule_AddIntConstant(m,"SPI_MODE0",BCM2835_SPI_MODE0); PyModule_AddIntConstant(m,"SPI_MODE1",BCM2835_SPI_MODE1); PyModule_AddIntConstant(m,"SPI_MODE2",BCM2835_SPI_MODE2); PyModule_AddIntConstant(m,"SPI_MODE3",BCM2835_SPI_MODE3); // Chip Select PyModule_AddIntConstant(m,"SPI_CS0",BCM2835_SPI_CS0); PyModule_AddIntConstant(m,"SPI_CS1",BCM2835_SPI_CS1); PyModule_AddIntConstant(m,"SPI_CS2",BCM2835_SPI_CS2); PyModule_AddIntConstant(m,"SPI_CS_NONE",BCM2835_SPI_CS_NONE); // bcm2835SPIClockDivider PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_65536",BCM2835_SPI_CLOCK_DIVIDER_65536); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_32768",BCM2835_SPI_CLOCK_DIVIDER_32768); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_16384",BCM2835_SPI_CLOCK_DIVIDER_16384); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_8192",BCM2835_SPI_CLOCK_DIVIDER_8192); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_4096",BCM2835_SPI_CLOCK_DIVIDER_4096); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_2048",BCM2835_SPI_CLOCK_DIVIDER_2048); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_1024",BCM2835_SPI_CLOCK_DIVIDER_1024); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_512",BCM2835_SPI_CLOCK_DIVIDER_512); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_256",BCM2835_SPI_CLOCK_DIVIDER_256); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_128",BCM2835_SPI_CLOCK_DIVIDER_128); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_64",BCM2835_SPI_CLOCK_DIVIDER_64); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_32",BCM2835_SPI_CLOCK_DIVIDER_32); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_16",BCM2835_SPI_CLOCK_DIVIDER_16); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_8",BCM2835_SPI_CLOCK_DIVIDER_8); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_4",BCM2835_SPI_CLOCK_DIVIDER_4); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_2",BCM2835_SPI_CLOCK_DIVIDER_2); PyModule_AddIntConstant(m,"SPI_CLOCK_DIVIDER_1",BCM2835_SPI_CLOCK_DIVIDER_1); PyBCM2835Error = PyErr_NewException("PyBCM2835.error", NULL, NULL); Py_INCREF(PyBCM2835Error); PyModule_AddObject(m, "error", PyBCM2835Error); }
void session_init(PyObject *m) { Py_INCREF(&SessionType); PyModule_AddObject(m, "Session", (PyObject *)&SessionType); }