[gjs/ewlsh/gvalues: 44/46] gi: Return null if return argument is a pointer type




commit 94a0b309083f6bd60e2ed8a6654eb9f11c0817a6
Author: Evan Welsh <contact evanwelsh com>
Date:   Tue Aug 24 22:01:36 2021 -0700

    gi: Return null if return argument is a pointer type

 gi/arg.cpp                              | 10 ++++++++--
 installed-tests/js/testGIMarshalling.js |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 63e8e03c..e1a74634 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2430,9 +2430,15 @@ gjs_value_from_g_argument (JSContext             *context,
 
     switch (type_tag) {
     case GI_TYPE_TAG_VOID:
-        value_p.setUndefined(); /* or .setNull() ? */
-        break;
+        // If the argument is a pointer, convert
+        // to null to match our in handling.
+        if (g_type_info_is_pointer(type_info)) {
+            value_p.setNull();
+        } else {
+            value_p.setUndefined();
+        }
 
+        break;
     case GI_TYPE_TAG_BOOLEAN:
         value_p.setBoolean(gjs_arg_get<bool>(arg));
         break;
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index 27e05c8a..5958605d 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -920,9 +920,9 @@ describe('Raw pointers', function () {
         expect(GIMarshallingTests.pointer_in_return(null)).toBeFalsy();
     });
 
-    xit('can be roundtripped at least if the pointer is null', function () {
+    it('can be roundtripped at least if the pointer is null', function () {
         expect(GIMarshallingTests.pointer_in_return(null)).toBeNull();
-    }).pend('https://gitlab.gnome.org/GNOME/gjs/merge_requests/46');
+    });
 });
 
 describe('Registered enum type', function () {


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