diff options
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r-- | plugins/pychrysalide/plugin.c | 26 | ||||
-rw-r--r-- | plugins/pychrysalide/plugin.h | 2 | ||||
-rw-r--r-- | plugins/pychrysalide/pychrysa.c | 8 | ||||
-rw-r--r-- | plugins/pychrysalide/struct.c | 28 | ||||
-rw-r--r-- | plugins/pychrysalide/struct.h | 2 |
5 files changed, 45 insertions, 21 deletions
diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c index a916668..cc69dd7 100644 --- a/plugins/pychrysalide/plugin.c +++ b/plugins/pychrysalide/plugin.c @@ -37,6 +37,7 @@ #include <plugins/plugin-int.h> +#include "access.h" #include "helpers.h" @@ -912,7 +913,7 @@ PyTypeObject *get_python_plugin_module_type(void) /****************************************************************************** * * -* Paramètres : module = module dont la définition est à compléter. * +* Paramètres : - * * * * Description : Prend en charge l'objet 'pychrysalide.PluginModule'. * * * @@ -922,20 +923,27 @@ PyTypeObject *get_python_plugin_module_type(void) * * ******************************************************************************/ -bool register_python_plugin_module(PyObject *module) +bool ensure_python_plugin_module_is_registered(void) { - PyTypeObject *py_plugin_module_type; /* Type Python 'PluginModule' */ + PyTypeObject *type; /* Type Python 'PluginModule' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_plugin_module_type = get_python_plugin_module_type(); + type = get_python_plugin_module_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide"); - if (!register_class_for_pygobject(dict, G_TYPE_PLUGIN_MODULE, py_plugin_module_type, &PyGObject_Type)) - return false; + dict = PyModule_GetDict(module); - if (!py_plugin_module_define_constants(py_plugin_module_type)) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_PLUGIN_MODULE, type, &PyGObject_Type)) + return false; + + if (!py_plugin_module_define_constants(type)) + return false; + + } return true; diff --git a/plugins/pychrysalide/plugin.h b/plugins/pychrysalide/plugin.h index 1b7f7ba..e129155 100644 --- a/plugins/pychrysalide/plugin.h +++ b/plugins/pychrysalide/plugin.h @@ -68,7 +68,7 @@ GPluginModule *g_python_plugin_new(const char *, const char *); PyTypeObject *get_python_plugin_module_type(void); /* Prend en charge l'objet 'pychrysalide.PluginModule'. */ -bool register_python_plugin_module(PyObject *); +bool ensure_python_plugin_module_is_registered(void); diff --git a/plugins/pychrysalide/pychrysa.c b/plugins/pychrysalide/pychrysa.c index dee0d84..7403927 100644 --- a/plugins/pychrysalide/pychrysa.c +++ b/plugins/pychrysalide/pychrysa.c @@ -43,6 +43,7 @@ #include <plugins/plugin-int.h> +#include "access.h" #include "helpers.h" #include "plugin.h" #include "struct.h" @@ -360,7 +361,9 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) result = PyModule_Create(&py_chrysalide_module); - status = register_python_py_struct(result); + register_access_to_python_module(py_chrysalide_module.m_name, result); + + status = true; if (status) status = add_analysis_module(result); if (status) status = add_arch_module(result); @@ -373,6 +376,9 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) if (status) status = add_gui_module(result); if (status) status = add_mangling_module(result); + if (status) status = ensure_python_plugin_module_is_registered(); + if (status) status = ensure_python_py_struct_is_registered(); + if (status) status = populate_analysis_module(); if (status) status = populate_arch_module(); if (status) status = populate_common_module(); diff --git a/plugins/pychrysalide/struct.c b/plugins/pychrysalide/struct.c index 33b58b8..98704c0 100644 --- a/plugins/pychrysalide/struct.c +++ b/plugins/pychrysalide/struct.c @@ -25,6 +25,9 @@ #include "struct.h" +#include "access.h" + + /* Objet à vocation abstraite */ typedef struct _PyStructObject @@ -130,7 +133,7 @@ PyTypeObject *get_python_py_struct_type(void) /****************************************************************************** * * -* Paramètres : module = module dont la définition est à compléter. * +* Paramètres : - * * * * Description : Prend en charge l'objet 'pychrysalide.PyStructObject'. * * * @@ -140,21 +143,28 @@ PyTypeObject *get_python_py_struct_type(void) * * ******************************************************************************/ -bool register_python_py_struct(PyObject *module) +bool ensure_python_py_struct_is_registered(void) { - PyTypeObject *py_struct_type; /* Type Python 'PyStructObject'*/ + PyTypeObject *type; /* Type Python 'PyStructObject'*/ + PyObject *module; /* Module à recompléter */ int ret; /* Bilan des préparatifs */ - py_struct_type = get_python_py_struct_type(); + type = get_python_py_struct_type(); - ret = PyType_Ready(py_struct_type); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide"); - if (ret != 0) - return false; + ret = PyType_Ready(type); - Py_INCREF(py_struct_type); + if (ret != 0) + return false; - PyModule_AddObject(module, "PyStructObject", (PyObject *)py_struct_type);; + Py_INCREF(type); + + PyModule_AddObject(module, "PyStructObject", (PyObject *)type); + + } return true; diff --git a/plugins/pychrysalide/struct.h b/plugins/pychrysalide/struct.h index 7c5391c..c063c5e 100644 --- a/plugins/pychrysalide/struct.h +++ b/plugins/pychrysalide/struct.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_py_struct_type(void); /* Prend en charge l'objet 'pychrysalide.PyStructObject'. */ -bool register_python_py_struct(PyObject *); +bool ensure_python_py_struct_is_registered(void); |