Пример #1
0
/* initialization of the module */
PyMODINIT_FUNC initctemplate (void) {
    PyObject* m;
    if (PyType_Ready(&Template_Type) < 0) {
        return;
    }
    if (PyType_Ready(&Dictionary_Type) < 0) {
        return;
    }
    m = Py_InitModule3("ctemplate", ctemplate_methods,
                       "Wrapper for the ctemplate library.");
    if (m == NULL) {
        goto onError;
    }
    /* Register cleanup function */
    if (Py_AtExit(ctemplate_Cleanup) == -1)
        goto onError;

    Py_INCREF(&Template_Type);
    if (PyModule_AddObject(m, "Template",
                           (PyObject *)&Template_Type) == -1) {
        goto onError;
    }
    Py_INCREF(&Dictionary_Type);
    if (PyModule_AddObject(m, "Dictionary",
                           (PyObject *)&Dictionary_Type) == -1) {
        goto onError;
    }
    add_constants(m);
onError:
    if (PyErr_Occurred())
	Py_ReportModuleInitError("ctemplate");
}
Пример #2
0
void
initocfs2 (void)
{
  PyObject *m;

  if (PyType_Ready (&DInode_Type) < 0)
    return;

  if (PyType_Ready (&DirEntry_Type) < 0)
    return;

  if (PyType_Ready (&SuperBlock_Type) < 0)
    return;

  if (PyType_Ready (&DirScanIter_Type) < 0)
    return;

  Filesystem_Type.tp_new = PyType_GenericNew;
  if (PyType_Ready (&Filesystem_Type) < 0)
    return;

  initialize_ocfs_error_table ();

  m = Py_InitModule ("ocfs2", ocfs2_methods);

  ocfs2_error = PyErr_NewException ("ocfs2.error", PyExc_RuntimeError, NULL);

  if (ocfs2_error)
    {
      Py_INCREF (ocfs2_error);
      PyModule_AddObject (m, "error", ocfs2_error);
    }

  Py_INCREF (&DInode_Type);
  PyModule_AddObject (m, "DInode", (PyObject *) &DInode_Type);

  Py_INCREF (&DirEntry_Type);
  PyModule_AddObject (m, "DirEntry", (PyObject *) &DirEntry_Type);

  Py_INCREF (&SuperBlock_Type);
  PyModule_AddObject (m, "SuperBlock", (PyObject *) &SuperBlock_Type);

  Py_INCREF (&DirScanIter_Type);
  PyModule_AddObject (m, "DirScanIter", (PyObject *) &DirScanIter_Type);

  Py_INCREF (&Filesystem_Type);
  PyModule_AddObject (m, "Filesystem", (PyObject *) &Filesystem_Type);

  add_constants (m);

  if (PyErr_Occurred ())
    Py_FatalError ("can't initialize module ocfs2");
}
Пример #3
0
PyMODINIT_FUNC
initmidi (void)
{
    PyObject *m, *d;
    m = Py_InitModule ("midi", MidiMethods);
    d = PyModule_GetDict (m);

    Midi_error = PyString_FromString ("midi.error");
    PyDict_SetItemString (d, "error", Midi_error);
    add_constants (d);
    Midi_warning = PyString_FromString ("midi.warning");
    PyDict_SetItemString (d, "warning", Midi_warning);

    /*
      FIXME.
     */
    (void) midi_warning;
}
Пример #4
0
DL_EXPORT(void) initconst(void)
{
  PyObject* const_module = Py_InitModule("const", constMethods);

#ifdef _PYGSL_GSL_HAS_MKS
  PyObject* mks_module   = PyImport_AddModule("pygsl.const.mks");
#endif
#ifdef _PYGSL_GSL_HAS_CGS
  PyObject* cgs_module   = PyImport_AddModule("pygsl.const.cgs");
#endif

#ifdef _PYGSL_GSL_HAS_MKSA
  PyObject* mksa_module   = PyImport_AddModule("pygsl.const.mksa");
#endif
#ifdef _PYGSL_GSL_HAS_CGSM
  PyObject* cgsm_module   = PyImport_AddModule("pygsl.const.cgsm");
#endif

  PyObject* math_module  = PyImport_AddModule("pygsl.const.m");
  PyObject* num_module   = PyImport_AddModule("pygsl.const.num");

  /* distribute constants on modules */
  add_constants(m_array  , const_module);
  add_constants(num_array, const_module);

#ifdef _PYGSL_GSL_HAS_MKS
  add_constants(mks_array, const_module);
  add_constants(mks_array, mks_module);
#endif
#ifdef _PYGSL_GSL_HAS_CGS
  add_constants(cgs_array, cgs_module);
#endif

#ifdef _PYGSL_GSL_HAS_MKSA
  add_constants(mksa_array, const_module);
  add_constants(mksa_array, mksa_module);
#endif
#ifdef _PYGSL_GSL_HAS_CGSM
  add_constants(cgsm_array, cgsm_module);
#endif

  add_constants(num_array, num_module);
  add_constants(m_array  , math_module);

  PyModule_AddObject(const_module, "m",   math_module);
#ifdef _PYGSL_GSL_HAS_CGS
  PyModule_AddObject(const_module, "cgs", cgs_module);
#endif
#ifdef _PYGSL_GSL_HAS_MKS
  PyModule_AddObject(const_module, "mks", mks_module);
#endif
   
#ifdef _PYGSL_GSL_HAS_CGSM
  PyModule_AddObject(const_module, "cgsm", cgsm_module);
#endif
#ifdef _PYGSL_GSL_HAS_MKSA
  PyModule_AddObject(const_module, "mksa", mksa_module);
#endif

  PyModule_AddObject(const_module, "num", num_module);
  return;
}