Commit f38511f2 authored by John (J5) Palmieri's avatar John (J5) Palmieri
Browse files

fix inline struct array handling

* we now assume any non-boxed structs are inline in an array since there is
   no way to check in GI and this is the most common use for an array of
   non-boxed structs

https://bugzilla.gnome.org/show_bug.cgi?id=657120
parent d92846a5
......@@ -331,20 +331,15 @@ _pygi_marshal_out_array (PyGIInvokeState *state,
if (seq_cache->array_type == GI_ARRAY_TYPE_PTR_ARRAY) {
item_arg.v_pointer = g_ptr_array_index ( ( GPtrArray *)array_, i);
} else if (item_arg_cache->type_tag == GI_TYPE_TAG_INTERFACE) {
item_arg.v_pointer = g_array_index (array_, gpointer, i);
if (arg_cache->transfer == GI_TRANSFER_EVERYTHING) {
PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *) item_arg_cache;
switch (g_base_info_get_type (iface_cache->interface_info)) {
case GI_INFO_TYPE_STRUCT:
{
gpointer *_struct = g_malloc (item_size);
memcpy (_struct, item_arg.v_pointer, item_size);
item_arg.v_pointer = _struct;
break;
}
default:
break;
}
PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *) item_arg_cache;
switch (g_base_info_get_type (iface_cache->interface_info)) {
case GI_INFO_TYPE_STRUCT:
item_arg.v_pointer = array_->data + i * item_size;
break;
default:
item_arg.v_pointer = g_array_index (array_, gpointer, i);
break;
}
} else {
memcpy (&item_arg, array_->data + i * item_size, item_size);
......
......@@ -703,6 +703,14 @@ class TestArray(unittest.TestCase):
object_ = GIMarshallingTests.Object()
self.assertEquals([-1, 0, 1, 2], object_.method_array_return())
def test_array_fixed_out_struct(self):
struct1, struct2 = GIMarshallingTests.array_fixed_out_struct()
self.assertEquals(7, struct1.long_)
self.assertEquals(6, struct1.int8)
self.assertEquals(6, struct2.long_)
self.assertEquals(7, struct2.int8)
def test_array_zero_terminated_return(self):
self.assertEquals(['0', '1', '2'], GIMarshallingTests.array_zero_terminated_return())
......
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