diff options
Diffstat (limited to 'plugins/pychrysalide/format/format.c')
-rw-r--r-- | plugins/pychrysalide/format/format.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/plugins/pychrysalide/format/format.c b/plugins/pychrysalide/format/format.c index 561c0c2..bf6c3f1 100644 --- a/plugins/pychrysalide/format/format.c +++ b/plugins/pychrysalide/format/format.c @@ -33,6 +33,7 @@ #include "symbol.h" #include "symiter.h" +#include "../access.h" #include "../helpers.h" #include "../arch/vmpa.h" @@ -732,22 +733,29 @@ PyTypeObject *get_python_binary_format_type(void) * * ******************************************************************************/ -bool register_python_binary_format(PyObject *module) +bool ensure_python_binary_format_is_registered(void) { - PyTypeObject *py_bin_format_type; /* Type Python 'BinFormat' */ + PyTypeObject *type; /* Type Python 'BinFormat' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_bin_format_type = get_python_binary_format_type(); + type = get_python_binary_format_type(); - APPLY_ABSTRACT_FLAG(py_bin_format_type); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.format"); + + APPLY_ABSTRACT_FLAG(type); - dict = PyModule_GetDict(module); + dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_BIN_FORMAT, py_bin_format_type, &PyGObject_Type)) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_BIN_FORMAT, type, &PyGObject_Type)) + return false; - if (!define_python_binary_format_constants(py_bin_format_type)) - return false; + if (!define_python_binary_format_constants(type)) + return false; + + } return true; |