summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/arch/module.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-06-25 06:46:04 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-06-25 06:46:04 (GMT)
commit3bf12eda58a8d04ac3d2d6754a480de4c262570d (patch)
tree010fc97ad481adc00ac4722d77093f469096638b /plugins/pychrysa/arch/module.c
parent11395d684736467fb010b93b0eaeefcc06bf0f5e (diff)
Built the first steps to upgrade to Python3.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@379 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/arch/module.c')
-rw-r--r--plugins/pychrysa/arch/module.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/plugins/pychrysa/arch/module.c b/plugins/pychrysa/arch/module.c
index 7e8fcb3..92172e0 100644
--- a/plugins/pychrysa/arch/module.c
+++ b/plugins/pychrysa/arch/module.c
@@ -25,9 +25,7 @@
#include "module.h"
-#include "instruction.h"
-
-
+#include "vmpa.h"
@@ -45,28 +43,49 @@
bool add_arch_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_arch_methods[] = {
- { NULL }
+ static PyModuleDef py_chrysalide_arch_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.arch",
+ .m_doc = "Python module for Chrysalide.arch",
+
+ .m_size = -1,
+
};
- module = Py_InitModule("pychrysalide.arch", py_arch_methods);
+ result = false;
+
+ module = PyModule_Create(&py_chrysalide_arch_module);
if (module == NULL) return false;
+ ret = PyState_AddModule(super, &py_chrysalide_arch_module);
+ if (ret != 0) goto aamtpm_exit;
+
+ ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch");
+ if (ret != 0) goto aamtpm_exit;
Py_INCREF(module);
- ret = PyModule_AddObject(super, "pychrysalide.arch", module);
+ ret = PyModule_AddObject(super, "arch", module);
+ if (ret != 0) goto aamtpm_exit;
+
+ result = true;
+
+ result &= register_python_vmpa(module);
- result = (ret == 0);
+ aamtpm_exit:
- if (ret != 0) /* ... */;
+ if (!result)
+ {
+ printf("something went wrong in %s...\n", __FUNCTION__);
+ /* ... */
- result &= register_python_arch_instruction(module);
- result &= register_python_arch_instruction_iterator(module);
+ }
- return true;
+ return result;
}