diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-07-17 16:36:21 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-07-17 16:36:21 (GMT) |
commit | 24d3836fcf8d443eb654b981f65478cd9923b8f1 (patch) | |
tree | 7672a28b864127e8958c3c6cce751dcf646d2fbe /plugins/pychrysa/format/module.c | |
parent | a61f089babe336b012da31a494b0f7470b6e1a9a (diff) |
Updated the Python bindings.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@552 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/format/module.c')
-rw-r--r-- | plugins/pychrysa/format/module.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/plugins/pychrysa/format/module.c b/plugins/pychrysa/format/module.c index efaade6..bd81187 100644 --- a/plugins/pychrysa/format/module.c +++ b/plugins/pychrysa/format/module.c @@ -25,15 +25,17 @@ #include "module.h" +#include <assert.h> + + #include "executable.h" #include "format.h" +#include "symbol.h" #include "dex/module.h" #include "elf/module.h" - - /****************************************************************************** * * * Paramètres : module = module dont la définition est à compléter. * @@ -48,28 +50,50 @@ bool add_format_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_methods[] = { - { NULL } + static PyModuleDef py_chrysalide_format_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.format", + .m_doc = "Python module for Chrysalide.format", + + .m_size = -1, + }; - module = Py_InitModule("pychrysalide.format", py_format_methods); + result = false; + + module = PyModule_Create(&py_chrysalide_format_module); if (module == NULL) return false; + ret = PyState_AddModule(super, &py_chrysalide_format_module); + if (ret != 0) goto loading_failed; + + ret = _PyImport_FixupBuiltin(module, "pychrysalide.format"); + if (ret != 0) goto loading_failed; + Py_INCREF(module); - ret = PyModule_AddObject(super, "pychrysalide.format", module); + ret = PyModule_AddObject(super, "format", module); + if (ret != 0) goto loading_failed; - result = (ret == 0); + result = true; + result &= register_python_binary_symbol_iterator(module); result &= register_python_binary_format(module); result &= register_python_executable_format(module); + result &= register_python_binary_symbol(module); result &= add_format_dex_module_to_python_module(module); result &= add_format_elf_module_to_python_module(module); + loading_failed: + + assert(result); + return result; } |