summaryrefslogtreecommitdiff
path: root/plugins/dex/python/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dex/python/format.c')
-rw-r--r--plugins/dex/python/format.c336
1 files changed, 15 insertions, 321 deletions
diff --git a/plugins/dex/python/format.c b/plugins/dex/python/format.c
index 8f18fc8..77ebef6 100644
--- a/plugins/dex/python/format.c
+++ b/plugins/dex/python/format.c
@@ -39,30 +39,14 @@
#include "constants.h"
#include "../class.h"
#include "../format.h"
-#include "../pool.h"
/* Crée un nouvel objet Python de type 'DexFormat'. */
static PyObject *py_dex_format_new(PyTypeObject *, PyObject *, PyObject *);
-/* Fournit la liste de toutes les chaînes de la table globale. */
-static PyObject *py_dex_format_get_pool_strings(PyObject *, void *);
-
-/* Fournit la liste de tous les types de la table globale. */
-static PyObject *py_dex_format_get_pool_types(PyObject *, void *);
-
-/* Fournit la liste de tous les prototypes de la table globale. */
-static PyObject *py_dex_format_get_pool_prototypes(PyObject *, void *);
-
-/* Fournit la liste de tous les champs de la table globale. */
-static PyObject *py_dex_format_get_pool_fields(PyObject *, void *);
-
-/* Fournit la liste de toutes les méthodes de la table globale. */
-static PyObject *py_dex_format_get_pool_methods(PyObject *, void *);
-
-/* Fournit la liste de toutes les classes du format. */
-static PyObject *py_dex_format_get_classes(PyObject *, void *);
+/* Fournit la table des ressources associée au format Dex. */
+static PyObject *py_dex_format_get_pool(PyObject *, void *);
@@ -117,300 +101,33 @@ static PyObject *py_dex_format_new(PyTypeObject *type, PyObject *args, PyObject
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
-* Description : Fournit la liste de toutes les chaînes de la table globale. *
-* *
-* Retour : Liste vide ou remplie de chaînes. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_dex_format_get_pool_strings(PyObject *self, void *closure)
-{
- PyObject *result; /* Valeur à retourner */
- GDexFormat *format; /* Version native */
- uint32_t count; /* Nombre d'éléments à traiter */
- uint32_t i; /* Boucle de parcours */
- const char *string; /* Chaîne à intégrer */
- PyObject *str; /* Chaîne au format Python */
-
- format = G_DEX_FORMAT(pygobject_get(self));
-
- count = count_strings_in_dex_pool(format);
-
- result = PyTuple_New(count);
-
- for (i = 0; i < count; i++)
- {
- string = get_string_from_dex_pool(format, i, NULL);
-
- if (string == NULL)
- {
- str = Py_None;
- Py_INCREF(str);
- }
-
- else
- str = PyUnicode_FromString(string);
-
- PyTuple_SetItem(result, i, str);
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* closure = non utilisé ici. *
-* *
-* Description : Fournit la liste de tous les types de la table globale. *
-* *
-* Retour : Liste vide ou remplie de types. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_dex_format_get_pool_types(PyObject *self, void *closure)
-{
- PyObject *result; /* Valeur à retourner */
- GDexFormat *format; /* Version native */
- uint32_t count; /* Nombre d'éléments à traiter */
- uint32_t i; /* Boucle de parcours */
- GDataType *type; /* Type à intégrer */
- PyObject *tp; /* Type au format Python */
-
- format = G_DEX_FORMAT(pygobject_get(self));
-
- count = count_types_in_dex_pool(format);
-
- result = PyTuple_New(count);
-
- for (i = 0; i < count; i++)
- {
- type = get_type_from_dex_pool(format, i);
-
- if (type == NULL)
- {
- tp = Py_None;
- Py_INCREF(tp);
- }
-
- else
- {
- tp = pygobject_new(G_OBJECT(type));
- g_object_unref(type);
- }
-
- PyTuple_SetItem(result, i, tp);
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* closure = non utilisé ici. *
-* *
-* Description : Fournit la liste de tous les champs de la table globale. *
-* *
-* Retour : Liste vide ou remplie de méthodes. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_dex_format_get_pool_fields(PyObject *self, void *closure)
-{
- PyObject *result; /* Valeur à retourner */
- GDexFormat *format; /* Version native */
- uint32_t count; /* Nombre d'éléments à traiter */
- uint32_t i; /* Boucle de parcours */
- GBinVariable *variable; /* Champ à intégrer */
- PyObject *var; /* Champ au format Python */
-
- format = G_DEX_FORMAT(pygobject_get(self));
-
- count = count_fields_in_dex_pool(format);
-
- result = PyTuple_New(count);
-
- for (i = 0; i < count; i++)
- {
- variable = get_field_from_dex_pool(format, i);
-
- if (variable == NULL)
- {
- var = Py_None;
- Py_INCREF(var);
- }
-
- else
- {
- var = pygobject_new(G_OBJECT(variable));
- g_object_unref(variable);
- }
-
- PyTuple_SetItem(result, i, var);
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* closure = non utilisé ici. *
-* *
-* Description : Fournit la liste de toutes les méthodes de la table globale. *
-* *
-* Retour : Liste vide ou remplie de méthodes. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_dex_format_get_pool_methods(PyObject *self, void *closure)
-{
- PyObject *result; /* Valeur à retourner */
- GDexFormat *format; /* Version native */
- uint32_t count; /* Nombre d'éléments à traiter */
- uint32_t i; /* Boucle de parcours */
- GDexMethod *method; /* Méthode à intégrer */
- PyObject *meth; /* Méthode au format Python */
-
- format = G_DEX_FORMAT(pygobject_get(self));
-
- count = count_methods_in_dex_pool(format);
-
- result = PyTuple_New(count);
-
- for (i = 0; i < count; i++)
- {
- method = get_method_from_dex_pool(format, i);
-
- if (method == NULL)
- {
- meth = Py_None;
- Py_INCREF(meth);
- }
-
- else
- {
- meth = pygobject_new(G_OBJECT(method));
- g_object_unref(method);
- }
-
- PyTuple_SetItem(result, i, meth);
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* closure = non utilisé ici. *
-* *
-* Description : Fournit la liste de tous les prototypes de la table globale. *
+* Description : Fournit la table des ressources associée au format Dex. *
* *
-* Retour : Liste vide ou remplie de méthodes. *
+* Retour : Table de ressources mise en place ou None si aucune. *
* *
* Remarques : - *
* *
******************************************************************************/
-static PyObject *py_dex_format_get_pool_prototypes(PyObject *self, void *closure)
+static PyObject *py_dex_format_get_pool(PyObject *self, void *closure)
{
PyObject *result; /* Valeur à retourner */
GDexFormat *format; /* Version native */
- uint32_t count; /* Nombre d'éléments à traiter */
- uint32_t i; /* Boucle de parcours */
- GBinRoutine *routine; /* Routine à intégrer */
- PyObject *rtn; /* Routine au format Python */
-
- format = G_DEX_FORMAT(pygobject_get(self));
-
- count = count_prototypes_in_dex_pool(format);
-
- result = PyTuple_New(count);
-
- for (i = 0; i < count; i++)
- {
- routine = get_prototype_from_dex_pool(format, i);
-
- if (routine == NULL)
- {
- rtn = Py_None;
- Py_INCREF(rtn);
- }
-
- else
- {
- rtn = pygobject_new(G_OBJECT(routine));
- g_object_unref(routine);
- }
-
- PyTuple_SetItem(result, i, rtn);
-
- }
-
- return result;
-
-}
+ GDexPool *pool; /* Table de ressources associée*/
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* closure = non utilisé ici. *
-* *
-* Description : Fournit la liste de toutes les classes du format. *
-* *
-* Retour : Liste vide ou remplie de classes. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_dex_format_get_classes(PyObject *self, void *closure)
-{
- PyObject *result; /* Valeur à retourner */
- GDexFormat *format; /* Version native */
- size_t count; /* Nombre d'éléments à traiter */
- size_t i; /* Boucle de parcours */
- GDexClass *class; /* Classe du format à intégrer */
+#define DEX_FORMAT_POOL_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ pool, py_dex_format, \
+ "Resource pool of the Dex format." \
+)
format = G_DEX_FORMAT(pygobject_get(self));
- count = g_dex_format_count_classes(format);
+ pool = g_dex_format_get_pool(format);
- result = PyTuple_New(count);
+ result = pygobject_new(G_OBJECT(pool));
- for (i = 0; i < count; i++)
- {
- class = g_dex_format_get_class(format, i);
- assert(class != NULL);
-
- PyTuple_SetItem(result, i, pygobject_new(G_OBJECT(class)));
-
- g_object_unref(G_OBJECT(class));
-
- }
+ g_object_unref(G_OBJECT(pool));
return result;
@@ -436,30 +153,7 @@ PyTypeObject *get_python_dex_format_type(void)
};
static PyGetSetDef py_dex_format_getseters[] = {
- {
- "pool_strings", py_dex_format_get_pool_strings, NULL,
- "Strings inside the Dex pool.", NULL
- },
- {
- "pool_types", py_dex_format_get_pool_types, NULL,
- "Types inside the Dex pool.", NULL
- },
- {
- "pool_prototypes", py_dex_format_get_pool_prototypes, NULL,
- "Prototypes inside the Dex pool.", NULL
- },
- {
- "pool_fields", py_dex_format_get_pool_fields, NULL,
- "Fields inside the Dex pool.", NULL
- },
- {
- "pool_methods", py_dex_format_get_pool_methods, NULL,
- "Methods inside the Dex pool.", NULL
- },
- {
- "classes", py_dex_format_get_classes, NULL,
- "Classes inside the Dex format.", NULL
- },
+ DEX_FORMAT_POOL_ATTRIB,
{ NULL }
};