[gjs/wip/ptomato/mozjs45prep: 21/36] js: Global object is implicit in many functions



commit 2f538ea7054fa97b5f946251d3b57260dfe23a09
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Mar 19 05:06:48 2017 +0000

    js: Global object is implicit in many functions
    
    In many function calls where you had to pass in a global object, it is
    now implicit and will use the global for the current scope.
    
    FIXME: Make sure we don't now have unused rooted global objects all over
    the place

 gi/boxed.cpp                |    2 +-
 gjs/context.cpp             |    2 +-
 gjs/jsapi-dynamic-class.cpp |    4 +---
 test/gjs-test-call-args.cpp |    8 ++------
 4 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 4ea2112..9801b44 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -605,7 +605,7 @@ define_native_accessor_wrapper(JSContext  *cx,
                                uint32_t    id)
 {
     JSFunction *func = js::NewFunctionWithReserved(cx, call, nargs, 0,
-                                                   NULL, func_name);
+                                                   func_name);
     if (!func)
         return NULL;
 
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 43a04c1..9c4eba2 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -309,7 +309,7 @@ gjs_define_promise_object(JSContext       *cx,
         .setFile("<Promise>");
 
     JS::RootedValue promise(cx);
-    if (!JS::Evaluate(cx, global, options, lie_code, lie_length, &promise)) {
+    if (!JS::Evaluate(cx, options, lie_code, lie_length, &promise)) {
         g_bytes_unref(lie_bytes);
         return false;
     }
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 4900ee5..6ed69a2 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -67,8 +67,6 @@ gjs_init_class_dynamic(JSContext              *context,
 
     JS_BeginRequest(context);
 
-    JS::RootedObject global(context, gjs_get_import_global(context));
-
     /* Class initalization consists of three parts:
        - building a prototype
        - defining prototype properties and functions
@@ -99,7 +97,7 @@ gjs_init_class_dynamic(JSContext              *context,
 
     full_function_name = g_strdup_printf("%s_%s", ns_name, class_name);
     constructor_fun = JS_NewFunction(context, constructor_native, nargs, JSFUN_CONSTRUCTOR,
-                                     global, full_function_name);
+                                     full_function_name);
     if (!constructor_fun)
         goto out;
 
diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp
index 1adebb8..1331210 100644
--- a/test/gjs-test-call-args.cpp
+++ b/test/gjs-test-call-args.cpp
@@ -272,10 +272,8 @@ run_code(GjsUnitTestFixture *fx,
     JS::CompileOptions options(fx->cx, JSVERSION_UNKNOWN);
     options.setFileAndLine("unit test", 1);
 
-    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);
+    bool ok = JS::Evaluate(fx->cx, options, script, strlen(script), &ignored);
     JS_ReportPendingException(fx->cx);
 
     g_assert_null(fx->message);
@@ -291,10 +289,8 @@ run_code_expect_exception(GjsUnitTestFixture *fx,
     JS::CompileOptions options(fx->cx, JSVERSION_UNKNOWN);
     options.setFileAndLine("unit test", 1);
 
-    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);
+    bool ok = JS::Evaluate(fx->cx, options, script, strlen(script), &ignored);
     g_assert_false(ok);
     g_assert_true(JS_IsExceptionPending(fx->cx));
     JS_ReportPendingException(fx->cx);


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