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/module.c | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/arch/module.c')
-rw-r--r-- | plugins/pychrysalide/arch/module.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/plugins/pychrysalide/arch/module.c b/plugins/pychrysalide/arch/module.c index 406b78c..c81a762 100644 --- a/plugins/pychrysalide/arch/module.c +++ b/plugins/pychrysalide/arch/module.c @@ -39,7 +39,6 @@ #include "raw.h" #include "targetableop.h" #include "vmpa.h" -#include "../access.h" #include "../helpers.h" @@ -94,21 +93,20 @@ static bool py_base_define_constants(PyTypeObject *obj_type) /****************************************************************************** * * -* Paramètres : module = module dont la définition est à compléter. * +* Paramètres : super = module dont la définition est à compléter. * * * -* Description : Ajoute le module 'arch' au module Python. * +* Description : Ajoute le module 'arch' à un module Python. * * * -* Retour : - * +* Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -bool add_arch_module_to_python_module(PyObject *super) +bool add_arch_module(PyObject *super) { bool result; /* Bilan à retourner */ PyObject *module; /* Sous-module mis en place */ - int ret; /* Bilan d'un appel */ static PyModuleDef py_chrysalide_arch_module = { @@ -121,41 +119,44 @@ bool add_arch_module_to_python_module(PyObject *super) }; - result = false; + module = build_python_module(super, &py_chrysalide_arch_module); - module = PyModule_Create(&py_chrysalide_arch_module); - if (module == NULL) return false; + result = (module != NULL); - ret = PyState_AddModule(super, &py_chrysalide_arch_module); - if (ret != 0) goto loading_failed; + if (result) result = py_base_define_constants(Py_TYPE(module)); - ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch"); - if (ret != 0) goto loading_failed; - - Py_INCREF(module); - ret = PyModule_AddObject(super, "arch", module); - if (ret != 0) goto loading_failed; - - result = true; + return result; - result &= py_base_define_constants(Py_TYPE(module)); +} - result &= register_python_targetable_operand(module); - result &= register_python_arch_instruction(module); - result &= register_python_arch_operand(module); - result &= register_python_arch_processor(module); - result &= register_python_instr_iterator(module); - result &= register_python_raw_instruction(module); - result &= register_python_vmpa(module); - result &= register_python_mrange(module); +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Intègre les objets du module 'arch'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ - result &= register_python_imm_operand(module); +bool populate_arch_module(void) +{ + bool result; /* Bilan à retourner */ - if (result) - register_access_to_python_module("pychrysalide.arch", module); + result = true; - loading_failed: + if (result) result = ensure_python_imm_operand_is_registered(); + if (result) result = ensure_python_instr_iterator_is_registered(); + if (result) result = ensure_python_arch_instruction_is_registered(); + if (result) result = ensure_python_arch_operand_is_registered(); + if (result) result = ensure_python_arch_processor_is_registered(); + if (result) result = ensure_python_raw_instruction_is_registered(); + if (result) result = ensure_python_targetable_operand_is_registered(); + if (result) result = ensure_python_vmpa_is_registered(); + if (result) result = ensure_python_mrange_is_registered(); assert(result); |