[gjs] arg: Marshal all structs in out array correctly



commit b4061d441d82f271402ed38e4f3b11a7bb0d2d97
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Feb 6 20:06:57 2016 -0800

    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.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761658

 gi/arg.cpp                                |    2 +-
 installed-tests/js/testEverythingBasic.js |    8 ++++++++
 installed-tests/js/testGtk.js             |    8 --------
 3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 7cb92bd..7ce45bf 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2180,7 +2180,7 @@ gjs_array_from_carray_internal (JSContext  *context,
                   struct_size = g_struct_info_get_size ((GIStructInfo*)interface_info);
 
               for (i = 0; i < length; i++) {
-                  arg.v_pointer = ((char*)array) + struct_size;
+                  arg.v_pointer = ((char*)array) + (struct_size * i);
 
                   if (!gjs_value_from_g_argument(context, &elem, param_info, &arg, TRUE))
                       goto finally;
diff --git a/installed-tests/js/testEverythingBasic.js b/installed-tests/js/testEverythingBasic.js
index a9c3b1a..3291dd8 100644
--- a/installed-tests/js/testEverythingBasic.js
+++ b/installed-tests/js/testEverythingBasic.js
@@ -361,6 +361,14 @@ function testArrayOut() {
     Everything.test_array_int_null_in(null);
 }
 
+function testArrayOfStructsOut() {
+   let array = Everything.test_array_struct_out();
+   let ints = array.map(struct => struct.some_int);
+   JSUnit.assertEquals(22, ints[0]);
+   JSUnit.assertEquals(33, ints[1]);
+   JSUnit.assertEquals(44, ints[2]);
+}
+
 /* GHash type */
 
 // Convert an object to a predictable (not-hash-order-dependent) string
diff --git a/installed-tests/js/testGtk.js b/installed-tests/js/testGtk.js
index fa32d19..69046c6 100755
--- a/installed-tests/js/testGtk.js
+++ b/installed-tests/js/testGtk.js
@@ -93,12 +93,4 @@ function testGtk() {
     validateTemplate(new MyComplexGtkSubclassFromResource());
 }
 
-// https://bugzilla.gnome.org/show_bug.cgi?id=704842
-function testGdkKeymap() {
-    Gtk.init(null);
-
-    let keymap = Gdk.Keymap.get_default();
-    JSUnit.assertNotEquals(keymap.get_entries_for_keyval(Gdk.KEY_a), null);
-}
-
 JSUnit.gjstestRun(this, JSUnit.setUp, JSUnit.tearDown);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]