diff options
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r-- | plugins/pychrysalide/analysis/content.c | 5 | ||||
-rw-r--r-- | plugins/pychrysalide/analysis/loaded.c | 5 | ||||
-rw-r--r-- | plugins/pychrysalide/arch/feeder.c | 5 | ||||
-rw-r--r-- | plugins/pychrysalide/arch/targetableop.c | 5 | ||||
-rw-r--r-- | plugins/pychrysalide/glibext/linegen.c | 4 | ||||
-rw-r--r-- | plugins/pychrysalide/glibext/loadedpanel.c | 4 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/dockable.c | 5 | ||||
-rw-r--r-- | plugins/pychrysalide/helpers.c | 36 | ||||
-rw-r--r-- | plugins/pychrysalide/helpers.h | 3 |
9 files changed, 65 insertions, 7 deletions
diff --git a/plugins/pychrysalide/analysis/content.c b/plugins/pychrysalide/analysis/content.c index fab7dfe..f332167 100644 --- a/plugins/pychrysalide/analysis/content.c +++ b/plugins/pychrysalide/analysis/content.c @@ -37,6 +37,7 @@ #include "../access.h" +#include "../helpers.h" #include "../arch/vmpa.h" @@ -620,7 +621,9 @@ bool ensure_python_binary_content_is_registered(void) module = get_access_to_python_module("pychrysalide.analysis"); dict = PyModule_GetDict(module); - pyg_register_interface(dict, "BinContent", G_TYPE_BIN_CONTENT, type); + + if (!register_interface_for_pygobject(dict, G_TYPE_BIN_CONTENT, type)) + return false; } diff --git a/plugins/pychrysalide/analysis/loaded.c b/plugins/pychrysalide/analysis/loaded.c index dd236ed..9c30261 100644 --- a/plugins/pychrysalide/analysis/loaded.c +++ b/plugins/pychrysalide/analysis/loaded.c @@ -37,6 +37,7 @@ #include "../access.h" +#include "../helpers.h" @@ -321,7 +322,9 @@ bool ensure_python_loaded_content_is_registered(void) module = get_access_to_python_module("pychrysalide.analysis"); dict = PyModule_GetDict(module); - pyg_register_interface(dict, "LoadedContent", G_TYPE_LOADED_CONTENT, type); + + if (!register_interface_for_pygobject(dict, G_TYPE_LOADED_CONTENT, type)) + return false; } diff --git a/plugins/pychrysalide/arch/feeder.c b/plugins/pychrysalide/arch/feeder.c index b50124d..1dd9373 100644 --- a/plugins/pychrysalide/arch/feeder.c +++ b/plugins/pychrysalide/arch/feeder.c @@ -33,6 +33,7 @@ #include "../access.h" +#include "../helpers.h" @@ -104,7 +105,9 @@ bool ensure_python_proxy_feeder_is_registered(void) module = get_access_to_python_module("pychrysalide.arch"); dict = PyModule_GetDict(module); - pyg_register_interface(dict, "ProxyFeeder", G_TYPE_PROXY_FEEDER, type); + + if (!register_interface_for_pygobject(dict, G_TYPE_PROXY_FEEDER, type)) + return false; } diff --git a/plugins/pychrysalide/arch/targetableop.c b/plugins/pychrysalide/arch/targetableop.c index 0fb23e0..52d00e0 100644 --- a/plugins/pychrysalide/arch/targetableop.c +++ b/plugins/pychrysalide/arch/targetableop.c @@ -38,6 +38,7 @@ #include "processor.h" #include "vmpa.h" #include "../access.h" +#include "../helpers.h" #include "../format/format.h" @@ -177,7 +178,9 @@ bool ensure_python_targetable_operand_is_registered(void) module = get_access_to_python_module("pychrysalide.arch"); dict = PyModule_GetDict(module); - pyg_register_interface(dict, "TargetableOperand", G_TYPE_TARGETABLE_OPERAND, type); + + if (!register_interface_for_pygobject(dict, G_TYPE_TARGETABLE_OPERAND, type)) + return false; } diff --git a/plugins/pychrysalide/glibext/linegen.c b/plugins/pychrysalide/glibext/linegen.c index 7b93f7e..c9ad013 100644 --- a/plugins/pychrysalide/glibext/linegen.c +++ b/plugins/pychrysalide/glibext/linegen.c @@ -407,7 +407,9 @@ bool ensure_python_line_generator_is_registered(void) module = get_access_to_python_module("pychrysalide.glibext"); dict = PyModule_GetDict(module); - pyg_register_interface(dict, "LineGenerator", G_TYPE_LINE_GENERATOR, type); + + if (!register_interface_for_pygobject(dict, G_TYPE_LINE_GENERATOR, type)) + return false; } diff --git a/plugins/pychrysalide/glibext/loadedpanel.c b/plugins/pychrysalide/glibext/loadedpanel.c index 949ed1c..d9364c5 100644 --- a/plugins/pychrysalide/glibext/loadedpanel.c +++ b/plugins/pychrysalide/glibext/loadedpanel.c @@ -186,7 +186,9 @@ bool ensure_python_loaded_panel_is_registered(void) module = get_access_to_python_module("pychrysalide.glibext"); dict = PyModule_GetDict(module); - pyg_register_interface(dict, "LoadedPanel", G_TYPE_LOADED_PANEL, type); + + if (!register_interface_for_pygobject(dict, G_TYPE_LOADED_PANEL, type)) + return false; if (!py_loaded_panel_define_constants(type)) return false; diff --git a/plugins/pychrysalide/gtkext/dockable.c b/plugins/pychrysalide/gtkext/dockable.c index f67e0fa..7e5cb81 100644 --- a/plugins/pychrysalide/gtkext/dockable.c +++ b/plugins/pychrysalide/gtkext/dockable.c @@ -32,6 +32,7 @@ #include "../access.h" +#include "../helpers.h" @@ -103,7 +104,9 @@ bool ensure_python_gtk_dockable_is_registered(void) module = get_access_to_python_module("pychrysalide.gtkext"); dict = PyModule_GetDict(module); - pyg_register_interface(dict, "LineGenerator", GTK_TYPE_DOCKABLE, type); + + if (!register_interface_for_pygobject(dict, GTK_TYPE_DOCKABLE, type)) + return false; } diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c index 2b62e57..d4c56e8 100644 --- a/plugins/pychrysalide/helpers.c +++ b/plugins/pychrysalide/helpers.c @@ -780,6 +780,42 @@ bool _register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *ty * Paramètres : dict = dictionnaire où conserver une référence au type créé.* * gtype = type dans sa version GLib. * * type = type dans sa version Python. * +* * +* Description : Enregistre correctement une interface GObject pour Python. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_interface_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *type) +{ + bool result; /* Bilan à retourner */ + char *name; /* Désignation de la classe */ + + name = strrchr(type->tp_name, '.'); + assert(name != NULL); + + name++; + + pyg_register_interface(dict, name, gtype, type); + + if (startswith(type->tp_name, "pychrysalide.")) + result = include_python_type_into_features(dict, type); + else + result = true; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : dict = dictionnaire où conserver une référence au type créé.* +* gtype = type dans sa version GLib. * +* type = type dans sa version Python. * * base = type de base de l'objet. * * * * Description : Enregistre un type Python dérivant d'un type GLib dynamique. * diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h index f7ebdc3..ffbfe30 100644 --- a/plugins/pychrysalide/helpers.h +++ b/plugins/pychrysalide/helpers.h @@ -104,6 +104,9 @@ bool _register_class_for_pygobject(PyObject *, GType, PyTypeObject *, PyTypeObje #define register_class_for_pygobject(dict, gtype, type, base) \ _register_class_for_pygobject(dict, gtype, type, base, NULL) +/* Enregistre correctement une interface GObject pour Python. */ +bool register_interface_for_pygobject(PyObject *, GType, PyTypeObject *); + /* Enregistre un type Python dérivant d'un type GLib dynamique. */ bool register_class_for_dynamic_pygobject(GType, PyTypeObject *, PyTypeObject *); |