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/file.c | |
parent | 7b8eed3f8207fe9b629165f8230e38ee620900ea (diff) |
Registered properly the PyGObject wrappers for Python classes.
Diffstat (limited to 'plugins/pychrysa/analysis/contents/file.c')
-rw-r--r-- | plugins/pychrysa/analysis/contents/file.c | 71 |
1 files changed, 9 insertions, 62 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; |