summaryrefslogtreecommitdiff
path: root/contrib/python/jsonglib-module.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/python/jsonglib-module.c')
-rw-r--r--contrib/python/jsonglib-module.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/contrib/python/jsonglib-module.c b/contrib/python/jsonglib-module.c
new file mode 100644
index 0000000..81109a2
--- /dev/null
+++ b/contrib/python/jsonglib-module.c
@@ -0,0 +1,33 @@
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* include this first, before NO_IMPORT_PYGOBJECT is defined */
+#include <pygobject.h>
+
+/* include any extra headers needed here */
+#include <json-glib/json-glib.h>
+
+void pyjsonglib_register_classes(PyObject *d);
+void pyjsonglib_add_constants(PyObject *module, const gchar *strip_prefix);
+extern PyMethodDef pyjsonglib_functions[];
+
+DL_EXPORT(void)
+initjsonglib(void)
+{
+ PyObject *m, *d;
+
+ /* perform any initialisation required by the library here */
+ init_pygobject();
+
+ m = Py_InitModule("json_glib", pyjsonglib_functions);
+ d = PyModule_GetDict(m);
+
+ /* add anything else to the module dictionary (such as constants) */
+ pyjsonglib_register_classes(d);
+ pyjsonglib_add_constants(m, "JSON_");
+
+ if (PyErr_Occurred())
+ Py_FatalError("could not initialise module json_glib");
+}