[gjs/wip/ptomato/mozjs52: 10/38] js: Global object is implicit in many functions
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs52: 10/38] js: Global object is implicit in many functions
- Date: Sat, 8 Jul 2017 19:46:14 +0000 (UTC)
commit 4d39589ea2b2565ccf9178013ae63a0386c59c63
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.
https://bugzilla.gnome.org/show_bug.cgi?id=784196
gi/boxed.cpp | 2 +-
gjs/coverage.cpp | 12 ++++--------
gjs/global.cpp | 2 +-
gjs/jsapi-dynamic-class.cpp | 4 +---
gjs/jsapi-util.cpp | 2 +-
gjs/module.cpp | 3 +--
modules/console.cpp | 13 ++++++-------
test/gjs-test-call-args.cpp | 8 ++------
8 files changed, 17 insertions(+), 29 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 3cec390..7ff0aa2 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -594,7 +594,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/coverage.cpp b/gjs/coverage.cpp
index 722e7e5..41f9727 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1295,12 +1295,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);
@@ -1505,10 +1504,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/global.cpp b/gjs/global.cpp
index 2256d71..f91e449 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -226,7 +226,7 @@ class GjsGlobal {
.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 3d70222..7d45339 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 b7fbfa7..465b04f 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -835,7 +835,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/gjs/module.cpp b/gjs/module.cpp
index 0a4ea97..ceeb8b6 100644
--- a/gjs/module.cpp
+++ b/gjs/module.cpp
@@ -92,8 +92,7 @@ class GjsModule {
.setSourceIsLazy(true);
JS::RootedScript compiled_script(cx);
- if (!JS::Compile(cx, module, options, script, script_len,
- &compiled_script))
+ if (!JS::Compile(cx, options, script, script_len, &compiled_script))
return false;
JS::AutoObjectVector scope_chain(cx);
diff --git a/modules/console.cpp b/modules/console.cpp
index 81d150e..932d9f8 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -190,18 +190,17 @@ gjs_console_readline(JSContext *cx, char **bufp, FILE *file, const char *prompt)
* invocation of this function.)
*/
static bool
-gjs_console_eval_and_print(JSContext *cx,
- JS::HandleObject global,
- const char *bytes,
- size_t length,
- int lineno)
+gjs_console_eval_and_print(JSContext *cx,
+ const char *bytes,
+ size_t length,
+ int lineno)
{
JS::CompileOptions options(cx);
options.setUTF8(true)
.setFileAndLine("typein", lineno);
JS::RootedValue result(cx);
- if (!JS::Evaluate(cx, global, options, bytes, length, &result)) {
+ if (!JS::Evaluate(cx, options, bytes, length, &result)) {
if (!JS_IsExceptionPending(cx))
return false;
}
@@ -264,7 +263,7 @@ gjs_console_interact(JSContext *context,
buffer->str, buffer->len));
AutoReportException are(context);
- if (!gjs_console_eval_and_print(context, global, buffer->str, buffer->len,
+ if (!gjs_console_eval_and_print(context, buffer->str, buffer->len,
startline)) {
/* 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 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]