| 1 | #include <Python.h> |
| 2 | #include <py3cairo.h> |
| 3 | #include "cmodulelib.h" |
| 4 | |
| 5 | static PyMethodDef CModMethods[] = { |
| 6 | {"create_image_surface", create_image_surface, METH_NOARGS, NULL}, |
| 7 | {NULL, NULL, 0, NULL} |
| 8 | }; |
| 9 | |
| 10 | #ifdef __GNUC__ |
| 11 | #define PYCAIRO_MODINIT_FUNC __attribute__((visibility("default"))) PyMODINIT_FUNC |
| 12 | #else |
| 13 | #define PYCAIRO_MODINIT_FUNC PyMODINIT_FUNC |
| 14 | #endif |
| 15 | |
| 16 | static struct PyModuleDef cmod_module = { |
| 17 | PyModuleDef_HEAD_INIT, |
| 18 | "cmod", |
| 19 | NULL, |
| 20 | -1, |
| 21 | CModMethods, |
| 22 | }; |
| 23 | |
| 24 | PYCAIRO_MODINIT_FUNC |
| 25 | PyInit_cmod (void) |
| 26 | { |
| 27 | PyObject *m; |
| 28 | |
| 29 | if (import_cairo () < 0) |
| 30 | return NULL; |
| 31 | |
| 32 | m = PyModule_Create (&cmod_module); |
| 33 | if (m == NULL) |
| 34 | return NULL; |
| 35 | |
| 36 | return m; |
| 37 | } |