summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-04-19 18:36:28 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-04-19 18:36:28 (GMT)
commit3dada5fbc27777217625603905727364a0cc996d (patch)
tree0ff4b94aca92e64a9e01594b4421f86465560395 /plugins/pychrysalide/arch
parentfad679ef8cd654646c9234ff8fd39507adad9b8e (diff)
Changed the way the key for an architecture is provided.
Diffstat (limited to 'plugins/pychrysalide/arch')
-rw-r--r--plugins/pychrysalide/arch/processor.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/pychrysalide/arch/processor.c b/plugins/pychrysalide/arch/processor.c
index 379df02..f04929e 100644
--- a/plugins/pychrysalide/arch/processor.c
+++ b/plugins/pychrysalide/arch/processor.c
@@ -60,6 +60,9 @@ 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 la désignation interne du processeur d'architecture. */
+static char *py_arch_processor_get_key_wrapper(const GArchProcessor *);
+
/* Fournit un contexte propre au processeur d'une architecture. */
static GProcContext *py_arch_processor_get_context_wrapper(const GArchProcessor *);
@@ -225,6 +228,7 @@ static void py_arch_processor_init_gclass(GArchProcessorClass *class, gpointer u
*/
}
+ class->get_key = py_arch_processor_get_key_wrapper;
class->get_ctx = py_arch_processor_get_context_wrapper;
class->disassemble = py_arch_processor_disassemble_wrapper;
@@ -313,6 +317,68 @@ static int py_arch_processor_init(PyObject *self, PyObject *args, PyObject *kwds
/******************************************************************************
* *
+* Paramètres : proc = processeur d'architecture à consulter. *
+* *
+* Description : Fournit la désignation interne du processeur d'architecture. *
+* *
+* Retour : Simple chaîne de caractères. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *py_arch_processor_get_key_wrapper(const GArchProcessor *proc)
+{
+ char *result; /* Désignation à renvoyer */
+ PyGILState_STATE gstate; /* Sauvegarde d'environnement */
+ PyObject *pyobj; /* Objet Python concerné */
+ PyObject *pykey; /* Clef en objet Python */
+ int ret; /* Bilan d'une conversion */
+ GArchProcessorClass *class; /* Classe de l'objet courant */
+ GArchProcessorClass *parent; /* Classe parente */
+
+ result = NULL;
+
+ gstate = PyGILState_Ensure();
+
+ pyobj = pygobject_new(G_OBJECT(proc));
+
+ if (has_python_method(pyobj, "_get_key"))
+ {
+ pykey = run_python_method(pyobj, "_get_key", NULL);
+
+ if (pykey != NULL)
+ {
+ ret = PyUnicode_Check(pykey);
+
+ if (ret)
+ result = strdup(PyUnicode_AsUTF8(pykey));
+
+ Py_DECREF(pykey);
+
+ }
+
+ }
+
+ else
+ {
+ class = G_ARCH_PROCESSOR_GET_CLASS(proc);
+ parent = g_type_class_peek_parent(class);
+
+ if (parent->get_key != NULL)
+ result = parent->get_key(proc);
+
+ }
+
+ PyGILState_Release(gstate);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : proc = architecture visée par la procédure. *
* *
* Description : Fournit un contexte propre au processeur d'une architecture. *