[gjs/gnome-3-34] Respect transfer/allow-none annotation on return/out args of a callback/vfunc
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-3-34] Respect transfer/allow-none annotation on return/out args of a callback/vfunc
- Date: Wed, 13 Nov 2019 00:31:00 +0000 (UTC)
commit f2081e42719ad2ee9908f4822deec46dca36c71c
Author: Xavier Claessens <xavier claessens collabora com>
Date: Sun Apr 27 22:42:20 2014 -0400
Respect transfer/allow-none annotation on return/out args of a callback/vfunc
Note that allow-none does not seem to be set in the .gir for return
value, so it's still hardcoded to true.
https://gitlab.gnome.org/GNOME/gjs/issues/86
gi/function.cpp | 27 ++++++---------------------
installed-tests/js/testGIMarshalling.js | 4 +---
2 files changed, 7 insertions(+), 24 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 474904a8..de7d84db 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -363,20 +363,12 @@ static void gjs_callback_closure(ffi_cif* cif G_GNUC_UNUSED, void* result,
* be a single return value. */
for (i = 0; i < n_args; i++) {
GIArgInfo arg_info;
- GITypeInfo type_info;
g_callable_info_load_arg(trampoline->info, i, &arg_info);
if (g_arg_info_get_direction(&arg_info) == GI_DIRECTION_IN)
continue;
- g_arg_info_load_type(&arg_info, &type_info);
- if (!gjs_value_to_g_argument(context,
- rval,
- &type_info,
- "callback",
- GJS_ARGUMENT_ARGUMENT,
- GI_TRANSFER_NOTHING,
- true,
- *(GIArgument **)args[i + c_args_offset]))
+ if (!gjs_value_to_arg(context, rval, &arg_info,
+ *reinterpret_cast<GIArgument **>(args[i + c_args_offset])))
goto out;
break;
@@ -390,6 +382,7 @@ static void gjs_callback_closure(ffi_cif* cif G_GNUC_UNUSED, void* result,
if (!ret_type_is_void) {
GIArgument argument;
+ GITransfer transfer = g_callable_info_get_caller_owns(trampoline->info);
if (!JS_GetElement(context, out_array, elem_idx, &elem))
goto out;
@@ -399,7 +392,7 @@ static void gjs_callback_closure(ffi_cif* cif G_GNUC_UNUSED, void* result,
&ret_type,
"callback",
GJS_ARGUMENT_ARGUMENT,
- GI_TRANSFER_NOTHING,
+ transfer,
true,
&argument))
goto out;
@@ -413,23 +406,15 @@ static void gjs_callback_closure(ffi_cif* cif G_GNUC_UNUSED, void* result,
for (i = 0; i < n_args; i++) {
GIArgInfo arg_info;
- GITypeInfo type_info;
g_callable_info_load_arg(trampoline->info, i, &arg_info);
if (g_arg_info_get_direction(&arg_info) == GI_DIRECTION_IN)
continue;
- g_arg_info_load_type(&arg_info, &type_info);
if (!JS_GetElement(context, out_array, elem_idx, &elem))
goto out;
- if (!gjs_value_to_g_argument(context,
- elem,
- &type_info,
- "callback",
- GJS_ARGUMENT_ARGUMENT,
- GI_TRANSFER_NOTHING,
- true,
- *(GIArgument **)args[i + c_args_offset]))
+ if (!gjs_value_to_arg(context, elem, &arg_info,
+ *(GIArgument **)args[i + c_args_offset]))
goto out;
elem_idx++;
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index 17c09333..901e380a 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -1257,9 +1257,7 @@ describe('Virtual function', function () {
testVfuncRefcount('return', 'none', 1);
testVfuncRefcount('return', 'full', 2);
testVfuncRefcount('out', 'none', 1);
- testVfuncRefcount('out', 'full', 2, {
- skip: 'https://gitlab.gnome.org/GNOME/gjs/issues/275',
- });
+ testVfuncRefcount('out', 'full', 2);
testVfuncRefcount('in', 'none', 2, {}, GIMarshallingTests.Object);
testVfuncRefcount('in', 'full', 1, {
skip: 'https://gitlab.gnome.org/GNOME/gjs/issues/275',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]