summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch/instriter.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/arch/instriter.c')
-rw-r--r--plugins/pychrysalide/arch/instriter.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/plugins/pychrysalide/arch/instriter.c b/plugins/pychrysalide/arch/instriter.c
index 244a825..f665cba 100644
--- a/plugins/pychrysalide/arch/instriter.c
+++ b/plugins/pychrysalide/arch/instriter.c
@@ -32,6 +32,7 @@
#include "processor.h"
+#include "../access.h"
@@ -258,19 +259,29 @@ PyTypeObject *get_python_instr_iterator_type(void)
* *
******************************************************************************/
-bool register_python_instr_iterator(PyObject *module)
+bool ensure_python_instr_iterator_is_registered(void)
{
- PyTypeObject *py_instr_iterator_type; /* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'InstrIterator' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_instr_iterator_type = get_python_instr_iterator_type();
+ type = get_python_instr_iterator_type();
- if (PyType_Ready(py_instr_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.arch");
+
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "InstrIterator", (PyObject *)type);
- Py_INCREF(py_instr_iterator_type);
- ret = PyModule_AddObject(module, "InstrIterator", (PyObject *)py_instr_iterator_type);
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}