[gjs/wip/ptomato/mozjs31prep] function: Use whole value array
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31prep] function: Use whole value array
- Date: Sat, 29 Oct 2016 00:43:51 +0000 (UTC)
commit aa8dbecab58620b11f177a5b064148d7662262a9
Author: Philip Chimento <philip endlessm com>
Date: Fri Oct 28 17:34:35 2016 -0700
function: Use whole value array
In mozjs31, it will not be possible to do pointer fiddling with the
AutoValueVector passed into JS_CallFunctionValue(), because that function
will take the whole vector instead of a vp array plus number of args.
Therefore, we restructure gjs_callback_closure() so that vfuncs pop the
first element of the vector back into the this_object root, instead of
manipulating the pointer passed to JS_CallFunctionValue().
https://bugzilla.gnome.org/show_bug.cgi?id=742249
gi/function.cpp | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 9c4c3cd..21a8308 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -217,8 +217,7 @@ gjs_callback_closure(ffi_cif *cif,
n_outargs = 0;
JS::AutoValueVector jsargs(context);
- jsargs.resize(n_args);
- JS::Value *args_ptr = jsargs.begin();
+ jsargs.reserve(n_args);
JS::RootedValue rval(context);
JS::RootedObject this_object(context);
@@ -260,12 +259,14 @@ gjs_callback_closure(ffi_cif *cif,
(GArgument *) args[array_length_pos], true))
goto out;
+ jsargs.growBy(1);
if (!gjs_value_from_explicit_array(context, jsargs.handleAt(n_jsargs++),
&type_info, (GArgument*) args[i], length.toInt32()))
goto out;
break;
}
case PARAM_NORMAL:
+ jsargs.growBy(1);
if (!gjs_value_from_g_argument(context,
jsargs.handleAt(n_jsargs++),
&type_info,
@@ -278,20 +279,20 @@ gjs_callback_closure(ffi_cif *cif,
default:
g_assert_not_reached();
}
- }
- if (trampoline->is_vfunc) {
- g_assert(n_args > 0);
- this_object = jsargs[0].toObjectOrNull();
- args_ptr++;
- n_jsargs--;
+ if (trampoline->is_vfunc && i == 0) {
+ g_assert(n_jsargs > 0);
+ this_object = jsargs[0].toObjectOrNull();
+ jsargs.popBack();
+ n_jsargs--;
+ }
}
if (!JS_CallFunctionValue(context,
this_object,
trampoline->js_function,
n_jsargs,
- args_ptr,
+ jsargs.begin(),
rval.address())) {
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]