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/arm | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/arm')
-rw-r--r-- | plugins/arm/python/module.c | 32 | ||||
-rw-r--r-- | plugins/arm/python/v7/module.c | 35 |
2 files changed, 16 insertions, 51 deletions
diff --git a/plugins/arm/python/module.c b/plugins/arm/python/module.c index 9e832ba..12189c9 100644 --- a/plugins/arm/python/module.c +++ b/plugins/arm/python/module.c @@ -29,6 +29,7 @@ #include <plugins/pychrysalide/access.h> +#include <plugins/pychrysalide/helpers.h> #include "instruction.h" @@ -54,7 +55,6 @@ bool add_arch_arm_module_to_python_module(void) bool result; /* Bilan à retourner */ PyObject *super; /* Module à compléter */ PyObject *module; /* Sous-module mis en place */ - int ret; /* Bilan d'un appel */ static PyModuleDef py_chrysalide_arm_module = { @@ -71,34 +71,16 @@ bool add_arch_arm_module_to_python_module(void) super = get_access_to_python_module("pychrysalide.arch"); - module = PyModule_Create(&py_chrysalide_arm_module); - if (module == NULL) return false; + module = build_python_module(super, &py_chrysalide_arm_module); - ret = PyState_AddModule(super, &py_chrysalide_arm_module); - if (ret != 0) goto aaamtpm_exit; + result = (module != NULL); - ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm"); - if (ret != 0) goto aaamtpm_exit; + if (result) result = register_python_arm_instruction(module); + if (result) result = register_python_arm_processor(module); - Py_INCREF(module); - ret = PyModule_AddObject(super, "arm", module); - if (ret != 0) goto aaamtpm_exit; + if (result) result = add_arch_arm_v7_module_to_python_module(module); - result = true; - - result &= register_python_arm_instruction(module); - result &= register_python_arm_processor(module); - - result &= add_arch_arm_v7_module_to_python_module(module); - - aaamtpm_exit: - - if (!result) - { - printf("something went wrong in %s...\n", __FUNCTION__); - /* ... */ - - } + assert(result); return result; diff --git a/plugins/arm/python/v7/module.c b/plugins/arm/python/v7/module.c index 9188ae4..e7971bc 100644 --- a/plugins/arm/python/v7/module.c +++ b/plugins/arm/python/v7/module.c @@ -25,6 +25,10 @@ #include "module.h" +#include <plugins/pychrysalide/access.h> +#include <plugins/pychrysalide/helpers.h> + + #include "instruction.h" #include "processor.h" @@ -46,7 +50,6 @@ bool add_arch_arm_v7_module_to_python_module(PyObject *super) { bool result; /* Bilan à retourner */ PyObject *module; /* Sous-module mis en place */ - int ret; /* Bilan d'un appel */ static PyModuleDef py_chrysalide_v7_module = { @@ -59,34 +62,14 @@ bool add_arch_arm_v7_module_to_python_module(PyObject *super) }; - result = false; - - module = PyModule_Create(&py_chrysalide_v7_module); - if (module == NULL) return false; - - ret = PyState_AddModule(super, &py_chrysalide_v7_module); - if (ret != 0) goto aaamtpm_exit; - - ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm.v7"); - if (ret != 0) goto aaamtpm_exit; - - Py_INCREF(module); - ret = PyModule_AddObject(super, "v7", module); - if (ret != 0) goto aaamtpm_exit; - - result = true; - - result &= register_python_armv7_instruction(module); - result &= register_python_armv7_processor(module); + module = build_python_module(super, &py_chrysalide_v7_module); - aaamtpm_exit: + result = (module != NULL); - if (!result) - { - printf("something went wrong in %s...\n", __FUNCTION__); - /* ... */ + if (result) result = register_python_armv7_instruction(module); + if (result) result = register_python_armv7_processor(module); - } + assert(result); return result; |