summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-07-30 10:57:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-07-30 10:57:08 (GMT)
commitfb1d26845908d131b1c92d7d7cd1bc402b656ca4 (patch)
treea6c6a30482ce97dfe7b985116877bb0ce8b7b0a0 /plugins/pychrysa/format
parent7b8eed3f8207fe9b629165f8230e38ee620900ea (diff)
Registered properly the PyGObject wrappers for Python classes.
Diffstat (limited to 'plugins/pychrysa/format')
-rw-r--r--plugins/pychrysa/format/dex/class.c17
-rw-r--r--plugins/pychrysa/format/dex/dex.c16
-rw-r--r--plugins/pychrysa/format/elf/elf.c16
-rw-r--r--plugins/pychrysa/format/executable.c15
-rw-r--r--plugins/pychrysa/format/format.c16
-rw-r--r--plugins/pychrysa/format/symbol.c14
6 files changed, 21 insertions, 73 deletions
diff --git a/plugins/pychrysa/format/dex/class.c b/plugins/pychrysa/format/dex/class.c
index 1741b52..59dfe44 100644
--- a/plugins/pychrysa/format/dex/class.c
+++ b/plugins/pychrysa/format/dex/class.c
@@ -31,6 +31,9 @@
#include <format/dex/class.h>
+#include "../../helpers.h"
+
+
/******************************************************************************
* *
@@ -90,25 +93,15 @@ PyTypeObject *get_python_dex_class_type(void)
bool register_python_dex_class(PyObject *module)
{
PyTypeObject *py_dex_class_type; /* Type Python 'DexClass' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_dex_class_type = get_python_dex_class_type();
- py_dex_class_type->tp_base = &PyGObject_Type;
- py_dex_class_type->tp_basicsize = py_dex_class_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_dex_class_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_DEX_CLASS, py_dex_class_type, &PyGObject_Type))
return false;
- Py_INCREF(py_dex_class_type);
- ret = PyModule_AddObject(module, "DexClass", (PyObject *)py_dex_class_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "DexClass", G_TYPE_DEX_CLASS, py_dex_class_type,
- Py_BuildValue("(O)", py_dex_class_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/format/dex/dex.c b/plugins/pychrysa/format/dex/dex.c
index dac6c90..6bb1888 100644
--- a/plugins/pychrysa/format/dex/dex.c
+++ b/plugins/pychrysa/format/dex/dex.c
@@ -34,6 +34,7 @@
#include "../executable.h"
#include "../../analysis/content.h"
+#include "../../helpers.h"
@@ -239,25 +240,16 @@ PyTypeObject *get_python_dex_format_type(void)
bool register_python_dex_format(PyObject *module)
{
PyTypeObject *py_dex_format_type; /* Type Python 'DexFormat' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_dex_format_type = get_python_dex_format_type();
- py_dex_format_type->tp_base = get_python_executable_format_type();
- py_dex_format_type->tp_basicsize = py_dex_format_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_dex_format_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_DEX_FORMAT,
+ py_dex_format_type, get_python_executable_format_type()))
return false;
- Py_INCREF(py_dex_format_type);
- ret = PyModule_AddObject(module, "DexFormat", (PyObject *)py_dex_format_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "DexFormat", G_TYPE_DEX_FORMAT, py_dex_format_type,
- Py_BuildValue("(O)", py_dex_format_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/format/elf/elf.c b/plugins/pychrysa/format/elf/elf.c
index 2787702..8778d56 100644
--- a/plugins/pychrysa/format/elf/elf.c
+++ b/plugins/pychrysa/format/elf/elf.c
@@ -36,6 +36,7 @@
#include "../executable.h"
#include "../../analysis/content.h"
+#include "../../helpers.h"
@@ -147,25 +148,16 @@ PyTypeObject *get_python_elf_format_type(void)
bool register_python_elf_format(PyObject *module)
{
PyTypeObject *py_elf_format_type; /* Type Python 'ElfFormat' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_elf_format_type = get_python_elf_format_type();
- py_elf_format_type->tp_base = get_python_executable_format_type();
- py_elf_format_type->tp_basicsize = py_elf_format_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_elf_format_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_ELF_FORMAT,
+ py_elf_format_type, get_python_executable_format_type()))
return false;
- Py_INCREF(py_elf_format_type);
- ret = PyModule_AddObject(module, "ElfFormat", (PyObject *)py_elf_format_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "ElfFormat", G_TYPE_ELF_FORMAT, py_elf_format_type,
- Py_BuildValue("(O)", py_elf_format_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/format/executable.c b/plugins/pychrysa/format/executable.c
index e7e218d..c48ae2f 100644
--- a/plugins/pychrysa/format/executable.c
+++ b/plugins/pychrysa/format/executable.c
@@ -32,6 +32,7 @@
#include "format.h"
+#include "../helpers.h"
@@ -93,25 +94,15 @@ PyTypeObject *get_python_executable_format_type(void)
bool register_python_executable_format(PyObject *module)
{
PyTypeObject *py_exe_format_type; /* Type Python 'ExeFormat' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_exe_format_type = get_python_executable_format_type();
- py_exe_format_type->tp_base = get_python_binary_format_type();
- py_exe_format_type->tp_basicsize = py_exe_format_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_exe_format_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_EXE_FORMAT, py_exe_format_type, get_python_binary_format_type()))
return false;
- Py_INCREF(py_exe_format_type);
- ret = PyModule_AddObject(module, "ExeFormat", (PyObject *)py_exe_format_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "ExeFormat", G_TYPE_EXE_FORMAT, py_exe_format_type,
- Py_BuildValue("(O)", py_exe_format_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/format/format.c b/plugins/pychrysa/format/format.c
index fb8b249..22ade20 100644
--- a/plugins/pychrysa/format/format.c
+++ b/plugins/pychrysa/format/format.c
@@ -576,26 +576,16 @@ PyTypeObject *get_python_binary_format_type(void)
bool register_python_binary_format(PyObject *module)
{
PyTypeObject *py_bin_format_type; /* Type Python 'BinFormat' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_bin_format_type = get_python_binary_format_type();
- py_bin_format_type->tp_base = &PyGObject_Type;
- py_bin_format_type->tp_basicsize = py_bin_format_type->tp_base->tp_basicsize;
-
APPLY_ABSTRACT_FLAG(py_bin_format_type);
- if (PyType_Ready(py_bin_format_type) != 0)
- return false;
-
- Py_INCREF(py_bin_format_type);
- ret = PyModule_AddObject(module, "BinFormat", (PyObject *)py_bin_format_type);
- if (ret != 0) return false;
-
dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "BinFormat", G_TYPE_BIN_FORMAT, py_bin_format_type,
- Py_BuildValue("(O)", py_bin_format_type->tp_base));
+
+ if (!register_class_for_pygobject(dict, G_TYPE_BIN_FORMAT, py_bin_format_type, &PyGObject_Type))
+ return false;
return true;
diff --git a/plugins/pychrysa/format/symbol.c b/plugins/pychrysa/format/symbol.c
index 1fc868e..27674e0 100644
--- a/plugins/pychrysa/format/symbol.c
+++ b/plugins/pychrysa/format/symbol.c
@@ -693,28 +693,18 @@ PyTypeObject *get_python_binary_symbol_type(void)
bool register_python_binary_symbol(PyObject *module)
{
PyTypeObject *py_bin_symbol_type; /* Type Python 'BinSymbol' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_bin_symbol_type = get_python_binary_symbol_type();
- py_bin_symbol_type->tp_base = &PyGObject_Type;
- py_bin_symbol_type->tp_basicsize = py_bin_symbol_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_bin_symbol_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_BIN_SYMBOL, py_bin_symbol_type, &PyGObject_Type))
return false;
if (!py_binary_symbol_define_constants(py_bin_symbol_type))
return false;
- Py_INCREF(py_bin_symbol_type);
- ret = PyModule_AddObject(module, "BinSymbol", (PyObject *)py_bin_symbol_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "BinSymbol", G_TYPE_BIN_SYMBOL, py_bin_symbol_type,
- Py_BuildValue("(O)", py_bin_symbol_type->tp_base));
-
return true;
}