diff options
Diffstat (limited to 'plugins/pychrysa/helpers.c')
-rw-r--r-- | plugins/pychrysa/helpers.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/plugins/pychrysa/helpers.c b/plugins/pychrysa/helpers.c index df1df05..a0a828f 100644 --- a/plugins/pychrysa/helpers.c +++ b/plugins/pychrysa/helpers.c @@ -26,6 +26,7 @@ #include <assert.h> #include <pygobject.h> +#include <stdarg.h> @@ -256,8 +257,13 @@ bool PyDict_AddStringConstant(PyTypeObject *obj_type, const char *key, const cha * * ******************************************************************************/ -bool register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *type, PyTypeObject *base) +bool _register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *type, PyTypeObject *base, ...) { + Py_ssize_t size; /* Taille de liste actuelle */ + PyObject *static_bases; /* Base(s) de l'objet */ + va_list ap; /* Parcours des arguments */ + PyTypeObject *static_base; /* Base à rajouter à la liste */ + /** * pygobject_register_class() définit type->tp_base à partir des arguments fournis, * puis fait appel à PyType_Ready(). @@ -285,7 +291,32 @@ bool register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *typ type->tp_basicsize = base->tp_basicsize; } - pygobject_register_class(dict, NULL, gtype, type, Py_BuildValue("(O)", base)); + size = 1; + static_bases = PyTuple_New(size); + + Py_INCREF(base); + PyTuple_SetItem(static_bases, 0, (PyObject *)base); + + va_start(ap, base); + + while (1) + { + static_base = va_arg(ap, PyTypeObject *); + + if (static_base == NULL) break; + + _PyTuple_Resize(&static_bases, ++size); + + Py_INCREF(static_base); + PyTuple_SetItem(static_bases, size - 1, (PyObject *)static_base); + + } + + va_end(ap); + + pygobject_register_class(dict, NULL, gtype, type, static_bases); + + assert(PyErr_Occurred() == NULL); return true; |