summaryrefslogtreecommitdiff
path: root/plugins/arm/python
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/python')
-rw-r--r--plugins/arm/python/module.c32
-rw-r--r--plugins/arm/python/v7/module.c35
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;