Commit 0c496d23 authored by Olivier Crête's avatar Olivier Crête Committed by Martin Pitt
Browse files

pygi-property: Support boxed GSList/GList types



Note that this does not yet work for construct properties.
Co-Authored-By: default avatarMartin Pitt <martinpitt@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=684059
parent 074f10d8
......@@ -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:
{
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment