[gjs: 5/7] compat: Remove use of JS_GetGlobalObject define



commit 0c0ec76dd15096af02361b5109859cd193e4dfb9
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 8f73a7d..b82877b 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -55,7 +55,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 JSBool G_GNUC_UNUSED
 JS_NewNumberValue(JSContext *cx,
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 29780a7..92b3beb 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1612,7 +1612,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),
@@ -1743,7 +1743,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 e0e8fc4..6f61b19 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 3e6d111..64910ec 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 b2c6f9e..3149d6e 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) == JS_TRUE);
@@ -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]