/Tools/modulator/Templates/module_tail

http://unladen-swallow.googlecode.com/ · #! · 37 lines · 26 code · 11 blank · 0 comment · 0 complexity · 6035d090ebce62f492ea2d5e939659ff MD5 · raw file

  1. /* List of methods defined in the module */
  2. static struct PyMethodDef $abbrev$_methods[] = {
  3. $methodlist$
  4. {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
  5. };
  6. /* Initialization function for the module (*must* be called init$name$) */
  7. static char $name$_module_documentation[] =
  8. ""
  9. ;
  10. void
  11. init$name$()
  12. {
  13. PyObject *m, *d;
  14. /* Create the module and add the functions */
  15. m = Py_InitModule4("$name$", $abbrev$_methods,
  16. $name$_module_documentation,
  17. (PyObject*)NULL,PYTHON_API_VERSION);
  18. /* Add some symbolic constants to the module */
  19. d = PyModule_GetDict(m);
  20. ErrorObject = PyString_FromString("$name$.error");
  21. PyDict_SetItemString(d, "error", ErrorObject);
  22. /* XXXX Add constants here */
  23. /* Check for errors */
  24. if (PyErr_Occurred())
  25. Py_FatalError("can't initialize module $name$");
  26. }