diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-07-30 10:57:08 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-07-30 10:57:08 (GMT) |
commit | fb1d26845908d131b1c92d7d7cd1bc402b656ca4 (patch) | |
tree | a6c6a30482ce97dfe7b985116877bb0ce8b7b0a0 /plugins/pychrysa/analysis/db | |
parent | 7b8eed3f8207fe9b629165f8230e38ee620900ea (diff) |
Registered properly the PyGObject wrappers for Python classes.
Diffstat (limited to 'plugins/pychrysa/analysis/db')
-rw-r--r-- | plugins/pychrysa/analysis/db/collection.c | 17 | ||||
-rw-r--r-- | plugins/pychrysa/analysis/db/item.c | 17 | ||||
-rw-r--r-- | plugins/pychrysa/analysis/db/items/comment.c | 15 |
3 files changed, 13 insertions, 36 deletions
diff --git a/plugins/pychrysa/analysis/db/collection.c b/plugins/pychrysa/analysis/db/collection.c index 87d46e5..60afb02 100644 --- a/plugins/pychrysa/analysis/db/collection.c +++ b/plugins/pychrysa/analysis/db/collection.c @@ -32,6 +32,9 @@ #include <analysis/db/collection.h> +#include "../../helpers.h" + + /****************************************************************************** * * @@ -93,25 +96,15 @@ PyTypeObject *get_python_db_collection_type(void) bool register_python_db_collection(PyObject *module) { PyTypeObject *py_db_collection_type; /* Type Python 'DbCollection' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_db_collection_type = get_python_db_collection_type(); - py_db_collection_type->tp_base = &PyGObject_Type; - py_db_collection_type->tp_basicsize = py_db_collection_type->tp_base->tp_basicsize; + dict = PyModule_GetDict(module); - if (PyType_Ready(py_db_collection_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_DB_COLLECTION, py_db_collection_type, &PyGObject_Type)) return false; - Py_INCREF(py_db_collection_type); - ret = PyModule_AddObject(module, "DbCollection", (PyObject *)py_db_collection_type); - if (ret != 0) return false; - - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "DbCollection", G_TYPE_DB_COLLECTION, py_db_collection_type, - Py_BuildValue("(O)", py_db_collection_type->tp_base)); - return true; } diff --git a/plugins/pychrysa/analysis/db/item.c b/plugins/pychrysa/analysis/db/item.c index 4f536b4..e314552 100644 --- a/plugins/pychrysa/analysis/db/item.c +++ b/plugins/pychrysa/analysis/db/item.c @@ -32,6 +32,9 @@ #include <analysis/db/item.h> +#include "../../helpers.h" + + /* Indique si l'élément contient des données à oublier ou non. */ static PyObject *py_db_item_get_volatile(PyObject *, void *); @@ -165,25 +168,15 @@ PyTypeObject *get_python_db_item_type(void) bool register_python_db_item(PyObject *module) { PyTypeObject *py_db_item_type; /* Type Python 'DbItem' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_db_item_type = get_python_db_item_type(); - py_db_item_type->tp_base = &PyGObject_Type; - py_db_item_type->tp_basicsize = py_db_item_type->tp_base->tp_basicsize; + dict = PyModule_GetDict(module); - if (PyType_Ready(py_db_item_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_DB_ITEM, py_db_item_type, &PyGObject_Type)) return false; - Py_INCREF(py_db_item_type); - ret = PyModule_AddObject(module, "DbItem", (PyObject *)py_db_item_type); - if (ret != 0) return false; - - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "DbItem", G_TYPE_DB_ITEM, py_db_item_type, - Py_BuildValue("(O)", py_db_item_type->tp_base)); - return true; } diff --git a/plugins/pychrysa/analysis/db/items/comment.c b/plugins/pychrysa/analysis/db/items/comment.c index ead5179..5ce54c9 100644 --- a/plugins/pychrysa/analysis/db/items/comment.c +++ b/plugins/pychrysa/analysis/db/items/comment.c @@ -33,6 +33,7 @@ #include "../item.h" +#include "../../../helpers.h" #include "../../../arch/vmpa.h" @@ -213,25 +214,15 @@ PyTypeObject *get_python_db_comment_type(void) bool register_python_db_comment(PyObject *module) { PyTypeObject *py_db_comment_type; /* Type Python 'DbComment' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_db_comment_type = get_python_db_comment_type(); - py_db_comment_type->tp_base = get_python_db_item_type(); - py_db_comment_type->tp_basicsize = py_db_comment_type->tp_base->tp_basicsize; + dict = PyModule_GetDict(module); - if (PyType_Ready(py_db_comment_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_DB_COMMENT, py_db_comment_type, get_python_db_item_type())) return false; - Py_INCREF(py_db_comment_type); - ret = PyModule_AddObject(module, "DbComment", (PyObject *)py_db_comment_type); - if (ret != 0) return false; - - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "DbComment", G_TYPE_DB_COMMENT, py_db_comment_type, - Py_BuildValue("(O)", py_db_comment_type->tp_base)); - return true; } |