diff options
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r-- | plugins/pychrysalide/helpers.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c index f811ad3..b2ecbec 100644 --- a/plugins/pychrysalide/helpers.c +++ b/plugins/pychrysalide/helpers.c @@ -977,6 +977,11 @@ bool register_class_for_dynamic_pygobject(GType gtype, PyTypeObject *type, PyTyp PyObject *modname; /* Nom du module du type */ PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire dudit module */ + Py_ssize_t i; /* Boucle de parcours */ + PyObject *mro_base; /* Base finale effective */ + GType itype; /* Type d'interface implémentée*/ + GQuark pyginterface_info_key; /* Clef d'accès non déclarée */ + const GInterfaceInfo *iinfo; /* Informations associées */ /** * Lors de l'appel à pygobject_register_class(), PyGObject remplace systématiquement @@ -1023,6 +1028,47 @@ bool register_class_for_dynamic_pygobject(GType gtype, PyTypeObject *type, PyTyp Py_TYPE(type) = legacy_parent; + /** + * Comme la mise en place dynamique de nouveau GType court-circuite les + * mécanismes internes de pygobject, les interfaces implémentées ne sont + * nominalement plus complétées. + * + * On reprend donc la logique copiée depuis le contenu de la fonction + * pyg_type_add_interfaces() du fichier "pygobject-3.22.0/gi/gobjectmodule.c". + */ + + for (i = 0; i < PyTuple_GET_SIZE(type->tp_mro); i++) + { + mro_base = PyTuple_GET_ITEM(type->tp_mro, i); + + if (!PyType_Check(mro_base)) + continue; + + itype = pyg_type_from_object(mro_base); + + if (itype == G_TYPE_INTERFACE) + continue; + + if (!G_TYPE_IS_INTERFACE(itype)) + continue; + + if (!g_type_is_a(gtype, itype)) + { + /** + * Reproduction de pyg_lookup_interface_info(). + */ + + pyginterface_info_key = g_quark_from_static_string("PyGInterface::info"); + + iinfo = g_type_get_qdata(itype, pyginterface_info_key); + assert(iinfo != NULL); + + g_type_add_interface_static(gtype, itype, iinfo); + + } + + } + return result; } |