diff options
Diffstat (limited to 'plugins/pychrysalide/analysis/scan/expr.c')
| -rw-r--r-- | plugins/pychrysalide/analysis/scan/expr.c | 56 | 
1 files changed, 50 insertions, 6 deletions
| 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 }      }; | 
