Commit 274d60a7 authored by Jasper St. Pierre's avatar Jasper St. Pierre
Browse files

gi: Support zero-terminated arrays with length arguments

Sometimes, you may see (array zero-terminated=1 length=length) annotations.
Don't expose the length argument to the user in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=677124
parent 62c2e962
......@@ -155,16 +155,11 @@ _sequence_cache_new (GITypeInfo *type_info,
sc = g_slice_new0 (PyGISequenceCache);
( (PyGIArgCache *)sc)->destroy_notify = (GDestroyNotify)_sequence_cache_free_func;
sc->fixed_size = -1;
sc->len_arg_index = -1;
sc->is_zero_terminated = g_type_info_is_zero_terminated (type_info);
if (!sc->is_zero_terminated) {
sc->fixed_size = g_type_info_get_array_fixed_size (type_info);
if (sc->fixed_size < 0)
sc->len_arg_index = g_type_info_get_array_length (type_info);
if (sc->len_arg_index >= 0)
sc->len_arg_index += child_offset;
}
sc->fixed_size = g_type_info_get_array_fixed_size (type_info);
sc->len_arg_index = g_type_info_get_array_length (type_info);
if (sc->len_arg_index >= 0)
sc->len_arg_index += child_offset;
item_type_info = g_type_info_get_param_type (type_info, 0);
......
......@@ -689,6 +689,9 @@ class TestArray(unittest.TestCase):
def test_array_in(self):
GIMarshallingTests.array_in(Sequence([-1, 0, 1, 2]))
def test_array_in_len_zero_terminated(self):
GIMarshallingTests.array_in_len_zero_terminated(Sequence([-1, 0, 1, 2]))
def test_array_uint8_in(self):
GIMarshallingTests.array_uint8_in(Sequence([97, 98, 99, 100]))
GIMarshallingTests.array_uint8_in(_bytes("abcd"))
......
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