summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-05-17 08:48:02 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-05-17 08:48:02 (GMT)
commitf3e136eab9fd6adcb51988c9f70ca7f35552abc4 (patch)
tree69c074fec2b72637bd01142add44b130dd13a909 /plugins/pychrysalide/helpers.c
parent85bd3c6c415d42c0722298cf8e4542c94a87d7f1 (diff)
Introduced a new object of string constant sets.
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r--plugins/pychrysalide/helpers.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index 5e911ea..73fb4a7 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -40,6 +40,7 @@
#include "access.h"
#include "constval.h"
+#include "strenum.h"
@@ -1324,3 +1325,71 @@ PyObject *_cast_with_constants_group(const char *owner, const char *name, unsign
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : dict = dictionnaire dont le contenu est à compléter. *
+* name = désignation humaine du groupe à constituer. *
+* doc = documentation à associer au groupe. *
+* out = dictionnaire à compléter. [OUT] *
+* *
+* Description : Officialise un groupe de constantes de chaînes de caractères.*
+* *
+* Retour : true en cas de succès de l'opération, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool _create_string_constants_group(PyObject *dict, const char *name, const char *doc, PyObject **out)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *class; /* Classe "Enum*" */
+ PyObject *args; /* Argument de construction */
+ int ret; /* Bilan d'une insertion */
+ PyObject *features; /* Module à recompléter */
+ PyObject *features_dict; /* Dictionnaire à compléter */
+
+ result = false;
+
+ /* Recherche et instanciation de la classe Python */
+
+ class = (PyObject *)get_python_string_enum_type();
+
+ args = Py_BuildValue("(s)", doc);
+
+ *out = PyObject_CallObject(class, args);
+
+ Py_DECREF(args);
+
+ if (*out == NULL)
+ goto exit;
+
+ /* Constitution de l'énumération et enregistrement */
+
+ ret = PyDict_SetItemString(dict, name, *out);
+ if (ret != 0) goto register_0_error;
+
+ features = get_access_to_python_module("pychrysalide.features");
+
+ features_dict = PyModule_GetDict(features);
+
+ ret = PyDict_SetItemString(features_dict, name, *out);
+ if (ret != 0) goto register_1_error;
+
+ result = true;
+
+ /* Sortie propre */
+
+ register_1_error:
+ register_0_error:
+
+ if (!result)
+ Py_DECREF(*out);
+
+ exit:
+
+ return result;
+
+}