diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-08-19 09:39:33 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-09-12 04:43:34 (GMT) |
commit | 155c500b8933d2c7269215ea1d141d341de0a44f (patch) | |
tree | 520c55ae047f8e47236bc4476aa43011a226708d /plugins/pychrysalide/analysis/scan | |
parent | 9cceceee1691a9f6c36df508d278d5fb9af9f122 (diff) |
Remove old unused code.
Diffstat (limited to 'plugins/pychrysalide/analysis/scan')
-rw-r--r-- | plugins/pychrysalide/analysis/scan/constants.c | 27 | ||||
-rw-r--r-- | plugins/pychrysalide/analysis/scan/constants.h | 4 | ||||
-rw-r--r-- | plugins/pychrysalide/analysis/scan/expr.c | 56 |
3 files changed, 64 insertions, 23 deletions
diff --git a/plugins/pychrysalide/analysis/scan/constants.c b/plugins/pychrysalide/analysis/scan/constants.c index 87f3ae8..7ada8d3 100644 --- a/plugins/pychrysalide/analysis/scan/constants.c +++ b/plugins/pychrysalide/analysis/scan/constants.c @@ -51,13 +51,10 @@ bool define_expression_value_type_constants(PyTypeObject *type) values = PyDict_New(); - result = add_const_to_group(values, "BOOLEAN", EVT_BOOLEAN); - if (result) result = add_const_to_group(values, "INTEGER", EVT_INTEGER); - if (result) result = add_const_to_group(values, "STRING", EVT_STRING); - if (result) result = add_const_to_group(values, "REG_EXPR", EVT_REG_EXPR); - if (result) result = add_const_to_group(values, "COUNT", EVT_COUNT); - if (result) result = add_const_to_group(values, "PENDING", EVT_PENDING); - if (result) result = add_const_to_group(values, "UNRESOLVABLE", EVT_UNRESOLVABLE); + result = add_const_to_group(values, "SRS_PENDING", SRS_PENDING); + if (result) result = add_const_to_group(values, "REDUCED", SRS_REDUCED); + if (result) result = add_const_to_group(values, "WAIT_FOR_SCAN", SRS_WAIT_FOR_SCAN); + if (result) result = add_const_to_group(values, "UNRESOLVABLE", SRS_UNRESOLVABLE); if (!result) { @@ -65,8 +62,8 @@ bool define_expression_value_type_constants(PyTypeObject *type) goto exit; } - result = attach_constants_group_to_type(type, false, "ExprValueType", values, - "Natural type equivalent to a given scan expression."); + result = attach_constants_group_to_type(type, false, "ScanReductionState", values, + "State of a scanexpression during the reduction process."); exit: @@ -80,7 +77,7 @@ bool define_expression_value_type_constants(PyTypeObject *type) * Paramètres : arg = argument quelconque à tenter de convertir. * * dst = destination des valeurs récupérées en cas de succès. * * * -* Description : Tente de convertir en constante ExprValueType. * +* Description : Tente de convertir en constante ScanReductionState. * * * * Retour : Bilan de l'opération, voire indications supplémentaires. * * * @@ -88,7 +85,7 @@ bool define_expression_value_type_constants(PyTypeObject *type) * * ******************************************************************************/ -int convert_to_expression_value_type(PyObject *arg, void *dst) +int convert_to_scan_reduction_state(PyObject *arg, void *dst) { int result; /* Bilan à retourner */ unsigned long value; /* Valeur transcrite */ @@ -103,20 +100,20 @@ int convert_to_expression_value_type(PyObject *arg, void *dst) break; case 0: - PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to ExprValueType"); + PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to ScanReductionState"); break; case 1: value = PyLong_AsUnsignedLong(arg); - if (value > EVT_COUNT) + if (value > SRS_UNRESOLVABLE) { - PyErr_SetString(PyExc_TypeError, "invalid value for ExprValueType"); + PyErr_SetString(PyExc_TypeError, "invalid value for ScanReductionState"); result = 0; } else - *((ExprValueType *)dst) = value; + *((ScanReductionState *)dst) = value; break; diff --git a/plugins/pychrysalide/analysis/scan/constants.h b/plugins/pychrysalide/analysis/scan/constants.h index 65eb7bc..aa6c571 100644 --- a/plugins/pychrysalide/analysis/scan/constants.h +++ b/plugins/pychrysalide/analysis/scan/constants.h @@ -34,8 +34,8 @@ /* Définit les constantes relatives aux expressions de scan. */ bool define_expression_value_type_constants(PyTypeObject *); -/* Tente de convertir en constante ExprValueType. */ -int convert_to_expression_value_type(PyObject *, void *); +/* Tente de convertir en constante ScanReductionState. */ +int convert_to_scan_reduction_state(PyObject *, void *); diff --git a/plugins/pychrysalide/analysis/scan/expr.c b/plugins/pychrysalide/analysis/scan/expr.c index d1b5145..3622e9b 100644 --- a/plugins/pychrysalide/analysis/scan/expr.c +++ b/plugins/pychrysalide/analysis/scan/expr.c @@ -52,6 +52,9 @@ static int py_scan_expression_init(PyObject *, PyObject *, PyObject *); /* Réalise une comparaison entre objets selon un critère précis. */ static bool py_scan_expression_compare_rich_wrapper(const GScanExpression *, const GScanExpression *, RichCmpOperation, bool *); +/* Indique l'état de réduction d'une expression. */ +static PyObject *py_scan_expression_get_state(PyObject *, void *); + /****************************************************************************** @@ -90,11 +93,11 @@ static void py_scan_expression_init_gclass(GScanExpressionClass *class, gpointer static int py_scan_expression_init(PyObject *self, PyObject *args, PyObject *kwds) { - ExprValueType vtype; /* Type de valeur représentée */ + ScanReductionState state; /* Etat de réduction initial */ int ret; /* Bilan de lecture des args. */ GScanExpression *expr; /* Création GLib à transmettre */ - static char *kwlist[] = { "vtype", NULL }; + static char *kwlist[] = { "state", NULL }; #define SCAN_EXPRESSION_DOC \ "A ScanExpression is an abstract object which defines an expression"\ @@ -102,15 +105,16 @@ static int py_scan_expression_init(PyObject *self, PyObject *args, PyObject *kwd "\n" \ "Calls to the *__init__* constructor of this abstract object expect"\ " the following arguments as keyword parameters:\n" \ - "* *vtype*: type of the value carried by the expression, as a" \ - " pychrysalide.analysis.scan.ScanExpression.ExprValueType value." \ + "* *state*: initial state of reduction for the expression, as a" \ + " pychrysalide.analysis.scan.ScanExpression.ScanReductionState" \ + " value." \ "\n" \ "The following methods have to be defined for new classes:\n" \ "* pychrysalide.analysis.scan.ScanExpression._cmp_rich().\n" /* Récupération des paramètres */ - ret = PyArg_ParseTupleAndKeywords(args, kwds, "O&", kwlist, convert_to_expression_value_type, &vtype); + ret = PyArg_ParseTupleAndKeywords(args, kwds, "O&", kwlist, convert_to_scan_reduction_state, &state); if (!ret) return -1; /* Initialisation d'un objet GLib */ @@ -122,7 +126,7 @@ static int py_scan_expression_init(PyObject *self, PyObject *args, PyObject *kwd expr = G_SCAN_EXPRESSION(pygobject_get(self)); - if (!g_scan_expression_create(expr, vtype)) + if (!g_scan_expression_create(expr, state)) { PyErr_SetString(PyExc_ValueError, _("Unable to create scan expression.")); return -1; @@ -217,6 +221,45 @@ static bool py_scan_expression_compare_rich_wrapper(const GScanExpression *item, /****************************************************************************** * * +* Paramètres : self = objet Python concerné par l'appel. * +* closure = non utilisé ici. * +* * +* Description : Indique l'état de réduction d'une expression. * +* * +* Retour : Etat courant associé à l'expression. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_scan_expression_get_state(PyObject *self, void *closure) +{ + PyObject *result; /* Instance Python à retourner */ + GScanExpression *expr; /* Version GLib de l'opérande */ + ScanReductionState state; /* Etat courant de l'expression*/ + +#define SCAN_EXPRESSION_STATE_ATTRIB PYTHON_GET_DEF_FULL \ +( \ + state, py_scan_expression, \ + "Current state of the expression, relative to the reduction" \ + " process, as a" \ + " pychrysalide.analysis.scan.ScanExpression.ScanReductionState" \ + " value." \ +) + + expr = G_SCAN_EXPRESSION(pygobject_get(self)); + + state = g_scan_expression_get_state(expr); + + result = cast_with_constants_group_from_type(get_python_scan_expression_type(), "ScanReductionState", state); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : - * * * * Description : Fournit un accès à une définition de type à diffuser. * @@ -235,6 +278,7 @@ PyTypeObject *get_python_scan_expression_type(void) }; static PyGetSetDef py_scan_expression_getseters[] = { + SCAN_EXPRESSION_STATE_ATTRIB, { NULL } }; |