diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2017-04-29 09:53:28 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2017-04-29 09:53:28 (GMT) | 
| commit | b16071a35adaf95d5e67b0dd984e9ba9d7ba28f9 (patch) | |
| tree | 10470449f230593ea62f696e30e647a1c8d95ed2 /plugins/pychrysa/arch/immediate.c | |
| parent | aead324676d997c30aac2851f4a37125db195d3e (diff) | |
Improved the behavior of immediate operands display.
Diffstat (limited to 'plugins/pychrysa/arch/immediate.c')
| -rw-r--r-- | plugins/pychrysa/arch/immediate.c | 81 | 
1 files changed, 81 insertions, 0 deletions
| diff --git a/plugins/pychrysa/arch/immediate.c b/plugins/pychrysa/arch/immediate.c index 363c3cc..69efa97 100644 --- a/plugins/pychrysa/arch/immediate.c +++ b/plugins/pychrysa/arch/immediate.c @@ -43,6 +43,12 @@  static PyObject *py_imm_operand_get_value(PyObject *, void *);  /* Indique si l'affichage est complété avec des zéros. */ +static PyObject *py_imm_operand_get_padding_by_default(PyObject *self, void *); + +/* Précise si des zéro doivent compléter l'affichage ou non. */ +static int py_imm_operand_set_padding_by_default(PyObject *, PyObject *, void *); + +/* Indique si l'affichage est complété avec des zéros. */  static PyObject *py_imm_operand_get_padding(PyObject *self, void *);  /* Précise si des zéro doivent compléter l'affichage ou non. */ @@ -195,6 +201,76 @@ static PyObject *py_imm_operand_get_value(PyObject *self, void *closure)  *                                                                             *  ******************************************************************************/ +static PyObject *py_imm_operand_get_padding_by_default(PyObject *self, void *closure) +{ +    PyObject *result;                       /* Instance Python à retourner */ +    GImmOperand *operand;                   /* Version GLib de l'opérande  */ +    bool padding;                           /* Bourrage en préfixe ?       */ + +    operand = G_IMM_OPERAND(pygobject_get(self)); +    assert(operand != NULL); + +    padding = g_imm_operand_does_padding_by_default(operand); + +    result = Py_BuildValue("p", padding); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : self    = objet Python concerné par l'appel.                 * +*                value   = valeur fournie à intégrer ou prendre en compte.    * +*                closure = non utilisé ici.                                   * +*                                                                             * +*  Description : Précise si des zéro doivent compléter l'affichage ou non.    * +*                                                                             * +*  Retour      : Bilan de l'opération pour Python.                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static int py_imm_operand_set_padding_by_default(PyObject *self, PyObject *value, void *closure) +{ +    bool padding;                           /* Bourrage en préfixe ?       */ +    GImmOperand *operand;                   /* Version GLib de l'opérande  */ + +    if (!PyBool_Check(value)) +    { +        PyErr_SetString(PyExc_TypeError, _("Invalid padding state")); +        return -1; +    } + +    padding = (value == Py_True); + +    operand = G_IMM_OPERAND(pygobject_get(self)); +    assert(operand != NULL); + +    g_imm_operand_pad_by_default(&operand, padding, NULL); + +    pygobject_set(self, operand); + +    return 0; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : self    = objet Python concerné par l'appel.                 * +*                closure = non utilisé ici.                                   * +*                                                                             * +*  Description : Indique si l'affichage est complété avec des zéros.          * +*                                                                             * +*  Retour      : true si des zéro sont ajoutés à l'affichage, false sinon.    * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ +  static PyObject *py_imm_operand_get_padding(PyObject *self, void *closure)  {      PyObject *result;                       /* Instance Python à retourner */ @@ -251,6 +327,7 @@ static int py_imm_operand_set_padding(PyObject *self, PyObject *value, void *clo  } +  /******************************************************************************  *                                                                             *  *  Paramètres  : self    = objet Python concerné par l'appel.                 * @@ -562,6 +639,10 @@ PyTypeObject *get_python_imm_operand_type(void)              "Status of padding with zeros in front of the textual representation.", NULL          },          { +            "default_padding", py_imm_operand_get_padding_by_default, py_imm_operand_set_padding_by_default, +            "Status of default padding with zeros in front of the textual representation.", NULL +        }, +        {              "default_display", py_imm_operand_get_default_display, py_imm_operand_set_default_display,              "Definition of the immediate operand default textual representation.", NULL          }, | 
