diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2017-03-19 05:06:48 +0000 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2017-05-05 23:26:30 -0700 |
commit | 46dfc059f09f20e1e93747a47fa224f5acedbca1 (patch) | |
tree | 67fd5c00748baf075bcc15e475be3f3b04b6a19b | |
parent | 78c87c9ff16d9b21ffa11f91c3280046a5a3217f (diff) | |
download | gjs-46dfc059f09f20e1e93747a47fa224f5acedbca1.tar.gz |
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
-rw-r--r-- | gi/boxed.cpp | 2 | ||||
-rw-r--r-- | gjs/context.cpp | 2 | ||||
-rw-r--r-- | gjs/coverage.cpp | 12 | ||||
-rw-r--r-- | gjs/jsapi-dynamic-class.cpp | 4 | ||||
-rw-r--r-- | gjs/jsapi-util.cpp | 2 | ||||
-rw-r--r-- | modules/console.cpp | 2 | ||||
-rw-r--r-- | test/gjs-test-call-args.cpp | 8 |
7 files changed, 11 insertions, 21 deletions
diff --git a/gi/boxed.cpp b/gi/boxed.cpp index 6b4e2615..8a438ef7 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 24a615b2..c7bb686a 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/coverage.cpp b/gjs/coverage.cpp index 579b1417..02b4569d 100644 --- a/gjs/coverage.cpp +++ b/gjs/coverage.cpp @@ -1310,12 +1310,11 @@ gjs_context_eval_file_in_compartment(GjsContext *context, .setFileAndLine(filename, start_line_number) .setSourceIsLazy(true); JS::RootedScript compiled_script(js_context); - if (!JS::Compile(js_context, compartment_object, options, stripped_script, - script_len, &compiled_script)) + if (!JS::Compile(js_context, options, stripped_script, script_len, + &compiled_script)) return false; - if (!JS::CloneAndExecuteScript(js_context, compartment_object, - compiled_script)) { + if (!JS::CloneAndExecuteScript(js_context, compiled_script)) { g_free(script); gjs_log_exception(js_context); g_set_error(error, GJS_ERROR, GJS_ERROR_FAILED, "Failed to evaluate %s", filename); @@ -1521,10 +1520,7 @@ gjs_run_script_in_coverage_compartment(GjsCoverage *coverage, options.setUTF8(true); JS::RootedValue rval(js_context); - JS::RootedObject global(js_context, - JS_GetGlobalForObject(js_context, priv->coverage_statistics)); - if (!JS::Evaluate(js_context, global, options, script, strlen(script), - &rval)) { + if (!JS::Evaluate(js_context, options, script, strlen(script), &rval)) { gjs_log_exception(js_context); g_warning("Failed to evaluate <coverage_modifier>"); return false; diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp index 3d702228..7d45339b 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/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp index 84071743..af2f1830 100644 --- a/gjs/jsapi-util.cpp +++ b/gjs/jsapi-util.cpp @@ -938,7 +938,7 @@ gjs_eval_with_scope(JSContext *context, .setSourceIsLazy(true); JS::RootedScript compiled_script(context); - if (!JS::Compile(context, object, options, script, real_len, &compiled_script)) + if (!JS::Compile(context, options, script, real_len, &compiled_script)) return false; JS::AutoObjectVector scope_chain(context); diff --git a/modules/console.cpp b/modules/console.cpp index bbc6b9f1..57a16b7c 100644 --- a/modules/console.cpp +++ b/modules/console.cpp @@ -197,7 +197,7 @@ gjs_console_interact(JSContext *context, JS::CompileOptions options(context); options.setUTF8(true) .setFileAndLine("typein", startline); - if (!JS::Evaluate(context, global, options, buffer->str, buffer->len, + if (!JS::Evaluate(context, options, buffer->str, buffer->len, &result)) { /* If this was an uncatchable exception, throw another uncatchable * exception on up to the surrounding JS::Evaluate() in main(). This diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp index 1adebb89..13312109 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); |