summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/glibext
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/glibext')
-rw-r--r--plugins/pychrysa/glibext/bufferline.c34
-rw-r--r--plugins/pychrysa/glibext/bufferline.h5
-rw-r--r--plugins/pychrysa/glibext/codebuffer.c40
-rw-r--r--plugins/pychrysa/glibext/codebuffer.h5
4 files changed, 15 insertions, 69 deletions
diff --git a/plugins/pychrysa/glibext/bufferline.c b/plugins/pychrysa/glibext/bufferline.c
index 1e3b611..3804082 100644
--- a/plugins/pychrysa/glibext/bufferline.c
+++ b/plugins/pychrysa/glibext/bufferline.c
@@ -29,6 +29,9 @@
#include <pygobject.h>
+#include <glibext/gbufferline.h>
+
+
#include "../quirks.h"
@@ -40,34 +43,6 @@ static PyObject *py_buffer_line_get_text(PyObject *, PyObject *);
/******************************************************************************
* *
-* Paramètres : binary = instance existante GLib. *
-* *
-* Description : Crée un nouvel objet Python de type 'BufferLine'. *
-* *
-* Retour : Instance Python mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyObject *py_buffer_line_from_c(GBufferLine *line)
-{
- PyObject *module; /* Module d'appartenance */
- PyTypeObject *type; /* Type Python correspondant */
-
- module = PyImport_ImportModule("pychrysalide.glibext");
- type = (PyTypeObject *)PyObject_GetAttrString(module, "BufferLine");
- Py_DECREF(module);
-
- pychrysalide_set_instance_data(G_OBJECT(line), type);
-
- return pygobject_new(G_OBJECT(line));
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : self = classe représentant une ligne de tampon. *
* args = arguments fournis à l'appel. *
* *
@@ -150,6 +125,9 @@ bool register_python_buffer_line(PyObject *module)
Py_INCREF(&py_buffer_line_type);
ret = PyModule_AddObject(module, "BufferLine", (PyObject *)&py_buffer_line_type);
+ pygobject_register_class(module, "GBufferLine", G_TYPE_BUFFER_LINE, &py_buffer_line_type,
+ Py_BuildValue("(O)", py_buffer_line_type.tp_base));
+
return (ret == 0);
}
diff --git a/plugins/pychrysa/glibext/bufferline.h b/plugins/pychrysa/glibext/bufferline.h
index d15928f..abe6cd8 100644
--- a/plugins/pychrysa/glibext/bufferline.h
+++ b/plugins/pychrysa/glibext/bufferline.h
@@ -29,13 +29,8 @@
#include <Python.h>
#include <stdbool.h>
-#include <glibext/gbufferline.h>
-
-/* Crée un nouvel objet Python de type 'BufferLine'. */
-PyObject *py_buffer_line_from_c(GBufferLine *);
-
/* Prend en charge l'objet 'pychrysalide.glibext.BufferLine'. */
bool register_python_buffer_line(PyObject *);
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);
}
diff --git a/plugins/pychrysa/glibext/codebuffer.h b/plugins/pychrysa/glibext/codebuffer.h
index ba53fda..d80597e 100644
--- a/plugins/pychrysa/glibext/codebuffer.h
+++ b/plugins/pychrysa/glibext/codebuffer.h
@@ -29,13 +29,8 @@
#include <Python.h>
#include <stdbool.h>
-#include <glibext/gcodebuffer.h>
-
-/* Crée un nouvel objet Python de type 'CodeBuffer'. */
-PyObject *py_code_buffer_from_c(GCodeBuffer *);
-
/* Prend en charge l'objet 'pychrysalide.glibext.CodeBuffer'. */
bool register_python_code_buffer(PyObject *);