From 9167c2a44efba513aaf8cac6d5589c565ed14ddf Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 16 Aug 2018 20:02:13 +0200 Subject: Added some constants for instructions in the Python API. --- plugins/pychrysalide/arch/instruction.c | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/plugins/pychrysalide/arch/instruction.c b/plugins/pychrysalide/arch/instruction.c index df5bc15..4202625 100644 --- a/plugins/pychrysalide/arch/instruction.c +++ b/plugins/pychrysalide/arch/instruction.c @@ -74,6 +74,11 @@ static PyObject *py_arch_instruction_get_operands(PyObject *, void *); +/* Définit les constantes pour les instructions. */ +static bool py_arch_instruction_define_constants(PyTypeObject *); + + + @@ -422,6 +427,39 @@ static PyObject *py_arch_instruction_get_operands(PyObject *self, void *unused) /****************************************************************************** * * +* Paramètres : obj_type = type dont le dictionnaire est à compléter. * +* * +* Description : Définit les constantes pour les instructions. * +* * +* Retour : true en cas de succès de l'opération, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool py_arch_instruction_define_constants(PyTypeObject *obj_type) +{ + bool result; /* Bilan à retourner */ + + result = true; + + result &= PyDict_AddIntMacro(obj_type, ILT_EXEC_FLOW); + result &= PyDict_AddIntMacro(obj_type, ILT_JUMP); + result &= PyDict_AddIntMacro(obj_type, ILT_CASE_JUMP); + result &= PyDict_AddIntMacro(obj_type, ILT_JUMP_IF_TRUE); + result &= PyDict_AddIntMacro(obj_type, ILT_JUMP_IF_FALSE); + result &= PyDict_AddIntMacro(obj_type, ILT_LOOP); + result &= PyDict_AddIntMacro(obj_type, ILT_CALL); + result &= PyDict_AddIntMacro(obj_type, ILT_CATCH_EXCEPTION); + result &= PyDict_AddIntMacro(obj_type, ILT_REF); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : - * * * * Description : Fournit un accès à une définition de type à diffuser. * @@ -522,6 +560,9 @@ bool ensure_python_arch_instruction_is_registered(void) &PyGObject_Type, get_python_line_generator_type(), NULL)) return false; + if (!py_arch_instruction_define_constants(type)) + return false; + } return true; -- cgit v0.11.2-87-g4458