diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
commit | fb315963527f6412273829f09513325e446eb6c9 (patch) | |
tree | 361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/pychrysalide/format/symiter.c | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/format/symiter.c')
-rw-r--r-- | plugins/pychrysalide/format/symiter.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/plugins/pychrysalide/format/symiter.c b/plugins/pychrysalide/format/symiter.c index db0b744..74a215d 100644 --- a/plugins/pychrysalide/format/symiter.c +++ b/plugins/pychrysalide/format/symiter.c @@ -32,6 +32,7 @@ #include "format.h" +#include "../access.h" @@ -258,19 +259,29 @@ PyTypeObject *get_python_sym_iterator_type(void) * * ******************************************************************************/ -bool register_python_sym_iterator(PyObject *module) +bool ensure_python_sym_iterator_is_registered(void) { - PyTypeObject *py_sym_iterator_type; /* Type Python 'BinContent' */ + PyTypeObject *type; /* Type Python 'SymIterator' */ + PyObject *module; /* Module à recompléter */ int ret; /* Bilan d'un appel */ - py_sym_iterator_type = get_python_sym_iterator_type(); + type = get_python_sym_iterator_type(); - if (PyType_Ready(py_sym_iterator_type) < 0) - return false; + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + if (PyType_Ready(type) < 0) + return false; + + module = get_access_to_python_module("pychrysalide.format"); + + Py_INCREF(type); + ret = PyModule_AddObject(module, "SymIterator", (PyObject *)type); - Py_INCREF(py_sym_iterator_type); - ret = PyModule_AddObject(module, "SymIterator", (PyObject *)py_sym_iterator_type); + if (ret != 0) + return false; + + } - return (ret == 0); + return true; } |