[gjs/wip/ptomato/mozjs45prep: 22/39] 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/mozjs45prep: 22/39] js: Global object is implicit in many functions
- Date: Wed, 12 Apr 2017 06:46:31 +0000 (UTC)
commit 94d3ef134c8970076ac48dfe8cce18a2c0d0d85e
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 | 6 +++---
gi/function.cpp | 2 +-
gi/fundamental.cpp | 3 +--
gi/gerror.cpp | 2 +-
gi/ns.cpp | 2 +-
gi/object.cpp | 5 +----
gi/param.cpp | 2 +-
gi/repo.cpp | 3 +--
gi/union.cpp | 2 +-
gjs/context.cpp | 2 +-
gjs/importer.cpp | 2 +-
gjs/jsapi-dynamic-class.cpp | 7 +++----
test/gjs-test-call-args.cpp | 8 ++------
13 files changed, 18 insertions(+), 28 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 840e7f9..45e5317 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -570,7 +570,7 @@ get_nested_interface_object(JSContext *context,
offset = g_field_info_get_offset (field_info);
- obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+ obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
if (obj == NULL)
return false;
@@ -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;
@@ -1224,7 +1224,7 @@ gjs_boxed_from_c_struct(JSContext *context,
JS::RootedObject proto(context, gjs_lookup_generic_prototype(context, info));
proto_priv = priv_from_js(context, proto);
- obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+ obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
GJS_INC_COUNTER(boxed);
priv = g_slice_new0(Boxed);
diff --git a/gi/function.cpp b/gi/function.cpp
index b86a4a9..f9e5166 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1702,7 +1702,7 @@ function_new(JSContext *context,
}
JS::RootedObject function(context,
- JS_NewObject(context, &gjs_function_class, global));
+ JS_NewObject(context, &gjs_function_class));
if (function == NULL) {
gjs_debug(GJS_DEBUG_GFUNCTION, "Failed to construct function");
return NULL;
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 7a3b5ec..8c3b201 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -778,8 +778,7 @@ gjs_object_from_g_fundamental(JSContext *context,
return NULL;
JS::RootedObject global(context, gjs_get_import_global(context));
- object = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto,
- global);
+ object = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
if (object == NULL)
goto out;
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index 4c2b689..6c29535 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -448,7 +448,7 @@ gjs_error_from_gerror(JSContext *context,
proto_priv = priv_from_js(context, proto);
JS::RootedObject obj(context,
- JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global));
+ JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto));
GJS_INC_COUNTER(gerror);
priv = g_slice_new0(Error);
diff --git a/gi/ns.cpp b/gi/ns.cpp
index 0bf815e..23cc2f0 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -221,7 +221,7 @@ ns_new(JSContext *context,
gjs_ns_class.name, prototype);
}
- JS::RootedObject ns(context, JS_NewObject(context, &gjs_ns_class, global));
+ JS::RootedObject ns(context, JS_NewObject(context, &gjs_ns_class));
if (ns == NULL)
g_error("No memory to create ns object");
diff --git a/gi/object.cpp b/gi/object.cpp
index 98f384b..0e988b6 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2034,11 +2034,8 @@ gjs_object_from_g_object(JSContext *context,
if (!proto)
return nullptr;
- JS::RootedObject global(context, gjs_get_import_global(context));
-
JS::RootedObject obj(context,
- JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto,
- global));
+ JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto));
if (obj == NULL)
return nullptr;
diff --git a/gi/param.cpp b/gi/param.cpp
index b943992..2f11e25 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -259,7 +259,7 @@ gjs_param_from_g_param(JSContext *context,
JS::RootedObject proto(context, gjs_lookup_param_prototype(context));
JS::RootedObject global(context, gjs_get_import_global(context));
- obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+ obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
GJS_INC_COUNTER(param);
priv = g_slice_new0(Param);
diff --git a/gi/repo.cpp b/gi/repo.cpp
index e4fd124..55c7bcb 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -287,8 +287,7 @@ repo_new(JSContext *context)
gjs_repo_class.name, prototype);
}
- JS::RootedObject repo(context,
- JS_NewObject(context, &gjs_repo_class, global));
+ JS::RootedObject repo(context, JS_NewObject(context, &gjs_repo_class));
if (repo == NULL) {
gjs_throw(context, "No memory to create repo object");
return NULL;
diff --git a/gi/union.cpp b/gi/union.cpp
index 28c793d..145edfe 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -405,7 +405,7 @@ gjs_union_from_c_union(JSContext *context,
gjs_lookup_generic_prototype(context, (GIUnionInfo*) info));
JS::RootedObject global(context, gjs_get_import_global(context));
- obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+ obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
GJS_INC_COUNTER(boxed);
priv = g_slice_new0(Union);
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/importer.cpp b/gjs/importer.cpp
index b68584a..da40c90 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -942,7 +942,7 @@ importer_new(JSContext *context,
}
JS::RootedObject importer(context,
- JS_NewObject(context, js::Jsvalify(&gjs_importer_class), global));
+ JS_NewObject(context, js::Jsvalify(&gjs_importer_class)));
if (importer == NULL)
g_error("No memory to create importer importer");
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 1205a65..819a000 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -78,8 +78,7 @@ gjs_init_class_dynamic(JSContext *context,
*/
if (parent_proto) {
- prototype.set(JS_NewObjectWithGivenProto(context, clasp,
- parent_proto, global));
+ prototype.set(JS_NewObjectWithGivenProto(context, clasp, parent_proto));
} else {
/* JS_NewObject will try to search for clasp prototype in the
* global object, which is wrong, but it's not a problem because
@@ -87,7 +86,7 @@ gjs_init_class_dynamic(JSContext *context,
* constructor is not found (and it won't be found, because we
* never call JS_InitClass).
*/
- prototype.set(JS_NewObject(context, clasp, global));
+ prototype.set(JS_NewObject(context, clasp));
}
if (!prototype)
goto out;
@@ -99,7 +98,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]