summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/common/bits.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/common/bits.c')
-rw-r--r--plugins/pychrysalide/common/bits.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/plugins/pychrysalide/common/bits.c b/plugins/pychrysalide/common/bits.c
index 065f32e..e137213 100644
--- a/plugins/pychrysalide/common/bits.c
+++ b/plugins/pychrysalide/common/bits.c
@@ -25,6 +25,7 @@
#include "bits.h"
+#include "../access.h"
#include "../helpers.h"
@@ -757,20 +758,30 @@ PyTypeObject *get_python_bitfield_type(void)
* *
******************************************************************************/
-bool register_python_bitfield(PyObject *module)
+bool ensure_python_bitfield_is_registered(void)
{
- PyTypeObject *py_bitfield_type; /* Type Python pour 'bitfield' */
+ PyTypeObject *type; /* Type Python pour 'bitfield' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_bitfield_type = get_python_bitfield_type();
+ type = get_python_bitfield_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ if (PyType_Ready(type) != 0)
+ return false;
- if (PyType_Ready(py_bitfield_type) != 0)
- return false;
+ module = get_access_to_python_module("pychrysalide.common");
- Py_INCREF(py_bitfield_type);
- ret = PyModule_AddObject(module, "bitfield", (PyObject *)py_bitfield_type);
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "bitfield", (PyObject *)type);
+
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}