summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-26 09:19:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-26 09:19:53 (GMT)
commitdff8fd4c83d9833d4539e2dd0c9d3f998b73608f (patch)
tree5e1088e0572b1e921df6d31d3db3ef753d97555b /src
parentae3725eae3c1f2008e6f26b1057d97a6b9050a3c (diff)
Extended the Python API.
Diffstat (limited to 'src')
-rw-r--r--src/arch/instruction.c46
-rw-r--r--src/arch/instruction.h54
2 files changed, 44 insertions, 56 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 5ce0c12..1d1ccaf 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -585,35 +585,6 @@ GArchOperand *_g_arch_instruction_get_operand(const GArchInstruction *instr, siz
/******************************************************************************
* *
* Paramètres : instr = instance à mettre à jour. *
-* old = ancien opérande à remplacer. *
-* new = nouvel opérande à intégrer. *
-* *
-* Description : Remplace un opérande d'une instruction par un autre. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand *old, GArchOperand *new)
-{
- bool result; /* Bilan à retourner */
-
- g_arch_instruction_lock_operands(instr);
-
- result = _g_arch_instruction_replace_operand(instr, old, new);
-
- g_arch_instruction_unlock_operands(instr);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instr = instance à mettre à jour. *
* old = ancienne opérande à détacher. *
* new = nouvelle opérande à attacher. *
* *
@@ -670,14 +641,15 @@ bool _g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand *
* *
* Description : Détache un opérande liée d'une instruction. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-void _g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *target)
+bool _g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *target)
{
+ bool result; /* Bilan à retourner */
size_t count; /* Nombre d'opérandes en place */
size_t i; /* Boucle de parcours */
GArchOperand *op; /* Opérande à manipuler */
@@ -695,9 +667,17 @@ void _g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *t
}
- rem_item_from_flat_array(&instr->operands, i, sizeof(GArchOperand *));
+ result = (i < count);
+
+ if (result)
+ {
+ rem_item_from_flat_array(&instr->operands, i, sizeof(GArchOperand *));
+
+ g_object_unref(G_OBJECT(target));
+
+ }
- g_object_unref(G_OBJECT(target));
+ return result;
}
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index 8289a43..217e38b 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -148,38 +148,46 @@ size_t _g_arch_instruction_count_operands(const GArchInstruction *);
GArchOperand *_g_arch_instruction_get_operand(const GArchInstruction *, size_t);
/* Remplace un opérande d'une instruction par un autre. */
-bool g_arch_instruction_replace_operand(GArchInstruction *, GArchOperand *, GArchOperand *);
-
-/* Remplace un opérande d'une instruction par un autre. */
bool _g_arch_instruction_replace_operand(GArchInstruction *, GArchOperand *, GArchOperand *);
/* Détache un opérande liée d'une instruction. */
-void _g_arch_instruction_detach_operand(GArchInstruction *, GArchOperand *);
+bool _g_arch_instruction_detach_operand(GArchInstruction *, GArchOperand *);
-#define g_arch_instruction_count_operands(ins) \
- ({ \
- size_t __result; \
- g_arch_instruction_lock_operands(ins); \
- __result = _g_arch_instruction_count_operands(ins); \
- g_arch_instruction_unlock_operands(ins); \
- __result; \
+#define g_arch_instruction_count_operands(ins) \
+ ({ \
+ size_t __result; \
+ g_arch_instruction_lock_operands(ins); \
+ __result = _g_arch_instruction_count_operands(ins); \
+ g_arch_instruction_unlock_operands(ins); \
+ __result; \
+ })
+
+#define g_arch_instruction_get_operand(ins, idx) \
+ ({ \
+ GArchOperand *__result; \
+ g_arch_instruction_lock_operands(ins); \
+ __result = _g_arch_instruction_get_operand(ins, idx); \
+ g_arch_instruction_unlock_operands(ins); \
+ __result; \
})
-#define g_arch_instruction_get_operand(ins, idx) \
- ({ \
- GArchOperand *__result; \
- g_arch_instruction_lock_operands(ins); \
- __result = _g_arch_instruction_get_operand(ins, idx); \
- g_arch_instruction_unlock_operands(ins); \
- __result; \
+#define g_arch_instruction_replace_operand(ins, o, n) \
+ ({ \
+ bool __result; \
+ g_arch_instruction_lock_operands(ins); \
+ __result = _g_arch_instruction_replace_operand(ins, o, n); \
+ g_arch_instruction_unlock_operands(ins); \
+ __result; \
})
-#define g_arch_instruction_detach_operand(ins, o) \
- ({ \
- g_arch_instruction_lock_operands(ins); \
- _g_arch_instruction_detach_operand(ins, o); \
- g_arch_instruction_unlock_operands(ins); \
+#define g_arch_instruction_detach_operand(ins, o) \
+ ({ \
+ bool __result; \
+ g_arch_instruction_lock_operands(ins); \
+ __result = _g_arch_instruction_detach_operand(ins, o); \
+ g_arch_instruction_unlock_operands(ins); \
+ __result; \
})