diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-05-03 18:15:46 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-05-03 18:15:46 (GMT) |
commit | 78da8b1ad594ca24292eb0f047698bc952b7b961 (patch) | |
tree | 1e461944f2a5d9f6b61eb6ca31048021580596cd /plugins/pychrysalide/arch/operands/immediate.c | |
parent | 85ddac0558313b5d3fbd9428ae3e9614f16d514d (diff) |
Defined the missing features required to build operands from Python.
Diffstat (limited to 'plugins/pychrysalide/arch/operands/immediate.c')
-rw-r--r-- | plugins/pychrysalide/arch/operands/immediate.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/plugins/pychrysalide/arch/operands/immediate.c b/plugins/pychrysalide/arch/operands/immediate.c index 39ce2e2..2634352 100644 --- a/plugins/pychrysalide/arch/operands/immediate.c +++ b/plugins/pychrysalide/arch/operands/immediate.c @@ -42,6 +42,7 @@ #include "../../access.h" #include "../../helpers.h" #include "../../analysis/content.h" +#include "../../glibext/bufferline.h" @@ -51,6 +52,12 @@ /* Crée un nouvel objet Python de type 'ImmOperand'. */ static PyObject *py_imm_operand_new(PyTypeObject *, PyObject *, PyObject *); +/* Compare un opérande avec un autre. */ +static PyObject *py_imm_operand___cmp__(PyObject *, PyObject *); + +/* Traduit un opérande en version humainement lisible. */ +static PyObject *py_imm_operand__print(PyObject *, PyObject *); + /* Renseigne la taille de la valeur indiquée à la construction. */ static PyObject *py_imm_operand_get_size(PyObject *, void *); @@ -158,6 +165,98 @@ static PyObject *py_imm_operand_new(PyTypeObject *type, PyObject *args, PyObject /****************************************************************************** * * +* Paramètres : self = serveur à manipuler. * +* args = arguments associés à l'appel. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_imm_operand___cmp__(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + GImmOperand *other; /* Autre opérande à manipuler */ + int ret; /* Bilan de lecture des args. */ + GImmOperand *operand; /* Elément à manipuler */ + int status; /* Bilan de comparaison */ + +#define IMM_OPERAND_CMP_METHOD PYTHON_METHOD_DEF \ +( \ + __cmp__, "$self, other, /", \ + METH_VARARGS, py_imm_operand, \ + "Implementation of the required method used to compare the" \ + " operand with another one. This second object is always" \ + " an pychrysalide.arch.ImmOperand instance.\n" \ + "\n" \ + "See the parent class for more information about this method." \ +) + + ret = PyArg_ParseTuple(args, "O&", convert_to_imm_operand, &other); + if (!ret) return NULL; + + operand = G_IMM_OPERAND(pygobject_get(self)); + + status = g_arch_operand_compare(G_ARCH_OPERAND(operand), G_ARCH_OPERAND(other)); + + result = PyLong_FromLong(status); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : self = serveur à manipuler. * +* args = arguments associés à l'appel. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_imm_operand__print(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + GBufferLine *line; /* Ligne fournie à peupler */ + int ret; /* Bilan de lecture des args. */ + GImmOperand *operand; /* Elément à manipuler */ + +#define IMM_OPERAND_PRINT_METHOD PYTHON_METHOD_DEF \ +( \ + _print, "$self, line, /", \ + METH_VARARGS, py_imm_operand, \ + "Implementation of the required method used to print the operand" \ + " into a rendering line, which is a provided" \ + " pychrysalide.glibext.BufferLine instance.\n" \ + "\n" \ + "See the parent class for more information about this method." \ +) + + ret = PyArg_ParseTuple(args, "O&", convert_to_buffer_line, &line); + if (!ret) return NULL; + + operand = G_IMM_OPERAND(pygobject_get(self)); + + g_arch_operand_print(G_ARCH_OPERAND(operand), line); + + result = Py_None; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -614,6 +713,8 @@ static int py_imm_operand_set_display(PyObject *self, PyObject *value, void *clo PyTypeObject *get_python_imm_operand_type(void) { static PyMethodDef py_imm_operand_methods[] = { + IMM_OPERAND_CMP_METHOD, + IMM_OPERAND_PRINT_METHOD, { NULL } }; |