BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*init_function)()) { #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, name, 0, /* m_doc */ -1, /* m_size */ initial_methods, 0, /* m_reload */ 0, /* m_traverse */ 0, /* m_clear */ 0, /* m_free */ }; PyObject* m = PyModule_Create(&moduledef); #else PyObject* m = Py_InitModule(const_cast<char*>(name), initial_methods); #endif if (m != 0) { // Create the current module scope object m_obj(((borrowed_reference_t*)m)); scope current_module(m_obj); handle_exception(init_function); } return m; }
static Dispatcher* handler_dispatcher_new(DsmeDbusHandler* handler, const char* interface, const char* name) { Dispatcher* dispatcher = g_new(Dispatcher, 1); dispatcher->can_dispatch = handler_dispatcher_can_dispatch; dispatcher->dispatch = handler_dispatcher_dispatch; dispatcher->target.handler = handler; // NOTE: we don't bother to strdup() dispatcher->interface = interface; dispatcher->name = name; dispatcher->module = current_module(); return dispatcher; }
static Dispatcher* method_dispatcher_new(DsmeDbusMethod* method, const char* interface, const char* name, const char* rules) { Dispatcher* dispatcher = g_new(Dispatcher, 1); dispatcher->can_dispatch = method_dispatcher_can_dispatch; dispatcher->dispatch = method_dispatcher_dispatch; dispatcher->target.method = method; // NOTE: we don't bother to strdup() dispatcher->interface = interface; dispatcher->name = name; dispatcher->rules = rules; dispatcher->module = current_module(); return dispatcher; }
BOOST_PYTHON_DECL void init_module(char const* name, void(*init_function)()) { PyObject* m = Py_InitModule(const_cast<char*>(name), initial_methods); if (m != 0) { // Create the current module scope scope current_module( (object( ((borrowed_reference_t*)m) )) ); handle_exception(init_function); } }