summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/glibext/codebuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/glibext/codebuffer.c')
-rw-r--r--plugins/pychrysa/glibext/codebuffer.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/plugins/pychrysa/glibext/codebuffer.c b/plugins/pychrysa/glibext/codebuffer.c
index a090e27..e4c94e3 100644
--- a/plugins/pychrysa/glibext/codebuffer.c
+++ b/plugins/pychrysa/glibext/codebuffer.c
@@ -28,6 +28,9 @@
#include <pygobject.h>
+#include <glibext/gcodebuffer.h>
+
+
#include "../quirks.h"
@@ -39,34 +42,6 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *, PyObject *);
/******************************************************************************
* *
-* Paramètres : binary = instance existante GLib. *
-* *
-* Description : Crée un nouvel objet Python de type 'Codebuffer'. *
-* *
-* Retour : Instance Python mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyObject *py_code_buffer_from_c(GCodeBuffer *buffer)
-{
- PyObject *module; /* Module d'appartenance */
- PyTypeObject *type; /* Type Python correspondant */
-
- module = PyImport_ImportModule("pychrysalide.glibext");
- type = (PyTypeObject *)PyObject_GetAttrString(module, "CodeBuffer");
- Py_DECREF(module);
-
- pychrysalide_set_instance_data(G_OBJECT(buffer), type);
-
- return pygobject_new(G_OBJECT(buffer));
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : self = classe représentant un tampon de code. *
* args = arguments fournis à l'appel. *
* *
@@ -89,12 +64,12 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *self, PyObject *args
buffer = G_CODE_BUFFER(pygobject_get(self));
ret = PyArg_ParseTuple(args, "K", &addr);
- if (!ret) return Py_None;
+ if (!ret) Py_RETURN_NONE;
line = g_code_buffer_find_line_by_addr(buffer, addr);
- if (line == NULL) return Py_None;
+ if (line == NULL) Py_RETURN_NONE;
- result = py_buffer_line_from_c(line);
+ result = pygobject_new(G_OBJECT(line));
return result;
@@ -154,6 +129,9 @@ bool register_python_code_buffer(PyObject *module)
Py_INCREF(&py_code_buffer_type);
ret = PyModule_AddObject(module, "CodeBuffer", (PyObject *)&py_code_buffer_type);
+ pygobject_register_class(module, "GCodeBuffer", G_TYPE_CODE_BUFFER, &py_code_buffer_type,
+ Py_BuildValue("(O)", py_code_buffer_type.tp_base));
+
return (ret == 0);
}