summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/format/executable.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
commitfb315963527f6412273829f09513325e446eb6c9 (patch)
tree361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/pychrysalide/format/executable.c
parent36945bffa2ca648b58c99905ebf9b1b536a9188a (diff)
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/format/executable.c')
-rw-r--r--plugins/pychrysalide/format/executable.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/plugins/pychrysalide/format/executable.c b/plugins/pychrysalide/format/executable.c
index a3bcdd1..8e24699 100644
--- a/plugins/pychrysalide/format/executable.c
+++ b/plugins/pychrysalide/format/executable.c
@@ -32,6 +32,7 @@
#include "format.h"
+#include "../access.h"
#include "../helpers.h"
#include "../arch/vmpa.h"
@@ -198,17 +199,27 @@ PyTypeObject *get_python_executable_format_type(void)
* *
******************************************************************************/
-bool register_python_executable_format(PyObject *module)
+bool ensure_python_executable_format_is_registered(void)
{
- PyTypeObject *py_exe_format_type; /* Type Python 'ExeFormat' */
+ PyTypeObject *type; /* Type Python 'ExeFormat' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_exe_format_type = get_python_executable_format_type();
+ type = get_python_executable_format_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.format");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_binary_format_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_EXE_FORMAT, py_exe_format_type, get_python_binary_format_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_EXE_FORMAT, type, get_python_binary_format_type()))
+ return false;
+
+ }
return true;