summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/analysis')
-rw-r--r--plugins/pychrysa/analysis/binary.c16
-rw-r--r--plugins/pychrysa/analysis/block.c14
-rw-r--r--plugins/pychrysa/analysis/blocks/flow.c19
-rw-r--r--plugins/pychrysa/analysis/blocks/virtual.c16
-rw-r--r--plugins/pychrysa/analysis/content.c27
-rw-r--r--plugins/pychrysa/analysis/contents/file.c71
-rw-r--r--plugins/pychrysa/analysis/contents/file.h2
-rw-r--r--plugins/pychrysa/analysis/contents/restricted.c70
-rw-r--r--plugins/pychrysa/analysis/contents/restricted.h2
-rw-r--r--plugins/pychrysa/analysis/db/collection.c17
-rw-r--r--plugins/pychrysa/analysis/db/item.c17
-rw-r--r--plugins/pychrysa/analysis/db/items/comment.c15
-rw-r--r--plugins/pychrysa/analysis/routine.c17
13 files changed, 50 insertions, 253 deletions
diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c
index 93b1c57..14bf450 100644
--- a/plugins/pychrysa/analysis/binary.c
+++ b/plugins/pychrysa/analysis/binary.c
@@ -330,27 +330,15 @@ PyTypeObject *get_python_loaded_binary_type(void)
bool register_python_loaded_binary(PyObject *module)
{
PyTypeObject *py_loaded_binary_type; /* Type Python 'LoadedBinary' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_loaded_binary_type = get_python_loaded_binary_type();
- py_loaded_binary_type->tp_base = &PyGObject_Type;
- py_loaded_binary_type->tp_basicsize = py_loaded_binary_type->tp_base->tp_basicsize;
-
- //APPLY_ABSTRACT_FLAG(py_loaded_binary_type);
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_loaded_binary_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_LOADED_BINARY, py_loaded_binary_type, &PyGObject_Type))
return false;
- Py_INCREF(py_loaded_binary_type);
- ret = PyModule_AddObject(module, "LoadedBinary", (PyObject *)py_loaded_binary_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "LoadedBinary", G_TYPE_LOADED_BINARY, py_loaded_binary_type,
- Py_BuildValue("(O)", py_loaded_binary_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/analysis/block.c b/plugins/pychrysa/analysis/block.c
index 4cbc353..3ee7fcd 100644
--- a/plugins/pychrysa/analysis/block.c
+++ b/plugins/pychrysa/analysis/block.c
@@ -257,28 +257,18 @@ PyTypeObject *get_python_instr_block_type(void)
bool register_python_instr_block(PyObject *module)
{
PyTypeObject *py_instr_block_type; /* Type Python 'InstrBlock' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_instr_block_type = get_python_instr_block_type();
- py_instr_block_type->tp_base = &PyGObject_Type;
- py_instr_block_type->tp_basicsize = py_instr_block_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_instr_block_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_INSTR_BLOCK, py_instr_block_type, &PyGObject_Type))
return false;
if (!py_instructions_block_define_constants(py_instr_block_type))
return false;
- Py_INCREF(py_instr_block_type);
- ret = PyModule_AddObject(module, "InstrBlock", (PyObject *)py_instr_block_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "InstrBlock", G_TYPE_INSTR_BLOCK, py_instr_block_type,
- Py_BuildValue("(O)", py_instr_block_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/analysis/blocks/flow.c b/plugins/pychrysa/analysis/blocks/flow.c
index 626d5c8..aa0e3bf 100644
--- a/plugins/pychrysa/analysis/blocks/flow.c
+++ b/plugins/pychrysa/analysis/blocks/flow.c
@@ -32,6 +32,7 @@
#include "../block.h"
+#include "../../helpers.h"
@@ -177,8 +178,8 @@ bool register_python_flow_block(PyObject *module)
Py_INCREF(&py_flow_block_type);
ret = PyModule_AddObject(module, "FlowBlock", (PyObject *)&py_flow_block_type);
- pygobject_register_class(module, "GFlowBlock", G_TYPE_FLOW_BLOCK, &py_flow_block_type,
- Py_BuildValue("(O)", py_flow_block_type.tp_base));
+ register_class_for_pygobject(module, "GFlowBlock", G_TYPE_FLOW_BLOCK, &py_flow_block_type,
+ Py_BuildValue("(O)", py_flow_block_type.tp_base));
return (ret == 0);
@@ -261,25 +262,15 @@ PyTypeObject *get_python_flow_block_type(void)
bool register_python_flow_block(PyObject *module)
{
PyTypeObject *py_flow_block_type; /* Type Python 'FlowBlock' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_flow_block_type = get_python_flow_block_type();
- py_flow_block_type->tp_base = get_python_instr_block_type();
- py_flow_block_type->tp_basicsize = py_flow_block_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_flow_block_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_FLOW_BLOCK, py_flow_block_type, get_python_instr_block_type()))
return false;
- Py_INCREF(py_flow_block_type);
- ret = PyModule_AddObject(module, "FlowBlock", (PyObject *)py_flow_block_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "FlowBlock", G_TYPE_FLOW_BLOCK, py_flow_block_type,
- Py_BuildValue("(O)", py_flow_block_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/analysis/blocks/virtual.c b/plugins/pychrysa/analysis/blocks/virtual.c
index bdc81b0..6a35925 100644
--- a/plugins/pychrysa/analysis/blocks/virtual.c
+++ b/plugins/pychrysa/analysis/blocks/virtual.c
@@ -32,6 +32,7 @@
#include "../block.h"
+#include "../../helpers.h"
@@ -92,25 +93,16 @@ PyTypeObject *get_python_virtual_block_type(void)
bool register_python_virtual_block(PyObject *module)
{
PyTypeObject *py_virtual_block_type; /* Type Python 'VirtualBlock' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_virtual_block_type = get_python_virtual_block_type();
- py_virtual_block_type->tp_base = get_python_instr_block_type();
- py_virtual_block_type->tp_basicsize = py_virtual_block_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_virtual_block_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_VIRTUAL_BLOCK,
+ py_virtual_block_type, get_python_instr_block_type()))
return false;
- Py_INCREF(py_virtual_block_type);
- ret = PyModule_AddObject(module, "VirtualBlock", (PyObject *)py_virtual_block_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "VirtualBlock", G_TYPE_VIRTUAL_BLOCK, py_virtual_block_type,
- Py_BuildValue("(O)", py_virtual_block_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/analysis/content.c b/plugins/pychrysa/analysis/content.c
index d3da2b1..fa59d69 100644
--- a/plugins/pychrysa/analysis/content.c
+++ b/plugins/pychrysa/analysis/content.c
@@ -60,7 +60,6 @@ static PyObject *py_binary_content_read_u64(PyObject *, PyObject *);
-
/******************************************************************************
* *
* Paramètres : self = contenu binaire à manipuler. *
@@ -213,6 +212,7 @@ static PyObject *py_binary_content_read_u16(PyObject *self, PyObject *args)
}
+
/******************************************************************************
* *
* Paramètres : self = contenu binaire à manipuler. *
@@ -306,13 +306,6 @@ static PyObject *py_binary_content_read_u64(PyObject *self, PyObject *args)
}
-
-
-
-
-
-
-
/******************************************************************************
* *
* Paramètres : - *
@@ -401,28 +394,10 @@ PyTypeObject *get_python_binary_content_type(void)
bool register_python_binary_content(PyObject *module)
{
PyTypeObject *py_binary_content_type; /* Type Python 'BinContent' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_binary_content_type = get_python_binary_content_type();
- //py_binary_content_type->tp_base = &PyGObject_Type;
- //py_binary_content_type->tp_basicsize = py_binary_content_type->tp_base->tp_basicsize;
-
- //py_binary_content_type->tp_base = &PyObject_Type;
- //py_binary_content_type->tp_basicsize = py_binary_content_type->tp_base->tp_basicsize;
-
- /*
- if (PyType_Ready(py_binary_content_type) != 0)
- return false;
- */
-
- /*
- Py_INCREF(py_binary_content_type);
- ret = PyModule_AddObject(module, "BinContent", (PyObject *)py_binary_content_type);
- if (ret != 0) return false;
- */
-
dict = PyModule_GetDict(module);
pyg_register_interface(dict, "BinContent", G_TYPE_BIN_CONTENT, py_binary_content_type);
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 *);
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;
}
diff --git a/plugins/pychrysa/analysis/routine.c b/plugins/pychrysa/analysis/routine.c
index e42650a..39025b5 100644
--- a/plugins/pychrysa/analysis/routine.c
+++ b/plugins/pychrysa/analysis/routine.c
@@ -37,6 +37,7 @@
#include "block.h"
+#include "../helpers.h"
@@ -277,26 +278,16 @@ PyTypeObject *get_python_binary_routine_type(void)
bool register_python_binary_routine(PyObject *module)
{
- PyTypeObject *py_binary_routine_type; /* Type Python 'BinRoutine' */
- int ret; /* Bilan d'un appel */
+ PyTypeObject *py_binary_routine_type; /* Type Python 'BinRoutine' */
PyObject *dict; /* Dictionnaire du module */
py_binary_routine_type = get_python_binary_routine_type();
- py_binary_routine_type->tp_base = &PyGObject_Type;
- py_binary_routine_type->tp_basicsize = py_binary_routine_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_binary_routine_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_BIN_ROUTINE, py_binary_routine_type, &PyGObject_Type))
return false;
- Py_INCREF(py_binary_routine_type);
- ret = PyModule_AddObject(module, "BinRoutine", (PyObject *)py_binary_routine_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "BinRoutine", G_TYPE_BIN_ROUTINE, py_binary_routine_type,
- Py_BuildValue("(O)", py_binary_routine_type->tp_base));
-
return true;
}