Debian Codegraph @

pysobug/mypymod.c

raw symbols SCIP
1 #include <Python.h>
2
3
4 PyObject* id(PyObject* self, PyObject* args);
5
6
7 static PyMethodDef functions[] =
8 {
9 {"id", id, METH_VARARGS, "id()"},
10 {NULL, NULL, 0, NULL} /*Sentinel*/
11 };
12
13
14 static struct PyModuleDef module_def =
15 {
16 PyModuleDef_HEAD_INIT,
17 "mypymod", /* Name */
18 "My Python Module", /* Module documentation */
19 -1, /* Size of per-interpreter state */
20 functions,
21 NULL, // m_reload
22 NULL, // m_traverse
23 NULL, // m_clear
24 NULL // m_free
25 };
26
27
28 PyMODINIT_FUNC PyInit_mypymod(void)
29 {
30 PyObject* module = NULL;
31
32 printf("PyInit_mypymod: enter\n");
33
34 module = PyModule_Create(&module_def);
35 if (module == NULL) {
36 return NULL;
37 }
38
39 printf("PyInit_mypymod: exit: module=%p\n", module);
40
41 return module;
42 }
43
44
45 PyObject* id(PyObject* self, PyObject* args)
46 {
47 static int idval = 0;
48 idval++;
49 return Py_BuildValue("i", idval);
50 }
51
52