summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/types/encaps.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis/types/encaps.c')
-rw-r--r--plugins/pychrysalide/analysis/types/encaps.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/pychrysalide/analysis/types/encaps.c b/plugins/pychrysalide/analysis/types/encaps.c
index 6fa1487..3b5dc18 100644
--- a/plugins/pychrysalide/analysis/types/encaps.c
+++ b/plugins/pychrysalide/analysis/types/encaps.c
@@ -32,6 +32,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -241,21 +242,30 @@ static bool py_encapsulated_type_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_encapsulated_type(PyObject *module)
+bool ensure_python_encapsulated_type_is_registered(void)
{
- PyTypeObject *py_encapsulated_type_type;/* Type 'EncapsulatedType' */
+ PyTypeObject *type; /* Type 'EncapsulatedType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_encapsulated_type_type = get_python_encapsulated_type_type();
+ type = get_python_encapsulated_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
- if (!register_class_for_pygobject(dict, G_TYPE_ENCAPSULATED_TYPE,
- py_encapsulated_type_type, get_python_data_type_type()))
- return false;
+ dict = PyModule_GetDict(module);
- if (!py_encapsulated_type_define_constants(py_encapsulated_type_type))
- return false;
+ if (!ensure_python_data_type_is_registered())
+ return false;
+
+ if (!register_class_for_pygobject(dict, G_TYPE_ENCAPSULATED_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ if (!py_encapsulated_type_define_constants(type))
+ return false;
+
+ }
return true;