From fe3966c22cbf5e198164b088b4f46f280bc33126 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sat, 7 Jul 2007 12:09:52 +0000 Subject: Bug 351072 – Cannot handle signals with parameter type G_TYPE_VALUE (marshal/unmarshal for GValue-wrapped GValue) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=680 --- tests/test_gtype.py | 5 +++++ tests/testhelpermodule.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/test_gtype.py b/tests/test_gtype.py index df75ccf..ad54dc6 100644 --- a/tests/test_gtype.py +++ b/tests/test_gtype.py @@ -64,6 +64,11 @@ class GTypeTest(unittest.TestCase): def testObject(self): self.checkType(gobject.TYPE_OBJECT, 'PyObject') + def testValue(self): + array = [1, "foo", True] + for i in array: + self.assertEqual(i, testhelper.test_value(i)) + def testValueArray(self): array = [1, 2, 3, "foo", True] self.assertEqual(array, testhelper.test_value_array(array)) diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c index 8d9419e..d78cf55 100644 --- a/tests/testhelpermodule.c +++ b/tests/testhelpermodule.c @@ -450,6 +450,24 @@ _wrap_connectcallbacks(PyObject * self, PyObject *args) return Py_None; } +static PyObject * +_wrap_test_value(PyObject *self, PyObject *args) +{ + GValue tvalue = {0,}, *value = &tvalue; + PyObject *obj; + + if (!PyArg_ParseTuple(args, "O", &obj)) + return NULL; + + g_value_init(value, G_TYPE_VALUE); + if (pyg_value_from_pyobject(value, obj)) { + PyErr_SetString(PyExc_TypeError, "Could not convert to GValue"); + return NULL; + } + + return pyg_value_as_pyobject(value, FALSE); +} + static PyObject * _wrap_test_value_array(PyObject *self, PyObject *args) { @@ -500,6 +518,7 @@ static PyMethodDef testhelper_functions[] = { { "create_test_type", (PyCFunction)_wrap_create_test_type, METH_NOARGS }, { "test_g_object_new", (PyCFunction)_wrap_test_g_object_new, METH_NOARGS }, { "connectcallbacks", (PyCFunction)_wrap_connectcallbacks, METH_VARARGS }, + { "test_value", (PyCFunction)_wrap_test_value, METH_VARARGS }, { "test_value_array", (PyCFunction)_wrap_test_value_array, METH_VARARGS }, { "test_gerror_exception", (PyCFunction)_wrap_test_gerror_exception, METH_VARARGS }, { NULL, NULL } -- cgit