[pygobject] pygi-property: Support boxed GSList/GList types
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] pygi-property: Support boxed GSList/GList types
- Date: Mon, 14 Jan 2013 08:15:08 +0000 (UTC)
commit 0c496d230fee7fd3ada90ee9af10e0bc1e29ee12
Author: Olivier CrÃte <olivier crete collabora com>
Date: Fri Sep 14 21:31:32 2012 -0400
pygi-property: Support boxed GSList/GList types
Note that this does not yet work for construct properties.
Co-Authored-By: Martin Pitt <martinpitt gnome org>
https://bugzilla.gnome.org/show_bug.cgi?id=684059
gi/pygi-property.c | 10 ++++++++--
tests/test_gi.py | 21 +++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-property.c b/gi/pygi-property.c
index 6079efc..2e32fea 100644
--- a/gi/pygi-property.c
+++ b/gi/pygi-property.c
@@ -217,7 +217,10 @@ pygi_get_property_value_real (PyGObject *instance, GParamSpec *pspec)
break;
case GI_TYPE_TAG_GLIST:
case GI_TYPE_TAG_GSLIST:
- arg.v_pointer = g_value_get_pointer (&value);
+ if (G_VALUE_HOLDS_BOXED(&value))
+ arg.v_pointer = g_value_get_boxed (&value);
+ else
+ arg.v_pointer = g_value_get_pointer (&value);
break;
case GI_TYPE_TAG_ARRAY:
{
@@ -384,7 +387,10 @@ pygi_set_property_value_real (PyGObject *instance,
g_value_set_boxed (&value, arg.v_pointer);
break;
case GI_TYPE_TAG_GLIST:
- g_value_set_pointer (&value, arg.v_pointer);
+ if (G_VALUE_HOLDS_BOXED(&value))
+ g_value_set_boxed (&value, arg.v_pointer);
+ else
+ g_value_set_pointer (&value, arg.v_pointer);
break;
case GI_TYPE_TAG_ARRAY:
{
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 5fd5261..ca6e3c9 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2735,6 +2735,27 @@ class TestPropertiesObject(unittest.TestCase):
obj = GIMarshallingTests.PropertiesObject(some_boxed_struct=struct1)
self.assertEqual(obj.props.some_boxed_struct.long_, 1)
+ @unittest.skipUnless(hasattr(GIMarshallingTests.PropertiesObject, 'some_boxed_glist'),
+ 'too old gobject-introspection')
+ def test_boxed_glist(self):
+ self.assertEqual(self.obj.props.some_boxed_glist, [])
+
+ l = [GObject.G_MININT, 42, GObject.G_MAXINT]
+ self.obj.props.some_boxed_glist = l
+ self.assertEqual(self.obj.props.some_boxed_glist, l)
+ self.obj.props.some_boxed_glist = []
+ self.assertEqual(self.obj.props.some_boxed_glist, [])
+
+ self.assertRaises(TypeError, setattr, self.obj.props, 'some_boxed_glist', 1)
+ self.assertRaises(TypeError, setattr, self.obj.props, 'some_boxed_glist', 'foo')
+ self.assertRaises(TypeError, setattr, self.obj.props, 'some_boxed_glist', ['a'])
+
+ @unittest.expectedFailure
+ def test_boxed_glist_ctor(self):
+ l = [GObject.G_MININT, 42, GObject.G_MAXINT]
+ obj = GIMarshallingTests.PropertiesObject(some_boxed_glist=l)
+ self.assertEqual(obj.props.some_boxed_glist, l)
+
@unittest.skipUnless(hasattr(GIMarshallingTests.PropertiesObject, 'some_variant'),
'too old gobject-introspection')
def test_variant(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]