summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch/instriter.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
commitfb315963527f6412273829f09513325e446eb6c9 (patch)
tree361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/pychrysalide/arch/instriter.c
parent36945bffa2ca648b58c99905ebf9b1b536a9188a (diff)
Reorganized the Python plugin code.
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;
}