From e7325a7e273ea1df59aa949cf8b2614e1e6eb46e Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 31 Jan 2019 20:04:18 +0100 Subject: Extended the Python API for symbols. --- plugins/pychrysalide/format/symbol.c | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c index c948423..bb58f64 100644 --- a/plugins/pychrysalide/format/symbol.c +++ b/plugins/pychrysalide/format/symbol.c @@ -60,6 +60,9 @@ 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 *); +/* Définit la couverture physique / en mémoire d'un symbole. */ +static int py_binary_symbol_set_range(PyObject *, PyObject *, void *); + /* Fournit la visibilité du symbole. */ static PyObject *py_binary_symbol_get_status(PyObject *, void *); @@ -295,6 +298,40 @@ static PyObject *py_binary_symbol_get_range(PyObject *self, void *closure) /****************************************************************************** * * * Paramètres : self = objet Python concerné par l'appel. * +* value = valeur fournie à intégrer ou prendre en compte. * +* closure = adresse non utilisée ici. * +* * +* Description : Définit la couverture physique / en mémoire d'un symbole. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int py_binary_symbol_set_range(PyObject *self, PyObject *value, void *closure) +{ + int ret; /* Bilan d'analyse */ + mrange_t *range; /* Espace mémoire à manipuler */ + GBinSymbol *symbol; /* Elément à consulter */ + + ret = PyObject_IsInstance(value, (PyObject *)get_python_mrange_type()); + if (!ret) return -1; + + range = get_internal_mrange(value); + + symbol = G_BIN_SYMBOL(pygobject_get(self)); + + g_binary_symbol_set_range(symbol, range); + + return 0; + +} + + +/****************************************************************************** +* * +* Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * * Description : Fournit la visibilité du symbole. * @@ -391,7 +428,7 @@ PyTypeObject *get_python_binary_symbol_type(void) "Label of the symbol, provided by the internal component or by an alternative label.", NULL }, { - "range", py_binary_symbol_get_range, NULL, + "range", py_binary_symbol_get_range, py_binary_symbol_set_range, "Range covered by the symbol.", NULL }, { -- cgit v0.11.2-87-g4458