diff options
Diffstat (limited to 'plugins/pychrysalide/arch/operand.c')
-rw-r--r-- | plugins/pychrysalide/arch/operand.c | 112 |
1 files changed, 110 insertions, 2 deletions
diff --git a/plugins/pychrysalide/arch/operand.c b/plugins/pychrysalide/arch/operand.c index e464eac..4630b3a 100644 --- a/plugins/pychrysalide/arch/operand.c +++ b/plugins/pychrysalide/arch/operand.c @@ -29,6 +29,7 @@ #include <arch/operand.h> +#include <plugins/dt.h> #include "../access.h" @@ -36,6 +37,113 @@ +/* ------------------------ GLUE POUR CREATION DEPUIS PYTHON ------------------------ */ + + +/* Accompagne la création d'une instance dérivée en Python. */ +static PyObject *py_arch_operand_new(PyTypeObject *, PyObject *, PyObject *); + +/* Initialise la classe des descriptions de fichier binaire. */ +static void py_arch_operand_init_gclass(GArchOperandClass *, gpointer); + + + +/* ------------------------ DEFINITION D'OPERANDE QUELCONQUE ------------------------ */ + + + + +/* ---------------------------------------------------------------------------------- */ +/* GLUE POUR CREATION DEPUIS PYTHON */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : type = type du nouvel objet à mettre en place. * +* args = éventuelle liste d'arguments. * +* kwds = éventuel dictionnaire de valeurs mises à disposition. * +* * +* Description : Accompagne la création d'une instance dérivée en Python. * +* * +* Retour : Nouvel objet Python mis en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_arch_operand_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *result; /* Objet à retourner */ + PyTypeObject *base; /* Type de base à dériver */ + bool first_time; /* Evite les multiples passages*/ + GType gtype; /* Nouveau type de processeur */ + bool status; /* Bilan d'un enregistrement */ + + /* Validations diverses */ + + base = get_python_arch_operand_type(); + + if (type == base) + goto simple_way; + + /* Mise en place d'un type dédié */ + + first_time = (g_type_from_name(type->tp_name) == 0); + + gtype = build_dynamic_type(G_TYPE_ARCH_OPERAND, type->tp_name, + (GClassInitFunc)py_arch_operand_init_gclass, NULL, NULL); + + if (first_time) + { + status = register_class_for_dynamic_pygobject(gtype, type, base); + + if (!status) + { + result = NULL; + goto exit; + } + + } + + /* On crée, et on laisse ensuite la main à PyGObject_Type.tp_init() */ + + simple_way: + + result = PyType_GenericNew(type, args, kwds); + + exit: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : class = classe à initialiser. * +* unused = données non utilisées ici. * +* * +* Description : Initialise la classe des descriptions de fichier binaire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void py_arch_operand_init_gclass(GArchOperandClass *class, gpointer unused) +{ + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* DEFINITION D'OPERANDE QUELCONQUE */ +/* ---------------------------------------------------------------------------------- */ + + /****************************************************************************** * * * Paramètres : - * @@ -72,6 +180,8 @@ PyTypeObject *get_python_arch_operand_type(void) .tp_methods = py_arch_operand_methods, .tp_getset = py_arch_operand_getseters, + .tp_new = py_arch_operand_new, + }; return &py_arch_operand_type; @@ -101,8 +211,6 @@ bool ensure_python_arch_operand_is_registered(void) if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) { - APPLY_ABSTRACT_FLAG(type); - module = get_access_to_python_module("pychrysalide.arch"); dict = PyModule_GetDict(module); |