[gjs/wip/ptomato/mozjs31prep: 2/5] compat: Remove use of JS_GetGlobalObject define



commit ac063a231b7947868705da382b24c84b3393346c
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Sep 18 08:17:14 2016 -0700

    compat: Remove use of JS_GetGlobalObject define
    
    As long as we are switching to new SpiderMonkey API, we should get rid of
    all usage this define that mimics removed API, since we wrote a function
    to replace it.
    
    Unfortunately we must leave the define itself, since it's part of the
    libgjs API, but we can mark it deprecated.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742249

 gjs/compat.h             |    4 +++-
 gjs/coverage.cpp         |    4 ++--
 gjs/jsapi-util-error.cpp |    2 +-
 gjs/jsapi-util.cpp       |    6 +++---
 test/gjs-tests.cpp       |    6 +++---
 5 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/gjs/compat.h b/gjs/compat.h
index 8746e1a..ac971ea 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -59,7 +59,9 @@ G_BEGIN_DECLS
     _Pragma("GCC warning \"JSVAL_IS_OBJECT is deprecated. Use JS::Value::isObjectOrNull() instead.\"") \
     ((obj).isObjectOrNull())
 
-#define JS_GetGlobalObject(cx) gjs_get_global_object(cx)
+#define JS_GetGlobalObject(cx) \
+    _Pragma("GCC warning \"JS_GetGlobalObject is deprecated. Use JS_GetGlobalForObject() or 
JS_GetGlobalForScopeChain() instead.\"") \
+    gjs_get_global_object(cx)
 
 static bool G_GNUC_UNUSED JS_NewNumberValue(JSContext *cx, double d, JS::Value *rval)
     {
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 3962136..417b895 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1611,7 +1611,7 @@ bootstrap_coverage(GjsCoverage *coverage)
     JSContext *context = (JSContext *) gjs_context_get_native_context(priv->context);
     JSAutoRequest ar(context);
 
-    JSObject *debuggee = JS_GetGlobalObject(context);
+    JSObject *debuggee = gjs_get_global_object(context);
     JS::CompartmentOptions options;
     options.setVersion(JSVERSION_LATEST);
     JS::RootedObject debugger_compartment(JS_GetRuntime(context),
@@ -1742,7 +1742,7 @@ gjs_coverage_constructed(GObject *object)
     JS_SetOptions(context, options_flags);
 
     if (!bootstrap_coverage(coverage)) {
-        JSAutoCompartment compartment(context, JS_GetGlobalObject(context));
+        JSAutoCompartment compartment(context, gjs_get_global_object(context));
         gjs_log_exception(context);
     }
 }
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index b7de3be..c6849a7 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -54,7 +54,7 @@ gjs_throw_valist(JSContext       *context,
 
     s = g_strdup_vprintf(format, args);
 
-    JSAutoCompartment compartment(context, JS_GetGlobalObject(context));
+    JSAutoCompartment compartment(context, gjs_get_global_object(context));
 
     JS_BeginRequest(context);
 
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 44dd557..0af9ae1 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -119,7 +119,7 @@ gjs_set_global_slot (JSContext     *context,
                      JS::Value      value)
 {
     JSObject *global;
-    global = JS_GetGlobalObject(context);
+    global = gjs_get_global_object(context);
     JS_SetReservedSlot(global, JSCLASS_GLOBAL_SLOT_COUNT + slot, value);
 }
 
@@ -128,7 +128,7 @@ gjs_get_global_slot (JSContext     *context,
                      GjsGlobalSlot  slot)
 {
     JSObject *global;
-    global = JS_GetGlobalObject(context);
+    global = gjs_get_global_object(context);
     return JS_GetReservedSlot(global, JSCLASS_GLOBAL_SLOT_COUNT + slot);
 }
 
@@ -444,7 +444,7 @@ gjs_explain_scope(JSContext  *context,
               context,
               "");
 
-    global = JS_GetGlobalObject(context);
+    global = gjs_get_global_object(context);
     debugstr = gjs_value_debug_string(context, JS::ObjectOrNullValue(global));
     gjs_debug(GJS_DEBUG_SCOPE,
               "  Global: %p %s",
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index f6267cf..7c3837f 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -106,7 +106,7 @@ gjstest_test_func_gjs_jsapi_util_array(void)
 
     array = gjs_rooted_array_new();
 
-    global = JS_GetGlobalObject(context);
+    global = gjs_get_global_object(context);
     JSCompartment *oldCompartment = JS_EnterCompartment(context, global);
 
     for (i = 0; i < N_ELEMS; i++) {
@@ -147,7 +147,7 @@ gjstest_test_func_gjs_jsapi_util_string_js_string_utf8(void)
 
     _gjs_unit_test_fixture_begin(&fixture);
     context = fixture.context;
-    global = JS_GetGlobalObject(context);
+    global = gjs_get_global_object(context);
     JSCompartment *oldCompartment = JS_EnterCompartment(context, global);
 
     g_assert(gjs_string_from_utf8(context, utf8_string, -1, &js_string));
@@ -174,7 +174,7 @@ gjstest_test_func_gjs_jsapi_util_error_throw(void)
 
     _gjs_unit_test_fixture_begin(&fixture);
     context = fixture.context;
-    global = JS_GetGlobalObject(context);
+    global = gjs_get_global_object(context);
     JSCompartment *oldCompartment = JS_EnterCompartment(context, global);
     /* Test that we can throw */
 


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