summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-22 18:28:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-22 18:34:46 (GMT)
commitc1bcf3e7bd0a256005bd15832117b78cee5fdfab (patch)
tree54188ab3933526ca79ae3e8f86dd99adad49e681 /plugins
parent3a8bc79d69acae3735cc0203b54d93b4137caa09 (diff)
Allowed to initialize instances of created dynamic types if needed.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pychrysalide/arch/operands/register.c4
-rw-r--r--plugins/pychrysalide/arch/processor.c105
-rw-r--r--plugins/pychrysalide/arch/register.c4
-rw-r--r--plugins/pychrysalide/gui/panels/panel.c4
-rw-r--r--plugins/pychrysalide/plugin.c4
5 files changed, 110 insertions, 11 deletions
diff --git a/plugins/pychrysalide/arch/operands/register.c b/plugins/pychrysalide/arch/operands/register.c
index 74b6a4f..8144af0 100644
--- a/plugins/pychrysalide/arch/operands/register.c
+++ b/plugins/pychrysalide/arch/operands/register.c
@@ -100,8 +100,8 @@ static PyObject *py_register_operand_new(PyTypeObject *type, PyObject *args, PyO
first_time = (g_type_from_name(type->tp_name) == 0);
- gtype = built_dynamic_type(G_TYPE_REGISTER_OPERAND, type->tp_name,
- (GClassInitFunc)py_register_operand_init_gclass, NULL);
+ gtype = build_dynamic_type(G_TYPE_REGISTER_OPERAND, type->tp_name,
+ (GClassInitFunc)py_register_operand_init_gclass, NULL, NULL);
if (first_time)
{
diff --git a/plugins/pychrysalide/arch/processor.c b/plugins/pychrysalide/arch/processor.c
index 8fc2598..b59e59b 100644
--- a/plugins/pychrysalide/arch/processor.c
+++ b/plugins/pychrysalide/arch/processor.c
@@ -54,6 +54,12 @@ static PyObject *py_arch_processor_new(PyTypeObject *, PyObject *, PyObject *);
/* Initialise la classe des descriptions de fichier binaire. */
static void py_arch_processor_init_gclass(GArchProcessorClass *, gpointer);
+/* Initialise une instance de processeur d'architecture. */
+static void py_arch_processor_init_ginstance(GArchProcessor *, GArchProcessor *);
+
+/* Initialise une instance sur la base du dérivé de GObject. */
+static int py_arch_processor_init(PyObject *, PyObject *, PyObject *);
+
/* Fournit un contexte propre au processeur d'une architecture. */
static GProcContext *py_arch_processor_get_context_wrapper(const GArchProcessor *);
@@ -160,8 +166,9 @@ static PyObject *py_arch_processor_new(PyTypeObject *type, PyObject *args, PyObj
first_time = (g_type_from_name(type->tp_name) == 0);
- gtype = built_dynamic_type(G_TYPE_ARCH_PROCESSOR, type->tp_name,
- (GClassInitFunc)py_arch_processor_init_gclass, NULL);
+ gtype = build_dynamic_type(G_TYPE_ARCH_PROCESSOR, type->tp_name,
+ (GClassInitFunc)py_arch_processor_init_gclass, NULL,
+ (GInstanceInitFunc)py_arch_processor_init_ginstance);
if (first_time)
{
@@ -191,7 +198,7 @@ static PyObject *py_arch_processor_new(PyTypeObject *type, PyObject *args, PyObj
* Paramètres : class = classe à initialiser. *
* unused = données non utilisées ici. *
* *
-* Description : Initialise la classe des descriptions de fichier binaire. *
+* Description : Initialise la classe générique des processeurs. *
* *
* Retour : - *
* *
@@ -210,6 +217,97 @@ static void py_arch_processor_init_gclass(GArchProcessorClass *class, gpointer u
/******************************************************************************
* *
+* Paramètres : proc = instance à initialiser. *
+* class = classe du type correspondant. *
+* *
+* Description : Initialise une instance de processeur d'architecture. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void py_arch_processor_init_ginstance(GArchProcessor *proc, GArchProcessor *class)
+{
+ GType type; /* Type d'instances concerné */
+ GArchProcessor *pattern; /* Patron de données à copier */
+
+ type = G_TYPE_FROM_INSTANCE(proc);
+
+ pattern = get_dynamic_type_pattern(type);
+
+ if (pattern != NULL)
+ {
+ proc->endianness = pattern->endianness;
+ proc->memsize = pattern->memsize;
+ proc->inssize = pattern->inssize;
+ proc->virt_space = pattern->virt_space;
+ }
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet à initialiser (théoriquement). *
+* args = arguments fournis à l'appel. *
+* kwds = arguments de type key=val fournis. *
+* *
+* Description : Initialise une instance sur la base du dérivé de GObject. *
+* *
+* Retour : 0. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static int py_arch_processor_init(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ unsigned long endianness; /* Boutisme du processeur */
+ unsigned long mem_size; /* Taille d'adressage */
+ unsigned long ins_min_size; /* Taille minimale d'instruct° */
+ int vspace; /* Support d'un espace virtuel */
+ int ret; /* Bilan de lecture des args. */
+ PyObject *new_kwds; /* Nouveau dictionnaire épuré */
+ GArchProcessor *proc; /* Processeur à manipuler */
+
+ static char *kwlist[] = { "endianness", "mem_size", "ins_min_size", "vspace", NULL };
+
+ /* Récupération des paramètres */
+
+ ret = PyArg_ParseTupleAndKeywords(args, kwds, "kkkp", kwlist,
+ &endianness, &mem_size, &ins_min_size, &vspace);
+ if (!ret) return -1;
+
+ /* Initialisation d'un objet GLib */
+
+ new_kwds = PyDict_New();
+
+ ret = PyGObject_Type.tp_init(self, args, new_kwds);
+
+ Py_DECREF(new_kwds);
+
+ if (ret == -1) return -1;
+
+ /* Eléments de base */
+
+ proc = G_ARCH_PROCESSOR(pygobject_get(self));
+
+ proc->endianness = endianness;
+ proc->memsize = mem_size;
+ proc->inssize = ins_min_size;
+ proc->virt_space = vspace;
+
+ register_dynamic_type_pattern(G_OBJECT(proc));
+
+ return 0;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : proc = architecture visée par la procédure. *
* *
* Description : Fournit un contexte propre au processeur d'une architecture. *
@@ -930,6 +1028,7 @@ PyTypeObject *get_python_arch_processor_type(void)
.tp_methods = py_arch_processor_methods,
.tp_getset = py_arch_processor_getseters,
+ .tp_init = py_arch_processor_init,
.tp_new = py_arch_processor_new,
};
diff --git a/plugins/pychrysalide/arch/register.c b/plugins/pychrysalide/arch/register.c
index 0299fa6..c55cd2b 100644
--- a/plugins/pychrysalide/arch/register.c
+++ b/plugins/pychrysalide/arch/register.c
@@ -103,8 +103,8 @@ static PyObject *py_arch_register_new(PyTypeObject *type, PyObject *args, PyObje
first_time = (g_type_from_name(type->tp_name) == 0);
- gtype = built_dynamic_type(G_TYPE_ARCH_REGISTER, type->tp_name,
- (GClassInitFunc)py_arch_register_init_gclass, NULL);
+ gtype = build_dynamic_type(G_TYPE_ARCH_REGISTER, type->tp_name,
+ (GClassInitFunc)py_arch_register_init_gclass, NULL, NULL);
if (first_time)
{
diff --git a/plugins/pychrysalide/gui/panels/panel.c b/plugins/pychrysalide/gui/panels/panel.c
index 0db1df8..2d0b562 100644
--- a/plugins/pychrysalide/gui/panels/panel.c
+++ b/plugins/pychrysalide/gui/panels/panel.c
@@ -109,8 +109,8 @@ static PyObject *py_panel_item_new(PyTypeObject *type, PyObject *args, PyObject
first_time = (g_type_from_name(type->tp_name) == 0);
- gtype = built_dynamic_type(G_TYPE_PANEL_ITEM, type->tp_name,
- (GClassInitFunc)py_panel_item_init_gclass, NULL);
+ gtype = build_dynamic_type(G_TYPE_PANEL_ITEM, type->tp_name,
+ (GClassInitFunc)py_panel_item_init_gclass, NULL, NULL);
if (first_time)
{
diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c
index 7667af7..51da910 100644
--- a/plugins/pychrysalide/plugin.c
+++ b/plugins/pychrysalide/plugin.c
@@ -175,8 +175,8 @@ static PyObject *py_plugin_module_new(PyTypeObject *type, PyObject *args, PyObje
first_time = (g_type_from_name(type->tp_name) == 0);
- gtype = built_dynamic_type(G_TYPE_PYTHON_PLUGIN, type->tp_name,
- (GClassInitFunc)py_plugin_module_init_gclass, NULL);
+ gtype = build_dynamic_type(G_TYPE_PYTHON_PLUGIN, type->tp_name,
+ (GClassInitFunc)py_plugin_module_init_gclass, NULL, NULL);
if (first_time)
{