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/arch/raw.c | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/arch/raw.c')
-rw-r--r-- | plugins/pychrysalide/arch/raw.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/plugins/pychrysalide/arch/raw.c b/plugins/pychrysalide/arch/raw.c index 39b5fe7..318eb6b 100644 --- a/plugins/pychrysalide/arch/raw.c +++ b/plugins/pychrysalide/arch/raw.c @@ -32,6 +32,7 @@ #include "instruction.h" +#include "../access.h" #include "../helpers.h" @@ -243,20 +244,27 @@ PyTypeObject *get_python_raw_instruction_type(void) * * ******************************************************************************/ -bool register_python_raw_instruction(PyObject *module) +bool ensure_python_raw_instruction_is_registered(void) { - PyTypeObject *py_raw_instruction_type; /* Type Python 'RawInstruction'*/ + PyTypeObject *type; /* Type Python 'RawInstruction'*/ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - PyTypeObject *base; /* Base parente pour héritage */ - py_raw_instruction_type = get_python_raw_instruction_type(); + type = get_python_raw_instruction_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.arch"); - base = get_python_arch_instruction_type(); + dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_RAW_INSTRUCTION, py_raw_instruction_type, base)) - return false; + if (!ensure_python_arch_instruction_is_registered()) + return false; + + if (!register_class_for_pygobject(dict, G_TYPE_RAW_INSTRUCTION, type, get_python_arch_instruction_type())) + return false; + + } return true; |