[gjs] js: No need to use .address() in new API



commit 71573291e8e8281a3261ec8fc86323793e22ccdc
Author: Philip Chimento <philip endlessm com>
Date:   Thu Nov 3 17:55:28 2016 -0700

    js: No need to use .address() in new API
    
    Since in mozjs31 all out parameters for GC things have been changed from
    pointers to MutableHandles, there is no need to get the underlying GC
    thing's address with JS::Handle::address(). Instead, we can simply use
    the unary & operator to get a MutableHandle from a Rooted.
    
    In some cases, such as JS_SetProperty(), the SpiderMonkey API changed a
    JS::Value* parameter to a JS::HandleValue, so we can just delete the
    .address() call and pass the RootedValue directly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751252

 gi/arg.cpp                  |   20 ++++++++++----------
 gi/boxed.cpp                |    2 +-
 gi/function.cpp             |   10 +++++-----
 gi/fundamental.cpp          |    4 ++--
 gi/gerror.cpp               |    2 +-
 gi/gtype.cpp                |    4 ++--
 gi/object.cpp               |   16 ++++++++--------
 gi/param.cpp                |    2 +-
 gi/repo.cpp                 |    7 +++----
 gi/union.cpp                |    2 +-
 gjs/byteArray.cpp           |    6 +++---
 gjs/context.cpp             |    2 +-
 gjs/coverage.cpp            |   32 ++++++++++++++------------------
 gjs/importer.cpp            |   19 +++++++------------
 gjs/jsapi-util-error.cpp    |    2 +-
 gjs/jsapi-util-string.cpp   |    2 +-
 gjs/jsapi-util.cpp          |   16 ++++++++--------
 gjs/jsapi-util.h            |    2 +-
 modules/cairo-context.cpp   |   18 +++++++++---------
 modules/cairo-region.cpp    |    8 ++++----
 modules/console.cpp         |    4 ++--
 test/gjs-test-call-args.cpp |    4 ++--
 test/gjs-tests.cpp          |    6 +++---
 23 files changed, 90 insertions(+), 100 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 79ec9ad..c0fc24c 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -287,7 +287,7 @@ gjs_array_to_g_list(JSContext   *context,
         GArgument elem_arg = { 0 };
 
         elem = JS::UndefinedValue();
-        if (!JS_GetElement(context, array, i, elem.address())) {
+        if (!JS_GetElement(context, array, i, &elem)) {
             gjs_throw(context,
                       "Missing array element %u",
                       i);
@@ -512,14 +512,14 @@ gjs_object_to_g_hash(JSContext   *context,
         gpointer key_ptr, val_ptr;
         GIArgument val_arg = { 0 };
 
-        if (!JS_IdToValue(context, cur_id, key_js.address()))
+        if (!JS_IdToValue(context, cur_id, &key_js))
             goto free_hash_and_fail;
 
         /* Type check key type. */
         if (!value_to_ghashtable_key(context, key_js, key_param_info, &key_ptr))
             goto free_hash_and_fail;
 
-        if (!JS_GetPropertyById(context, props, cur_id, val_js.address()))
+        if (!JS_GetPropertyById(context, props, cur_id, &val_js))
             goto free_hash_and_fail;
 
         /* Type check and convert value to a c type */
@@ -602,7 +602,7 @@ gjs_array_to_strv(JSContext   *context,
 
     for (i = 0; i < length; ++i) {
         elem = JS::UndefinedValue();
-        if (!JS_GetElement(context, array, i, elem.address())) {
+        if (!JS_GetElement(context, array, i, &elem)) {
             g_free(result);
             gjs_throw(context,
                       "Missing array element %u",
@@ -684,7 +684,7 @@ gjs_array_to_gboolean_array(JSContext      *cx,
     gboolean *result = g_new0(gboolean, length);
 
     for (i = 0; i < length; i++) {
-        if (!JS_GetElement(cx, array, i, elem.address())) {
+        if (!JS_GetElement(cx, array, i, &elem)) {
             g_free(result);
             gjs_throw(cx, "Missing array element %u", i);
             return false;
@@ -719,7 +719,7 @@ gjs_array_to_intarray(JSContext   *context,
         bool success;
 
         elem = JS::UndefinedValue();
-        if (!JS_GetElement(context, array, i, elem.address())) {
+        if (!JS_GetElement(context, array, i, &elem)) {
             g_free(result);
             gjs_throw(context,
                       "Missing array element %u",
@@ -776,7 +776,7 @@ gjs_gtypearray_to_array(JSContext   *context,
         GType gtype;
 
         elem = JS::UndefinedValue();
-        if (!JS_GetElement(context, array, i, elem.address())) {
+        if (!JS_GetElement(context, array, i, &elem)) {
             g_free(result);
             gjs_throw(context, "Missing array element %u", i);
             return false;
@@ -823,7 +823,7 @@ gjs_array_to_floatarray(JSContext   *context,
         bool success;
 
         elem = JS::UndefinedValue();
-        if (!JS_GetElement(context, array, i, elem.address())) {
+        if (!JS_GetElement(context, array, i, &elem)) {
             g_free(result);
             gjs_throw(context,
                       "Missing array element %u",
@@ -879,7 +879,7 @@ gjs_array_to_ptrarray(JSContext   *context,
         bool success;
 
         elem = JS::UndefinedValue();
-        if (!JS_GetElement(context, array_obj, i, elem.address())) {
+        if (!JS_GetElement(context, array_obj, i, &elem)) {
             g_free(array);
             gjs_throw(context,
                       "Missing array element %u",
@@ -925,7 +925,7 @@ gjs_array_to_flat_gvalue_array(JSContext   *context,
     for (i = 0; i < length; i ++) {
         elem = JS::UndefinedValue();
 
-        if (!JS_GetElement(context, array, i, elem.address())) {
+        if (!JS_GetElement(context, array, i, &elem)) {
             g_free(values);
             gjs_throw(context,
                       "Missing array element %u",
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index d302b9e..97f92cf 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -431,7 +431,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(boxed)
                         "boxed constructor, obj %p priv %p",
                         object.get(), priv);
 
-    JS_GetPrototype(context, object, proto.address());
+    JS_GetPrototype(context, object, &proto);
     gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "boxed instance __proto__ is %p",
                         proto.get());
     /* If we're the prototype, then post-construct we'll fill in priv->info.
diff --git a/gi/function.cpp b/gi/function.cpp
index 7ac6a0f..71fdd5d 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -293,7 +293,7 @@ gjs_callback_closure(ffi_cif *cif,
                               this_object,
                               rooted_function,
                               jsargs,
-                              rval.address())) {
+                              &rval)) {
         goto out;
     }
 
@@ -355,7 +355,7 @@ gjs_callback_closure(ffi_cif *cif,
         if (!ret_type_is_void) {
             GIArgument argument;
 
-            if (!JS_GetElement(context, out_array, elem_idx, elem.address()))
+            if (!JS_GetElement(context, out_array, elem_idx, &elem))
                 goto out;
 
             if (!gjs_value_to_g_argument(context,
@@ -383,7 +383,7 @@ gjs_callback_closure(ffi_cif *cif,
                 continue;
 
             g_arg_info_load_type(&arg_info, &type_info);
-            if (!JS_GetElement(context, out_array, elem_idx, elem.address()))
+            if (!JS_GetElement(context, out_array, elem_idx, &elem))
                 goto out;
 
             if (!gjs_value_to_g_argument(context,
@@ -1654,10 +1654,10 @@ function_new(JSContext      *context,
         JS::RootedObject parent_proto(context);
         JS::RootedValue v_native_function(context);
 
-        JS_GetProperty(context, global, "Function", v_native_function.address());
+        JS_GetProperty(context, global, "Function", &v_native_function);
         JS::RootedObject native_function(context, &v_native_function.toObject());
         /* We take advantage from that fact that Function.__proto__ is Function.prototype */
-        JS_GetPrototype(context, native_function, parent_proto.address());
+        JS_GetPrototype(context, native_function, &parent_proto);
 
         prototype = JS_InitClass(context, global,
                                  /* parent prototype JSObject* for
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index f16e2eb..1a0c96a 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -131,7 +131,7 @@ proto_priv_from_js(JSContext       *context,
                    JS::HandleObject obj)
 {
     JS::RootedObject proto(context);
-    JS_GetPrototype(context, obj, proto.address());
+    JS_GetPrototype(context, obj, &proto);
     return (Fundamental*) priv_from_js(context, proto);
 }
 
@@ -582,7 +582,7 @@ gjs_lookup_fundamental_prototype(JSContext    *context,
         return NULL;
 
     JS::RootedValue value(context);
-    if (!JS_GetProperty(context, in_object, constructor_name, value.address()))
+    if (!JS_GetProperty(context, in_object, constructor_name, &value))
         return NULL;
 
     JS::RootedObject constructor(context);
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index 22f8d69..4949175 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -76,7 +76,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(error)
                         object.get(), priv);
 
     JS::RootedObject proto(context);
-    JS_GetPrototype(context, object, proto.address());
+    JS_GetPrototype(context, object, &proto);
     gjs_debug_lifecycle(GJS_DEBUG_GERROR, "GError instance __proto__ is %p",
                         proto.get());
 
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index 4d476c3..10ba932 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -160,12 +160,12 @@ _gjs_gtype_get_actual_gtype(JSContext       *context,
 
     /* OK, we don't have a GType wrapper object -- grab the "$gtype"
      * property on that and hope it's a GType wrapper object */
-    if (!JS_GetProperty(context, object, "$gtype", gtype_val.address()) ||
+    if (!JS_GetProperty(context, object, "$gtype", &gtype_val) ||
         !gtype_val.isObject()) {
 
         /* OK, so we're not a class. But maybe we're an instance. Check
            for "constructor" and recurse on that. */
-        if (!JS_GetProperty(context, object, "constructor", gtype_val.address()))
+        if (!JS_GetProperty(context, object, "constructor", &gtype_val))
             return G_TYPE_INVALID;
     }
 
diff --git a/gi/object.cpp b/gi/object.cpp
index 333ddea..d0ed86c 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -247,7 +247,7 @@ proto_priv_from_js(JSContext       *context,
                    JS::HandleObject obj)
 {
     JS::RootedObject proto(context);
-    JS_GetPrototype(context, obj, proto.address());
+    JS_GetPrototype(context, obj, &proto);
     return priv_from_js(context, proto);
 }
 
@@ -1456,7 +1456,7 @@ gjs_lookup_object_constructor_from_info(JSContext    *context,
         return NULL;
 
     JS::RootedValue value(context);
-    if (!JS_GetProperty(context, in_object, constructor_name, value.address()))
+    if (!JS_GetProperty(context, in_object, constructor_name, &value))
         return NULL;
 
     JS::RootedObject constructor(context);
@@ -2347,7 +2347,7 @@ gjs_object_get_gproperty (GObject    *object,
     JS::RootedValue jsvalue(context);
 
     underscore_name = hyphen_to_underscore((gchar *)pspec->name);
-    if (!JS_GetProperty(context, js_obj, underscore_name, jsvalue.address()) ||
+    if (!JS_GetProperty(context, js_obj, underscore_name, &jsvalue) ||
         !gjs_value_to_g_value(context, jsvalue, value))
         gjs_log_exception(context);
     g_free (underscore_name);
@@ -2366,7 +2366,7 @@ jsobj_set_gproperty(JSContext       *context,
         return;
 
     underscore_name = hyphen_to_underscore((gchar *)pspec->name);
-    if (!JS_SetProperty(context, object, underscore_name, jsvalue.address()))
+    if (!JS_SetProperty(context, object, underscore_name, jsvalue))
         gjs_log_exception(context);
     g_free (underscore_name);
 }
@@ -2601,7 +2601,7 @@ gjs_object_custom_init(GTypeInstance *instance,
 
     JS::RootedValue r(context);
     if (!JS_CallFunctionValue(context, object, v,
-                              JS::HandleValueArray::empty(), r.address()))
+                              JS::HandleValueArray::empty(), &r))
         gjs_log_exception(context);
 }
 
@@ -2660,7 +2660,7 @@ get_interface_gtypes(JSContext       *cx,
         JS::RootedValue iface_val(cx);
         GType iface_type;
 
-        if (!JS_GetElement(cx, interfaces, i, &iface_val.get()))
+        if (!JS_GetElement(cx, interfaces, i, &iface_val))
             return false;
 
         if (!iface_val.isObject()) {
@@ -2695,7 +2695,7 @@ save_properties_for_class_init(JSContext       *cx,
     for (i = 0; i < n_properties; i++) {
         JS::RootedValue prop_val(cx);
 
-        if (!JS_GetElement(cx, properties, i, &prop_val.get())) {
+        if (!JS_GetElement(cx, properties, i, &prop_val)) {
             g_clear_pointer(&properties_native, g_ptr_array_unref);
             return false;
         }
@@ -2957,7 +2957,7 @@ gjs_signal_new(JSContext *cx,
     params = g_newa(GType, n_parameters);
     JS::RootedValue gtype_val(cx);
     for (i = 0; i < n_parameters; i++) {
-        if (!JS_GetElement(cx, params_obj, i, gtype_val.address()) ||
+        if (!JS_GetElement(cx, params_obj, i, &gtype_val) ||
             !gtype_val.isObject()) {
             gjs_throw(cx, "Invalid signal parameter number %d", i);
             return false;
diff --git a/gi/param.cpp b/gi/param.cpp
index 474599a..84a0e54 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -180,7 +180,7 @@ gjs_lookup_param_prototype(JSContext    *context)
         return NULL;
 
     JS::RootedValue value(context);
-    if (!JS_GetProperty(context, in_object, "ParamSpec", value.address()))
+    if (!JS_GetProperty(context, in_object, "ParamSpec", &value))
         return NULL;
 
     if (G_UNLIKELY (!value.isObject()))
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 13cda99..00c6e64 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -130,8 +130,7 @@ resolve_namespace_object(JSContext       *context,
     if (!override.isNull() &&
         !JS_CallFunctionValue (context, gi_namespace, /* thisp */
                                override, /* callee */
-                               JS::HandleValueArray::empty(),
-                               result.address()))
+                               JS::HandleValueArray::empty(), &result))
         return false;
 
     gjs_debug(GJS_DEBUG_GNAMESPACE,
@@ -308,7 +307,7 @@ repo_new(JSContext *context)
      */
     {
         JS::RootedValue value(context);
-        JS_GetProperty(context, repo, "GLib", value.address());
+        JS_GetProperty(context, repo, "GLib", &value);
     }
 
     return repo;
@@ -740,7 +739,7 @@ gjs_lookup_generic_constructor(JSContext  *context,
         return NULL;
 
     JS::RootedValue value(context);
-    if (!JS_GetProperty(context, in_object, constructor_name, value.address()))
+    if (!JS_GetProperty(context, in_object, constructor_name, &value))
         return NULL;
 
     if (G_UNLIKELY (!value.isObject()))
diff --git a/gi/union.cpp b/gi/union.cpp
index dc45811..28db3dc 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -198,7 +198,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(union)
                         "union constructor, obj %p priv %p",
                         object.get(), priv);
 
-    JS_GetPrototype(context, object, proto.address());
+    JS_GetPrototype(context, object, &proto);
     gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "union instance __proto__ is %p",
                         proto.get());
 
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 0f18b5d..453f951 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -200,7 +200,7 @@ byte_array_get_prop(JSContext *context,
         return true; /* prototype, not an instance. */
 
     JS::RootedValue id_value(context);
-    if (!JS_IdToValue(context, id, id_value.address()))
+    if (!JS_IdToValue(context, id, &id_value))
         return false;
 
     /* First handle array indexing */
@@ -307,7 +307,7 @@ byte_array_set_prop(JSContext *context,
         return true; /* prototype, not an instance. */
 
     JS::RootedValue id_value(context);
-    if (!JS_IdToValue(context, id, id_value.address()))
+    if (!JS_IdToValue(context, id, &id_value))
         return false;
 
     /* First handle array indexing */
@@ -679,7 +679,7 @@ from_array_func(JSContext *context,
         guint8 b;
 
         elem = JS::UndefinedValue();
-        if (!JS_GetElement(context, array_obj, i, elem.address())) {
+        if (!JS_GetElement(context, array_obj, i, &elem)) {
             /* this means there was an exception, while elem.isUndefined()
              * means no element found
              */
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 66f9347..5817957 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -766,7 +766,7 @@ gjs_object_get_property_const(JSContext             *cx,
                               JS::MutableHandleValue value_p)
 {
     JS::RootedId pname(cx, gjs_context_get_const_string(cx, property_name));
-    return JS_GetPropertyById(cx, obj, pname, value_p.address());
+    return JS_GetPropertyById(cx, obj, pname, value_p);
 }
 
 /**
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 38cc46b..733f68e 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -425,7 +425,7 @@ get_array_from_js_value(JSContext             *context,
         u_int32_t i = 0;
         JS::RootedValue element(context);
         for (; i < js_array_len; ++i) {
-            if (!JS_GetElement(context, js_array, i, element.address())) {
+            if (!JS_GetElement(context, js_array, i, &element)) {
                 g_array_unref(c_side_array);
                 gjs_throw(context, "Failed to get function names array element %d", i);
                 return false;
@@ -476,7 +476,7 @@ get_executed_lines_for(JSContext        *context,
     args[0].set(filename_value);
 
     if (!JS_CallFunctionName(context, coverage_statistics, "getExecutedLinesFor",
-                             args, rval.address())) {
+                             args, &rval)) {
         gjs_log_exception(context);
         return NULL;
     }
@@ -588,7 +588,7 @@ get_functions_for(JSContext        *context,
     args[0].set(filename_value);
 
     if (!JS_CallFunctionName(context, coverage_statistics, "getFunctionsFor",
-                             args, rval.address())) {
+                             args, &rval)) {
         gjs_log_exception(context);
         return NULL;
     }
@@ -678,7 +678,7 @@ convert_and_insert_branch_info(GArray         *array,
         JS::RootedValue branch_exits_value(context);
         GArray *branch_exits_array = NULL;
 
-        if (!JS_GetProperty(context, object, "exits", branch_exits_value.address()) ||
+        if (!JS_GetProperty(context, object, "exits", &branch_exits_value) ||
             !branch_exits_value.isObject()) {
             gjs_throw(context, "Failed to get exits property from element");
             return false;
@@ -717,7 +717,7 @@ get_branches_for(JSContext        *context,
     JS::RootedValue rval(context);
 
     if (!JS_CallFunctionName(context, coverage_statistics, "getBranchesFor",
-                             args, rval.address())) {
+                             args, &rval)) {
         gjs_log_exception(context);
         return NULL;
     }
@@ -852,7 +852,7 @@ get_covered_files(GjsCoverage *coverage)
     uint32_t n_files;
 
     if (!JS_CallFunctionName(context, rooted_priv, "getCoveredFiles",
-                             JS::HandleValueArray::empty(), rval.address())) {
+                             JS::HandleValueArray::empty(), &rval)) {
         gjs_log_exception(context);
         return NULL;
     }
@@ -868,7 +868,7 @@ get_covered_files(GjsCoverage *coverage)
     JS::RootedValue element(context);
     for (uint32_t i = 0; i < n_files; i++) {
         char *file;
-        if (!JS_GetElement(context, files_obj, i, element.address()))
+        if (!JS_GetElement(context, files_obj, i, &element))
             goto error;
 
         if (!gjs_string_to_utf8(context, element, &file))
@@ -1011,7 +1011,7 @@ gjs_serialize_statistics(GjsCoverage *coverage)
 
     if (!JS_CallFunctionName(js_context, rooted_priv, "stringify",
                              JS::HandleValueArray::empty(),
-                             string_value_return.address())) {
+                             &string_value_return)) {
         gjs_log_exception(js_context);
         return NULL;
     }
@@ -1166,7 +1166,7 @@ coverage_statistics_has_stale_cache(GjsCoverage *coverage)
     JS::RootedValue stale_cache_value(js_context);
     if (!JS_CallFunctionName(js_context, rooted_priv, "staleCache",
                              JS::HandleValueArray::empty(),
-                             stale_cache_value.address())) {
+                             &stale_cache_value)) {
         gjs_log_exception(js_context);
         g_error("Failed to call into javascript to get stale cache value. This is a bug");
     }
@@ -1527,10 +1527,8 @@ gjs_inject_value_into_coverage_compartment(GjsCoverage     *coverage,
     JS::RootedObject coverage_global_scope(JS_GetRuntime(js_context),
                                            JS_GetGlobalForObject(js_context, priv->coverage_statistics));
 
-    /* Removing const with cast is OK because the property value is not
-     * mutated in JS_SetProperty */
     if (!JS_SetProperty(js_context, coverage_global_scope, property,
-                        (JS::Value *) value.address())) {
+                        value)) {
         g_warning("Failed to set property %s to requested value", property);
         return false;
     }
@@ -1554,7 +1552,7 @@ gjs_wrap_root_importer_in_compartment(JSContext *context,
 
     JS::RootedObject wrapped_importer(JS_GetRuntime(context),
                                       importer.toObjectOrNull());
-    if (!JS_WrapObject(context, wrapped_importer.address())) {
+    if (!JS_WrapObject(context, &wrapped_importer)) {
         return NULL;
     }
 
@@ -1580,16 +1578,14 @@ bootstrap_coverage(GjsCoverage *coverage)
     {
         JSAutoCompartment compartment(context, debugger_compartment);
         JS::RootedObject debuggeeWrapper(context, debuggee);
-        if (!JS_WrapObject(context, debuggeeWrapper.address())) {
+        if (!JS_WrapObject(context, &debuggeeWrapper)) {
             gjs_throw(context, "Failed to wrap debugeee");
             return false;
         }
 
         JS::RootedValue debuggeeWrapperValue(context, JS::ObjectValue(*debuggeeWrapper));
-        /* Removing const with cast is OK because the property value is not
-         * mutated in JS_SetProperty */
         if (!JS_SetProperty(context, debugger_compartment, "debuggee",
-                            (JS::Value *) debuggeeWrapperValue.address())) {
+                            debuggeeWrapperValue)) {
             gjs_throw(context, "Failed to set debuggee property");
             return false;
         }
@@ -1749,7 +1745,7 @@ gjs_clear_js_side_statistics_from_coverage_object(GjsCoverage *coverage)
         JS::RootedObject rooted_priv(js_context, priv->coverage_statistics);
         JS::RootedValue rval(JS_GetRuntime(js_context));
         if (!JS_CallFunctionName(js_context, rooted_priv, "deactivate",
-                                 JS::HandleValueArray::empty(), rval.address())) {
+                                 JS::HandleValueArray::empty(), &rval)) {
             gjs_log_exception(js_context);
             g_error("Failed to deactivate debugger - this is a fatal error");
         }
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 8728f14..d9bb919 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -159,7 +159,7 @@ seal_import(JSContext       *cx,
      * practice this will always be an own property because we defined it in
      * define_import(). */
     if (!JS_GetPropertyDescriptorById(cx, obj, prop_id, 0 /* flags */,
-                                      descr.address()) ||
+                                      &descr) ||
         descr.object() == NULL) {
         gjs_debug(GJS_DEBUG_IMPORTER,
                   "Failed to get attributes to seal '%s' in importer",
@@ -306,10 +306,8 @@ load_module_init(JSContext       *context,
         gjs_context_get_const_string(context, GJS_STRING_MODULE_INIT));
     if (JS_HasPropertyById(context, in_object, module_init_name, &found) && found) {
         JS::RootedValue module_obj_val(context);
-        if (JS_GetPropertyById(context,
-                               in_object,
-                               module_init_name,
-                               module_obj_val.address())) {
+        if (JS_GetPropertyById(context, in_object,
+                               module_init_name, &module_obj_val)) {
             return &module_obj_val.toObject();
         }
     }
@@ -459,7 +457,7 @@ do_import(JSContext       *context,
 
     for (i = 0; i < search_path_len; ++i) {
         elem.setUndefined();
-        if (!JS_GetElement(context, search_path, i, elem.address())) {
+        if (!JS_GetElement(context, search_path, i, &elem)) {
             /* this means there was an exception, while elem.isUndefined()
              * means no element found
              */
@@ -493,10 +491,7 @@ do_import(JSContext       *context,
         module_obj.set(load_module_init(context, obj, full_path));
         if (module_obj != NULL) {
             JS::RootedValue obj_val(context);
-            if (JS_GetProperty(context,
-                               module_obj,
-                               name,
-                               obj_val.address())) {
+            if (JS_GetProperty(context, module_obj, name, &obj_val)) {
                 if (!obj_val.isUndefined() &&
                     JS_DefineProperty(context, obj, name, obj_val,
                                       GJS_MODULE_PROP_FLAGS & ~JSPROP_PERMANENT)) {
@@ -696,7 +691,7 @@ importer_new_enumerate(JSContext  *context,
             GDir *dir = NULL;
 
             elem = JS::UndefinedValue();
-            if (!JS_GetElement(context, search_path, i, elem.address())) {
+            if (!JS_GetElement(context, search_path, i, &elem)) {
                 /* this means there was an exception, while elem.isUndefined()
                  * means no element found
                  */
@@ -784,7 +779,7 @@ importer_new_enumerate(JSContext  *context,
                                          &element_val))
                 return false;
 
-            if (!JS_ValueToId(context, element_val, idp.address()))
+            if (!JS_ValueToId(context, element_val, idp))
                 return false;
 
             break;
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index a47d7e2..dc4182b 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -85,7 +85,7 @@ gjs_throw_valist(JSContext       *context,
         goto out;
     }
 
-    if (!JS_GetProperty(context, global, error_class, v_constructor.address()) ||
+    if (!JS_GetProperty(context, global, error_class, &v_constructor) ||
         !v_constructor.isObject()) {
         JS_ReportError(context, "??? Missing Error constructor in global object?");
         goto out;
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 1707256..6143b47 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -313,7 +313,7 @@ gjs_get_string_id (JSContext       *context,
 {
     JS::RootedValue id_val(context);
 
-    if (!JS_IdToValue(context, id, id_val.address()))
+    if (!JS_IdToValue(context, id, &id_val))
         return false;
 
     if (id_val.isString()) {
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 515f64a..a26abce 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -181,7 +181,7 @@ gjs_object_require_property(JSContext             *context,
 {
     value.setUndefined();
 
-    if (G_UNLIKELY(!JS_GetPropertyById(context, obj, property_name, value.address())))
+    if (G_UNLIKELY(!JS_GetPropertyById(context, obj, property_name, value)))
         return false;
 
     if (G_LIKELY(!value.isUndefined()))
@@ -200,7 +200,7 @@ gjs_object_require_property_value(JSContext       *cx,
                                   bool            *value)
 {
     JS::RootedValue prop_value(cx);
-    if (JS_GetPropertyById(cx, obj, property_name, prop_value.address()) &&
+    if (JS_GetPropertyById(cx, obj, property_name, &prop_value) &&
         prop_value.isBoolean()) {
         *value = prop_value.toBoolean();
         return true;
@@ -219,7 +219,7 @@ gjs_object_require_property_value(JSContext       *cx,
                                   int32_t         *value)
 {
     JS::RootedValue prop_value(cx);
-    if (JS_GetPropertyById(cx, obj, property_name, prop_value.address()) &&
+    if (JS_GetPropertyById(cx, obj, property_name, &prop_value) &&
         prop_value.isInt32()) {
         *value = prop_value.toInt32();
         return true;
@@ -239,7 +239,7 @@ gjs_object_require_property_value(JSContext       *cx,
                                   char           **value)
 {
     JS::RootedValue prop_value(cx);
-    if (JS_GetPropertyById(cx, obj, property_name, prop_value.address()) &&
+    if (JS_GetPropertyById(cx, obj, property_name, &prop_value) &&
         gjs_string_to_utf8(cx, prop_value, value)) {
         return true;
     }
@@ -257,7 +257,7 @@ gjs_object_require_property_value(JSContext              *cx,
                                   JS::MutableHandleObject value)
 {
     JS::RootedValue prop_value(cx);
-    if (JS_GetPropertyById(cx, obj, property_name, prop_value.address()) &&
+    if (JS_GetPropertyById(cx, obj, property_name, &prop_value) &&
         prop_value.isObject()) {
         value.set(&prop_value.toObject());
         return true;
@@ -276,7 +276,7 @@ gjs_object_require_converted_property_value(JSContext       *cx,
                                             uint32_t        *value)
 {
     JS::RootedValue prop_value(cx);
-    if (JS_GetPropertyById(cx, obj, property_name, prop_value.address()) &&
+    if (JS_GetPropertyById(cx, obj, property_name, &prop_value) &&
         JS::ToUint32(cx, prop_value, value)) {
         return true;
     }
@@ -630,7 +630,7 @@ gjs_log_exception(JSContext  *context)
     JS_BeginRequest(context);
 
     JS::RootedValue exc(context);
-    if (!JS_GetPendingException(context, exc.address()))
+    if (!JS_GetPendingException(context, &exc))
         goto out;
 
     JS_ClearPendingException(context);
@@ -878,7 +878,7 @@ gjs_eval_with_scope(JSContext             *context,
            .setFileAndLine(filename, start_line_number)
            .setSourcePolicy(JS::CompileOptions::LAZY_SOURCE);
 
-    if (!JS::Evaluate(context, eval_obj, options, script, script_len, retval.address()))
+    if (!JS::Evaluate(context, eval_obj, options, script, script_len, retval))
         return false;
 
     gjs_schedule_gc_if_needed(context);
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 80e363c..9f7c945 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -206,7 +206,7 @@ gjs_##cname##_create_proto(JSContext *context,                                 \
     JS::RootedObject global(context, gjs_get_import_global(context));          \
     JS::RootedId class_name(context,                                           \
         gjs_intern_string_to_id(context, gjs_##cname##_class.name));           \
-    if (!JS_GetPropertyById(context, global, class_name, rval.address()))      \
+    if (!JS_GetPropertyById(context, global, class_name, &rval))               \
         return JS::NullValue(); \
     if (rval.isUndefined()) { \
         JS::RootedObject prototype(context,                                    \
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index 1edbafb..cf5efa5 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -86,9 +86,9 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method)                               \
       if (!array)                                                          \
         return false;                                                      \
       JS::RootedValue r(context, JS::NumberValue(arg1));                   \
-      if (!JS_SetElement(context, array, 0, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 0, r)) return false;              \
       r.setNumber(arg2);                                                   \
-      if (!JS_SetElement(context, array, 1, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 1, r)) return false;              \
       argv.rval().setObject(*array);                                       \
     }                                                                      \
 _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
@@ -104,9 +104,9 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method)                               \
       if (!array)                                                          \
         return false;                                                      \
       JS::RootedValue r(context, JS::NumberValue(arg1));                   \
-      if (!JS_SetElement(context, array, 0, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 0, r)) return false;              \
       r.setNumber(arg2);                                                   \
-      if (!JS_SetElement(context, array, 1, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 1, r)) return false;              \
       argv.rval().setObject(*array);                                       \
     }                                                                      \
 _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
@@ -122,13 +122,13 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method)                               \
       if (!array)                                                          \
         return false;                                                      \
       JS::RootedValue r(context, JS::NumberValue(arg1));                   \
-      if (!JS_SetElement(context, array, 0, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 0, r)) return false;              \
       r.setNumber(arg2);                                                   \
-      if (!JS_SetElement(context, array, 1, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 1, r)) return false;              \
       r.setNumber(arg3);                                                   \
-      if (!JS_SetElement(context, array, 2, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 2, r)) return false;              \
       r.setNumber(arg4);                                                   \
-      if (!JS_SetElement(context, array, 3, r.address())) return false;    \
+      if (!JS_SetElement(context, array, 3, r)) return false;              \
       argv.rval().setObject(*array);                                       \
     }                                                                      \
 _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
@@ -558,7 +558,7 @@ setDash_func(JSContext *context,
         double b;
 
         elem.setUndefined();
-        if (!JS_GetElement(context, dashes, i, elem.address())) {
+        if (!JS_GetElement(context, dashes, i, &elem)) {
             return false;
         }
         if (elem.isUndefined())
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index 941f247..39ff07e 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -152,16 +152,16 @@ make_rectangle(JSContext *context,
     JS::RootedValue val(context);
 
     val = JS::Int32Value(rect->x);
-    JS_SetProperty(context, rect_obj, "x", val.address());
+    JS_SetProperty(context, rect_obj, "x", val);
 
     val = JS::Int32Value(rect->y);
-    JS_SetProperty(context, rect_obj, "y", val.address());
+    JS_SetProperty(context, rect_obj, "y", val);
 
     val = JS::Int32Value(rect->width);
-    JS_SetProperty(context, rect_obj, "width", val.address());
+    JS_SetProperty(context, rect_obj, "width", val);
 
     val = JS::Int32Value(rect->height);
-    JS_SetProperty(context, rect_obj, "height", val.address());
+    JS_SetProperty(context, rect_obj, "height", val);
 
     return rect_obj;
 }
diff --git a/modules/console.cpp b/modules/console.cpp
index c610155..a15cbbc 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -195,11 +195,11 @@ gjs_console_interact(JSContext *context,
         JS::CompileOptions options(context);
         options.setUTF8(true)
                .setFileAndLine("typein", startline);
-        JS::Evaluate(context, object, options, buffer->str, buffer->len, result.address());
+        JS::Evaluate(context, object, options, buffer->str, buffer->len, &result);
 
         gjs_schedule_gc_if_needed(context);
 
-        if (JS_GetPendingException(context, result.address())) {
+        if (JS_GetPendingException(context, &result)) {
             str = JS_ValueToString(context, result);
             JS_ClearPendingException(context);
         } else if (result.isUndefined()) {
diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp
index 2a6636b..90414a3 100644
--- a/test/gjs-test-call-args.cpp
+++ b/test/gjs-test-call-args.cpp
@@ -265,7 +265,7 @@ run_code(GjsUnitTestFixture *fx,
     JS::RootedObject global(fx->cx, gjs_get_import_global(fx->cx));
     JS::RootedValue ignored(fx->cx);
     bool ok = JS::Evaluate(fx->cx, global, options, script, strlen(script),
-                           ignored.address());
+                           &ignored);
     JS_ReportPendingException(fx->cx);
 
     g_assert_null(fx->message);
@@ -284,7 +284,7 @@ run_code_expect_exception(GjsUnitTestFixture *fx,
     JS::RootedObject global(fx->cx, gjs_get_import_global(fx->cx));
     JS::RootedValue ignored(fx->cx);
     bool ok = JS::Evaluate(fx->cx, global, options, script, strlen(script),
-                           ignored.address());
+                           &ignored);
     g_assert_false(ok);
     g_assert_true(JS_IsExceptionPending(fx->cx));
     JS_ReportPendingException(fx->cx);
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index 47559b1..065ca45 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -87,11 +87,11 @@ gjstest_test_func_gjs_jsapi_util_error_throw(GjsUnitTestFixture *fx,
 
     g_assert(JS_IsExceptionPending(fx->cx));
 
-    JS_GetPendingException(fx->cx, exc.address());
+    JS_GetPendingException(fx->cx, &exc);
     g_assert(!exc.isUndefined());
 
     JS::RootedObject exc_obj(fx->cx, &exc.toObject());
-    JS_GetProperty(fx->cx, exc_obj, "message", value.address());
+    JS_GetProperty(fx->cx, exc_obj, "message", &value);
 
     g_assert(value.isString());
 
@@ -117,7 +117,7 @@ gjstest_test_func_gjs_jsapi_util_error_throw(GjsUnitTestFixture *fx,
     g_assert(JS_IsExceptionPending(fx->cx));
 
     exc = JS::UndefinedValue();
-    JS_GetPendingException(fx->cx, exc.address());
+    JS_GetPendingException(fx->cx, &exc);
     g_assert(!exc.isUndefined());
     g_assert(&exc.toObject() == &previous.toObject());
 }



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