summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/core
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-05-16 18:41:37 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-05-16 18:41:37 (GMT)
commit85bd3c6c415d42c0722298cf8e4542c94a87d7f1 (patch)
tree6a620ac5e06fcfd09574596af8a6030deb22f547 /plugins/pychrysalide/core
parent90d1fa65a1d13128a66117095a44224e8c9de656 (diff)
Added a way to get all registered architectures.
Diffstat (limited to 'plugins/pychrysalide/core')
-rw-r--r--plugins/pychrysalide/core/processors.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/pychrysalide/core/processors.c b/plugins/pychrysalide/core/processors.c
index 262cc11..b1f85bc 100644
--- a/plugins/pychrysalide/core/processors.c
+++ b/plugins/pychrysalide/core/processors.c
@@ -25,6 +25,7 @@
#include "processors.h"
+#include <malloc.h>
#include <pygobject.h>
@@ -43,6 +44,9 @@
/* Enregistre un processeur pour une architecture donnée. */
static PyObject *py_processors_register_processor(PyObject *, PyObject *);
+/* Fournit la liste des processeurs d'architecture disponibles. */
+static PyObject *py_processors_get_all_processor_keys(PyObject *, PyObject *);
+
/* Fournit le processeur d'architecture correspondant à un nom. */
static PyObject *py_processors_get_processor_for_key(PyObject *, PyObject *);
@@ -131,6 +135,51 @@ static PyObject *py_processors_register_processor(PyObject *self, PyObject *args
* Paramètres : self = objet Python concerné par l'appel. *
* args = arguments fournis à l'appel. *
* *
+* Description : Fournit la liste des processeurs d'architecture disponibles. *
+* *
+* Retour : Liste de nom technique des processeurs enregistrés. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_processors_get_all_processor_keys(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ size_t count; /* Taille de la liste retournée*/
+ char **keys; /* Noms techniques à traiter */
+ size_t i; /* Boucle de parcours */
+
+#define PROCESSORS_GET_ALL_PROCESSOR_KEYS_METHOD PYTHON_METHOD_DEF \
+( \
+ get_all_processor_keys, "", \
+ METH_NOARGS, py_processors, \
+ "Provide the list of keys from all registered architecture processors." \
+)
+
+ keys = get_all_processor_keys(&count);
+
+ result = PyTuple_New(count);
+
+ for (i = 0; i < count; i++)
+ {
+ PyTuple_SetItem(result, i, PyUnicode_FromString(keys[i]));
+ free(keys[i]);
+ }
+
+ if (keys != NULL)
+ free(keys);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* args = arguments fournis à l'appel. *
+* *
* Description : Fournit le processeur d'architecture correspondant à un nom. *
* *
* Retour : Processeur d'architecture trouvé. *
@@ -196,6 +245,7 @@ bool populate_core_module_with_processors(void)
static PyMethodDef py_processors_methods[] = {
PROCESSORS_REGISTER_PROCESSOR_METHOD,
+ PROCESSORS_GET_ALL_PROCESSOR_KEYS_METHOD,
PROCESSORS_GET_PROCESSOR_FOR_KEY_METHOD,
{ NULL }
};