summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/glibext
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/glibext
parent85bd3c6c415d42c0722298cf8e4542c94a87d7f1 (diff)
Introduced a new object of string constant sets.
Diffstat (limited to 'plugins/pychrysalide/glibext')
-rw-r--r--plugins/pychrysalide/glibext/binportion.c35
-rw-r--r--plugins/pychrysalide/glibext/constants.c13
2 files changed, 13 insertions, 35 deletions
diff --git a/plugins/pychrysalide/glibext/binportion.c b/plugins/pychrysalide/glibext/binportion.c
index 14df461..3065755 100644
--- a/plugins/pychrysalide/glibext/binportion.c
+++ b/plugins/pychrysalide/glibext/binportion.c
@@ -73,9 +73,6 @@ static PyObject *py_binary_portion_get_rights(PyObject *, void *);
/* Définit les droits associés à une partie de code. */
static int py_binary_portion_set_rights(PyObject *, PyObject *, void *);
-/* Définit les constantes pour les portions de binaire. */
-static bool py_binary_portion_define_constants(PyTypeObject *);
-
/******************************************************************************
@@ -608,35 +605,6 @@ static int py_binary_portion_set_rights(PyObject *self, PyObject *value, void *c
/******************************************************************************
* *
-* Paramètres : obj_type = type dont le dictionnaire est à compléter. *
-* *
-* Description : Définit les constantes pour les portions de binaire. *
-* *
-* Retour : true en cas de succès de l'opération, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool py_binary_portion_define_constants(PyTypeObject *obj_type)
-{
- bool result; /* Bilan à retourner */
-
- result = true;
-
- if (result) result = PyDict_AddStringMacro(obj_type, BPC_RAW);
- if (result) result = PyDict_AddStringMacro(obj_type, BPC_CODE);
- if (result) result = PyDict_AddStringMacro(obj_type, BPC_DATA);
- if (result) result = PyDict_AddStringMacro(obj_type, BPC_DATA_RO);
- if (result) result = PyDict_AddStringMacro(obj_type, BPC_DISASS_ERROR);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : - *
* *
* Description : Fournit un accès à une définition de type à diffuser. *
@@ -718,9 +686,6 @@ bool ensure_python_binary_portion_is_registered(void)
if (!register_class_for_pygobject(dict, G_TYPE_BIN_PORTION, type, &PyGObject_Type))
return false;
- if (!py_binary_portion_define_constants(type))
- return false;
-
if (!define_binary_portion_constants(type))
return false;
diff --git a/plugins/pychrysalide/glibext/constants.c b/plugins/pychrysalide/glibext/constants.c
index 680feaf..e24a6e0 100644
--- a/plugins/pychrysalide/glibext/constants.c
+++ b/plugins/pychrysalide/glibext/constants.c
@@ -49,8 +49,21 @@
bool define_binary_portion_constants(PyTypeObject *type)
{
bool result; /* Bilan à retourner */
+ PyObject *strdict; /* Groupe de chaînes constantes*/
PyObject *values; /* Groupe de valeurs à établir */
+ result = create_string_constants_group_to_type(type, "BinaryPortionCode",
+ "Selector names for the CSS rendering.", &strdict);
+
+ if (result) result = extend_string_constants_group(strdict, "RAW", BPC_RAW);
+ if (result) result = extend_string_constants_group(strdict, "CODE", BPC_CODE);
+ if (result) result = extend_string_constants_group(strdict, "DATA", BPC_DATA);
+ if (result) result = extend_string_constants_group(strdict, "DATA_RO", BPC_DATA_RO);
+ if (result) result = extend_string_constants_group(strdict, "DISASS_ERROR", BPC_DISASS_ERROR);
+
+ if (!result)
+ goto exit;
+
values = PyDict_New();
result = add_const_to_group(values, "NONE", PAC_NONE);