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/arch | |
parent | 7b8eed3f8207fe9b629165f8230e38ee620900ea (diff) |
Registered properly the PyGObject wrappers for Python classes.
Diffstat (limited to 'plugins/pychrysa/arch')
-rw-r--r-- | plugins/pychrysa/arch/arm/instruction.c | 17 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/processor.c | 16 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/instruction.c | 16 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/processor.c | 15 | ||||
-rw-r--r-- | plugins/pychrysa/arch/instruction.c | 18 | ||||
-rw-r--r-- | plugins/pychrysa/arch/processor.c | 16 |
6 files changed, 19 insertions, 79 deletions
diff --git a/plugins/pychrysa/arch/arm/instruction.c b/plugins/pychrysa/arch/arm/instruction.c index ed53386..14c4ab5 100644 --- a/plugins/pychrysa/arch/arm/instruction.c +++ b/plugins/pychrysa/arch/arm/instruction.c @@ -94,26 +94,17 @@ PyTypeObject *get_python_arm_instruction_type(void) bool register_python_arm_instruction(PyObject *module) { PyTypeObject *py_arm_instruction_type; /* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_arm_instruction_type = get_python_arm_instruction_type(); - py_arm_instruction_type->tp_base = get_python_arch_instruction_type(); - py_arm_instruction_type->tp_basicsize = py_arm_instruction_type->tp_base->tp_basicsize; - APPLY_ABSTRACT_FLAG(py_arm_instruction_type); - if (PyType_Ready(py_arm_instruction_type) != 0) - return false; - - Py_INCREF(py_arm_instruction_type); - ret = PyModule_AddObject(module, "ArmInstruction", (PyObject *)py_arm_instruction_type); - if (ret != 0) return false; - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "ArmInstruction", G_TYPE_ARM_INSTRUCTION, py_arm_instruction_type, - Py_BuildValue("(O)", py_arm_instruction_type->tp_base)); + + if (!register_class_for_pygobject(dict, G_TYPE_ARM_INSTRUCTION, + py_arm_instruction_type, get_python_arch_instruction_type())) + return false; return true; diff --git a/plugins/pychrysa/arch/arm/processor.c b/plugins/pychrysa/arch/arm/processor.c index 049dcb3..bac06ef 100644 --- a/plugins/pychrysa/arch/arm/processor.c +++ b/plugins/pychrysa/arch/arm/processor.c @@ -94,27 +94,15 @@ PyTypeObject *get_python_arm_processor_type(void) bool register_python_arm_processor(PyObject *module) { PyTypeObject *py_arm_processor_type; /* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_arm_processor_type = get_python_arm_processor_type(); - py_arm_processor_type->tp_base = get_python_arch_processor_type(); - py_arm_processor_type->tp_basicsize = py_arm_processor_type->tp_base->tp_basicsize; - - APPLY_ABSTRACT_FLAG(py_arm_processor_type); + dict = PyModule_GetDict(module); - if (PyType_Ready(py_arm_processor_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_ARM_PROCESSOR, py_arm_processor_type, get_python_arch_processor_type())) return false; - Py_INCREF(py_arm_processor_type); - ret = PyModule_AddObject(module, "ArmProcessor", (PyObject *)py_arm_processor_type); - if (ret != 0) return false; - - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "ArmProcessor", G_TYPE_ARM_PROCESSOR, py_arm_processor_type, - Py_BuildValue("(O)", py_arm_processor_type->tp_base)); - return true; } diff --git a/plugins/pychrysa/arch/arm/v7/instruction.c b/plugins/pychrysa/arch/arm/v7/instruction.c index 8a19259..08e9468 100644 --- a/plugins/pychrysa/arch/arm/v7/instruction.c +++ b/plugins/pychrysa/arch/arm/v7/instruction.c @@ -32,6 +32,7 @@ #include "../instruction.h" +#include "../../../helpers.h" @@ -93,25 +94,16 @@ PyTypeObject *get_python_armv7_instruction_type(void) bool register_python_armv7_instruction(PyObject *module) { PyTypeObject *py_armv7_instruction_type;/* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_armv7_instruction_type = get_python_armv7_instruction_type(); - py_armv7_instruction_type->tp_base = get_python_arm_instruction_type(); - py_armv7_instruction_type->tp_basicsize = py_armv7_instruction_type->tp_base->tp_basicsize; + dict = PyModule_GetDict(module); - if (PyType_Ready(py_armv7_instruction_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_INSTRUCTION, + py_armv7_instruction_type, get_python_arm_instruction_type())) return false; - Py_INCREF(py_armv7_instruction_type); - ret = PyModule_AddObject(module, "ArmV7Instruction", (PyObject *)py_armv7_instruction_type); - if (ret != 0) return false; - - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "ArmV7Instruction", G_TYPE_ARMV7_INSTRUCTION, py_armv7_instruction_type, - Py_BuildValue("(O)", py_armv7_instruction_type->tp_base)); - return true; } diff --git a/plugins/pychrysa/arch/arm/v7/processor.c b/plugins/pychrysa/arch/arm/v7/processor.c index 1844066..25bd1eb 100644 --- a/plugins/pychrysa/arch/arm/v7/processor.c +++ b/plugins/pychrysa/arch/arm/v7/processor.c @@ -32,6 +32,7 @@ #include "../processor.h" +#include "../../../helpers.h" @@ -93,25 +94,15 @@ PyTypeObject *get_python_armv7_processor_type(void) bool register_python_armv7_processor(PyObject *module) { PyTypeObject *py_armv7_processor_type; /* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_armv7_processor_type = get_python_armv7_processor_type(); - py_armv7_processor_type->tp_base = get_python_arm_processor_type(); - py_armv7_processor_type->tp_basicsize = py_armv7_processor_type->tp_base->tp_basicsize; + dict = PyModule_GetDict(module); - if (PyType_Ready(py_armv7_processor_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_PROCESSOR, py_armv7_processor_type, get_python_arm_processor_type())) return false; - Py_INCREF(py_armv7_processor_type); - ret = PyModule_AddObject(module, "ArmV7Processor", (PyObject *)py_armv7_processor_type); - if (ret != 0) return false; - - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "ArmV7Processor", G_TYPE_ARMV7_PROCESSOR, py_armv7_processor_type, - Py_BuildValue("(O)", py_armv7_processor_type->tp_base)); - return true; } diff --git a/plugins/pychrysa/arch/instruction.c b/plugins/pychrysa/arch/instruction.c index 2a06ede..5e4c19d 100644 --- a/plugins/pychrysa/arch/instruction.c +++ b/plugins/pychrysa/arch/instruction.c @@ -369,26 +369,16 @@ PyTypeObject *get_python_arch_instruction_type(void) bool register_python_arch_instruction(PyObject *module) { PyTypeObject *py_arch_instruction_type; /* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_arch_instruction_type = get_python_arch_instruction_type(); - py_arch_instruction_type->tp_base = &PyGObject_Type; - py_arch_instruction_type->tp_basicsize = py_arch_instruction_type->tp_base->tp_basicsize; - APPLY_ABSTRACT_FLAG(py_arch_instruction_type); - if (PyType_Ready(py_arch_instruction_type) != 0) - return false; - - Py_INCREF(py_arch_instruction_type); - ret = PyModule_AddObject(module, "ArchInstruction", (PyObject *)py_arch_instruction_type); - if (ret != 0) return false; - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "ArchInstruction", G_TYPE_ARCH_INSTRUCTION, py_arch_instruction_type, - Py_BuildValue("(O)", py_arch_instruction_type->tp_base)); + + if (!register_class_for_pygobject(dict, G_TYPE_ARCH_INSTRUCTION, py_arch_instruction_type, &PyGObject_Type)) + return false; return true; @@ -781,7 +771,7 @@ bool register_python_arch_instruction(PyObject *module) Py_INCREF(&py_arch_instruction_type); ret = PyModule_AddObject(module, "ArchInstruction", (PyObject *)&py_arch_instruction_type); - pygobject_register_class(module, "GArchInstruction", G_TYPE_ARCH_INSTRUCTION, + register_class_for_pygobject(module, "GArchInstruction", G_TYPE_ARCH_INSTRUCTION, &py_arch_instruction_type, Py_BuildValue("(O)", py_arch_instruction_type.tp_base)); diff --git a/plugins/pychrysa/arch/processor.c b/plugins/pychrysa/arch/processor.c index 0a9ae3a..bed3a3a 100644 --- a/plugins/pychrysa/arch/processor.c +++ b/plugins/pychrysa/arch/processor.c @@ -386,27 +386,15 @@ PyTypeObject *get_python_arch_processor_type(void) bool register_python_arch_processor(PyObject *module) { PyTypeObject *py_arch_processor_type; /* Type Python 'BinContent' */ - int ret; /* Bilan d'un appel */ PyObject *dict; /* Dictionnaire du module */ py_arch_processor_type = get_python_arch_processor_type(); - py_arch_processor_type->tp_base = &PyGObject_Type; - py_arch_processor_type->tp_basicsize = py_arch_processor_type->tp_base->tp_basicsize; - - APPLY_ABSTRACT_FLAG(py_arch_processor_type); + dict = PyModule_GetDict(module); - if (PyType_Ready(py_arch_processor_type) != 0) + if (!register_class_for_pygobject(dict, G_TYPE_ARCH_PROCESSOR, py_arch_processor_type, &PyGObject_Type)) return false; - Py_INCREF(py_arch_processor_type); - ret = PyModule_AddObject(module, "ArchProcessor", (PyObject *)py_arch_processor_type); - if (ret != 0) return false; - - dict = PyModule_GetDict(module); - pygobject_register_class(dict, "ArchProcessor", G_TYPE_ARCH_PROCESSOR, py_arch_processor_type, - Py_BuildValue("(O)", py_arch_processor_type->tp_base)); - return true; } |