summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/format/dex
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-12-21 23:34:14 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-12-21 23:34:14 (GMT)
commit3bfff245c47c4dd1404c5ea7af0ff4858ac8d130 (patch)
treedc3613e2ebdef4d04fa874335795268dba732d31 /plugins/pychrysa/format/dex
parent0cfcbee3c536ac6d11ec806d47ce4c136f695697 (diff)
Resolved relative addresses for routines and fixed bugs related to PyGObjects construction.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@308 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/format/dex')
-rw-r--r--plugins/pychrysa/format/dex/class.c34
-rw-r--r--plugins/pychrysa/format/dex/class.h5
-rw-r--r--plugins/pychrysa/format/dex/dex.c50
-rw-r--r--plugins/pychrysa/format/dex/dex.h5
4 files changed, 20 insertions, 74 deletions
diff --git a/plugins/pychrysa/format/dex/class.c b/plugins/pychrysa/format/dex/class.c
index 97c1968..bc07fae 100644
--- a/plugins/pychrysa/format/dex/class.c
+++ b/plugins/pychrysa/format/dex/class.c
@@ -28,6 +28,9 @@
#include <pygobject.h>
+#include <format/dex/class.h>
+
+
#include "../../quirks.h"
@@ -53,37 +56,11 @@ static PyObject *py_dex_class_new(PyTypeObject *, PyObject *, PyObject *);
static PyObject *py_dex_class_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- return Py_None;
+ Py_RETURN_NONE;
}
-/******************************************************************************
-* *
-* Paramètres : item = instance existante GLib. *
-* *
-* Description : Crée un nouvel objet Python de type 'DexClass'. *
-* *
-* Retour : Instance Python mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyObject *py_dex_class_from_c(GDexClass *class)
-{
- PyObject *module; /* Module d'appartenance */
- PyTypeObject *type; /* Type Python correspondant */
-
- module = PyImport_ImportModule("pychrysalide.format.dex");
- type = (PyTypeObject *)PyObject_GetAttrString(module, "DexClass");
- Py_DECREF(module);
-
- pychrysalide_set_instance_data(G_OBJECT(class), type);
-
- return pygobject_new(G_OBJECT(class));
-
-}
@@ -152,6 +129,9 @@ bool register_python_dex_class(PyObject *module)
Py_INCREF(&py_dex_class_type);
ret = PyModule_AddObject(module, "DexClass", (PyObject *)&py_dex_class_type);
+ pygobject_register_class(module, "GDexClass", G_TYPE_DEX_CLASS, &py_dex_class_type,
+ Py_BuildValue("(O)", py_dex_class_type.tp_base));
+
return (ret == 0);
}
diff --git a/plugins/pychrysa/format/dex/class.h b/plugins/pychrysa/format/dex/class.h
index addf7ca..c2a8222 100644
--- a/plugins/pychrysa/format/dex/class.h
+++ b/plugins/pychrysa/format/dex/class.h
@@ -29,13 +29,8 @@
#include <Python.h>
#include <stdbool.h>
-#include <format/dex/class.h>
-
-/* Crée un nouvel objet Python de type 'DexClass'. */
-PyObject *py_dex_class_from_c(GDexClass *);
-
/* Prend en charge l'objet 'pychrysalide.format.dex.DexClass'. */
bool register_python_dex_class(PyObject *module);
diff --git a/plugins/pychrysa/format/dex/dex.c b/plugins/pychrysa/format/dex/dex.c
index 2df8d1b..cae87f7 100644
--- a/plugins/pychrysa/format/dex/dex.c
+++ b/plugins/pychrysa/format/dex/dex.c
@@ -27,6 +27,7 @@
#include <pygobject.h>
+
#include <format/dex/dex-int.h>
@@ -69,13 +70,13 @@ static PyObject *py_dex_format_new(PyTypeObject *type, PyObject *args, PyObject
GBinFormat *format; /* Version GLib du format */
ret = PyArg_ParseTuple(args, "s#", &content, &length);
- if (!ret) return Py_None;
+ if (!ret) Py_RETURN_NONE;
format = g_dex_format_new(content, length);
- if (format == NULL) return Py_None;
+ if (format == NULL) Py_RETURN_NONE;
- result = py_dex_format_from_c(G_DEX_FORMAT(format));
- g_object_unref(format);
+ result = pygobject_new(G_OBJECT(format));
+ //g_object_unref(format);
return (PyObject *)result;
@@ -84,34 +85,6 @@ static PyObject *py_dex_format_new(PyTypeObject *type, PyObject *args, PyObject
/******************************************************************************
* *
-* Paramètres : item = instance existante GLib. *
-* *
-* Description : Crée un nouvel objet Python de type 'DexFormat'. *
-* *
-* Retour : Instance Python mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyObject *py_dex_format_from_c(GDexFormat *format)
-{
- PyObject *module; /* Module d'appartenance */
- PyTypeObject *type; /* Type Python correspondant */
-
- module = PyImport_ImportModule("pychrysalide.format.dex");
- type = (PyTypeObject *)PyObject_GetAttrString(module, "DexFormat");
- Py_DECREF(module);
-
- pychrysalide_set_instance_data(G_OBJECT(format), type);
-
- return pygobject_new(G_OBJECT(format));
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : self = classe représentant un binaire. *
* args = arguments fournis à l'appel. *
* *
@@ -162,14 +135,14 @@ static PyObject *py_dex_format_get_class(PyObject *self, PyObject *args)
GDexClass *class; /* Classe à communiquer */
ret = PyArg_ParseTuple(args, "i", &index);
- if (!ret) return Py_None;
+ if (!ret) Py_RETURN_NONE;
format = G_DEX_FORMAT(pygobject_get(self));
class = g_dex_format_get_class(format, index);
- if (class == NULL) return Py_None;
+ if (class == NULL) Py_RETURN_NONE;
- result = py_dex_class_from_c(class);
+ result = pygobject_new(G_OBJECT(class));
return result;
@@ -233,10 +206,10 @@ bool register_python_dex_format(PyObject *module)
};
- pygobj_mod = PyImport_ImportModule("gobject");
+ pygobj_mod = PyImport_ImportModule("pychrysalide.format");
if (pygobj_mod == NULL) return false;
- py_dex_format_type.tp_base = (PyTypeObject *)PyObject_GetAttrString(pygobj_mod, "GObject");
+ py_dex_format_type.tp_base = (PyTypeObject *)PyObject_GetAttrString(pygobj_mod, "BinFormat");
Py_DECREF(pygobj_mod);
if (PyType_Ready(&py_dex_format_type) < 0)
@@ -245,6 +218,9 @@ bool register_python_dex_format(PyObject *module)
Py_INCREF(&py_dex_format_type);
ret = PyModule_AddObject(module, "DexFormat", (PyObject *)&py_dex_format_type);
+ pygobject_register_class(module, "GDexFormat", G_TYPE_DEX_FORMAT, &py_dex_format_type,
+ Py_BuildValue("(O)", py_dex_format_type.tp_base));
+
return (ret == 0);
}
diff --git a/plugins/pychrysa/format/dex/dex.h b/plugins/pychrysa/format/dex/dex.h
index 65eec0d..dc97269 100644
--- a/plugins/pychrysa/format/dex/dex.h
+++ b/plugins/pychrysa/format/dex/dex.h
@@ -29,13 +29,8 @@
#include <Python.h>
#include <stdbool.h>
-#include <format/dex/dex.h>
-
-/* Crée un nouvel objet Python de type 'DexFormat'. */
-PyObject *py_dex_format_from_c(GDexFormat *);
-
/* Prend en charge l'objet 'pychrysalide.format.dex.DexFormat'. */
bool register_python_dex_format(PyObject *module);