summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/scan/space.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis/scan/space.c')
-rw-r--r--plugins/pychrysalide/analysis/scan/space.c114
1 files changed, 50 insertions, 64 deletions
diff --git a/plugins/pychrysalide/analysis/scan/space.c b/plugins/pychrysalide/analysis/scan/space.c
index 7d85fca..79e0c28 100644
--- a/plugins/pychrysalide/analysis/scan/space.c
+++ b/plugins/pychrysalide/analysis/scan/space.c
@@ -30,20 +30,24 @@
#include <i18n.h>
#include <analysis/content.h>
+#include <analysis/scan/item.h>
#include <analysis/scan/space-int.h>
#include <plugins/pychrysalide/access.h>
#include <plugins/pychrysalide/helpers.h>
#include <plugins/pychrysalide/analysis/content.h>
+#include "item.h"
+
+
CREATE_DYN_CONSTRUCTOR(scan_namespace, G_TYPE_SCAN_NAMESPACE);
/* Initialise une instance sur la base du dérivé de GObject. */
static int py_scan_namespace_init(PyObject *, PyObject *, PyObject *);
-/* Indique le nom attribué à un espace de noms. */
-static PyObject *py_scan_namespace_get_name(PyObject *, void *);
+/* Intègre un nouvel élément dans l'esapce de noms. */
+static PyObject *py_scan_namespace_register_item(PyObject *, PyObject *);
@@ -63,7 +67,9 @@ static PyObject *py_scan_namespace_get_name(PyObject *, void *);
static int py_scan_namespace_init(PyObject *self, PyObject *args, PyObject *kwds)
{
+ const char *name; /* Désignation de l'espace */
int ret; /* Bilan de lecture des args. */
+ GScanNamespace *space; /* Création GLib à transmettre */
#define SCAN_NAMESPACE_DOC \
"ScanNamespace defines a group of properties and functions for a" \
@@ -71,101 +77,82 @@ static int py_scan_namespace_init(PyObject *self, PyObject *args, PyObject *kwds
"\n" \
"Instances can be created using the following constructor:\n" \
"\n" \
- " ScanNamespace()"
+ " ScanNamespace(name)" \
+ "\n" \
+ "Where *name* is a string providing the name of the new namespace."
+
+ /* Récupération des paramètres */
+
+ ret = PyArg_ParseTuple(args, "s", &name);
+ if (!ret) return -1;
/* Initialisation d'un objet GLib */
ret = forward_pygobjet_init(self);
if (ret == -1) return -1;
+ /* Elément de base */
+
+ space = G_SCAN_NAMESPACE(pygobject_get(self));
+
+ if (!g_scan_namespace_create(space, name))
+ {
+ PyErr_SetString(PyExc_ValueError, _("Unable to create scan namespace."));
+ return -1;
+ }
+
return 0;
}
-#if 0
+
/******************************************************************************
* *
* Paramètres : self = objet représentant une table de chaînes. *
* args = arguments fournis pour l'opération. *
* *
-* Description : Remplace les propriétés renvoyant à des ressources. *
+* Description : Intègre un nouvel élément dans l'esapce de noms. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-static PyObject *py_scan_namespace_resolve(PyObject *self, PyObject *args)
+static PyObject *py_scan_namespace_register_item(PyObject *self, PyObject *args)
{
PyObject *result; /* Bilan à retourner */
- GResourceTable *table; /* Table de ressources */
+ GRegisteredItem *item; /* Elément d'évaluation à lier */
int ret; /* Bilan de lecture des args. */
- GScanNamespace *format; /* Version native */
-
-#define SCAN_NAMESPACE_RESOLVE_METHOD PYTHON_METHOD_DEF \
-( \
- resolve, "$self, table, /", \
- METH_VARARGS, py_scan_namespace, \
- "Resolve all XML node attribute values pointing to" \
- " resource entries. Such values are identifiers" \
- " of the forme '@0x...'.\n" \
- "\n" \
- "The *table* argument has to be a loaded" \
- " pychrysalide.format.androidfw.ResourceTable" \
- " instance.\n" \
+ GScanNamespace *space; /* Version native */
+ bool status; /* Bilan de l'opération */
+
+#define SCAN_NAMESPACE_REGISTER_ITEM_METHOD PYTHON_METHOD_DEF \
+( \
+ register_item, "$self, item, /", \
+ METH_VARARGS, py_scan_namespace, \
+ "Include an item into a namespace.\n" \
+ "\n" \
+ "The *item* argument has to be a pychrysalide.analysis.scan.RegisteredItem" \
+ " instance.\n" \
+ "\n" \
+ "The function returns a boolean value translating the operation status:" \
+ " *True* in case of success, *False* for a failure.\n" \
)
- ret = PyArg_ParseTuple(args, "O&", convert_to_resource_table, &table);
+ ret = PyArg_ParseTuple(args, "O&", convert_to_registered_item, &item);
if (!ret) return NULL;
- format = G_SCAN_NAMESPACE(pygobject_get(self));
-
- g_scan_namespace_resvolve(format, table);
-
- result = Py_None;
- Py_INCREF(result);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = classe représentant un format Axml. *
-* closure = adresse non utilisée ici. *
-* *
-* Description : Indique le nom attribué à un espace de noms. *
-* *
-* Retour : Désignation associée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_scan_namespace_get_name(PyObject *self, void *closure)
-{
- PyObject *result; /* Liste éventuelle à renvoyer */
- GScanNamespace *space; /* Version native */
- const char *name; /* Désignation à exporter */
-
-#define SCAN_NAMESPACE_NAME_ATTRIB PYTHON_GET_DEF_FULL \
-( \
- name, py_scan_namespace, \
- "Name provided for the namespace." \
-)
-
space = G_SCAN_NAMESPACE(pygobject_get(self));
- name = g_scan_namespace_get_name(space);
+ status = g_scan_namespace_register_item(space, item);
- result = PyUnicode_FromString(name);
+ result = status ? Py_True : Py_False;
+ Py_INCREF(result);
return result;
}
-#endif
/******************************************************************************
@@ -183,12 +170,11 @@ static PyObject *py_scan_namespace_get_name(PyObject *self, void *closure)
PyTypeObject *get_python_scan_namespace_type(void)
{
static PyMethodDef py_scan_namespace_methods[] = {
- //SCAN_NAMESPACE_RESOLVE_METHOD,
+ SCAN_NAMESPACE_REGISTER_ITEM_METHOD,
{ NULL }
};
static PyGetSetDef py_scan_namespace_getseters[] = {
- //SCAN_NAMESPACE_NAME_ATTRIB,
{ NULL }
};