diff options
Diffstat (limited to 'contrib/python/jsonglib.override')
-rw-r--r-- | contrib/python/jsonglib.override | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/contrib/python/jsonglib.override b/contrib/python/jsonglib.override new file mode 100644 index 0000000..121ea5a --- /dev/null +++ b/contrib/python/jsonglib.override @@ -0,0 +1,56 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +headers +#include <Python.h> +#include <stdio.h> + +#define NO_IMPORT_PYGOBJECT +#include "pygobject.h" + +#include <json-glib/json-glib.h> +#include <json-glib/json-gobject.h> + +static PyObject * +_helper_wrap_pointer_gslist (GType type, GSList *list) +{ + GSList *tmp; + PyObject *py_list; + + if ((py_list = PyList_New(0)) == NULL) { + return NULL; + } + for (tmp = list; tmp != NULL; tmp = tmp->next) { + PyObject *obj = pyg_pointer_new (type, tmp->data); + PyList_Append(py_list, obj); + Py_DECREF(obj); + } + return py_list; +} + +static PyObject * +_helper_wrap_string_gslist (GSList *list) +{ + GSList *tmp; + PyObject *py_list; + + if ((py_list = PyList_New(0)) == NULL) { + return NULL; + } + for (tmp = list; tmp != NULL; tmp = tmp->next) { + PyObject *str_obj = PyString_FromString ((char*)tmp->data); + + if (str_obj == NULL) { + Py_DECREF(py_list); + return NULL; + } + PyList_Append(py_list, str_obj); + Py_DECREF(str_obj); + } + return py_list; +} +%% +modulename json_glib +%% +import gobject.GObject as PyGObject_Type + + |