diff options
Diffstat (limited to 'plugins/pychrysalide/analysis/types')
20 files changed, 208 insertions, 104 deletions
diff --git a/plugins/pychrysalide/analysis/types/array.c b/plugins/pychrysalide/analysis/types/array.c index 6f70b02..0e6760a 100644 --- a/plugins/pychrysalide/analysis/types/array.c +++ b/plugins/pychrysalide/analysis/types/array.c @@ -34,6 +34,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -408,17 +409,27 @@ PyTypeObject *get_python_array_type_type(void) * * ******************************************************************************/ -bool register_python_array_type(PyObject *module) +bool ensure_python_array_type_is_registered(void) { - PyTypeObject *py_array_type_type; /* Type Python 'ArrayType' */ + PyTypeObject *type; /* Type Python 'ArrayType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_array_type_type = get_python_array_type_type(); + type = get_python_array_type_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.analysis.types"); + + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_ARRAY_TYPE, py_array_type_type, get_python_data_type_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_ARRAY_TYPE, type, get_python_data_type_type())) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/array.h b/plugins/pychrysalide/analysis/types/array.h index 8762548..6abcfe4 100644 --- a/plugins/pychrysalide/analysis/types/array.h +++ b/plugins/pychrysalide/analysis/types/array.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_array_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.ArrayType'. */ -bool register_python_array_type(PyObject *); +bool ensure_python_array_type_is_registered(void); diff --git a/plugins/pychrysalide/analysis/types/basic.c b/plugins/pychrysalide/analysis/types/basic.c index e3bde6e..f584bb6 100644 --- a/plugins/pychrysalide/analysis/types/basic.c +++ b/plugins/pychrysalide/analysis/types/basic.c @@ -33,6 +33,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -230,20 +231,30 @@ static bool py_basic_type_define_constants(PyTypeObject *obj_type) * * ******************************************************************************/ -bool register_python_basic_type(PyObject *module) +bool ensure_python_basic_type_is_registered(void) { - PyTypeObject *py_basic_type_type; /* Type Python 'BasicType' */ + PyTypeObject *type; /* Type Python 'BasicType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_basic_type_type = get_python_basic_type_type(); + type = get_python_basic_type_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.analysis.types"); + + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_BASIC_TYPE, py_basic_type_type, get_python_data_type_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_BASIC_TYPE, type, get_python_data_type_type())) + return false; - if (!py_basic_type_define_constants(py_basic_type_type)) - return false; + if (!py_basic_type_define_constants(type)) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/basic.h b/plugins/pychrysalide/analysis/types/basic.h index ced9312..87b30d8 100644 --- a/plugins/pychrysalide/analysis/types/basic.h +++ b/plugins/pychrysalide/analysis/types/basic.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_basic_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.BasicType'. */ -bool register_python_basic_type(PyObject *); +bool ensure_python_basic_type_is_registered(void); diff --git a/plugins/pychrysalide/analysis/types/cse.c b/plugins/pychrysalide/analysis/types/cse.c index ff3984f..3444cc3 100644 --- a/plugins/pychrysalide/analysis/types/cse.c +++ b/plugins/pychrysalide/analysis/types/cse.c @@ -33,6 +33,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -248,21 +249,30 @@ static bool py_class_enum_type_define_constants(PyTypeObject *obj_type) * * ******************************************************************************/ -bool register_python_class_enum_type(PyObject *module) +bool ensure_python_class_enum_type_is_registered(void) { - PyTypeObject *py_class_enum_type_type; /* Type Python 'ClassEnumType' */ + PyTypeObject *type; /* Type Python 'ClassEnumType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_class_enum_type_type = get_python_class_enum_type_type(); + type = get_python_class_enum_type_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.analysis.types"); + + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_CLASS_ENUM_TYPE, - py_class_enum_type_type, get_python_data_type_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_CLASS_ENUM_TYPE, type, get_python_data_type_type())) + return false; - if (!py_class_enum_type_define_constants(py_class_enum_type_type)) - return false; + if (!py_class_enum_type_define_constants(type)) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/cse.h b/plugins/pychrysalide/analysis/types/cse.h index 26d25d6..41b27f5 100644 --- a/plugins/pychrysalide/analysis/types/cse.h +++ b/plugins/pychrysalide/analysis/types/cse.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_class_enum_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.ClassEnumType'. */ -bool register_python_class_enum_type(PyObject *); +bool ensure_python_class_enum_type_is_registered(void); 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; diff --git a/plugins/pychrysalide/analysis/types/encaps.h b/plugins/pychrysalide/analysis/types/encaps.h index 227527e..f1acfc0 100644 --- a/plugins/pychrysalide/analysis/types/encaps.h +++ b/plugins/pychrysalide/analysis/types/encaps.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_encapsulated_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.EncapsulatedType'. */ -bool register_python_encapsulated_type(PyObject *); +bool ensure_python_encapsulated_type_is_registered(void); diff --git a/plugins/pychrysalide/analysis/types/expr.c b/plugins/pychrysalide/analysis/types/expr.c index 2988af9..619b2da 100644 --- a/plugins/pychrysalide/analysis/types/expr.c +++ b/plugins/pychrysalide/analysis/types/expr.c @@ -33,6 +33,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -168,17 +169,27 @@ PyTypeObject *get_python_expr_type_type(void) * * ******************************************************************************/ -bool register_python_expr_type(PyObject *module) +bool ensure_python_expr_type_is_registered(void) { - PyTypeObject *py_expr_type_type; /* Type Python 'ExprType' */ + PyTypeObject *type; /* Type Python 'ExprType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_expr_type_type = get_python_expr_type_type(); + type = get_python_expr_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_EXPR_TYPE, py_expr_type_type, get_python_data_type_type())) - return false; + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; + + if (!register_class_for_pygobject(dict, G_TYPE_EXPR_TYPE, type, get_python_data_type_type())) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/expr.h b/plugins/pychrysalide/analysis/types/expr.h index 4764892..6df17bd 100644 --- a/plugins/pychrysalide/analysis/types/expr.h +++ b/plugins/pychrysalide/analysis/types/expr.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_expr_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.ExprType'. */ -bool register_python_expr_type(PyObject *); +bool ensure_python_expr_type_is_registered(void); diff --git a/plugins/pychrysalide/analysis/types/literal.c b/plugins/pychrysalide/analysis/types/literal.c index 7523153..7299be6 100644 --- a/plugins/pychrysalide/analysis/types/literal.c +++ b/plugins/pychrysalide/analysis/types/literal.c @@ -32,6 +32,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -118,17 +119,27 @@ PyTypeObject *get_python_literal_type_type(void) * * ******************************************************************************/ -bool register_python_literal_type(PyObject *module) +bool ensure_python_literal_type_is_registered(void) { - PyTypeObject *py_literal_type_type; /* Type 'LiteralType' */ + PyTypeObject *type; /* Type 'LiteralType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_literal_type_type = get_python_literal_type_type(); + type = get_python_literal_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_LITERAL_TYPE, py_literal_type_type, get_python_data_type_type())) - return false; + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; + + if (!register_class_for_pygobject(dict, G_TYPE_LITERAL_TYPE, type, get_python_data_type_type())) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/literal.h b/plugins/pychrysalide/analysis/types/literal.h index 8340093..7e12a02 100644 --- a/plugins/pychrysalide/analysis/types/literal.h +++ b/plugins/pychrysalide/analysis/types/literal.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_literal_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.LiteralType'. */ -bool register_python_literal_type(PyObject *); +bool ensure_python_literal_type_is_registered(void); diff --git a/plugins/pychrysalide/analysis/types/module.c b/plugins/pychrysalide/analysis/types/module.c index 1566014..baa8ad1 100644 --- a/plugins/pychrysalide/analysis/types/module.c +++ b/plugins/pychrysalide/analysis/types/module.c @@ -37,29 +37,28 @@ #include "override.h" #include "proto.h" #include "template.h" -#include "../../access.h" +#include "../../helpers.h" /****************************************************************************** * * -* Paramètres : module = module dont la définition est à compléter. * +* Paramètres : super = module dont la définition est à compléter. * * * -* Description : Ajoute le module 'types' au module Python. * +* Description : Ajoute le module 'analysis.types' à un module Python. * * * -* Retour : - * +* Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -bool add_analysis_types_module_to_python_module(PyObject *super) +bool add_analysis_types_module(PyObject *super) { bool result; /* Bilan à retourner */ PyObject *module; /* Sous-module mis en place */ - int ret; /* Bilan d'un appel */ - static PyModuleDef py_chrysalide_types_module = { + static PyModuleDef py_chrysalide_analysis_types_module = { .m_base = PyModuleDef_HEAD_INIT, @@ -70,35 +69,42 @@ bool add_analysis_types_module_to_python_module(PyObject *super) }; - result = false; + module = build_python_module(super, &py_chrysalide_analysis_types_module); - module = PyModule_Create(&py_chrysalide_types_module); - if (module == NULL) return false; + result = (module != NULL); - ret = PyState_AddModule(super, &py_chrysalide_types_module); - if (ret != 0) goto loading_failed; + return result; - ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.types"); - if (ret != 0) goto loading_failed; +} - Py_INCREF(module); - ret = PyModule_AddObject(super, "types", module); - if (ret != 0) goto loading_failed; - result = register_python_array_type(module); - if (result) result = register_python_basic_type(module); - if (result) result = register_python_class_enum_type(module); - if (result) result = register_python_expr_type(module); - if (result) result = register_python_encapsulated_type(module); - if (result) result = register_python_literal_type(module); - if (result) result = register_python_override_type(module); - if (result) result = register_python_proto_type(module); - if (result) result = register_python_template_type(module); +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Intègre les objets du module 'analysis.types'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ - if (result) - register_access_to_python_module("pychrysalide.analysis.types", module); +bool populate_analysis_types_module(void) +{ + bool result; /* Bilan à retourner */ - loading_failed: + result = true; + + if (result) result = ensure_python_array_type_is_registered(); + if (result) result = ensure_python_basic_type_is_registered(); + if (result) result = ensure_python_class_enum_type_is_registered(); + if (result) result = ensure_python_expr_type_is_registered(); + if (result) result = ensure_python_encapsulated_type_is_registered(); + if (result) result = ensure_python_literal_type_is_registered(); + if (result) result = ensure_python_override_type_is_registered(); + if (result) result = ensure_python_proto_type_is_registered(); + if (result) result = ensure_python_template_type_is_registered(); assert(result); diff --git a/plugins/pychrysalide/analysis/types/module.h b/plugins/pychrysalide/analysis/types/module.h index 2c6824d..a53d427 100644 --- a/plugins/pychrysalide/analysis/types/module.h +++ b/plugins/pychrysalide/analysis/types/module.h @@ -31,8 +31,11 @@ -/* Ajoute le module 'types' au module Python. */ -bool add_analysis_types_module_to_python_module(PyObject *); +/* Ajoute le module 'analysis.types' à un module Python. */ +bool add_analysis_types_module(PyObject *); + +/* Intègre les objets du module 'analysis.types'. */ +bool populate_analysis_types_module(void); diff --git a/plugins/pychrysalide/analysis/types/override.c b/plugins/pychrysalide/analysis/types/override.c index 17e32e3..c4b57b6 100644 --- a/plugins/pychrysalide/analysis/types/override.c +++ b/plugins/pychrysalide/analysis/types/override.c @@ -32,6 +32,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -229,18 +230,27 @@ PyTypeObject *get_python_override_type_type(void) * * ******************************************************************************/ -bool register_python_override_type(PyObject *module) +bool ensure_python_override_type_is_registered(void) { - PyTypeObject *py_override_type_type;/* Type 'OverrideType' */ + PyTypeObject *type; /* Type 'OverrideType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_override_type_type = get_python_override_type_type(); + type = get_python_override_type_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.analysis.types"); + + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_OVERRIDE_TYPE, - py_override_type_type, get_python_data_type_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_OVERRIDE_TYPE, type, get_python_data_type_type())) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/override.h b/plugins/pychrysalide/analysis/types/override.h index 2e874ca..cd9a3da 100644 --- a/plugins/pychrysalide/analysis/types/override.h +++ b/plugins/pychrysalide/analysis/types/override.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_override_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.OverrideType'. */ -bool register_python_override_type(PyObject *); +bool ensure_python_override_type_is_registered(void); diff --git a/plugins/pychrysalide/analysis/types/proto.c b/plugins/pychrysalide/analysis/types/proto.c index ac60deb..0477f0d 100644 --- a/plugins/pychrysalide/analysis/types/proto.c +++ b/plugins/pychrysalide/analysis/types/proto.c @@ -33,6 +33,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -297,17 +298,27 @@ PyTypeObject *get_python_proto_type_type(void) * * ******************************************************************************/ -bool register_python_proto_type(PyObject *module) +bool ensure_python_proto_type_is_registered(void) { - PyTypeObject *py_proto_type_type; /* Type Python 'ProtoType' */ + PyTypeObject *type; /* Type Python 'ProtoType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_proto_type_type = get_python_proto_type_type(); + type = get_python_proto_type_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.analysis.types"); + + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_PROTO_TYPE, py_proto_type_type, get_python_data_type_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_PROTO_TYPE, type, get_python_data_type_type())) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/proto.h b/plugins/pychrysalide/analysis/types/proto.h index 4e98df2..44437e8 100644 --- a/plugins/pychrysalide/analysis/types/proto.h +++ b/plugins/pychrysalide/analysis/types/proto.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_proto_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.ProtoType'. */ -bool register_python_proto_type(PyObject *); +bool ensure_python_proto_type_is_registered(void); diff --git a/plugins/pychrysalide/analysis/types/template.c b/plugins/pychrysalide/analysis/types/template.c index b8b13fb..cd2fa52 100644 --- a/plugins/pychrysalide/analysis/types/template.c +++ b/plugins/pychrysalide/analysis/types/template.c @@ -34,6 +34,7 @@ #include "../type.h" +#include "../../access.h" #include "../../helpers.h" @@ -293,18 +294,27 @@ PyTypeObject *get_python_template_type_type(void) * * ******************************************************************************/ -bool register_python_template_type(PyObject *module) +bool ensure_python_template_type_is_registered(void) { - PyTypeObject *py_template_type_type; /* Type Python 'TemplateType' */ + PyTypeObject *type; /* Type Python 'TemplateType' */ + PyObject *module; /* Module à recompléter */ PyObject *dict; /* Dictionnaire du module */ - py_template_type_type = get_python_template_type_type(); + type = get_python_template_type_type(); - dict = PyModule_GetDict(module); + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + module = get_access_to_python_module("pychrysalide.analysis.types"); + + dict = PyModule_GetDict(module); + + if (!ensure_python_data_type_is_registered()) + return false; - if (!register_class_for_pygobject(dict, G_TYPE_TEMPLATE_TYPE, - py_template_type_type, get_python_data_type_type())) - return false; + if (!register_class_for_pygobject(dict, G_TYPE_TEMPLATE_TYPE, type, get_python_data_type_type())) + return false; + + } return true; diff --git a/plugins/pychrysalide/analysis/types/template.h b/plugins/pychrysalide/analysis/types/template.h index d5665e1..34f4ccd 100644 --- a/plugins/pychrysalide/analysis/types/template.h +++ b/plugins/pychrysalide/analysis/types/template.h @@ -35,7 +35,7 @@ PyTypeObject *get_python_template_type_type(void); /* Prend en charge l'objet 'pychrysalide.analysis.types.TemplateType'. */ -bool register_python_template_type(PyObject *); +bool ensure_python_template_type_is_registered(void); |