diff options
Diffstat (limited to 'plugins/pychrysa/format')
-rw-r--r-- | plugins/pychrysa/format/symbol.c | 95 |
1 files changed, 13 insertions, 82 deletions
diff --git a/plugins/pychrysa/format/symbol.c b/plugins/pychrysa/format/symbol.c index 008aeb3..e337ea1 100644 --- a/plugins/pychrysa/format/symbol.c +++ b/plugins/pychrysa/format/symbol.c @@ -48,9 +48,6 @@ static PyObject *py_binary_symbol_richcompare(PyObject *, PyObject *, int); /* Définit un autre nom pour le symbole. */ static PyObject *py_binary_symbol_set_alt_label(PyObject *, PyObject *); -/* Attache la routine associée au symbole. */ -static PyObject *py_binary_symbol_attach_routine(PyObject *, PyObject *); - /* Fournit le type du symbole. */ static PyObject *py_binary_symbol_get_target_type(PyObject *, void *); @@ -60,9 +57,6 @@ static PyObject *py_binary_symbol_get_label(PyObject *, void *); /* Fournit l'emplacement où se situe un symbole. */ static PyObject *py_binary_symbol_get_range(PyObject *, void *); -/* Fournit l'éventuelle routine associée au symbole. */ -static PyObject *py_binary_symbol_get_routine(PyObject *, void *); - /* Définit les constantes pour les symboles binaires. */ static bool py_binary_symbol_define_constants(PyTypeObject *); @@ -131,10 +125,12 @@ static PyObject *py_binary_symbol_new(PyTypeObject *type, PyObject *args, PyObje { PyObject *result; /* Bilan à retourner */ SymbolType stype; /* Type prévu pour le symbole */ + PyObject *range_obj; /* Objet pour la couverture */ int ret; /* Bilan de lecture des args. */ + mrange_t *range; /* Version native d'un espace */ GBinSymbol *symbol; /* Version GLib du symble */ - ret = PyArg_ParseTuple(args, "l", &stype); + ret = PyArg_ParseTuple(args, "lO", &stype, &range_obj); if (!ret) return NULL; if (stype >= STP_COUNT) @@ -143,7 +139,16 @@ static PyObject *py_binary_symbol_new(PyTypeObject *type, PyObject *args, PyObje return NULL; } - symbol = g_binary_symbol_new(stype); + ret = PyObject_IsInstance(range_obj, (PyObject *)get_python_mrange_type()); + if (!ret) + { + PyErr_SetString(PyExc_TypeError, _("The second argument must be an instance of mrange.")); + return NULL; + } + + range = get_internal_mrange(range_obj); + + symbol = g_binary_symbol_new(range, stype); result = pygobject_new(G_OBJECT(symbol)); g_object_unref(symbol); @@ -186,42 +191,6 @@ static PyObject *py_binary_symbol_set_alt_label(PyObject *self, PyObject *args) /****************************************************************************** * * -* Paramètres : self = classe représentant un binaire. * -* args = arguments fournis à l'appel. * -* * -* Description : Attache la routine associée au symbole. * -* * -* Retour : None. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_binary_symbol_attach_routine(PyObject *self, PyObject *args) -{ - PyObject *py_routine; /* Routine version Python */ - int ret; /* Bilan de lecture des args. */ - GBinSymbol *symbol; /* Elément à consulter */ - GBinRoutine *routine; /* Routine à attacher */ - - ret = PyArg_ParseTuple(args, "O", &py_routine); - if (!ret) return NULL; - - ret = PyObject_IsInstance(py_routine, (PyObject *)get_python_binary_routine_type()); - if (!ret) return NULL; - - symbol = G_BIN_SYMBOL(pygobject_get(self)); - routine = G_BIN_ROUTINE(pygobject_get(py_routine)); - - g_binary_symbol_attach_routine(symbol, routine); - - Py_RETURN_NONE; - -} - - -/****************************************************************************** -* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -316,35 +285,6 @@ static PyObject *py_binary_symbol_get_range(PyObject *self, void *closure) /****************************************************************************** * * -* Paramètres : self = objet Python concerné par l'appel. * -* closure = non utilisé ici. * -* * -* Description : Fournit l'éventuelle routine associée au symbole. * -* * -* Retour : Instance en place ou None si aucune. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_binary_symbol_get_routine(PyObject *self, void *closure) -{ - PyObject *result; /* Valeur à retourner */ - GBinSymbol *symbol; /* Elément à consulter */ - GBinRoutine *routine; /* Routine attachée */ - - symbol = G_BIN_SYMBOL(pygobject_get(self)); - routine = g_binary_symbol_get_routine(symbol); - - result = pygobject_new(G_OBJECT(routine)); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : obj_type = type dont le dictionnaire est à compléter. * * * * Description : Définit les constantes pour les symboles binaires. * @@ -395,11 +335,6 @@ PyTypeObject *get_python_binary_symbol_type(void) METH_VARARGS, "set_alt_label($self, alt, /)\n--\n\nSet an alternative label for the symbol." }, - { - "attach_routine", py_binary_symbol_attach_routine, - METH_VARARGS, - "attach_routine($self, instr, /)\n--\n\nAttach a provided routine to the current symbol." - }, { NULL } }; @@ -416,10 +351,6 @@ PyTypeObject *get_python_binary_symbol_type(void) "range", py_binary_symbol_get_range, NULL, "Range covered by the symbol.", NULL }, - { - "routine", py_binary_symbol_get_routine, NULL, - "Potential routine attached to the symbol.", NULL - }, { NULL } }; |