From 42d32a8c729e4fc0d8b1f3cf18ce870d55f59e26 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 1 Oct 2019 22:49:03 +0200 Subject: Extended the Python API for database items. --- plugins/pychrysalide/analysis/db/item.c | 47 +++++++++++++++++++++++++++++++-- plugins/pychrysalide/format/symbol.c | 2 ++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/plugins/pychrysalide/analysis/db/item.c b/plugins/pychrysalide/analysis/db/item.c index 7ef30af..fe51752 100644 --- a/plugins/pychrysalide/analysis/db/item.c +++ b/plugins/pychrysalide/analysis/db/item.c @@ -54,6 +54,16 @@ static PyObject *py_db_item_get_timestamp(PyObject *, void *); /* Indique les propriétés particulières appliquées à l'élément. */ static PyObject *py_db_item_get_flags(PyObject *, void *); +/* Applique un ensemble de propriétés à un élément. */ +static int py_db_item_set_flags(PyObject *, PyObject *, void *); + + + +#define DB_ITEM_DOC \ + "DbItem handles all kinds of updates applied to the disassebled code." \ + "\n" \ + "These items are managed using a client/server model." + /****************************************************************************** @@ -231,7 +241,7 @@ static PyObject *py_db_item_get_flags(PyObject *self, void *closure) GDbItem *item; /* Elément à consulter */ DbItemFlags flags; /* Propriétés de l'élément */ -#define DB_ITEM_FLAGS_ATTRIB PYTHON_GET_DEF_FULL \ +#define DB_ITEM_FLAGS_ATTRIB PYTHON_GETSET_DEF_FULL \ ( \ flags, py_db_item, \ "Properties of the database item, provided as a mask" \ @@ -251,6 +261,39 @@ static PyObject *py_db_item_get_flags(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 : Applique un ensemble de propriétés à un élément. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int py_db_item_set_flags(PyObject *self, PyObject *value, void *closure) +{ + GDbItem *item; /* Elément à consulter */ + DbItemFlags flags; /* Propriétés d'élément */ + + if (!PyLong_Check(value)) + return -1; + + item = G_DB_ITEM(pygobject_get(self)); + + flags = PyLong_AsUnsignedLong(value); + + g_db_item_set_flags(item, flags); + + return 0; + +} + + +/****************************************************************************** +* * * Paramètres : - * * * * Description : Fournit un accès à une définition de type à diffuser. * @@ -285,7 +328,7 @@ PyTypeObject *get_python_db_item_type(void) .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_doc = "PyChrysalide item for DataBase collection", + .tp_doc = DB_ITEM_DOC, .tp_methods = py_db_item_methods, .tp_getset = py_db_item_getseters, diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c index a88a260..873510d 100644 --- a/plugins/pychrysalide/format/symbol.c +++ b/plugins/pychrysalide/format/symbol.c @@ -469,6 +469,7 @@ static int py_binary_symbol_set_stype(PyObject *self, PyObject *value, void *clo return -1; symbol = G_BIN_SYMBOL(pygobject_get(self)); + type = PyLong_AsUnsignedLong(value); g_binary_symbol_set_stype(symbol, type); @@ -537,6 +538,7 @@ static int py_binary_symbol_set_status(PyObject *self, PyObject *value, void *cl return -1; symbol = G_BIN_SYMBOL(pygobject_get(self)); + status = PyLong_AsUnsignedLong(value); g_binary_symbol_set_status(symbol, status); -- cgit v0.11.2-87-g4458