diff options
Diffstat (limited to 'plugins/pychrysalide/struct.c')
| -rw-r--r-- | plugins/pychrysalide/struct.c | 28 | 
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;  | 
