diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
commit | fb315963527f6412273829f09513325e446eb6c9 (patch) | |
tree | 361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/pychrysalide/format/flat.c | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/format/flat.c')
-rw-r--r-- | plugins/pychrysalide/format/flat.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/plugins/pychrysalide/format/flat.c b/plugins/pychrysalide/format/flat.c index c85ee37..18ad414 100644 --- a/plugins/pychrysalide/format/flat.c +++ b/plugins/pychrysalide/format/flat.c @@ -32,6 +32,7 @@ #include "executable.h" +#include "../access.h" #include "../helpers.h" #include "../analysis/content.h" @@ -188,18 +189,27 @@ PyTypeObject *get_python_flat_format_type(void) * * ******************************************************************************/ -bool register_python_flat_format(PyObject *module) +bool ensure_python_flat_format_is_registered(void) { - PyTypeObject *py_flat_format_type; /* Type Python 'FlatFormat' */ + PyTypeObject *type; /* Type Python 'FlatFormat' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_flat_format_type = get_python_flat_format_type(); + type = get_python_flat_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_executable_format_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_FLAT_FORMAT, py_flat_format_type, \ - get_python_executable_format_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_FLAT_FORMAT, type, get_python_executable_format_type())) + return false; + + } return true; |