summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-10-18 21:24:25 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-10-18 21:24:25 (GMT)
commit39f8a5c2a48a209507dbc3fd407052999954a199 (patch)
tree1dc29f7ddab258242c397e4a29a41913b5b24f66
parentf340a5d363c55d77aca047b6dd85dfaaae02bb6d (diff)
Updated the code for the types built from expressions.
-rw-r--r--plugins/itanium/component.c5
-rw-r--r--plugins/pychrysalide/analysis/types/expr.c27
-rw-r--r--src/analysis/types/expr.c6
-rw-r--r--src/analysis/types/expr.h2
4 files changed, 29 insertions, 11 deletions
diff --git a/plugins/itanium/component.c b/plugins/itanium/component.c
index 3baad57..25ea175 100644
--- a/plugins/itanium/component.c
+++ b/plugins/itanium/component.c
@@ -1407,6 +1407,7 @@ GDataType *itd_translate_component_to_type(const itanium_component *comp, Routin
GDataType *arg; /* Argument de prototype */
GDataType *members; /* Type de membres de tableau */
GDataType *param; /* Paramètre de gabarit */
+ char *value; /* Valeur quelconque exprimée */
/* Pour GCC !? */
result = NULL;
@@ -1855,7 +1856,9 @@ GDataType *itd_translate_component_to_type(const itanium_component *comp, Routin
break;
case ICT_OPERATED_EXPRESSION:
- result = g_expr_type_new(itd_translate_component(comp, NULL));
+ value = itd_translate_component(comp, NULL);
+ result = g_expr_type_new(value);
+ free(value);
break;
case ICT_STD_SUBST:
diff --git a/plugins/pychrysalide/analysis/types/expr.c b/plugins/pychrysalide/analysis/types/expr.c
index 0d68a60..02cb02f 100644
--- a/plugins/pychrysalide/analysis/types/expr.c
+++ b/plugins/pychrysalide/analysis/types/expr.c
@@ -67,10 +67,20 @@ static PyObject *py_expr_type_new(PyTypeObject *type, PyObject *args, PyObject *
int ret; /* Bilan de lecture des args. */
GDataType *dtype; /* Version GLib du type */
+#define EXPR_TYPE_DOC \
+ "The ExprType class handles raw expressions defined for some types.\n" \
+ "\n" \
+ "Instances can be created using the following constructor:\n" \
+ "\n" \
+ " ExprType(value)" \
+ "\n" \
+ "The *value* expression can be any string value, which is not further" \
+ " processed."
+
ret = PyArg_ParseTuple(args, "s", &value);
if (!ret) return NULL;
- dtype = g_expr_type_new(strdup(value));
+ dtype = g_expr_type_new(value);
result = pygobject_new(G_OBJECT(dtype));
g_object_unref(dtype);
@@ -98,6 +108,14 @@ static PyObject *py_expr_type_get_value(PyObject *self, void *closure)
GExprType *type; /* Version GLib du type */
const char *value; /* Valeur exprimée */
+#define EXPR_TYPE_VALUE_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ value, py_expr_type, \
+ "Value of the expression type.\n" \
+ "\n" \
+ "This value can be any string." \
+)
+
type = G_EXPR_TYPE(pygobject_get(self));
value = g_expr_type_get_value(type);
@@ -128,10 +146,7 @@ PyTypeObject *get_python_expr_type_type(void)
};
static PyGetSetDef py_expr_type_getseters[] = {
- {
- "value", py_expr_type_get_value, NULL,
- "Provide the value of the expression type.", NULL
- },
+ EXPR_TYPE_VALUE_ATTRIB,
{ NULL }
};
@@ -144,7 +159,7 @@ PyTypeObject *get_python_expr_type_type(void)
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = "PyChrysalide expr type",
+ .tp_doc = EXPR_TYPE_DOC,
.tp_methods = py_expr_type_methods,
.tp_getset = py_expr_type_getseters,
diff --git a/src/analysis/types/expr.c b/src/analysis/types/expr.c
index 376b0b4..02005f4 100644
--- a/src/analysis/types/expr.c
+++ b/src/analysis/types/expr.c
@@ -175,13 +175,13 @@ static void g_expr_type_finalize(GExprType *type)
* *
******************************************************************************/
-GDataType *g_expr_type_new(char *value)
+GDataType *g_expr_type_new(const char *value)
{
GExprType *result; /* Structure à retourner */
result = g_object_new(G_TYPE_EXPR_TYPE, NULL);
- result->value = value;
+ result->value = strdup(value);
return G_DATA_TYPE(result);
@@ -204,7 +204,7 @@ static GDataType *g_expr_type_dup(const GExprType *type)
{
GDataType *result; /* Copie à retourner */
- result = g_expr_type_new(strdup(type->value));
+ result = g_expr_type_new(type->value);
return result;
diff --git a/src/analysis/types/expr.h b/src/analysis/types/expr.h
index 3f7c953..45f66e3 100644
--- a/src/analysis/types/expr.h
+++ b/src/analysis/types/expr.h
@@ -51,7 +51,7 @@ typedef struct _GExprTypeClass GExprTypeClass;
GType g_expr_type_get_type(void);
/* Crée une représentation de type sous forme d'expressions. */
-GDataType *g_expr_type_new(char *);
+GDataType *g_expr_type_new(const char *);
/* Fournit la valeur d'un type fourni sous forme de caractères. */
const char *g_expr_type_get_value(const GExprType *);