Subject: [gjs/wip/ptomato/mozjs38: 2/17] js:
AutoValueVector's [] operator is rooted



commit d361934ceef801891e32311278a00a20ddec3893
Author: Philip Chimento <[email protected]>
Date: Wed Jan 11 22:32:37 2017 -0800

js: AutoValueVector's [] operator is rooted

Previously, the [] operator of JS::AutoValueVector would give you a raw
pointer, and if you wanted a rooted value you had to call the handleAt()
method. In SpiderMonkey 38, that method is removed, and the [] operator
gives you a rooted value.

gi/arg.cpp | 20 +++++++++-----------
gi/function.cpp | 13 ++++++-------
2 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 8f6ba96..d623f56 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -574,7 +574,7 @@ gjs_array_from_strv(JSContext *context,

for (i = 0; strv[i] != NULL; i++) {
elems.growBy(1);
- if (!gjs_string_from_utf8(context, strv[i], -1, elems.handleAt(i)))
+ if (!gjs_string_from_utf8(context, strv[i], -1, elems[i]))
return false;
}

@@ -959,7 +959,7 @@ gjs_array_from_flat_gvalue_array(JSContext
*context,

for (i = 0; i < length; i ++) {
GValue *gvalue = &values[i];
- result = gjs_value_from_g_value(context, elems.handleAt(i), gvalue);
+ result = gjs_value_from_g_value(context, elems[i], gvalue);
if (!result)
break;
}
@@ -2156,8 +2156,7 @@ gjs_array_from_g_list (JSContext *context,
arg.v_pointer = list->data;
elems.growBy(1);

- if (!gjs_value_from_g_argument(context, elems.handleAt(i),
- param_info, &arg,
+ if (!gjs_value_from_g_argument(context, elems[i], param_info, &arg,
true))
return false;
++i;
@@ -2167,8 +2166,7 @@ gjs_array_from_g_list (JSContext *context,
arg.v_pointer = slist->data;
elems.growBy(1);

- if (!gjs_value_from_g_argument(context, elems.handleAt(i),
- param_info, &arg,
+ if (!gjs_value_from_g_argument(context, elems[i], param_info, &arg,
true))
return false;
++i;
@@ -2225,8 +2223,8 @@ gjs_array_from_carray_internal (JSContext
*context,
#define ITERATE(type) \
for (i = 0; i < length; i++) { \
arg.v_##type = *(((g##type*)array) + i); \
- if (!gjs_value_from_g_argument(context, elems.handleAt(i), \
- param_info, &arg, true)) \
+ if (!gjs_value_from_g_argument(context, elems[i], param_info, \
+ &arg, true)) \
return false; \
}

@@ -2285,8 +2283,8 @@ gjs_array_from_carray_internal (JSContext
*context,
for (i = 0; i < length; i++) {
arg.v_pointer = ((char*)array) + (struct_size * i);

- if (!gjs_value_from_g_argument(context, elems.handleAt(i),
- param_info, &arg, true))
+ if (!gjs_value_from_g_argument(context, elems[i], param_info,
+ &arg, true))
return false;
}

@@ -2441,7 +2439,7 @@ gjs_array_from_zero_terminated_c_array (JSContext
*context,
for (i = 0; array[i]; i++) { \
arg.v_##type = array[i]; \
elems.growBy(1); \
- if (!gjs_value_from_g_argument(context, elems.handleAt(i), \
+ if (!gjs_value_from_g_argument(context, elems[i], \
param_info, &arg, true)) \
return false; \
} \
diff --git a/gi/function.cpp b/gi/function.cpp
index 76aa885..9ccea5e 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -261,15 +261,14 @@ gjs_callback_closure(ffi_cif *cif,
goto out;

jsargs.growBy(1);
- if (!gjs_value_from_explicit_array(context,
jsargs.handleAt(n_jsargs++),
+ if (!gjs_value_from_explicit_array(context, jsargs[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++),
+ if (!gjs_value_from_g_argument(context, jsargs[n_jsargs++],
&type_info,
(GArgument *) args[i], false))
goto out;
@@ -1042,7 +1041,7 @@ gjs_invoke_c_function(JSContext
*context,
true);
if (!arg_failed && !js_rval.empty()) {
arg_failed = !gjs_value_from_explicit_array(context,
-
return_values.handleAt(next_rval),
+
return_values[next_rval],
&return_info,

&return_gargument,

length.toInt32());
@@ -1058,7 +1057,7 @@ gjs_invoke_c_function(JSContext
*context,
} else {
if (!js_rval.empty())
arg_failed = !gjs_value_from_g_argument(context,
-
return_values.handleAt(next_rval),
+
return_values[next_rval],
&return_info,
&return_gargument,
true);
/* Free GArgument, the JS::Value should have ref'd or copied
it */
@@ -1187,14 +1186,14 @@ release:
true);
if (!arg_failed) {
arg_failed = !gjs_value_from_explicit_array(context,
-
return_values.handleAt(next_rval),
+
return_values[next_rval],

&arg_type_info,
arg,

array_length.toInt32());
}
} else {
arg_failed = !gjs_value_from_g_argument(context,
-
return_values.handleAt(next_rval),
+
return_values[next_rval],
&arg_type_info,
arg,
true);
_______________________________________________
commits-list mailing list (read only)
https://mail.gnome.org/mailman/listinfo/commits-list

Want to limit the commits to a few modules? Go to above URL, log in to edit
your options and select the modules ('topics') you want.



Programming list archiving by: Enterprise Git Hosting