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/analysis/types/cse.c | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/analysis/types/cse.c')
-rw-r--r-- | plugins/pychrysalide/analysis/types/cse.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/pychrysalide/analysis/types/cse.c b/plugins/pychrysalide/analysis/types/cse.c index ff3984f..3444cc3 100644 --- a/plugins/pychrysalide/analysis/types/cse.c +++ b/plugins/pychrysalide/analysis/types/cse.c @@ -33,6 +33,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -248,21 +249,30 @@ static bool py_class_enum_type_define_constants(PyTypeObject *obj_type) * * ******************************************************************************/ -bool register_python_class_enum_type(PyObject *module) +bool ensure_python_class_enum_type_is_registered(void) { - PyTypeObject *py_class_enum_type_type; /* Type Python 'ClassEnumType' */ + PyTypeObject *type; /* Type Python 'ClassEnumType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_class_enum_type_type = get_python_class_enum_type_type(); + type = get_python_class_enum_type_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.analysis.types"); + + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_CLASS_ENUM_TYPE, - py_class_enum_type_type, get_python_data_type_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_CLASS_ENUM_TYPE, type, get_python_data_type_type())) + return false; - if (!py_class_enum_type_define_constants(py_class_enum_type_type)) - return false; + if (!py_class_enum_type_define_constants(type)) + return false; + + } return true; |