PyMODINIT_FUNC PyInit_bloch_simulator(void){ import_array(); return PyModule_Create(&bloch_module); }
MOD_INIT_DECL( pip$_vendor$requests$packages$urllib3$packages ) { #if defined(_NUITKA_EXE) || PYTHON_VERSION >= 300 static bool _init_done = false; // Modules might be imported repeatedly, which is to be ignored. if ( _init_done ) { return MOD_RETURN_VALUE( module_pip$_vendor$requests$packages$urllib3$packages ); } else { _init_done = true; } #endif #ifdef _NUITKA_MODULE // In case of a stand alone extension module, need to call initialization // the init here because that's the first and only time we are going to get // called here. // Initialize the constant values used. _initBuiltinModule(); createGlobalConstants(); // Initialize the compiled types of Nuitka. PyType_Ready( &Nuitka_Generator_Type ); PyType_Ready( &Nuitka_Function_Type ); PyType_Ready( &Nuitka_Method_Type ); PyType_Ready( &Nuitka_Frame_Type ); #if PYTHON_VERSION >= 350 PyType_Ready( &Nuitka_Coroutine_Type ); PyType_Ready( &Nuitka_CoroutineWrapper_Type ); #endif #if PYTHON_VERSION < 300 _initSlotCompare(); #endif #if PYTHON_VERSION >= 270 _initSlotIternext(); #endif patchBuiltinModule(); patchTypeComparison(); // Enable meta path based loader if not already done. setupMetaPathBasedLoader(); #if PYTHON_VERSION >= 300 patchInspectModule(); #endif #endif createModuleConstants(); createModuleCodeObjects(); // puts( "in initpip$_vendor$requests$packages$urllib3$packages" ); // Create the module object first. There are no methods initially, all are // added dynamically in actual code only. Also no "__doc__" is initially // set at this time, as it could not contain NUL characters this way, they // are instead set in early module code. No "self" for modules, we have no // use for it. #if PYTHON_VERSION < 300 module_pip$_vendor$requests$packages$urllib3$packages = Py_InitModule4( "pip._vendor.requests.packages.urllib3.packages", // Module Name NULL, // No methods initially, all are added // dynamically in actual module code only. NULL, // No __doc__ is initially set, as it could // not contain NUL this way, added early in // actual code. NULL, // No self for modules, we don't use it. PYTHON_API_VERSION ); #else module_pip$_vendor$requests$packages$urllib3$packages = PyModule_Create( &mdef_pip$_vendor$requests$packages$urllib3$packages ); #endif moduledict_pip$_vendor$requests$packages$urllib3$packages = (PyDictObject *)((PyModuleObject *)module_pip$_vendor$requests$packages$urllib3$packages)->md_dict; CHECK_OBJECT( module_pip$_vendor$requests$packages$urllib3$packages ); // Seems to work for Python2.7 out of the box, but for Python3, the module // doesn't automatically enter "sys.modules", so do it manually. #if PYTHON_VERSION >= 300 { int r = PyObject_SetItem( PySys_GetObject( (char *)"modules" ), const_str_digest_717e0aa5e359f200231896bcbab797ab, module_pip$_vendor$requests$packages$urllib3$packages ); assert( r != -1 ); } #endif // For deep importing of a module we need to have "__builtins__", so we set // it ourselves in the same way than CPython does. Note: This must be done // before the frame object is allocated, or else it may fail. PyObject *module_dict = PyModule_GetDict( module_pip$_vendor$requests$packages$urllib3$packages ); if ( PyDict_GetItem( module_dict, const_str_plain___builtins__ ) == NULL ) { PyObject *value = (PyObject *)builtin_module; // Check if main module, not a dict then. #if !defined(_NUITKA_EXE) || !0 value = PyModule_GetDict( value ); #endif #ifndef __NUITKA_NO_ASSERT__ int res = #endif PyDict_SetItem( module_dict, const_str_plain___builtins__, value ); assert( res == 0 ); } #if PYTHON_VERSION >= 330 PyDict_SetItem( module_dict, const_str_plain___loader__, metapath_based_loader ); #endif // Temp variables if any PyObject *exception_type = NULL, *exception_value = NULL; PyTracebackObject *exception_tb = NULL; NUITKA_MAY_BE_UNUSED int exception_lineno = -1; PyObject *tmp_assign_source_1; PyObject *tmp_assign_source_2; PyObject *tmp_assign_source_3; PyObject *tmp_assign_source_4; PyObject *tmp_assign_source_5; PyObject *tmp_assign_source_6; PyObject *tmp_assign_source_7; PyObject *tmp_assign_source_8; PyObject *tmp_import_globals_1; PyObject *tmp_import_name_from_1; PyFrameObject *frame_module; // Module code. tmp_assign_source_1 = Py_None; UPDATE_STRING_DICT0( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain___doc__, tmp_assign_source_1 ); tmp_assign_source_2 = const_str_digest_2fda06de9b427b74c9496097feae88ce; UPDATE_STRING_DICT0( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain___file__, tmp_assign_source_2 ); tmp_assign_source_3 = LIST_COPY( const_list_str_digest_d3e5a07139fdaf41b1ccc2e249a03040_list ); UPDATE_STRING_DICT1( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain___path__, tmp_assign_source_3 ); tmp_assign_source_4 = Py_None; UPDATE_STRING_DICT0( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain___cached__, tmp_assign_source_4 ); tmp_assign_source_5 = const_str_digest_717e0aa5e359f200231896bcbab797ab; UPDATE_STRING_DICT0( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain___package__, tmp_assign_source_5 ); tmp_assign_source_6 = PyObject_GetAttrString(PyImport_ImportModule("__future__"), "absolute_import"); UPDATE_STRING_DICT0( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain_absolute_import, tmp_assign_source_6 ); // Frame without reuse. frame_module = MAKE_MODULE_FRAME( codeobj_690c45c406de567b9656102a490ecf48, module_pip$_vendor$requests$packages$urllib3$packages ); // Push the new frame as the currently active one, and we should be exclusively // owning it. pushFrameStack( frame_module ); assert( Py_REFCNT( frame_module ) == 1 ); #if PYTHON_VERSION >= 340 frame_module->f_executing += 1; #endif // Framed code: tmp_import_globals_1 = ((PyModuleObject *)module_pip$_vendor$requests$packages$urllib3$packages)->md_dict; frame_module->f_lineno = 3; tmp_import_name_from_1 = IMPORT_MODULE( const_str_empty, tmp_import_globals_1, tmp_import_globals_1, const_tuple_str_plain_ssl_match_hostname_tuple, const_int_pos_1 ); if ( tmp_import_name_from_1 == NULL ) { assert( ERROR_OCCURRED() ); FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); exception_lineno = 3; goto frame_exception_exit_1; } tmp_assign_source_7 = IMPORT_NAME( tmp_import_name_from_1, const_str_plain_ssl_match_hostname ); Py_DECREF( tmp_import_name_from_1 ); if ( tmp_assign_source_7 == NULL ) { assert( ERROR_OCCURRED() ); FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); exception_lineno = 3; goto frame_exception_exit_1; } UPDATE_STRING_DICT1( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain_ssl_match_hostname, tmp_assign_source_7 ); // Restore frame exception if necessary. #if 0 RESTORE_FRAME_EXCEPTION( frame_module ); #endif popFrameStack(); assertFrameObject( frame_module ); Py_DECREF( frame_module ); goto frame_no_exception_1; frame_exception_exit_1:; #if 0 RESTORE_FRAME_EXCEPTION( frame_module ); #endif if ( exception_tb == NULL ) { exception_tb = MAKE_TRACEBACK( frame_module, exception_lineno ); } else if ( exception_tb->tb_frame != frame_module ) { PyTracebackObject *traceback_new = MAKE_TRACEBACK( frame_module, exception_lineno ); traceback_new->tb_next = exception_tb; exception_tb = traceback_new; } // Put the previous frame back on top. popFrameStack(); #if PYTHON_VERSION >= 340 frame_module->f_executing -= 1; #endif Py_DECREF( frame_module ); // Return the error. goto module_exception_exit; frame_no_exception_1:; tmp_assign_source_8 = const_tuple_str_plain_ssl_match_hostname_tuple; UPDATE_STRING_DICT0( moduledict_pip$_vendor$requests$packages$urllib3$packages, (Nuitka_StringObject *)const_str_plain___all__, tmp_assign_source_8 ); return MOD_RETURN_VALUE( module_pip$_vendor$requests$packages$urllib3$packages ); module_exception_exit: RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb ); return MOD_RETURN_VALUE( NULL ); }
PyMODINIT_FUNC PyInit_quark_hash(void) { return PyModule_Create(&QuarkModule); }
PyMODINIT_FUNC PyInit_sophiacoin_hash(void) { return PyModule_Create(&SophiacoinModule); }
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("RPi.GPIO", rpi_gpio_methods)) == NULL) goto exit; #endif WrongDirectionException = PyErr_NewException("RPi.GPIO.WrongDirectionException", NULL, NULL); PyModule_AddObject(module, "WrongDirectionException", WrongDirectionException); InvalidModeException = PyErr_NewException("RPi.GPIO.InvalidModeException", NULL, NULL); PyModule_AddObject(module, "InvalidModeException", InvalidModeException); InvalidDirectionException = PyErr_NewException("RPi.GPIO.InvalidDirectionException", NULL, NULL); PyModule_AddObject(module, "InvalidDirectionException", InvalidDirectionException); InvalidChannelException = PyErr_NewException("RPi.GPIO.InvalidChannelException", NULL, NULL); PyModule_AddObject(module, "InvalidChannelException", InvalidChannelException); InvalidPullException = PyErr_NewException("RPi.GPIO.InvalidPullException", NULL, NULL); PyModule_AddObject(module, "InvalidPullException", InvalidPullException); ModeNotSetException = PyErr_NewException("RPi.GPIO.ModeNotSetException", NULL, NULL); PyModule_AddObject(module, "ModeNotSetException", ModeNotSetException); SetupException = PyErr_NewException("RPi.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); 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); if (module_setup() != SETUP_OK) { #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } if (Py_AtExit(gpio_cleanup) != 0) gpio_cleanup(); goto exit; exit: #if PY_MAJOR_VERSION > 2 return module; #else return; #endif }
/* Module initialization function */ PyMODINIT_FUNC PyInit_sample3(void) { return PyModule_Create(&samplemodule); }
MOD_INIT_DECL( django$utils$simplejson ) { #if defined(_NUITKA_EXE) || PYTHON_VERSION >= 300 static bool _init_done = false; // Packages can be imported recursively in deep executables. if ( _init_done ) { return MOD_RETURN_VALUE( module_django$utils$simplejson ); } else { _init_done = true; } #endif #ifdef _NUITKA_MODULE // In case of a stand alone extension module, need to call initialization // the init here because that's the first and only time we are going to get // called here. // Initialize the constant values used. _initBuiltinModule(); _initConstants(); // Initialize the compiled types of Nuitka. PyType_Ready( &Nuitka_Generator_Type ); PyType_Ready( &Nuitka_Function_Type ); PyType_Ready( &Nuitka_Method_Type ); PyType_Ready( &Nuitka_Frame_Type ); #if PYTHON_VERSION < 300 initSlotCompare(); #endif patchBuiltinModule(); patchTypeComparison(); #endif #if _MODULE_UNFREEZER registerMetaPathBasedUnfreezer( meta_path_loader_entries ); #endif _initModuleConstants(); _initModuleCodeObjects(); // puts( "in initdjango$utils$simplejson" ); // Create the module object first. There are no methods initially, all are // added dynamically in actual code only. Also no "__doc__" is initially // set at this time, as it could not contain NUL characters this way, they // are instead set in early module code. No "self" for modules, we have no // use for it. #if PYTHON_VERSION < 300 module_django$utils$simplejson = Py_InitModule4( "django.utils.simplejson", // Module Name NULL, // No methods initially, all are added // dynamically in actual module code only. NULL, // No __doc__ is initially set, as it could // not contain NUL this way, added early in // actual code. NULL, // No self for modules, we don't use it. PYTHON_API_VERSION ); #else module_django$utils$simplejson = PyModule_Create( &mdef_django$utils$simplejson ); #endif moduledict_django$utils$simplejson = (PyDictObject *)((PyModuleObject *)module_django$utils$simplejson)->md_dict; assertObject( module_django$utils$simplejson ); // Seems to work for Python2.7 out of the box, but for Python3, the module // doesn't automatically enter "sys.modules", so do it manually. #if PYTHON_VERSION >= 300 { int r = PyObject_SetItem( PySys_GetObject( (char *)"modules" ), const_str_digest_8e395302c5225c24e16f9edd8dd95062, module_django$utils$simplejson ); assert( r != -1 ); } #endif // For deep importing of a module we need to have "__builtins__", so we set // it ourselves in the same way than CPython does. Note: This must be done // before the frame object is allocated, or else it may fail. PyObject *module_dict = PyModule_GetDict( module_django$utils$simplejson ); if ( PyDict_GetItem( module_dict, const_str_plain___builtins__ ) == NULL ) { PyObject *value = (PyObject *)builtin_module; // Check if main module, not a dict then. #if !defined(_NUITKA_EXE) || !0 value = PyModule_GetDict( value ); #endif #ifndef __NUITKA_NO_ASSERT__ int res = #endif PyDict_SetItem( module_dict, const_str_plain___builtins__, value ); assert( res == 0 ); } #if PYTHON_VERSION >= 330 #if _MODULE_UNFREEZER PyDict_SetItem( module_dict, const_str_plain___loader__, metapath_based_loader ); #else PyDict_SetItem( module_dict, const_str_plain___loader__, Py_None ); #endif #endif // Temp variables if any PyObjectTempVariable tmp_or_1__value_1; PyObjectTempVariable tmp_try_except_1__unhandled_indicator; PyObject *exception_type, *exception_value; PyTracebackObject *exception_tb; PyObject *exception_keeper_type_1; PyObject *exception_keeper_value_1; PyTracebackObject *exception_keeper_tb_1; PyObject *exception_keeper_type_2; PyObject *exception_keeper_value_2; PyTracebackObject *exception_keeper_tb_2; PyObject *exception_keeper_type_3; PyObject *exception_keeper_value_3; PyTracebackObject *exception_keeper_tb_3; PyObject *exception_keeper_type_4; PyObject *exception_keeper_value_4; PyTracebackObject *exception_keeper_tb_4; PyObject *tmp_assign_source_1; PyObject *tmp_assign_source_2; PyObject *tmp_assign_source_3; PyObject *tmp_assign_source_4; PyObject *tmp_assign_source_5; PyObject *tmp_assign_source_6; PyObject *tmp_assign_source_7; PyObject *tmp_assign_source_8; PyObject *tmp_assign_source_9; PyObject *tmp_assign_source_10; PyObject *tmp_assign_source_11; PyObject *tmp_assign_source_12; PyObject *tmp_assign_source_13; PyObject *tmp_call_arg_element_1; PyObject *tmp_call_arg_element_2; PyObject *tmp_call_kw_1; PyObject *tmp_call_pos_1; PyObject *tmp_called_1; PyObject *tmp_called_2; PyObject *tmp_called_3; PyObject *tmp_compare_left_1; PyObject *tmp_compare_left_2; PyObject *tmp_compare_right_1; PyObject *tmp_compare_right_2; PyObject *tmp_compexpr_left_1; PyObject *tmp_compexpr_right_1; int tmp_cond_truth_1; int tmp_cond_truth_2; PyObject *tmp_cond_value_1; PyObject *tmp_cond_value_2; int tmp_exc_match_exception_match_1; PyObject *tmp_hasattr_attr_1; PyObject *tmp_hasattr_value_1; PyObject *tmp_import_globals_1; PyObject *tmp_import_globals_2; PyObject *tmp_import_globals_3; PyObject *tmp_import_globals_4; PyObject *tmp_import_globals_5; PyObject *tmp_import_globals_6; PyObject *tmp_import_globals_7; PyObject *tmp_import_globals_8; PyObject *tmp_import_name_from_1; PyObject *tmp_import_name_from_2; PyObject *tmp_import_name_from_3; PyObject *tmp_import_name_from_4; bool tmp_is_1; bool tmp_result; PyObject *tmp_source_name_1; PyObject *tmp_source_name_2; PyObject *tmp_source_name_3; PyObject *tmp_source_name_4; PyObject *tmp_star_imported_1; PyObject *tmp_star_imported_2; int tmp_tried_lineno_1; int tmp_tried_lineno_2; PyObject *tmp_tuple_element_1; NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; // Module code. tmp_assign_source_1 = Py_None; UPDATE_STRING_DICT0( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain___doc__, tmp_assign_source_1 ); tmp_assign_source_2 = const_str_digest_b263340febec452f7ce0d23d319dd69a; UPDATE_STRING_DICT0( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain___file__, tmp_assign_source_2 ); // Frame without reuse. PyFrameObject *frame_module = MAKE_FRAME( codeobj_525b0a67f88de51bd5157e3eb4d3fcf3, module_django$utils$simplejson ); // Push the new frame as the currently active one, and we should be exlusively // owning it. pushFrameStack( frame_module ); assert( Py_REFCNT( frame_module ) == 1 ); #if PYTHON_VERSION >= 340 frame_module->f_executing += 1; #endif // Framed code: tmp_import_globals_1 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 8; tmp_import_name_from_1 = IMPORT_MODULE( const_str_plain___future__, tmp_import_globals_1, tmp_import_globals_1, const_tuple_str_plain_absolute_import_tuple, const_int_0 ); if ( tmp_import_name_from_1 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 8; goto frame_exception_exit_1; } tmp_assign_source_3 = IMPORT_NAME( tmp_import_name_from_1, const_str_plain_absolute_import ); Py_DECREF( tmp_import_name_from_1 ); if ( tmp_assign_source_3 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 8; goto frame_exception_exit_1; } UPDATE_STRING_DICT1( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_absolute_import, tmp_assign_source_3 ); tmp_import_globals_2 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 10; tmp_assign_source_4 = IMPORT_MODULE( const_str_plain_warnings, tmp_import_globals_2, tmp_import_globals_2, Py_None, const_int_0 ); if ( tmp_assign_source_4 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 10; goto frame_exception_exit_1; } UPDATE_STRING_DICT1( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_warnings, tmp_assign_source_4 ); tmp_source_name_1 = GET_STRING_DICT_VALUE( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_warnings ); if (unlikely( tmp_source_name_1 == NULL )) { tmp_source_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_warnings ); } if ( tmp_source_name_1 == NULL ) { exception_type = INCREASE_REFCOUNT( PyExc_NameError ); exception_value = UNSTREAM_STRING( &constant_bin[ 6021 ], 30, 0 ); exception_tb = NULL; frame_module->f_lineno = 11; goto frame_exception_exit_1; } tmp_called_1 = LOOKUP_ATTRIBUTE( tmp_source_name_1, const_str_plain_warn ); if ( tmp_called_1 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 11; goto frame_exception_exit_1; } tmp_call_pos_1 = PyTuple_New( 2 ); tmp_tuple_element_1 = const_str_digest_7169b7e65e78489e48321bf243165725; Py_INCREF( tmp_tuple_element_1 ); PyTuple_SET_ITEM( tmp_call_pos_1, 0, tmp_tuple_element_1 ); tmp_tuple_element_1 = GET_STRING_DICT_VALUE( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_DeprecationWarning ); if (unlikely( tmp_tuple_element_1 == NULL )) { tmp_tuple_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_DeprecationWarning ); } if ( tmp_tuple_element_1 == NULL ) { Py_DECREF( tmp_called_1 ); Py_DECREF( tmp_call_pos_1 ); exception_type = INCREASE_REFCOUNT( PyExc_NameError ); exception_value = UNSTREAM_STRING( &constant_bin[ 6058 ], 40, 0 ); exception_tb = NULL; frame_module->f_lineno = 12; goto frame_exception_exit_1; } Py_INCREF( tmp_tuple_element_1 ); PyTuple_SET_ITEM( tmp_call_pos_1, 1, tmp_tuple_element_1 ); tmp_call_kw_1 = PyDict_Copy( const_dict_f154c9a58c9419d7e391901d7b7fe49e ); frame_module->f_lineno = 12; tmp_unused = CALL_FUNCTION( tmp_called_1, tmp_call_pos_1, tmp_call_kw_1 ); Py_DECREF( tmp_called_1 ); Py_DECREF( tmp_call_pos_1 ); Py_DECREF( tmp_call_kw_1 ); if ( tmp_unused == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 12; goto frame_exception_exit_1; } Py_DECREF( tmp_unused ); tmp_assign_source_5 = Py_True; assert( tmp_try_except_1__unhandled_indicator.object == NULL ); tmp_try_except_1__unhandled_indicator.object = INCREASE_REFCOUNT( tmp_assign_source_5 ); // Tried code // Tried block of try/except tmp_import_globals_3 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 15; tmp_assign_source_6 = IMPORT_MODULE( const_str_plain_simplejson, tmp_import_globals_3, tmp_import_globals_3, Py_None, const_int_0 ); if ( tmp_assign_source_6 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 15; goto try_except_handler_1; } UPDATE_STRING_DICT1( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_simplejson, tmp_assign_source_6 ); goto try_except_end_1; try_except_handler_1:; // Exception handler of try/except tmp_assign_source_7 = Py_False; if (tmp_try_except_1__unhandled_indicator.object == NULL) { tmp_try_except_1__unhandled_indicator.object = INCREASE_REFCOUNT( tmp_assign_source_7 ); } else { PyObject *old = tmp_try_except_1__unhandled_indicator.object; tmp_try_except_1__unhandled_indicator.object = INCREASE_REFCOUNT( tmp_assign_source_7 ); Py_DECREF( old ); } // Preserve existing published exception. PRESERVE_FRAME_EXCEPTION( frame_module ); if (exception_tb == NULL) { exception_tb = MAKE_TRACEBACK( INCREASE_REFCOUNT( frame_module ) ); } else if ( exception_tb->tb_frame != frame_module || exception_tb->tb_lineno != frame_module->f_lineno ) { exception_tb = ADD_TRACEBACK( frame_module, exception_tb ); } NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); PUBLISH_EXCEPTION( &exception_type, &exception_value, &exception_tb ); tmp_compare_left_1 = PyThreadState_GET()->exc_type; tmp_compare_right_1 = PyExc_ImportError; tmp_exc_match_exception_match_1 = EXCEPTION_MATCH_BOOL( tmp_compare_left_1, tmp_compare_right_1 ); if ( tmp_exc_match_exception_match_1 == -1 ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 16; goto try_finally_handler_1; } if (tmp_exc_match_exception_match_1 == 1) { goto branch_yes_1; } else { goto branch_no_1; } branch_yes_1:; tmp_assign_source_8 = Py_False; UPDATE_STRING_DICT0( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_use_simplejson, tmp_assign_source_8 ); goto branch_end_1; branch_no_1:; RERAISE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); if (exception_tb && exception_tb->tb_frame == frame_module) frame_module->f_lineno = exception_tb->tb_lineno; goto try_finally_handler_1; branch_end_1:; try_except_end_1:; tmp_compare_left_2 = tmp_try_except_1__unhandled_indicator.object; tmp_compare_right_2 = Py_True; tmp_is_1 = ( tmp_compare_left_2 == tmp_compare_right_2 ); if (tmp_is_1) { goto branch_yes_2; } else { goto branch_no_2; } branch_yes_2:; tmp_import_globals_4 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 21; tmp_import_name_from_2 = IMPORT_MODULE( const_str_plain_json, tmp_import_globals_4, tmp_import_globals_4, const_tuple_str_plain___version___tuple, const_int_0 ); if ( tmp_import_name_from_2 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 21; goto try_finally_handler_1; } tmp_assign_source_9 = IMPORT_NAME( tmp_import_name_from_2, const_str_plain___version__ ); Py_DECREF( tmp_import_name_from_2 ); if ( tmp_assign_source_9 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 21; goto try_finally_handler_1; } UPDATE_STRING_DICT1( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_stdlib_json_version, tmp_assign_source_9 ); // Tried code tmp_assign_source_10 = NULL; // Tried code tmp_hasattr_value_1 = GET_STRING_DICT_VALUE( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_simplejson ); if (unlikely( tmp_hasattr_value_1 == NULL )) { tmp_hasattr_value_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_simplejson ); } if ( tmp_hasattr_value_1 == NULL ) { exception_type = INCREASE_REFCOUNT( PyExc_NameError ); exception_value = UNSTREAM_STRING( &constant_bin[ 15633 ], 32, 0 ); exception_tb = NULL; frame_module->f_lineno = 22; goto try_finally_handler_3; } tmp_hasattr_attr_1 = const_str_plain__speedups; tmp_assign_source_11 = BUILTIN_HASATTR( tmp_hasattr_value_1, tmp_hasattr_attr_1 ); if ( tmp_assign_source_11 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 22; goto try_finally_handler_3; } assert( tmp_or_1__value_1.object == NULL ); tmp_or_1__value_1.object = INCREASE_REFCOUNT( tmp_assign_source_11 ); tmp_cond_value_1 = tmp_or_1__value_1.object; tmp_cond_truth_1 = CHECK_IF_TRUE( tmp_cond_value_1 ); if ( tmp_cond_truth_1 == -1 ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 22; goto try_finally_handler_3; } if (tmp_cond_truth_1 == 1) { goto condexpr_true_1; } else { goto condexpr_false_1; } condexpr_true_1:; tmp_assign_source_10 = tmp_or_1__value_1.object; Py_INCREF( tmp_assign_source_10 ); goto condexpr_end_1; condexpr_false_1:; tmp_assign_source_10 = NULL; // Tried code tmp_result = tmp_or_1__value_1.object != NULL; if ( tmp_result == true ) { Py_DECREF( tmp_or_1__value_1.object ); tmp_or_1__value_1.object = NULL; } assert( tmp_result != false ); tmp_source_name_3 = GET_STRING_DICT_VALUE( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_simplejson ); if (unlikely( tmp_source_name_3 == NULL )) { tmp_source_name_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_simplejson ); } if ( tmp_source_name_3 == NULL ) { exception_type = INCREASE_REFCOUNT( PyExc_NameError ); exception_value = UNSTREAM_STRING( &constant_bin[ 15633 ], 32, 0 ); exception_tb = NULL; frame_module->f_lineno = 23; goto try_finally_handler_4; } tmp_source_name_2 = LOOKUP_ATTRIBUTE( tmp_source_name_3, const_str_plain___version__ ); if ( tmp_source_name_2 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 23; goto try_finally_handler_4; } tmp_called_2 = LOOKUP_ATTRIBUTE( tmp_source_name_2, const_str_plain_split ); Py_DECREF( tmp_source_name_2 ); if ( tmp_called_2 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 23; goto try_finally_handler_4; } tmp_call_arg_element_1 = const_str_dot; frame_module->f_lineno = 23; tmp_compexpr_left_1 = CALL_FUNCTION_WITH_ARGS1( tmp_called_2, tmp_call_arg_element_1 ); Py_DECREF( tmp_called_2 ); if ( tmp_compexpr_left_1 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 23; goto try_finally_handler_4; } tmp_source_name_4 = GET_STRING_DICT_VALUE( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_stdlib_json_version ); if (unlikely( tmp_source_name_4 == NULL )) { tmp_source_name_4 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_stdlib_json_version ); } if ( tmp_source_name_4 == NULL ) { Py_DECREF( tmp_compexpr_left_1 ); exception_type = INCREASE_REFCOUNT( PyExc_NameError ); exception_value = UNSTREAM_STRING( &constant_bin[ 27036 ], 41, 0 ); exception_tb = NULL; frame_module->f_lineno = 23; goto try_finally_handler_4; } tmp_called_3 = LOOKUP_ATTRIBUTE( tmp_source_name_4, const_str_plain_split ); if ( tmp_called_3 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); Py_DECREF( tmp_compexpr_left_1 ); frame_module->f_lineno = 23; goto try_finally_handler_4; } tmp_call_arg_element_2 = const_str_dot; frame_module->f_lineno = 23; tmp_compexpr_right_1 = CALL_FUNCTION_WITH_ARGS1( tmp_called_3, tmp_call_arg_element_2 ); Py_DECREF( tmp_called_3 ); if ( tmp_compexpr_right_1 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); Py_DECREF( tmp_compexpr_left_1 ); frame_module->f_lineno = 23; goto try_finally_handler_4; } tmp_assign_source_10 = RICH_COMPARE_GE( tmp_compexpr_left_1, tmp_compexpr_right_1 ); Py_DECREF( tmp_compexpr_left_1 ); Py_DECREF( tmp_compexpr_right_1 ); if ( tmp_assign_source_10 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 23; goto try_finally_handler_4; } // Final block of try/finally // Tried block ends with no exception occured, note that. exception_type = NULL; exception_value = NULL; exception_tb = NULL; try_finally_handler_4:; exception_keeper_type_1 = exception_type; exception_keeper_value_1 = exception_value; exception_keeper_tb_1 = exception_tb; exception_type = NULL; exception_value = NULL; exception_tb = NULL; // Re-reraise as necessary after finally was executed. // Reraise exception if any. if ( exception_keeper_type_1 != NULL ) { exception_type = exception_keeper_type_1; exception_value = exception_keeper_value_1; exception_tb = exception_keeper_tb_1; goto try_finally_handler_3; } goto finally_end_1; finally_end_1:; condexpr_end_1:; // Final block of try/finally // Tried block ends with no exception occured, note that. exception_type = NULL; exception_value = NULL; exception_tb = NULL; try_finally_handler_3:; exception_keeper_type_2 = exception_type; exception_keeper_value_2 = exception_value; exception_keeper_tb_2 = exception_tb; exception_type = NULL; exception_value = NULL; exception_tb = NULL; // Re-reraise as necessary after finally was executed. // Reraise exception if any. if ( exception_keeper_type_2 != NULL ) { exception_type = exception_keeper_type_2; exception_value = exception_keeper_value_2; exception_tb = exception_keeper_tb_2; goto try_finally_handler_2; } goto finally_end_2; finally_end_2:; UPDATE_STRING_DICT1( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_use_simplejson, tmp_assign_source_10 ); // Final block of try/finally // Tried block ends with no exception occured, note that. exception_type = NULL; exception_value = NULL; exception_tb = NULL; try_finally_handler_2:; exception_keeper_type_3 = exception_type; exception_keeper_value_3 = exception_value; exception_keeper_tb_3 = exception_tb; exception_type = NULL; exception_value = NULL; exception_tb = NULL; tmp_tried_lineno_1 = frame_module->f_lineno; Py_XDECREF( tmp_or_1__value_1.object ); tmp_or_1__value_1.object = NULL; frame_module->f_lineno = tmp_tried_lineno_1; // Re-reraise as necessary after finally was executed. // Reraise exception if any. if ( exception_keeper_type_3 != NULL ) { exception_type = exception_keeper_type_3; exception_value = exception_keeper_value_3; exception_tb = exception_keeper_tb_3; goto try_finally_handler_1; } goto finally_end_3; finally_end_3:; branch_no_2:; // Final block of try/finally // Tried block ends with no exception occured, note that. exception_type = NULL; exception_value = NULL; exception_tb = NULL; try_finally_handler_1:; exception_keeper_type_4 = exception_type; exception_keeper_value_4 = exception_value; exception_keeper_tb_4 = exception_tb; exception_type = NULL; exception_value = NULL; exception_tb = NULL; tmp_tried_lineno_2 = frame_module->f_lineno; tmp_result = tmp_try_except_1__unhandled_indicator.object != NULL; if ( tmp_result == true ) { Py_DECREF( tmp_try_except_1__unhandled_indicator.object ); tmp_try_except_1__unhandled_indicator.object = NULL; } assert( tmp_result != false ); frame_module->f_lineno = tmp_tried_lineno_2; // Re-reraise as necessary after finally was executed. // Reraise exception if any. if ( exception_keeper_type_4 != NULL ) { exception_type = exception_keeper_type_4; exception_value = exception_keeper_value_4; exception_tb = exception_keeper_tb_4; goto frame_exception_exit_1; } goto finally_end_4; finally_end_4:; tmp_cond_value_2 = GET_STRING_DICT_VALUE( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain_use_simplejson ); if (unlikely( tmp_cond_value_2 == NULL )) { tmp_cond_value_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_use_simplejson ); } if ( tmp_cond_value_2 == NULL ) { exception_type = INCREASE_REFCOUNT( PyExc_NameError ); exception_value = UNSTREAM_STRING( &constant_bin[ 27077 ], 36, 0 ); exception_tb = NULL; frame_module->f_lineno = 26; goto frame_exception_exit_1; } tmp_cond_truth_2 = CHECK_IF_TRUE( tmp_cond_value_2 ); if ( tmp_cond_truth_2 == -1 ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 26; goto frame_exception_exit_1; } if (tmp_cond_truth_2 == 1) { goto branch_yes_3; } else { goto branch_no_3; } branch_yes_3:; tmp_import_globals_5 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 27; tmp_star_imported_1 = IMPORT_MODULE( const_str_plain_simplejson, tmp_import_globals_5, tmp_import_globals_5, const_tuple_str_chr_42_tuple, const_int_0 ); if ( tmp_star_imported_1 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 27; goto frame_exception_exit_1; } tmp_result = IMPORT_MODULE_STAR( module_django$utils$simplejson, true, tmp_star_imported_1 ); if ( tmp_result == false ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); Py_DECREF( tmp_star_imported_1 ); frame_module->f_lineno = 27; goto frame_exception_exit_1; } Py_DECREF( tmp_star_imported_1 ); tmp_import_globals_6 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 28; tmp_import_name_from_3 = IMPORT_MODULE( const_str_plain_simplejson, tmp_import_globals_6, tmp_import_globals_6, const_tuple_str_plain___version___tuple, const_int_0 ); if ( tmp_import_name_from_3 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 28; goto frame_exception_exit_1; } tmp_assign_source_12 = IMPORT_NAME( tmp_import_name_from_3, const_str_plain___version__ ); Py_DECREF( tmp_import_name_from_3 ); if ( tmp_assign_source_12 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 28; goto frame_exception_exit_1; } UPDATE_STRING_DICT1( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain___version__, tmp_assign_source_12 ); goto branch_end_3; branch_no_3:; tmp_import_globals_7 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 30; tmp_star_imported_2 = IMPORT_MODULE( const_str_plain_json, tmp_import_globals_7, tmp_import_globals_7, const_tuple_str_chr_42_tuple, const_int_0 ); if ( tmp_star_imported_2 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 30; goto frame_exception_exit_1; } tmp_result = IMPORT_MODULE_STAR( module_django$utils$simplejson, true, tmp_star_imported_2 ); if ( tmp_result == false ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); Py_DECREF( tmp_star_imported_2 ); frame_module->f_lineno = 30; goto frame_exception_exit_1; } Py_DECREF( tmp_star_imported_2 ); tmp_import_globals_8 = ((PyModuleObject *)module_django$utils$simplejson)->md_dict; frame_module->f_lineno = 31; tmp_import_name_from_4 = IMPORT_MODULE( const_str_plain_json, tmp_import_globals_8, tmp_import_globals_8, const_tuple_str_plain___version___tuple, const_int_0 ); if ( tmp_import_name_from_4 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 31; goto frame_exception_exit_1; } tmp_assign_source_13 = IMPORT_NAME( tmp_import_name_from_4, const_str_plain___version__ ); Py_DECREF( tmp_import_name_from_4 ); if ( tmp_assign_source_13 == NULL ) { assert( ERROR_OCCURED() ); PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb ); frame_module->f_lineno = 31; goto frame_exception_exit_1; } UPDATE_STRING_DICT1( moduledict_django$utils$simplejson, (Nuitka_StringObject *)const_str_plain___version__, tmp_assign_source_13 ); branch_end_3:; // Restore frame exception if necessary. #if 1 RESTORE_FRAME_EXCEPTION( frame_module ); #endif popFrameStack(); assertFrameObject( frame_module ); Py_DECREF( frame_module ); goto frame_no_exception_1; frame_exception_exit_1:; #if 1 RESTORE_FRAME_EXCEPTION( frame_module ); #endif if ( exception_tb == NULL ) { exception_tb = MAKE_TRACEBACK( INCREASE_REFCOUNT( frame_module ) ); } else if ( exception_tb->tb_frame != frame_module ) { PyTracebackObject *traceback_new = (PyTracebackObject *)MAKE_TRACEBACK( INCREASE_REFCOUNT( frame_module ) ); traceback_new->tb_next = exception_tb; exception_tb = traceback_new; } // Put the previous frame back on top. popFrameStack(); #if PYTHON_VERSION >= 340 frame_module->f_executing -= 1; #endif Py_DECREF( frame_module ); // Return the error. goto module_exception_exit; frame_no_exception_1:; return MOD_RETURN_VALUE( module_django$utils$simplejson ); module_exception_exit: PyErr_Restore( exception_type, exception_value, (PyObject *)exception_tb ); return MOD_RETURN_VALUE( NULL ); }
PyObject * PyInit__perlin(void) { return PyModule_Create(&moduledef); }
//------------------------------------------------------------------------------------- bool Script::install(const wchar_t* pythonHomeDir, std::wstring pyPaths, const char* moduleName, COMPONENT_TYPE componentType) { std::wstring pySysPaths = SCRIPT_PATH; wchar_t* pwpySysResPath = strutil::char2wchar(const_cast<char*>(Resmgr::getSingleton().getPySysResPath().c_str())); strutil::kbe_replace(pySysPaths, L"../../res/", pwpySysResPath); pyPaths += pySysPaths; free(pwpySysResPath); #if KBE_PLATFORM == PLATFORM_WIN32 Py_SetPythonHome(const_cast<wchar_t*>(pythonHomeDir)); // 先设置python的环境变量 #else std::wstring fs = L";"; std::wstring rs = L":"; size_t pos = 0; while(true) { pos = pyPaths.find(fs, pos); if (pos == std::wstring::npos) break; pyPaths.replace(pos, fs.length(), rs); } Py_SetPath(pyPaths.c_str()); char* tmpchar = strutil::wchar2char(const_cast<wchar_t*>(pyPaths.c_str())); DEBUG_MSG(boost::format("Script::install: paths=%1%.\n") % tmpchar); free(tmpchar); #endif // Initialise python // Py_VerboseFlag = 2; Py_FrozenFlag = 1; // Warn if tab and spaces are mixed in indentation. // Py_TabcheckFlag = 1; Py_NoSiteFlag = 1; Py_IgnoreEnvironmentFlag = 1; Py_Initialize(); // python解释器的初始化 if (!Py_IsInitialized()) { ERROR_MSG("Script::install::Py_Initialize is failed!\n"); return false; } #if KBE_PLATFORM == PLATFORM_WIN32 PySys_SetPath(pyPaths.c_str()); #endif PyObject *m = PyImport_AddModule("__main__"); module_ = PyImport_AddModule(moduleName); // 添加一个脚本基础模块 if (module_ == NULL) return false; const char* componentName = COMPONENT_NAME_EX(componentType); if (PyModule_AddStringConstant(module_, "component", componentName)) { ERROR_MSG(boost::format("Script::init: Unable to set KBEngine.component to %1%\n") % componentName ); return false; } // 注册产生uuid方法到py APPEND_SCRIPT_MODULE_METHOD(module_, genUUID64, __py_genUUID64, METH_VARARGS, 0); if(!install_py_dlls()) { ERROR_MSG("Script::init: install_py_dlls() is failed!\n"); return false; } #ifndef KBE_SINGLE_THREADED s_pOurInitTimeModules = PyDict_Copy( PySys_GetObject( "modules" ) ); s_pMainThreadState = PyThreadState_Get(); s_defaultContext = s_pMainThreadState; PyEval_InitThreads(); KBEConcurrency::setMainThreadIdleFunctions( &Script::releaseLock, &Script::acquireLock ); #endif ScriptStdOutErr::installScript(NULL); // 安装py重定向模块 ScriptStdOutErrHook::installScript(NULL); static struct PyModuleDef moduleDesc = { PyModuleDef_HEAD_INIT, moduleName, "This module is created by KBEngine!", -1, NULL }; PyModule_Create(&moduleDesc); // 初始化基础模块 PyObject_SetAttrString(m, moduleName, module_); // 将模块对象加入main pyStdouterr_ = new ScriptStdOutErr(); // 重定向python输出 pyStdouterrHook_ = new ScriptStdOutErrHook(); if(!pyStdouterr_->install()){ // 安装py重定向脚本模块 ERROR_MSG("Script::install::pyStdouterr_->install() is failed!\n"); SCRIPT_ERROR_CHECK(); return false; } Pickler::initialize(); PyProfile::initialize(this); PyStruct::initialize(); Copy::initialize(); SCRIPT_ERROR_CHECK(); math::installModule("Math"); INFO_MSG("Script::install is successfully!\n"); return installExtraModule("KBExtra"); }
PyMODINIT_FUNC SIP_MODULE_ENTRY() #endif { static PyMethodDef sip_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static PyModuleDef sip_module_def = { PyModuleDef_HEAD_INIT, "PyQt5.Enginio", NULL, -1, sip_methods, NULL, NULL, NULL, NULL }; #endif PyObject *sipModule, *sipModuleDict; PyObject *sip_sipmod, *sip_capiobj; /* Initialise the module and get it's dictionary. */ #if PY_MAJOR_VERSION >= 3 sipModule = PyModule_Create(&sip_module_def); #elif PY_VERSION_HEX >= 0x02050000 sipModule = Py_InitModule(sipName_PyQt5_Enginio, sip_methods); #else sipModule = Py_InitModule(const_cast<char *>(sipName_PyQt5_Enginio), sip_methods); #endif if (sipModule == NULL) SIP_MODULE_RETURN(NULL); sipModuleDict = PyModule_GetDict(sipModule); /* Get the SIP module's API. */ #if PY_VERSION_HEX >= 0x02050000 sip_sipmod = PyImport_ImportModule(SIP_MODULE_NAME); #else sip_sipmod = PyImport_ImportModule(const_cast<char *>(SIP_MODULE_NAME)); #endif if (sip_sipmod == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } sip_capiobj = PyDict_GetItemString(PyModule_GetDict(sip_sipmod), "_C_API"); Py_DECREF(sip_sipmod); #if defined(SIP_USE_PYCAPSULE) if (sip_capiobj == NULL || !PyCapsule_CheckExact(sip_capiobj)) #else if (sip_capiobj == NULL || !PyCObject_Check(sip_capiobj)) #endif { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #if defined(SIP_USE_PYCAPSULE) sipAPI_Enginio = reinterpret_cast<const sipAPIDef *>(PyCapsule_GetPointer(sip_capiobj, SIP_MODULE_NAME "._C_API")); #else sipAPI_Enginio = reinterpret_cast<const sipAPIDef *>(PyCObject_AsVoidPtr(sip_capiobj)); #endif #if defined(SIP_USE_PYCAPSULE) if (sipAPI_Enginio == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #endif /* Export the module and publish it's API. */ if (sipExportModule(&sipModuleAPI_Enginio,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,0) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } sip_Enginio_qt_metaobject = (sip_qt_metaobject_func)sipImportSymbol("qtcore_qt_metaobject"); sip_Enginio_qt_metacall = (sip_qt_metacall_func)sipImportSymbol("qtcore_qt_metacall"); sip_Enginio_qt_metacast = (sip_qt_metacast_func)sipImportSymbol("qtcore_qt_metacast"); if (!sip_Enginio_qt_metacast) Py_FatalError("Unable to import qtcore_qt_metacast"); /* Initialise the module now all its dependencies have been set up. */ if (sipInitModule(&sipModuleAPI_Enginio,sipModuleDict) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } /* Get the APIs of the modules that this one is dependent on. */ sipModuleAPI_Enginio_QtCore = sipModuleAPI_Enginio.em_imports[0].im_module; sipModuleAPI_Enginio_QtNetwork = sipModuleAPI_Enginio.em_imports[1].im_module; SIP_MODULE_RETURN(sipModule); }
PyMODINIT_FUNC PyInit_mod_http_head(void) { return PyModule_Create(&moduledef); }
PyMODINIT_FUNC PyInit_edit_distance(void) { return PyModule_Create(&module_def); }
PyMODINIT_FUNC PyInit__sqlite3(void) { PyObject *module, *dict; PyObject *tmp_obj; int i; module = PyModule_Create(&_sqlite3module); if (!module || (pysqlite_row_setup_types() < 0) || (pysqlite_cursor_setup_types() < 0) || (pysqlite_connection_setup_types() < 0) || (pysqlite_cache_setup_types() < 0) || (pysqlite_statement_setup_types() < 0) || (pysqlite_prepare_protocol_setup_types() < 0) ) { Py_XDECREF(module); return NULL; } Py_INCREF(&pysqlite_ConnectionType); PyModule_AddObject(module, "Connection", (PyObject*) &pysqlite_ConnectionType); Py_INCREF(&pysqlite_CursorType); PyModule_AddObject(module, "Cursor", (PyObject*) &pysqlite_CursorType); Py_INCREF(&pysqlite_CacheType); PyModule_AddObject(module, "Statement", (PyObject*)&pysqlite_StatementType); Py_INCREF(&pysqlite_StatementType); PyModule_AddObject(module, "Cache", (PyObject*) &pysqlite_CacheType); Py_INCREF(&pysqlite_PrepareProtocolType); PyModule_AddObject(module, "PrepareProtocol", (PyObject*) &pysqlite_PrepareProtocolType); Py_INCREF(&pysqlite_RowType); PyModule_AddObject(module, "Row", (PyObject*) &pysqlite_RowType); if (!(dict = PyModule_GetDict(module))) { goto error; } /*** Create DB-API Exception hierarchy */ if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Error", pysqlite_Error); if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Warning", pysqlite_Warning); /* Error subclasses */ if (!(pysqlite_InterfaceError = PyErr_NewException(MODULE_NAME ".InterfaceError", pysqlite_Error, NULL))) { goto error; } PyDict_SetItemString(dict, "InterfaceError", pysqlite_InterfaceError); if (!(pysqlite_DatabaseError = PyErr_NewException(MODULE_NAME ".DatabaseError", pysqlite_Error, NULL))) { goto error; } PyDict_SetItemString(dict, "DatabaseError", pysqlite_DatabaseError); /* pysqlite_DatabaseError subclasses */ if (!(pysqlite_InternalError = PyErr_NewException(MODULE_NAME ".InternalError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "InternalError", pysqlite_InternalError); if (!(pysqlite_OperationalError = PyErr_NewException(MODULE_NAME ".OperationalError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "OperationalError", pysqlite_OperationalError); if (!(pysqlite_ProgrammingError = PyErr_NewException(MODULE_NAME ".ProgrammingError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "ProgrammingError", pysqlite_ProgrammingError); if (!(pysqlite_IntegrityError = PyErr_NewException(MODULE_NAME ".IntegrityError", pysqlite_DatabaseError,NULL))) { goto error; } PyDict_SetItemString(dict, "IntegrityError", pysqlite_IntegrityError); if (!(pysqlite_DataError = PyErr_NewException(MODULE_NAME ".DataError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "DataError", pysqlite_DataError); if (!(pysqlite_NotSupportedError = PyErr_NewException(MODULE_NAME ".NotSupportedError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "NotSupportedError", pysqlite_NotSupportedError); /* In Python 2.x, setting Connection.text_factory to OptimizedUnicode caused Unicode objects to be returned for non-ASCII data and bytestrings to be returned for ASCII data. Now OptimizedUnicode is an alias for str, so it has no effect. */ Py_INCREF((PyObject*)&PyUnicode_Type); PyDict_SetItemString(dict, "OptimizedUnicode", (PyObject*)&PyUnicode_Type); /* Set integer constants */ for (i = 0; _int_constants[i].constant_name != 0; i++) { tmp_obj = PyLong_FromLong(_int_constants[i].constant_value); if (!tmp_obj) { goto error; } PyDict_SetItemString(dict, _int_constants[i].constant_name, tmp_obj); Py_DECREF(tmp_obj); } if (!(tmp_obj = PyUnicode_FromString(PYSQLITE_VERSION))) { goto error; } PyDict_SetItemString(dict, "version", tmp_obj); Py_DECREF(tmp_obj); if (!(tmp_obj = PyUnicode_FromString(sqlite3_libversion()))) { goto error; } PyDict_SetItemString(dict, "sqlite_version", tmp_obj); Py_DECREF(tmp_obj); /* initialize microprotocols layer */ pysqlite_microprotocols_init(dict); /* initialize the default converters */ converters_init(dict); _enable_callback_tracebacks = 0; pysqlite_BaseTypeAdapted = 0; /* Original comment from _bsddb.c in the Python core. This is also still * needed nowadays for Python 2.3/2.4. * * PyEval_InitThreads is called here due to a quirk in python 1.5 * - 2.2.1 (at least) according to Russell Williamson <*****@*****.**>: * The global interpreter lock is not initialized until the first * thread is created using thread.start_new_thread() or fork() is * called. that would cause the ALLOW_THREADS here to segfault due * to a null pointer reference if no threads or child processes * have been created. This works around that and is a no-op if * threads have already been initialized. * (see pybsddb-users mailing list post on 2002-08-07) */ #ifdef WITH_THREAD PyEval_InitThreads(); #endif error: if (PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, MODULE_NAME ": init failed"); Py_DECREF(module); module = NULL; } return module; }
PyMODINIT_FUNC initandroidembed(void) { return PyModule_Create(&androidembed); }
static PyObject* module_init(void) { PyObject *module, *ts_module, *capi; PyObject *copy_reg; if (init_strings() < 0) return NULL; #ifdef PY3K module = PyModule_Create(&moduledef); #else module = Py_InitModule3("cPersistence", cPersistence_methods, cPersistence_doc_string); #endif #ifdef PY3K ((PyObject*)&Pertype)->ob_type = &PyType_Type; #else Pertype.ob_type = &PyType_Type; #endif Pertype.tp_new = PyType_GenericNew; if (PyType_Ready(&Pertype) < 0) return NULL; if (PyModule_AddObject(module, "Persistent", (PyObject *)&Pertype) < 0) return NULL; cPersistenceCAPI = &truecPersistenceCAPI; #ifdef PY3K capi = PyCapsule_New(cPersistenceCAPI, CAPI_CAPSULE_NAME, NULL); #else capi = PyCObject_FromVoidPtr(cPersistenceCAPI, NULL); #endif if (!capi) return NULL; if (PyModule_AddObject(module, "CAPI", capi) < 0) return NULL; if (PyModule_AddIntConstant(module, "GHOST", cPersistent_GHOST_STATE) < 0) return NULL; if (PyModule_AddIntConstant(module, "UPTODATE", cPersistent_UPTODATE_STATE) < 0) return NULL; if (PyModule_AddIntConstant(module, "CHANGED", cPersistent_CHANGED_STATE) < 0) return NULL; if (PyModule_AddIntConstant(module, "STICKY", cPersistent_STICKY_STATE) < 0) return NULL; py_simple_new = PyObject_GetAttrString(module, "simple_new"); if (!py_simple_new) return NULL; #ifdef PY3K copy_reg = PyImport_ImportModule("copyreg"); #else copy_reg = PyImport_ImportModule("copy_reg"); #endif if (!copy_reg) return NULL; copy_reg_slotnames = PyObject_GetAttrString(copy_reg, "_slotnames"); if (!copy_reg_slotnames) { Py_DECREF(copy_reg); return NULL; } __newobj__ = PyObject_GetAttrString(copy_reg, "__newobj__"); if (!__newobj__) { Py_DECREF(copy_reg); return NULL; } if (!TimeStamp) { ts_module = PyImport_ImportModule("persistent.timestamp"); if (!ts_module) return NULL; TimeStamp = PyObject_GetAttrString(ts_module, "TimeStamp"); Py_DECREF(ts_module); /* fall through to immediate return on error */ } return module; }
PyMODINIT_FUNC PyInit_gil(void) { return PyModule_Create(&gil_module); }
PyMODINIT_FUNC PyInit__lpc(void) { import_array(); return PyModule_Create(&cModPyLPC); }
PyMODINIT_FUNC SIP_MODULE_ENTRY() #endif { static PyMethodDef sip_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static PyModuleDef sip_module_def = { PyModuleDef_HEAD_INIT, "MyMath", NULL, -1, sip_methods, NULL, NULL, NULL, NULL }; #endif PyObject *sipModule, *sipModuleDict; PyObject *sip_sipmod, *sip_capiobj; /* Initialise the module and get it's dictionary. */ #if PY_MAJOR_VERSION >= 3 sipModule = PyModule_Create(&sip_module_def); #elif PY_VERSION_HEX >= 0x02050000 sipModule = Py_InitModule(sipName_MyMath, sip_methods); #else sipModule = Py_InitModule(const_cast<char *>(sipName_MyMath), sip_methods); #endif if (sipModule == NULL) SIP_MODULE_RETURN(NULL); sipModuleDict = PyModule_GetDict(sipModule); /* Get the SIP module's API. */ #if PY_VERSION_HEX >= 0x02050000 sip_sipmod = PyImport_ImportModule(SIP_MODULE_NAME); #else sip_sipmod = PyImport_ImportModule(const_cast<char *>(SIP_MODULE_NAME)); #endif if (sip_sipmod == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } sip_capiobj = PyDict_GetItemString(PyModule_GetDict(sip_sipmod), "_C_API"); Py_DECREF(sip_sipmod); #if defined(SIP_USE_PYCAPSULE) if (sip_capiobj == NULL || !PyCapsule_CheckExact(sip_capiobj)) #else if (sip_capiobj == NULL || !PyCObject_Check(sip_capiobj)) #endif { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #if defined(SIP_USE_PYCAPSULE) sipAPI_MyMath = reinterpret_cast<const sipAPIDef *>(PyCapsule_GetPointer(sip_capiobj, SIP_MODULE_NAME "._C_API")); #else sipAPI_MyMath = reinterpret_cast<const sipAPIDef *>(PyCObject_AsVoidPtr(sip_capiobj)); #endif #if defined(SIP_USE_PYCAPSULE) if (sipAPI_MyMath == NULL) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(NULL); } #endif /* Export the module and publish it's API. */ if (sipExportModule(&sipModuleAPI_MyMath,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,0) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } /* Initialise the module now all its dependencies have been set up. */ if (sipInitModule(&sipModuleAPI_MyMath,sipModuleDict) < 0) { SIP_MODULE_DISCARD(sipModule); SIP_MODULE_RETURN(0); } SIP_MODULE_RETURN(sipModule); }
////////////////////////////////////// // // Python Interpreter initializes the module by // calling the routine given below // // PyMODINIT_FUNC PyInit_ArrayExt(void) { return PyModule_Create(&PyExtModule); }
static PyObject* PyInit_emb(void) { return PyModule_Create(&StateModule); }
PyMODINIT_FUNC *PyInit_dotted(void) { return PyModule_Create(&moduledef); }
void weechat_python_init_module_weechat () #endif /* PY_MAJOR_VERSION >= 3 */ { PyObject *weechat_module, *weechat_dict; #if PY_MAJOR_VERSION >= 3 /* python >= 3.x */ weechat_module = PyModule_Create (&moduleDef); #else /* python <= 2.x */ weechat_module = Py_InitModule ("weechat", weechat_python_funcs); #endif /* PY_MAJOR_VERSION >= 3 */ if (!weechat_module) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to initialize WeeChat " "module"), weechat_prefix ("error"), PYTHON_PLUGIN_NAME); #if PY_MAJOR_VERSION >= 3 return NULL; #else return; #endif /* PY_MAJOR_VERSION >= 3 */ } /* define some constants */ weechat_dict = PyModule_GetDict(weechat_module); PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK", PyLong_FromLong((long) WEECHAT_RC_OK)); PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_EAT", PyLong_FromLong((long) WEECHAT_RC_OK_EAT)); PyDict_SetItemString(weechat_dict, "WEECHAT_RC_ERROR", PyLong_FromLong((long) WEECHAT_RC_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_OK", PyLong_FromLong((long) WEECHAT_CONFIG_READ_OK)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_MEMORY_ERROR", PyLong_FromLong((long) WEECHAT_CONFIG_READ_MEMORY_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_FILE_NOT_FOUND", PyLong_FromLong((long) WEECHAT_CONFIG_READ_FILE_NOT_FOUND)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_WRITE_OK", PyLong_FromLong((long) WEECHAT_CONFIG_WRITE_OK)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_WRITE_ERROR", PyLong_FromLong((long) WEECHAT_CONFIG_WRITE_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_WRITE_MEMORY_ERROR", PyLong_FromLong((long) WEECHAT_CONFIG_WRITE_MEMORY_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_ERROR", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_SET_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_RESET)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED)); PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_ERROR", PyLong_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_SORT", PyUnicode_FromString(WEECHAT_LIST_POS_SORT)); PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_BEGINNING", PyUnicode_FromString(WEECHAT_LIST_POS_BEGINNING)); PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_END", PyUnicode_FromString(WEECHAT_LIST_POS_END)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_LOW", PyUnicode_FromString(WEECHAT_HOTLIST_LOW)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_MESSAGE", PyUnicode_FromString(WEECHAT_HOTLIST_MESSAGE)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_PRIVATE", PyUnicode_FromString(WEECHAT_HOTLIST_PRIVATE)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_HIGHLIGHT", PyUnicode_FromString(WEECHAT_HOTLIST_HIGHLIGHT)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_PROCESS_RUNNING", PyLong_FromLong((long) WEECHAT_HOOK_PROCESS_RUNNING)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_PROCESS_ERROR", PyLong_FromLong((long) WEECHAT_HOOK_PROCESS_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_OK", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_OK)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_PROXY_ERROR", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_PROXY_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_MEMORY_ERROR", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_MEMORY_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_TIMEOUT", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_TIMEOUT)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_SOCKET_ERROR", PyLong_FromLong((long) WEECHAT_HOOK_CONNECT_SOCKET_ERROR)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_STRING", PyUnicode_FromString(WEECHAT_HOOK_SIGNAL_STRING)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_INT", PyUnicode_FromString(WEECHAT_HOOK_SIGNAL_INT)); PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_POINTER", PyUnicode_FromString(WEECHAT_HOOK_SIGNAL_POINTER)); #if PY_MAJOR_VERSION >= 3 return weechat_module; #endif /* PY_MAJOR_VERSION >= 3 */ }
PyMODINIT_FUNC PyInit_red(void) { return PyModule_Create(&module); }
int weechat_python_load (const char *filename) { char *argv[] = { "__weechat_plugin__" , NULL }; #if PY_MAJOR_VERSION >= 3 wchar_t *wargv[] = { NULL, NULL }; #endif /* PY_MAJOR_VERSION >= 3 */ FILE *fp; PyObject *weechat_outputs, *python_path, *path; const char *weechat_home; char *str_home; int len; if ((fp = fopen (filename, "r")) == NULL) { weechat_printf (NULL, weechat_gettext ("%s%s: script \"%s\" not found"), weechat_prefix ("error"), PYTHON_PLUGIN_NAME, filename); return 0; } if ((weechat_python_plugin->debug >= 2) || !python_quiet) { weechat_printf (NULL, weechat_gettext ("%s: loading script \"%s\""), PYTHON_PLUGIN_NAME, filename); } python_current_script = NULL; python_registered_script = NULL; /* PyEval_AcquireLock (); */ python_current_interpreter = Py_NewInterpreter (); #if PY_MAJOR_VERSION >= 3 /* python >= 3.x */ len = mbstowcs (NULL, argv[0], 0) + 1; wargv[0] = malloc ((len + 1) * sizeof (wargv[0][0])); if (wargv[0]) { if (mbstowcs (wargv[0], argv[0], len) == (size_t)(-1)) { free (wargv[0]); wargv[0] = NULL; } PySys_SetArgv(1, wargv); if (wargv[0]) free (wargv[0]); } #else /* python <= 2.x */ PySys_SetArgv(1, argv); #endif /* PY_MAJOR_VERSION >= 3 */ if (!python_current_interpreter) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to create new " "sub-interpreter"), weechat_prefix ("error"), PYTHON_PLUGIN_NAME); fclose (fp); /* PyEval_ReleaseLock (); */ return 0; } PyThreadState_Swap (python_current_interpreter); /* adding $weechat_dir/python in $PYTHONPATH */ python_path = PySys_GetObject ("path"); weechat_home = weechat_info_get ("weechat_dir", ""); if (weechat_home) { len = strlen (weechat_home) + 1 + strlen (PYTHON_PLUGIN_NAME) + 1; str_home = malloc (len); if (str_home) { snprintf (str_home, len, "%s/python", weechat_home); #if PY_MAJOR_VERSION >= 3 /* python >= 3.x */ path = PyUnicode_FromString(str_home); #else /* python <= 2.x */ path = PyBytes_FromString (str_home); #endif /* PY_MAJOR_VERSION >= 3 */ if (path != NULL) { PyList_Insert (python_path, 0, path); Py_DECREF (path); } free (str_home); } } #if PY_MAJOR_VERSION >= 3 /* python >= 3.x */ weechat_outputs = PyModule_Create (&moduleDefOutputs); #else /* python <= 2.x */ weechat_outputs = Py_InitModule("weechatOutputs", weechat_python_output_funcs); #endif /* PY_MAJOR_VERSION >= 3 */ if (!weechat_outputs) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to redirect stdout and " "stderr"), weechat_prefix ("error"), PYTHON_PLUGIN_NAME); } else { if (PySys_SetObject("stdout", weechat_outputs) == -1) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to redirect stdout"), weechat_prefix ("error"), PYTHON_PLUGIN_NAME); } if (PySys_SetObject("stderr", weechat_outputs) == -1) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to redirect stderr"), weechat_prefix ("error"), PYTHON_PLUGIN_NAME); } } python_current_script_filename = filename; if (PyRun_SimpleFile (fp, filename) != 0) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to parse file \"%s\""), weechat_prefix ("error"), PYTHON_PLUGIN_NAME, filename); fclose (fp); if (PyErr_Occurred ()) PyErr_Print (); /* if script was registered, remove it from list */ if (python_current_script) { plugin_script_remove (weechat_python_plugin, &python_scripts, &last_python_script, python_current_script); python_current_script = NULL; } Py_EndInterpreter (python_current_interpreter); /* PyEval_ReleaseLock (); */ return 0; } if (PyErr_Occurred ()) PyErr_Print (); fclose (fp); if (!python_registered_script) { weechat_printf (NULL, weechat_gettext ("%s%s: function \"register\" not " "found (or failed) in file \"%s\""), weechat_prefix ("error"), PYTHON_PLUGIN_NAME, filename); if (PyErr_Occurred ()) PyErr_Print (); Py_EndInterpreter (python_current_interpreter); /* PyEval_ReleaseLock (); */ return 0; } python_current_script = python_registered_script; /* PyEval_ReleaseThread (python_current_script->interpreter); */ /* * set input/close callbacks for buffers created by this script * (to restore callbacks after upgrade) */ plugin_script_set_buffer_callbacks (weechat_python_plugin, python_scripts, python_current_script, &weechat_python_api_buffer_input_data_cb, &weechat_python_api_buffer_close_cb); (void) weechat_hook_signal_send ("python_script_loaded", WEECHAT_HOOK_SIGNAL_STRING, python_current_script->filename); return 1; }
PyMODINIT_FUNC PyInit_extension() { return PyModule_Create(&extensionmodule); }
PyMODINIT_FUNC PyInit__bisect(void) { return PyModule_Create(&_bisectmodule); }
PyMODINIT_FUNC PyInit_lua(void) { PyObject *m; #if PY_MAJOR_VERSION >= 3 if (PyType_Ready(&LuaObject_Type) < 0) return NULL; m = PyModule_Create(&lua_module); if (m == NULL) return NULL; #else if (PyType_Ready(&LuaObject_Type) < 0) return; m = Py_InitModule3("lua", lua_methods, "Lunatic-Python Python-Lua bridge"); if (m == NULL) return; #endif Py_INCREF(&LuaObject_Type); if (!LuaState) { #if defined(WIN32) FILE* file; char filename[_MAX_PATH]; char* slashptr; GetModuleFileName(GetModuleHandle("lua.pyd"), filename, _MAX_PATH); slashptr = strrchr(filename, '\\'); if (slashptr) { slashptr++; strcpy(slashptr, "lua.link"); file = fopen(filename, "r"); if (file) { char buffer[ MAX_PATH ]; if (fgets(buffer, sizeof(buffer), file) != NULL) { char *ptr = buffer + strlen(buffer) - 1; size_t len; while (ptr != buffer && (*ptr == '\n' || *ptr == '\r')) *ptr-- = 0; ++ptr; if (*ptr != '/' || *ptr != '\\') { *ptr++ = '/'; *ptr = 0; } if (buffer[0] == '/' || (buffer[1] && buffer[1] == ':')) strcpy(filename, buffer); else strcpy(slashptr, buffer); len = strlen(filename); #ifdef _DEBUG strcpy(filename + len, "lua51_debug.dll"); #else strcpy(filename + len, "lua51.dll"); #endif LoadLibrary(filename); } fclose(file); } } #endif /* WIN32 */ LuaState = luaL_newstate(); luaL_openlibs(LuaState); luaopen_python(LuaState); lua_settop(LuaState, 0); } #if PY_MAJOR_VERSION >= 3 return m; #endif }
BeamPy_Methods /* Structure containing all BEAM/Python API functions */ }; /** * Called by the Python interpreter once immediately after the shared lib _${libName}.pyk has been loaded. */ PyMODINIT_FUNC PyInit__${libName}() { PyObject* beampy_module; fprintf(stdout, "${libName}: enter PyInit__${libName}()\n"); ///////////////////////////////////////////////////////////////////////// // Create BeamPy_Module beampy_module = PyModule_Create(&BeamPy_Module); if (beampy_module == NULL) { return NULL; } ///////////////////////////////////////////////////////////////////////// // Register CArray_Type / CArray_module // In some forum I (nf) found one should use: CArray_type.tp_new = PyType_GenericNew; if (PyType_Ready(&CArray_Type) < 0) { return NULL; } Py_INCREF(&CArray_Type); PyModule_AddObject(beampy_module, "CArray", (PyObject*) &CArray_Type);
PyMODINIT_FUNC PyInit_atfork(void) { return PyModule_Create(&atfork_module); }
PyMODINIT_FUNC PyInit_amateurradio(void) { PyObject* m; /* full_sockaddr_ax25_type.tp_new = PyType_GenericNew; */ if (PyType_Ready(&full_sockaddr_ax25_type) < 0) return NULL; /* */ if (PyType_Ready(&ax25_address_type) < 0) return NULL; m = PyModule_Create(&amateurradio_module); if (m == NULL) return NULL; Py_INCREF(&full_sockaddr_ax25_type); PyModule_AddObject(m, "full_sockaddr_ax25", (PyObject *)&full_sockaddr_ax25_type); Py_INCREF(&ax25_address_type); PyModule_AddObject(m, "ax25_address", (PyObject *)&ax25_address_type); PyModule_AddObject(m, "SOL_AX25", PyLong_FromLong(SOL_AX25)); PyModule_AddObject(m, "AF_AX25", PyLong_FromLong(AF_AX25)); PyModule_AddObject(m, "PF_AX25", PyLong_FromLong(PF_AX25)); PyModule_AddObject(m, "AX25_WINDOW", PyLong_FromLong(AX25_WINDOW)); PyModule_AddObject(m, "AX25_T1", PyLong_FromLong(AX25_T1)); PyModule_AddObject(m, "AX25_T2", PyLong_FromLong(AX25_T2)); PyModule_AddObject(m, "AX25_T3", PyLong_FromLong(AX25_T3)); PyModule_AddObject(m, "AX25_N2", PyLong_FromLong(AX25_N2)); PyModule_AddObject(m, "AX25_BACKOFF", PyLong_FromLong(AX25_BACKOFF)); PyModule_AddObject(m, "AX25_EXTSEQ", PyLong_FromLong(AX25_EXTSEQ)); PyModule_AddObject(m, "AX25_PIDINCL", PyLong_FromLong(AX25_PIDINCL)); PyModule_AddObject(m, "AX25_IDLE", PyLong_FromLong(AX25_IDLE)); PyModule_AddObject(m, "AX25_PACLEN", PyLong_FromLong(AX25_PACLEN)); PyModule_AddObject(m, "AX25_IPMAXQUEUE", PyLong_FromLong(AX25_IPMAXQUEUE)); PyModule_AddObject(m, "AX25_IAMDIGI", PyLong_FromLong(AX25_IAMDIGI)); PyModule_AddObject(m, "AX25_KILL", PyLong_FromLong(AX25_KILL)); PyModule_AddObject(m, "SIOCAX25GETUID", PyLong_FromLong(SIOCAX25GETUID)); PyModule_AddObject(m, "SIOCAX25ADDUID", PyLong_FromLong(SIOCAX25ADDUID)); PyModule_AddObject(m, "SIOCAX25DELUID", PyLong_FromLong(SIOCAX25DELUID)); PyModule_AddObject(m, "SIOCAX25NOUID", PyLong_FromLong(SIOCAX25NOUID)); PyModule_AddObject(m, "SIOCAX25BPQADDR", PyLong_FromLong(SIOCAX25BPQADDR)); PyModule_AddObject(m, "SIOCAX25GETPARMS", PyLong_FromLong(SIOCAX25GETPARMS)); PyModule_AddObject(m, "SIOCAX25SETPARMS", PyLong_FromLong(SIOCAX25SETPARMS)); PyModule_AddObject(m, "SIOCAX25OPTRT", PyLong_FromLong(SIOCAX25OPTRT)); PyModule_AddObject(m, "SIOCAX25CTLCON", PyLong_FromLong(SIOCAX25CTLCON)); PyModule_AddObject(m, "SIOCAX25GETINFO", PyLong_FromLong(SIOCAX25GETINFO)); PyModule_AddObject(m, "SIOCAX25ADDFWD", PyLong_FromLong(SIOCAX25ADDFWD)); PyModule_AddObject(m, "SIOCAX25DELFWD", PyLong_FromLong(SIOCAX25DELFWD)); PyModule_AddObject(m, "AX25_NOUID_DEFAULT", PyLong_FromLong(AX25_NOUID_DEFAULT)); PyModule_AddObject(m, "AX25_NOUID_BLOCK", PyLong_FromLong(AX25_NOUID_BLOCK)); PyModule_AddObject(m, "AX25_SET_RT_IPMODE", PyLong_FromLong(AX25_SET_RT_IPMODE)); PyModule_AddObject(m, "AX25_DIGI_INBAND", PyLong_FromLong(AX25_DIGI_INBAND)); PyModule_AddObject(m, "AX25_DIGI_XBAND", PyLong_FromLong(AX25_DIGI_XBAND)); PyModule_AddObject(m, "AX25_MAX_DIGIS", PyLong_FromLong(AX25_MAX_DIGIS)); PyModule_AddObject(m, "AX25_VALUES_IPDEFMODE", PyLong_FromLong(AX25_VALUES_IPDEFMODE)); PyModule_AddObject(m, "AX25_VALUES_AXDEFMODE", PyLong_FromLong(AX25_VALUES_AXDEFMODE)); PyModule_AddObject(m, "AX25_VALUES_NETROM", PyLong_FromLong(AX25_VALUES_NETROM)); PyModule_AddObject(m, "AX25_VALUES_TEXT", PyLong_FromLong(AX25_VALUES_TEXT)); PyModule_AddObject(m, "AX25_VALUES_BACKOFF", PyLong_FromLong(AX25_VALUES_BACKOFF)); PyModule_AddObject(m, "AX25_VALUES_CONMODE", PyLong_FromLong(AX25_VALUES_CONMODE)); PyModule_AddObject(m, "AX25_VALUES_WINDOW", PyLong_FromLong(AX25_VALUES_WINDOW)); PyModule_AddObject(m, "AX25_VALUES_EWINDOW", PyLong_FromLong(AX25_VALUES_EWINDOW)); PyModule_AddObject(m, "AX25_VALUES_T1", PyLong_FromLong(AX25_VALUES_T1)); PyModule_AddObject(m, "AX25_VALUES_T2", PyLong_FromLong(AX25_VALUES_T2)); PyModule_AddObject(m, "AX25_VALUES_T3", PyLong_FromLong(AX25_VALUES_T3)); PyModule_AddObject(m, "AX25_VALUES_N2", PyLong_FromLong(AX25_VALUES_N2)); PyModule_AddObject(m, "AX25_VALUES_DIGI", PyLong_FromLong(AX25_VALUES_DIGI)); PyModule_AddObject(m, "AX25_VALUES_IDLE", PyLong_FromLong(AX25_VALUES_IDLE)); PyModule_AddObject(m, "AX25_VALUES_PACLEN", PyLong_FromLong(AX25_VALUES_PACLEN)); PyModule_AddObject(m, "AX25_VALUES_IPMAXQUEUE", PyLong_FromLong(AX25_VALUES_IPMAXQUEUE)); PyModule_AddObject(m, "AX25_MAX_VALUES", PyLong_FromLong(AX25_MAX_VALUES)); return m; }