summaryrefslogtreecommitdiff
path: root/plugins/dex/python
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/dex/python
parent36945bffa2ca648b58c99905ebf9b1b536a9188a (diff)
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/dex/python')
-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;