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



commit dffdfb3b6d2fc36b3ffe6197c1b444b6fbf449d2
Author: Philip Chimento <philip chimento gmail com>
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 ae46d69..3f92bf6 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -268,15 +268,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;
@@ -1052,7 +1051,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());
@@ -1068,7 +1067,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 */
@@ -1197,14 +1196,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);


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