summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-07-30 10:57:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-07-30 10:57:08 (GMT)
commitfb1d26845908d131b1c92d7d7cd1bc402b656ca4 (patch)
treea6c6a30482ce97dfe7b985116877bb0ce8b7b0a0 /plugins/pychrysa/glibext
parent7b8eed3f8207fe9b629165f8230e38ee620900ea (diff)
Registered properly the PyGObject wrappers for Python classes.
Diffstat (limited to 'plugins/pychrysa/glibext')
-rw-r--r--plugins/pychrysa/glibext/bufferline.c14
-rw-r--r--plugins/pychrysa/glibext/codebuffer.c15
-rw-r--r--plugins/pychrysa/glibext/configuration.c34
3 files changed, 15 insertions, 48 deletions
diff --git a/plugins/pychrysa/glibext/bufferline.c b/plugins/pychrysa/glibext/bufferline.c
index ce85cfb..f3ef2c0 100644
--- a/plugins/pychrysa/glibext/bufferline.c
+++ b/plugins/pychrysa/glibext/bufferline.c
@@ -356,28 +356,18 @@ PyTypeObject *get_python_buffer_line_type(void)
bool register_python_buffer_line(PyObject *module)
{
PyTypeObject *py_buffer_line_type; /* Type Python 'BufferLine' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_buffer_line_type = get_python_buffer_line_type();
- py_buffer_line_type->tp_base = &PyGObject_Type;
- py_buffer_line_type->tp_basicsize = py_buffer_line_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_buffer_line_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_BUFFER_LINE, py_buffer_line_type, &PyGObject_Type))
return false;
if (!py_buffer_line_define_constants(py_buffer_line_type))
return false;
- Py_INCREF(py_buffer_line_type);
- ret = PyModule_AddObject(module, "BufferLine", (PyObject *)py_buffer_line_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "BufferLine", G_TYPE_BUFFER_LINE, py_buffer_line_type,
- Py_BuildValue("(O)", py_buffer_line_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/glibext/codebuffer.c b/plugins/pychrysa/glibext/codebuffer.c
index 9d9bc96..efe3141 100644
--- a/plugins/pychrysa/glibext/codebuffer.c
+++ b/plugins/pychrysa/glibext/codebuffer.c
@@ -32,6 +32,7 @@
#include "../arch/vmpa.h"
+#include "../helpers.h"
@@ -146,25 +147,15 @@ PyTypeObject *get_python_code_buffer_type(void)
bool register_python_code_buffer(PyObject *module)
{
PyTypeObject *py_code_buffer_type; /* Type Python 'CodeBuffer' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_code_buffer_type = get_python_code_buffer_type();
- py_code_buffer_type->tp_base = &PyGObject_Type;
- py_code_buffer_type->tp_basicsize = py_code_buffer_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_code_buffer_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_CODE_BUFFER, py_code_buffer_type, &PyGObject_Type))
return false;
- Py_INCREF(py_code_buffer_type);
- ret = PyModule_AddObject(module, "CodeBuffer", (PyObject *)py_code_buffer_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "CodeBuffer", G_TYPE_CODE_BUFFER, py_code_buffer_type,
- Py_BuildValue("(O)", py_code_buffer_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/glibext/configuration.c b/plugins/pychrysa/glibext/configuration.c
index fd35b19..b35806a 100644
--- a/plugins/pychrysa/glibext/configuration.c
+++ b/plugins/pychrysa/glibext/configuration.c
@@ -31,6 +31,9 @@
#include <glibext/configuration.h>
+#include "../helpers.h"
+
+
/* ---------------------------- ELEMENT DE CONFIGURATION ---------------------------- */
@@ -574,29 +577,19 @@ static bool py_config_param_define_constants(PyObject *dict)
bool register_python_config_param(PyObject *module)
{
- PyTypeObject *py_config_param_type; /* Type Python 'ConfigParam' */
- int ret; /* Bilan d'un appel */
+ PyTypeObject *py_config_param_type; /* Type Python 'ConfigParam' */
PyObject *dict; /* Dictionnaire du module */
py_config_param_type = get_python_config_param_type();
- py_config_param_type->tp_base = &PyGObject_Type;
- py_config_param_type->tp_basicsize = py_config_param_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_config_param_type) != 0)
+ if (!register_class_for_pygobject(dict, G_TYPE_CFG_PARAM, py_config_param_type, &PyGObject_Type))
return false;
if (!py_config_param_define_constants(py_config_param_type->tp_dict))
return false;
- Py_INCREF(py_config_param_type);
- ret = PyModule_AddObject(module, "ConfigParam", (PyObject *)py_config_param_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "ConfigParam", G_TYPE_CFG_PARAM, py_config_param_type,
- Py_BuildValue("(O)", py_config_param_type->tp_base));
-
return true;
}
@@ -779,7 +772,7 @@ PyTypeObject *get_python_config_param_iterator_type(void)
bool register_python_config_param_iterator(PyObject *module)
{
- PyTypeObject *py_config_param_iterator_type; /* Type Python 'ConfigParamIterator' */
+ PyTypeObject *py_config_param_iterator_type;/* Type Python 'Cnf...Iter'*/
int ret; /* Bilan d'un appel */
py_config_param_iterator_type = get_python_config_param_iterator_type();
@@ -1158,24 +1151,17 @@ PyTypeObject *get_python_generic_config_type(void)
bool register_python_generic_config(PyObject *module)
{
PyTypeObject *py_generic_config_type; /* Type Python 'GenConfig' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_generic_config_type = get_python_generic_config_type();
- py_generic_config_type->tp_base = &PyGObject_Type;
- py_generic_config_type->tp_basicsize = py_generic_config_type->tp_base->tp_basicsize;
-
if (PyType_Ready(py_generic_config_type) != 0)
return false;
- Py_INCREF(py_generic_config_type);
- ret = PyModule_AddObject(module, "GenConfig", (PyObject *)py_generic_config_type);
- if (ret != 0) return false;
-
dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "GenConfig", G_TYPE_GEN_CONFIG, py_generic_config_type,
- Py_BuildValue("(O)", py_generic_config_type->tp_base));
+
+ if (!register_class_for_pygobject(dict, G_TYPE_GEN_CONFIG, py_generic_config_type, &PyGObject_Type))
+ return false;
return true;