summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/format/dex/dex.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/format/dex/dex.c')
-rw-r--r--plugins/pychrysa/format/dex/dex.c50
1 files changed, 13 insertions, 37 deletions
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);
}