diff options
Diffstat (limited to 'plugins/pychrysa/analysis/blocks/module.c')
-rw-r--r-- | plugins/pychrysa/analysis/blocks/module.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/plugins/pychrysa/analysis/blocks/module.c b/plugins/pychrysa/analysis/blocks/module.c index 881ebc7..4968e90 100644 --- a/plugins/pychrysa/analysis/blocks/module.c +++ b/plugins/pychrysa/analysis/blocks/module.c @@ -25,6 +25,9 @@ #include "module.h" +#include <assert.h> + + #include "flow.h" #include "virtual.h" @@ -42,27 +45,47 @@ * * ******************************************************************************/ -bool add_blocks_module_to_python_module(PyObject *super) +bool add_analysis_blocks_module_to_python_module(PyObject *super) { bool result; /* Bilan à retourner */ - PyObject *module; /* Module Python mis en place */ + PyObject *module; /* Sous-module mis en place */ int ret; /* Bilan d'un appel */ - static PyMethodDef py_blocks_methods[] = { - { NULL } + static PyModuleDef py_chrysalide_blocks_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.analysis.blocks", + .m_doc = "Python module for Chrysalide.analysis.blocks", + + .m_size = -1, + }; - module = Py_InitModule("pychrysalide.analysis.blocks", py_blocks_methods); + result = false; + + module = PyModule_Create(&py_chrysalide_blocks_module); if (module == NULL) return false; + ret = PyState_AddModule(super, &py_chrysalide_blocks_module); + if (ret != 0) goto loading_failed; + + ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.blocks"); + if (ret != 0) goto loading_failed; + Py_INCREF(module); - ret = PyModule_AddObject(super, "pychrysalide.analysis.blocks", module); + ret = PyModule_AddObject(super, "blocks", module); + if (ret != 0) goto loading_failed; - result = (ret == 0); + result = true; result &= register_python_flow_block(module); result &= register_python_virtual_block(module); + loading_failed: + + assert(result); + return result; } |