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



commit c3fc9fd2cd5bda0a4fc6f498915a5ce1c9e51b6a
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.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777962

 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 805fa1c..6a262b9 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;
     }
@@ -2153,8 +2153,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;
@@ -2164,8 +2163,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;
@@ -2222,8 +2220,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; \
     }
 
@@ -2282,8 +2280,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;
               }
 
@@ -2438,7 +2436,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 07d4783..8bc1098 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -253,15 +253,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;
@@ -1046,7 +1045,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());
@@ -1062,7 +1061,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 */
@@ -1191,14 +1190,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]