summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/struct.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-29 20:52:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-29 20:52:23 (GMT)
commitec826257323b853d3171f464fb57d37989715a44 (patch)
tree2b6dd292466f0b2ea6924b1cff7f6c9ca20e2f42 /plugins/pychrysalide/struct.c
parentee2ddc088b10622b08d1b9484894cabd73374c37 (diff)
Updated the root API of the Python bindings.
Diffstat (limited to 'plugins/pychrysalide/struct.c')
-rw-r--r--plugins/pychrysalide/struct.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/pychrysalide/struct.c b/plugins/pychrysalide/struct.c
index 33b58b8..98704c0 100644
--- a/plugins/pychrysalide/struct.c
+++ b/plugins/pychrysalide/struct.c
@@ -25,6 +25,9 @@
#include "struct.h"
+#include "access.h"
+
+
/* Objet à vocation abstraite */
typedef struct _PyStructObject
@@ -130,7 +133,7 @@ PyTypeObject *get_python_py_struct_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.PyStructObject'. *
* *
@@ -140,21 +143,28 @@ PyTypeObject *get_python_py_struct_type(void)
* *
******************************************************************************/
-bool register_python_py_struct(PyObject *module)
+bool ensure_python_py_struct_is_registered(void)
{
- PyTypeObject *py_struct_type; /* Type Python 'PyStructObject'*/
+ PyTypeObject *type; /* Type Python 'PyStructObject'*/
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan des préparatifs */
- py_struct_type = get_python_py_struct_type();
+ type = get_python_py_struct_type();
- ret = PyType_Ready(py_struct_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide");
- if (ret != 0)
- return false;
+ ret = PyType_Ready(type);
- Py_INCREF(py_struct_type);
+ if (ret != 0)
+ return false;
- PyModule_AddObject(module, "PyStructObject", (PyObject *)py_struct_type);;
+ Py_INCREF(type);
+
+ PyModule_AddObject(module, "PyStructObject", (PyObject *)type);
+
+ }
return true;