summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/format/dex/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/format/dex/module.c')
-rw-r--r--plugins/pychrysa/format/dex/module.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/plugins/pychrysa/format/dex/module.c b/plugins/pychrysa/format/dex/module.c
index 43f0dbb..41f48c4 100644
--- a/plugins/pychrysa/format/dex/module.c
+++ b/plugins/pychrysa/format/dex/module.c
@@ -44,27 +44,43 @@
bool add_format_dex_module_to_python_module(PyObject *super)
{
- bool result;
- PyObject *module;
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
int ret; /* Bilan d'un appel */
- static PyMethodDef py_format_dex_methods[] = {
- { NULL }
+ static PyModuleDef py_chrysalide_dex_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.format.dex",
+ .m_doc = "Python module for Chrysalide.format.dex",
+
+ .m_size = -1,
+
};
- module = Py_InitModule("pychrysalide.format.dex", py_format_dex_methods);
+ result = false;
+
+ module = PyModule_Create(&py_chrysalide_dex_module);
if (module == NULL) return false;
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "pychrysalide.format.dex", module);
+ ret = PyState_AddModule(super, &py_chrysalide_dex_module);
+ if (ret != 0) goto loading_failed;
+
+ ret = _PyImport_FixupBuiltin(module, "pychrysalide.format.dex");
+ if (ret != 0) goto loading_failed;
- result = (ret == 0);
+ Py_INCREF(module);
+ ret = PyModule_AddObject(super, "dex", module);
+ if (ret != 0) goto loading_failed;
- if (ret != 0) /* ... */;
+ result = true;
result &= register_python_dex_class(module);
result &= register_python_dex_format(module);
- return true;
+ loading_failed:
+
+ return result;
}