summaryrefslogtreecommitdiff
path: root/plugins/dex
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dex')
-rw-r--r--plugins/dex/python/module.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/plugins/dex/python/module.c b/plugins/dex/python/module.c
index 6a84af3..aedbc0f 100644
--- a/plugins/dex/python/module.c
+++ b/plugins/dex/python/module.c
@@ -29,6 +29,7 @@
#include <plugins/pychrysalide/access.h>
+#include <plugins/pychrysalide/helpers.h>
#include "class.h"
@@ -55,7 +56,6 @@ bool add_format_dex_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_dex_module = {
@@ -72,31 +72,16 @@ bool add_format_dex_module_to_python_module(void)
super = get_access_to_python_module("pychrysalide.format");
- module = PyModule_Create(&py_chrysalide_dex_module);
- if (module == NULL) return false;
+ module = build_python_module(super, &py_chrysalide_dex_module);
- ret = PyState_AddModule(super, &py_chrysalide_dex_module);
- if (ret != 0) goto loading_failed;
+ result = (module != NULL);
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.format.dex");
- if (ret != 0) goto loading_failed;
+ if (result) result = register_python_dex_class(module);
+ if (result) result = register_python_dex_field(module);
+ if (result) result = register_python_dex_format(module);
+ if (result) result = register_python_dex_method(module);
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "dex", module);
- if (ret != 0) goto loading_failed;
-
- result = register_python_dex_class(module);
-
- if (result)
- result = register_python_dex_field(module);
-
- if (result)
- result = register_python_dex_format(module);
-
- if (result)
- result = register_python_dex_method(module);
-
- loading_failed:
+ assert(result);
return result;