GNOME Bugzilla – Bug 761658
Out arrays of structs should not consist of identical elements
Last modified: 2016-02-08 04:54:58 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=704842, the patch committed there doesn't quite return the correct out array. Instead it places the same struct into each element of the returned array, so the array has the correct length but all the elements are identical. e.g. to continue the example use case from the other bug let keymap = Gdk.Keymap.get_default(); let [success, entries] = keymap.get_entries_for_keyval(Gdk.KEY_Return); print(entries.map(entry => entry.keycode)); would print 52,52 whereas it should print 36,52.
Created attachment 320562 [details] [review] arg: Marshal all structs in out array correctly Previously, an out array of structs would have all its elements be the same struct, since gjs_array_from_carray_internal() would not iterate through the C array correctly. This fixes the iteration and adds a test case (which is hopefully not locale- or keyboard-dependent!)
Review of attachment 320562 [details] [review]: OK. I would much prefer a test in Regress / Everything, but this is OK for now.
Not a problem. I already wrote a Regress test for the other bug I just filed, this actually reminded me that I forgot to attach it there ... :-P
Created attachment 320566 [details] [review] arg: Marshal all structs in out array correctly Previously, an out array of structs would have all its elements be the same struct, since gjs_array_from_carray_internal() would not iterate through the C array correctly. This fixes the iteration and expands the test case to cover this as well. It also changes the old test case, that used the Gdk function directly, to a Regress test case, newly added to Regress in gobject-introspection.
Created attachment 320567 [details] [review] tests: Add regression test for out array of struct This is a regression test for returning out arrays of structs, like gdk_keymap_get_entries_for_keyval() for example.
Review of attachment 320567 [details] [review]: OK.
Review of attachment 320566 [details] [review]: Nice, thank you.
Comment on attachment 320567 [details] [review] tests: Add regression test for out array of struct Attachment 320567 [details] pushed as b20ac73 - tests: Add regression test for out array of struct
Attachment 320566 [details] pushed as b4061d4 - arg: Marshal all structs in out array correctly