diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-05-24 00:24:00 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-05-24 00:26:23 (GMT) |
commit | 9f4abb8a20871c64b33f88ad5538bbbe111c1d4c (patch) | |
tree | 6fede4c409ba09151b79e88ee3ffe1831be6727e /plugins/yaml/python/pair.c | |
parent | 62f073f9a5eb039d8bc5b6d304fca484d4198a9f (diff) |
Update the YAML Python bindings code.
Diffstat (limited to 'plugins/yaml/python/pair.c')
-rw-r--r-- | plugins/yaml/python/pair.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/yaml/python/pair.c b/plugins/yaml/python/pair.c index 59ca0a9..1fffbeb 100644 --- a/plugins/yaml/python/pair.c +++ b/plugins/yaml/python/pair.c @@ -31,6 +31,7 @@ #include <i18n.h> +#include <plugins/pychrysalide/access.h> #include <plugins/pychrysalide/helpers.h> @@ -501,7 +502,6 @@ PyTypeObject *get_python_yaml_pair_type(void) .tp_init = py_yaml_pair_init, .tp_new = py_yaml_pair_new, - }; return &py_yaml_pair_type; @@ -511,7 +511,7 @@ PyTypeObject *get_python_yaml_pair_type(void) /****************************************************************************** * * -* Paramètres : module = module dont la définition est à compléter. * +* Paramètres : - * * * * Description : Prend en charge l'objet 'pychrysalide.plugins.....YamlPair. * * * @@ -521,22 +521,27 @@ PyTypeObject *get_python_yaml_pair_type(void) * * ******************************************************************************/ -bool register_python_yaml_pair(PyObject *module) +bool ensure_python_yaml_pair_is_registered(void) { PyTypeObject *type; /* Type Python 'YamlPair' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ type = get_python_yaml_pair_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.plugins.yaml"); - /* TODO : get_python_yaml_node_type() */ + dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_YAML_PAIR, type)) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_YAML_PAIR, type)) + return false; - if (!define_yaml_pair_constants(type)) - return false; + if (!define_yaml_pair_constants(type)) + return false; + + } return true; |