diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-09-11 21:25:13 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-09-11 21:25:13 (GMT) |
commit | 83faef9c8f78b20cb031af686f763cfb215cf9d7 (patch) | |
tree | ea95f741855044f4473573726804c6c2bcac5db1 /plugins/pychrysalide/analysis/db/item.c | |
parent | 3e1347d378e7ff0e21fb53b61e0317b8dfe52fc9 (diff) |
Reactivated bookmarks for disassembled code.
Diffstat (limited to 'plugins/pychrysalide/analysis/db/item.c')
-rw-r--r-- | plugins/pychrysalide/analysis/db/item.c | 137 |
1 files changed, 135 insertions, 2 deletions
diff --git a/plugins/pychrysalide/analysis/db/item.c b/plugins/pychrysalide/analysis/db/item.c index 981e0c0..bbaa21b 100644 --- a/plugins/pychrysalide/analysis/db/item.c +++ b/plugins/pychrysalide/analysis/db/item.c @@ -32,17 +32,109 @@ #include <analysis/db/item.h> +#include "constants.h" #include "../../access.h" #include "../../helpers.h" +/* Ajoute une propriété à un élément de base de données. */ +static PyObject *py_db_item_add_flag(PyObject *, PyObject *); + +/* Retire une propriété à un élément de base de données. */ +static PyObject *py_db_item_remove_flag(PyObject *, PyObject *); + /* Indique si l'élément contient des données à oublier ou non. */ static PyObject *py_db_item_get_volatile(PyObject *, void *); /* Définit si l'élément contient des données à oublier ou non. */ static int py_db_item_set_volatile(PyObject *, PyObject *, void *); +/* Indique les propriétés particulières appliquées à l'élément. */ +static PyObject *py_db_item_get_flags(PyObject *, void *); + + + +/****************************************************************************** +* * +* Paramètres : self = serveur à manipuler. * +* args = arguments d'appel non utilisés ici. * +* * +* Description : Ajoute une propriété à un élément de base de données. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_db_item_add_flag(PyObject *self, PyObject *args) +{ + unsigned int flag; /* Propriété à traiter */ + int ret; /* Bilan de lecture des args. */ + GDbItem *item; /* Elément à manipuler */ + +#define DB_ITEM_ADD_FLAG_METHOD PYTHON_METHOD_DEF \ +( \ + add_flag, "$self, flag, /", \ + METH_VARARGS, py_db_item, \ + "Add a property to a database item." \ + "\n" \ + "This property is one of the values listed in the" \ + " of pychrysalide.analysis.db.DbItem.DbItemFlags enumeration." \ +) + + ret = PyArg_ParseTuple(args, "I", &flag); + if (!ret) return NULL; + + item = G_DB_ITEM(pygobject_get(self)); + + g_db_item_add_flag(item, flag); + + Py_RETURN_NONE; + +} + + +/****************************************************************************** +* * +* Paramètres : self = serveur à manipuler. * +* args = arguments d'appel non utilisés ici. * +* * +* Description : Retire une propriété à un élément de base de données. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_db_item_remove_flag(PyObject *self, PyObject *args) +{ + unsigned int flag; /* Propriété à traiter */ + int ret; /* Bilan de lecture des args. */ + GDbItem *item; /* Elément à manipuler */ + +#define DB_ITEM_REMOVE_FLAG_METHOD PYTHON_METHOD_DEF \ +( \ + remove_flag, "$self, flag, /", \ + METH_VARARGS, py_db_item, \ + "Remove a property from a database item." \ + "\n" \ + "This property is one of the values listed in the" \ + " of pychrysalide.analysis.db.DbItem.DbItemFlags enumeration." \ +) + + ret = PyArg_ParseTuple(args, "I", &flag); + if (!ret) return NULL; + + item = G_DB_ITEM(pygobject_get(self)); + + g_db_item_remove_flag(item, flag); + + Py_RETURN_NONE; + +} /****************************************************************************** @@ -107,6 +199,43 @@ static int py_db_item_set_volatile(PyObject *self, PyObject *value, void *closur /****************************************************************************** * * +* Paramètres : self = objet Python concerné par l'appel. * +* closure = non utilisé ici. * +* * +* Description : Indique les propriétés particulières appliquées à l'élément. * +* * +* Retour : Propriétés actives de l'élément. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_db_item_get_flags(PyObject *self, void *closure) +{ + PyObject *result; /* Valeur à retourner */ + GDbItem *item; /* Elément à consulter */ + DbItemFlags flags; /* Propriétés de l'élément */ + +#define DB_ITEM_FLAGS_ATTRIB PYTHON_GET_DEF_FULL \ +( \ + flags, py_db_item, \ + "Properties of the database item, provided as a mask" \ + " of pychrysalide.analysis.db.DbItem.DbItemFlags values." \ +) + + item = G_DB_ITEM(pygobject_get(self)); + + flags = g_db_item_get_flags(item); + + result = cast_with_constants_group(get_python_db_item_type(), "DbItemFlags", flags); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : - * * * * Description : Fournit un accès à une définition de type à diffuser. * @@ -120,17 +249,18 @@ static int py_db_item_set_volatile(PyObject *self, PyObject *value, void *closur PyTypeObject *get_python_db_item_type(void) { static PyMethodDef py_db_item_methods[] = { + DB_ITEM_ADD_FLAG_METHOD, + DB_ITEM_REMOVE_FLAG_METHOD, { NULL } }; static PyGetSetDef py_db_item_getseters[] = { - { "volatile", py_db_item_get_volatile, py_db_item_set_volatile, "Define if a Database item can be forgotten.", NULL }, + DB_ITEM_FLAGS_ATTRIB, { NULL } - }; static PyTypeObject py_db_item_type = { @@ -183,6 +313,9 @@ bool ensure_python_db_item_is_registered(void) if (!register_class_for_pygobject(dict, G_TYPE_DB_ITEM, type, &PyGObject_Type)) return false; + if (!define_db_item_constants(type)) + return false; + } return true; |