PyObject* init_pyejdb(void) { PyObject *pyejdb; if (PyType_Ready(&EJDBType) || PyType_Ready(&DBCursorType) ) { return NULL; } pyejdb = PyModule_Create(&pyejdb_module); if (!pyejdb) { return NULL; } Error = PyErr_NewException("_pyejdb.Error", NULL, NULL); Py_XINCREF(Error); if (!Error || PyModule_AddObject(pyejdb, "Error", Error)) { Py_XDECREF(Error); goto fail; } /* adding types and constants */ if ( PyModule_AddType(pyejdb, "EJDB", &EJDBType) || PyModule_AddType(pyejdb, "DBCursor", &DBCursorType) || PyModule_AddIntMacro(pyejdb, JBOREADER) || PyModule_AddIntMacro(pyejdb, JBOWRITER) || PyModule_AddIntMacro(pyejdb, JBOCREAT) || PyModule_AddIntMacro(pyejdb, JBOTRUNC) || PyModule_AddIntMacro(pyejdb, JBONOLCK) || PyModule_AddIntMacro(pyejdb, JBOLCKNB) || PyModule_AddIntMacro(pyejdb, JBOTSYNC) || PyModule_AddIntMacro(pyejdb, JBIDXDROP) || PyModule_AddIntMacro(pyejdb, JBIDXDROPALL) || PyModule_AddIntMacro(pyejdb, JBIDXOP) || PyModule_AddIntMacro(pyejdb, JBIDXREBLD) || PyModule_AddIntMacro(pyejdb, JBIDXNUM) || PyModule_AddIntMacro(pyejdb, JBIDXSTR) || PyModule_AddIntMacro(pyejdb, JBIDXARR) || PyModule_AddIntMacro(pyejdb, JBIDXISTR) || PyModule_AddIntMacro(pyejdb, PYEJDBTXBEGIN) || PyModule_AddIntMacro(pyejdb, PYEJDBTXABORT) || PyModule_AddIntMacro(pyejdb, PYEJDBTXCOMMIT) || PyModule_AddIntMacro(pyejdb, PYEJDBTXSTATUS) || PyModule_AddIntMacro(pyejdb, JBQRYCOUNT) ) { goto fail; } return pyejdb; fail: Py_DECREF(pyejdb); return NULL; }
/* Add a watcher to a module */ int PyModule_AddWatcher(PyObject *module, const char *name, PyTypeObject *type, PyTypeObject *base) { if (base) { type->tp_base = base; } else { type->tp_base = &WatcherType; } return PyModule_AddType(module, name, type); }
PyMODINIT_FUNC init_pyejdb(void) { PyObject *pyejdb; if (PyType_Ready(&EJDBType) || PyType_Ready(&DBCursorType) ) { INITERROR; } #if PY_MAJOR_VERSION >= 3 pyejdb = PyModule_Create(&pyejdb_module); #else pyejdb = Py_InitModule("_pyejdb", pyejdb_m_methods); #endif if (!pyejdb) { INITERROR; } Error = PyErr_NewException("_pyejdb.Error", NULL, NULL); Py_XINCREF(Error); if (!Error || PyModule_AddObject(pyejdb, "Error", Error)) { Py_XDECREF(Error); goto fail; } /* adding types and constants */ if ( PyModule_AddType(pyejdb, "EJDB", &EJDBType) || PyModule_AddType(pyejdb, "DBCursor", &DBCursorType) || PyModule_AddIntMacro(pyejdb, JBOREADER) || PyModule_AddIntMacro(pyejdb, JBOWRITER) || PyModule_AddIntMacro(pyejdb, JBOCREAT) || PyModule_AddIntMacro(pyejdb, JBOTRUNC) || PyModule_AddIntMacro(pyejdb, JBONOLCK) || PyModule_AddIntMacro(pyejdb, JBOLCKNB) || PyModule_AddIntMacro(pyejdb, JBOTSYNC) || PyModule_AddIntMacro(pyejdb, JBIDXDROP) || PyModule_AddIntMacro(pyejdb, JBIDXDROPALL) || PyModule_AddIntMacro(pyejdb, JBIDXOP) || PyModule_AddIntMacro(pyejdb, JBIDXREBLD) || PyModule_AddIntMacro(pyejdb, JBIDXNUM) || PyModule_AddIntMacro(pyejdb, JBIDXSTR) || PyModule_AddIntMacro(pyejdb, JBIDXARR) || PyModule_AddIntMacro(pyejdb, JBIDXISTR) || PyModule_AddIntMacro(pyejdb, PYEJDBTXBEGIN) || PyModule_AddIntMacro(pyejdb, PYEJDBTXABORT) || PyModule_AddIntMacro(pyejdb, PYEJDBTXCOMMIT) || PyModule_AddIntMacro(pyejdb, PYEJDBTXSTATUS) || PyModule_AddIntMacro(pyejdb, JBQRYCOUNT) ) { goto fail; } #if PY_MAJOR_VERSION >= 3 return pyejdb; #else return; #endif fail: Py_DECREF(pyejdb); INITERROR; }
/* pyev_module initialization */ PyObject * init_pyev(void) { PyObject *pyev; #ifdef MS_WINDOWS if (pyev_setmaxstdio() || pyev_import_socket()) { return NULL; } #endif /* fill in deferred data addresses */ WatcherType.tp_new = PyType_GenericNew; #if EV_PERIODIC_ENABLE PeriodicBaseType.tp_base = &WatcherType; #endif #if EV_STAT_ENABLE /* init StatdataType */ if (!StatdataType_initialized) { PyStructSequence_InitType(&StatdataType, &Statdata_desc); StatdataType_initialized = 1; } #endif /* pyev */ #if PY_MAJOR_VERSION >= 3 pyev = PyModule_Create(&pyev_module); #else pyev = Py_InitModule3("pyev", pyev_m_methods, pyev_m_doc); #endif if (!pyev) { return NULL; } /* pyev.Error */ Error = PyErr_NewException("pyev.Error", NULL, NULL); if (!Error || PyModule_AddObject(pyev, "Error", Error)) { Py_XDECREF(Error); goto fail; } /* adding types and constants */ if ( /* Loop */ PyModule_AddType(pyev, "Loop", &LoopType) || PyModule_AddUnsignedIntMacro(pyev, EVFLAG_AUTO) || PyModule_AddUnsignedIntMacro(pyev, EVFLAG_NOENV) || PyModule_AddUnsignedIntMacro(pyev, EVFLAG_FORKCHECK) || PyModule_AddUnsignedIntMacro(pyev, EVFLAG_NOINOTIFY) || PyModule_AddUnsignedIntMacro(pyev, EVFLAG_SIGNALFD) || PyModule_AddUnsignedIntMacro(pyev, EVFLAG_NOSIGMASK) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_SELECT) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_POLL) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_EPOLL) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_KQUEUE) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_DEVPOLL) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_PORT) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_ALL) || PyModule_AddUnsignedIntMacro(pyev, EVBACKEND_MASK) || PyModule_AddIntMacro(pyev, EVRUN_NOWAIT) || PyModule_AddIntMacro(pyev, EVRUN_ONCE) || PyModule_AddIntMacro(pyev, EVBREAK_ONE) || PyModule_AddIntMacro(pyev, EVBREAK_ALL) || /* watchers */ PyType_Ready(&WatcherType) || PyModule_AddWatcher(pyev, "Io", &IoType, NULL) || PyModule_AddIntMacro(pyev, EV_IO) || PyModule_AddIntMacro(pyev, EV_READ) || PyModule_AddIntMacro(pyev, EV_WRITE) || PyModule_AddWatcher(pyev, "Timer", &TimerType, NULL) || PyModule_AddIntMacro(pyev, EV_TIMER) || #if EV_PERIODIC_ENABLE PyType_Ready(&PeriodicBaseType) || PyModule_AddWatcher(pyev, "Periodic", &PeriodicType, &PeriodicBaseType) || PyModule_AddIntMacro(pyev, EV_PERIODIC) || #if EV_PREPARE_ENABLE PyModule_AddWatcher(pyev, "Scheduler", &SchedulerType, &PeriodicBaseType) || #endif #endif #if EV_SIGNAL_ENABLE PyModule_AddWatcher(pyev, "Signal", &SignalType, NULL) || PyModule_AddIntMacro(pyev, EV_SIGNAL) || #endif #if EV_CHILD_ENABLE PyModule_AddWatcher(pyev, "Child", &ChildType, NULL) || PyModule_AddIntMacro(pyev, EV_CHILD) || #endif #if EV_STAT_ENABLE PyModule_AddWatcher(pyev, "Stat", &StatType, NULL) || PyModule_AddIntMacro(pyev, EV_STAT) || #endif #if EV_IDLE_ENABLE PyModule_AddWatcher(pyev, "Idle", &IdleType, NULL) || PyModule_AddIntMacro(pyev, EV_IDLE) || #endif #if EV_PREPARE_ENABLE PyModule_AddWatcher(pyev, "Prepare", &PrepareType, NULL) || PyModule_AddIntMacro(pyev, EV_PREPARE) || #endif #if EV_CHECK_ENABLE PyModule_AddWatcher(pyev, "Check", &CheckType, NULL) || PyModule_AddIntMacro(pyev, EV_CHECK) || #endif #if EV_EMBED_ENABLE PyModule_AddWatcher(pyev, "Embed", &EmbedType, NULL) || PyModule_AddIntMacro(pyev, EV_EMBED) || #endif #if EV_FORK_ENABLE PyModule_AddWatcher(pyev, "Fork", &ForkType, NULL) || PyModule_AddIntMacro(pyev, EV_FORK) || #endif #if EV_ASYNC_ENABLE PyModule_AddWatcher(pyev, "Async", &AsyncType, NULL) || PyModule_AddIntMacro(pyev, EV_ASYNC) || #endif /* additional events */ PyModule_AddIntMacro(pyev, EV_CUSTOM) || PyModule_AddIntMacro(pyev, EV_ERROR) || /* priorities */ PyModule_AddIntMacro(pyev, EV_MINPRI) || PyModule_AddIntMacro(pyev, EV_MAXPRI) ) { goto fail; } /* setup libev */ ev_set_allocator(pyev_allocator); ev_set_syserr_cb(pyev_syserr_cb); return pyev; fail: #if PY_MAJOR_VERSION >= 3 Py_DECREF(pyev); #endif return NULL; }
int _Expat_Handler_Init(PyObject *module) { if (PyModule_AddType(module, &Handler_Type) < 0) return -1; return 0; }