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/contents | |
parent | 7b8eed3f8207fe9b629165f8230e38ee620900ea (diff) |
Registered properly the PyGObject wrappers for Python classes.
Diffstat (limited to 'plugins/pychrysa/analysis/contents')
-rw-r--r-- | plugins/pychrysa/analysis/contents/file.c | 71 | ||||
-rw-r--r-- | plugins/pychrysa/analysis/contents/file.h | 2 | ||||
-rw-r--r-- | plugins/pychrysa/analysis/contents/restricted.c | 70 | ||||
-rw-r--r-- | plugins/pychrysa/analysis/contents/restricted.h | 2 |
4 files changed, 19 insertions, 126 deletions
diff --git a/plugins/pychrysa/analysis/contents/file.c b/plugins/pychrysa/analysis/contents/file.c index 897561e..c9f880f 100644 --- a/plugins/pychrysa/analysis/contents/file.c +++ b/plugins/pychrysa/analysis/contents/file.c @@ -31,6 +31,9 @@ #include <analysis/contents/file.h> +#include "../../helpers.h" + + /* Crée un nouvel objet Python de type 'BinContent'. */ static PyObject *py_file_content_new(PyTypeObject *, PyObject *, PyObject *); @@ -85,41 +88,8 @@ static PyObject *py_file_content_new(PyTypeObject *type, PyObject *args, PyObjec * * ******************************************************************************/ - - -PyMethodDef py_file_content_methods[] = { - { NULL } -}; - -PyGetSetDef py_file_content_getseters[] = { - { NULL } -}; - -PyTypeObject py_file_content_type = { - - PyVarObject_HEAD_INIT(NULL, 0) - - .tp_name = "pychrysalide.analysis.contents.FileContent", - .tp_basicsize = sizeof(PyGObject), - - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - - .tp_doc = "PyChrysalide binary file content", - - /* - .tp_methods = py_file_content_methods, - .tp_getset = py_file_content_getseters, - .tp_new = (newfunc)py_file_content_new - */ - .tp_new = (newfunc)py_file_content_new - -}; - - - PyTypeObject *get_python_file_content_type(void) { -#if 0 static PyMethodDef py_file_content_methods[] = { { NULL } }; @@ -135,18 +105,16 @@ PyTypeObject *get_python_file_content_type(void) .tp_name = "pychrysalide.analysis.contents.FileContent", .tp_basicsize = sizeof(PyGObject), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | 1 << 9, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_doc = "PyChrysalide binary file content", - /* .tp_methods = py_file_content_methods, .tp_getset = py_file_content_getseters, .tp_new = (newfunc)py_file_content_new - */ }; -#endif + return &py_file_content_type; } @@ -156,46 +124,25 @@ PyTypeObject *get_python_file_content_type(void) * * * Paramètres : module = module dont la définition est à compléter. * * * -* Description : Prend en charge l'objet 'pychrysalide.glibext.BinContent'. * +* Description : Prend en charge l'objet 'pychrysalide.....FileContent'. * * * * Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -#include "../content.h"////////////////////////////////////////// + bool register_python_file_content(PyObject *module) { - PyTypeObject *py_file_content_type; /* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ + PyTypeObject *py_file_content_type; /* Type Python 'FileContent' */ PyObject *dict; /* Dictionnaire du module */ py_file_content_type = get_python_file_content_type(); - //py_file_content_type->tp_base = &PyGObject_Type; - //py_file_content_type->tp_basicsize = py_file_content_type->tp_base->tp_basicsize; - - /* - if (PyType_Ready(py_file_content_type) != 0) - return false; - */ - - /* - Py_INCREF(py_file_content_type); - ret = PyModule_AddObject(module, "FileContent", (PyObject *)py_file_content_type); - if (ret != 0) return false; - */ - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "FileContent", G_TYPE_FILE_CONTENT, py_file_content_type, - Py_BuildValue("(O)", &PyGObject_Type/*py_file_content_type->tp_base*/, - get_python_binary_content_type())); - /* - if (PyType_Ready(py_file_content_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_FILE_CONTENT, py_file_content_type, &PyGObject_Type)) return false; - */ - return true; diff --git a/plugins/pychrysa/analysis/contents/file.h b/plugins/pychrysa/analysis/contents/file.h index a9edcef..4652ad6 100644 --- a/plugins/pychrysa/analysis/contents/file.h +++ b/plugins/pychrysa/analysis/contents/file.h @@ -34,7 +34,7 @@ /* Fournit un accès à une définition de type à diffuser. */ PyTypeObject *get_python_file_content_type(void); -/* Prend en charge l'objet 'pychrysalide.glibext.BinContent'. */ +/* Prend en charge l'objet 'pychrysalide.analysis.contents.FileContent'. */ bool register_python_file_content(PyObject *); diff --git a/plugins/pychrysa/analysis/contents/restricted.c b/plugins/pychrysa/analysis/contents/restricted.c index 0b8c7da..300031a 100644 --- a/plugins/pychrysa/analysis/contents/restricted.c +++ b/plugins/pychrysa/analysis/contents/restricted.c @@ -35,6 +35,7 @@ #include "../content.h" +#include "../../helpers.h" #include "../../arch/vmpa.h" @@ -110,41 +111,8 @@ static PyObject *py_restricted_content_new(PyTypeObject *type, PyObject *args, P * * ******************************************************************************/ - - -PyMethodDef py_restricted_content_methods[] = { - { NULL } -}; - -PyGetSetDef py_restricted_content_getseters[] = { - { NULL } -}; - -PyTypeObject py_restricted_content_type = { - - PyVarObject_HEAD_INIT(NULL, 0) - - .tp_name = "pychrysalide.analysis.contents.RestrictedContent", - .tp_basicsize = sizeof(PyGObject), - - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - - .tp_doc = "PyChrysalide binary restricted content", - - /* - .tp_methods = py_restricted_content_methods, - .tp_getset = py_restricted_content_getseters, - .tp_new = (newfunc)py_restricted_content_new - */ - .tp_new = (newfunc)py_restricted_content_new - -}; - - - PyTypeObject *get_python_restricted_content_type(void) { -#if 0 static PyMethodDef py_restricted_content_methods[] = { { NULL } }; @@ -160,18 +128,16 @@ PyTypeObject *get_python_restricted_content_type(void) .tp_name = "pychrysalide.analysis.contents.RestrictedContent", .tp_basicsize = sizeof(PyGObject), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | 1 << 9, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_doc = "PyChrysalide binary restricted content", - /* .tp_methods = py_restricted_content_methods, .tp_getset = py_restricted_content_getseters, .tp_new = (newfunc)py_restricted_content_new - */ }; -#endif + return &py_restricted_content_type; } @@ -181,46 +147,26 @@ PyTypeObject *get_python_restricted_content_type(void) * * * Paramètres : module = module dont la définition est à compléter. * * * -* Description : Prend en charge l'objet 'pychrysalide.glibext.BinContent'. * +* Description : Prend en charge l'objet 'pychrysalide.....RestrictedContent'.* * * * Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -#include "../content.h"////////////////////////////////////////// + bool register_python_restricted_content(PyObject *module) { - PyTypeObject *py_restricted_content_type; /* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ + PyTypeObject *py_restricted_content_type;/* Type Python 'BinContent' */ PyObject *dict; /* Dictionnaire du module */ py_restricted_content_type = get_python_restricted_content_type(); - //py_restricted_content_type->tp_base = &PyGObject_Type; - //py_restricted_content_type->tp_basicsize = py_restricted_content_type->tp_base->tp_basicsize; - - /* - if (PyType_Ready(py_restricted_content_type) != 0) - return false; - */ - - /* - Py_INCREF(py_restricted_content_type); - ret = PyModule_AddObject(module, "RestrictedContent", (PyObject *)py_restricted_content_type); - if (ret != 0) return false; - */ - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "RestrictedContent", G_TYPE_RESTRICTED_CONTENT, py_restricted_content_type, - Py_BuildValue("(O)", &PyGObject_Type/*py_restricted_content_type->tp_base*/, - get_python_binary_content_type())); - /* - if (PyType_Ready(py_restricted_content_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_RESTRICTED_CONTENT, + py_restricted_content_type, &PyGObject_Type)) return false; - */ - return true; diff --git a/plugins/pychrysa/analysis/contents/restricted.h b/plugins/pychrysa/analysis/contents/restricted.h index 24f2697..46875e2 100644 --- a/plugins/pychrysa/analysis/contents/restricted.h +++ b/plugins/pychrysa/analysis/contents/restricted.h @@ -34,7 +34,7 @@ /* Fournit un accès à une définition de type à diffuser. */ PyTypeObject *get_python_restricted_content_type(void); -/* Prend en charge l'objet 'pychrysalide.glibext.BinContent'. */ +/* Prend en charge l'objet 'pychrysalide.analysis.contents.RestrictedContent'. */ bool register_python_restricted_content(PyObject *); |