summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-09-25 13:40:18 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-09-25 13:40:18 (GMT)
commit6ba868e1b5961cec8db21adabf36027f97205f0f (patch)
tree56f18eb487affb51818d818f1ff8af4439f5c359 /plugins/pychrysalide/arch
parent76fb13178cf6be94b8e01675b37f7cb1b92f7709 (diff)
Provided as much information as possible for instruction links in Python.
Diffstat (limited to 'plugins/pychrysalide/arch')
-rw-r--r--plugins/pychrysalide/arch/instruction.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/plugins/pychrysalide/arch/instruction.c b/plugins/pychrysalide/arch/instruction.c
index fcd0c83..3606cfe 100644
--- a/plugins/pychrysalide/arch/instruction.c
+++ b/plugins/pychrysalide/arch/instruction.c
@@ -725,15 +725,25 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, void *unused)
{
PyObject *result; /* Instance à retourner */
GArchInstruction *instr; /* Version native */
- const instr_link_t *source; /* Origine des liens */
size_t count; /* Nombre de liens présents */
size_t i; /* Boucle de parcours */
+ const instr_link_t *source; /* Origine des liens */
PyObject *linked; /* Source de lien Python */
PyObject *type; /* Nature du lien en Python */
#ifndef NDEBUG
int ret; /* Bilan d'une écriture d'arg. */
#endif
+#define ARCH_INSTRUCTION_SOURCES_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ sources, py_arch_instruction, \
+ "Provide the instructions list driving to the current instruction.\n" \
+ "\n" \
+ "Each item of the resulting tuple is a pair of" \
+ " pychrysalide.arch.ArchInstruction instance and" \
+ " pychrysalide.arch.ArchInstruction.InstructionLinkType value." \
+)
+
instr = G_ARCH_INSTRUCTION(pygobject_get(self));
g_arch_instruction_lock_src(instr);
@@ -747,7 +757,8 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, void *unused)
source = g_arch_instruction_get_source(instr, i);
linked = pygobject_new(G_OBJECT(source->linked));
- type = PyLong_FromLong(source->type);
+ type = cast_with_constants_group_from_type(get_python_arch_instruction_type(),
+ "InstructionLinkType", source->type);
#ifndef NDEBUG
ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", linked, type));
@@ -784,15 +795,25 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *self, void *unus
{
PyObject *result; /* Instance à retourner */
GArchInstruction *instr; /* Version native */
- const instr_link_t *dest; /* Destination des liens */
size_t count; /* Nombre de liens présents */
size_t i; /* Boucle de parcours */
+ const instr_link_t *dest; /* Destination des liens */
PyObject *linked; /* Destination de lien Python */
PyObject *type; /* Nature du lien en Python */
#ifndef NDEBUG
int ret; /* Bilan d'une écriture d'arg. */
#endif
+#define ARCH_INSTRUCTION_DESTINATIONS_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ destinations, py_arch_instruction, \
+ "Provide the instructions list following the current instruction.\n" \
+ "\n" \
+ "Each item of the resulting tuple is a pair of" \
+ " pychrysalide.arch.ArchInstruction instance and" \
+ " pychrysalide.arch.ArchInstruction.InstructionLinkType value." \
+)
+
instr = G_ARCH_INSTRUCTION(pygobject_get(self));
g_arch_instruction_lock_dest(instr);
@@ -806,7 +827,8 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *self, void *unus
dest = g_arch_instruction_get_destination(instr, i);
linked = pygobject_new(G_OBJECT(dest->linked));
- type = PyLong_FromLong(dest->type);
+ type = cast_with_constants_group_from_type(get_python_arch_instruction_type(),
+ "InstructionLinkType", dest->type);
#ifndef NDEBUG
ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", linked, type));
@@ -1005,14 +1027,8 @@ PyTypeObject *get_python_arch_instruction_type(void)
"operands", (getter)py_arch_instruction_get_operands, (setter)NULL,
"Provide the list of instruction attached operands.", NULL
},
- {
- "sources", (getter)py_arch_instruction_get_sources, (setter)NULL,
- "Provide the instructions list driving to the current instruction."
- },
- {
- "destinations", (getter)py_arch_instruction_get_destinations, (setter)NULL,
- "Provide the instructions list following the current instruction."
- },
+ ARCH_INSTRUCTION_SOURCES_ATTRIB,
+ ARCH_INSTRUCTION_DESTINATIONS_ATTRIB,
{ NULL }
};