summaryrefslogtreecommitdiff
path: root/plugins/elf
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
commitfb315963527f6412273829f09513325e446eb6c9 (patch)
tree361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/elf
parent36945bffa2ca648b58c99905ebf9b1b536a9188a (diff)
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/elf')
-rw-r--r--plugins/elf/python/module.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/plugins/elf/python/module.c b/plugins/elf/python/module.c
index f986659..5655c18 100644
--- a/plugins/elf/python/module.c
+++ b/plugins/elf/python/module.c
@@ -29,6 +29,7 @@
#include <plugins/pychrysalide/access.h>
+#include <plugins/pychrysalide/helpers.h>
#include "format.h"
@@ -52,7 +53,6 @@ bool add_format_elf_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_elf_module = {
@@ -69,22 +69,13 @@ bool add_format_elf_module_to_python_module(void)
super = get_access_to_python_module("pychrysalide.format");
- module = PyModule_Create(&py_chrysalide_elf_module);
- if (module == NULL) return false;
+ module = build_python_module(super, &py_chrysalide_elf_module);
- ret = PyState_AddModule(super, &py_chrysalide_elf_module);
- if (ret != 0) goto loading_failed;
+ result = (module != NULL);
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.format.elf");
- if (ret != 0) goto loading_failed;
+ if (result) result = register_python_elf_format(module);
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "elf", module);
- if (ret != 0) goto loading_failed;
-
- result = register_python_elf_format(module);
-
- loading_failed:
+ assert(result);
return result;