summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Welsh <contact@evanwelsh.com>2021-08-24 22:01:36 -0700
committerEvan Welsh <contact@evanwelsh.com>2021-08-24 22:05:17 -0700
commit94a0b309083f6bd60e2ed8a6654eb9f11c0817a6 (patch)
treec4a89335b3042b69fe446fda9a7c6b79817309f7
parenta3450059256c20f7751cb0f36c8ab187cf0de65e (diff)
downloadgjs-ewlsh/return-null-for-pointers.tar.gz
gi: Return null if return argument is a pointer typeewlsh/return-null-for-pointers
-rw-r--r--gi/arg.cpp10
-rw-r--r--installed-tests/js/testGIMarshalling.js4
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 () {