[gjs: 10/14] js: Misc mozjs60 API changes
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 10/14] js: Misc mozjs60 API changes
- Date: Sun, 29 Jul 2018 16:55:07 +0000 (UTC)
commit 67d7efc63211cffb4e8528d4dd40153968561cca
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Dec 10 01:09:13 2017 -0800
js: Misc mozjs60 API changes
- An argument that we didn't use was removed from the JSFinalizeCallback
signature
- JS_SetLocaleCallbacks API changed (is JSRuntime coming back again?)
- Giving a JSVERSION to a compartment or CompileOptions is not supported
anymore
- Use JS::CurrentThreadIsHeapCollecting() instead of our hacky workaround
in GC
- JS::PromiseRejectionHandlingState now is in the JS namespace
- JS::Value is now incompatible with C-linkage, so any function returning
one must be moved outside G_BEGIN_DECLS/G_END_DECLS
- JSPROP_SHARED is gone
- Defining a property with getter and setter now doesn't take a JS::Value
See: #161
gjs/engine.cpp | 14 +++++---------
gjs/global.cpp | 1 -
gjs/global.h | 5 ++---
gjs/jsapi-dynamic-class.cpp | 8 ++++----
gjs/jsapi-util-root.h | 5 +----
test/gjs-test-call-args.cpp | 4 ++--
6 files changed, 14 insertions(+), 23 deletions(-)
---
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index 720267d9..a22199b3 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -118,7 +118,6 @@ static JSLocaleCallbacks gjs_locale_callbacks =
static void
gjs_finalize_callback(JSFreeOp *fop,
JSFinalizeStatus status,
- bool isCompartment,
void *data)
{
auto js_context = static_cast<GjsContext *>(data);
@@ -193,16 +192,13 @@ on_enqueue_promise_job(JSContext *cx,
return _gjs_context_enqueue_job(gjs_context, callback);
}
-static void
-on_promise_unhandled_rejection(JSContext *cx,
- JS::HandleObject promise,
- PromiseRejectionHandlingState state,
- void *data)
-{
+static void on_promise_unhandled_rejection(
+ JSContext* cx, JS::HandleObject promise,
+ JS::PromiseRejectionHandlingState state, void* data) {
auto gjs_context = static_cast<GjsContext *>(data);
uint64_t id = JS::GetPromiseID(promise);
- if (state == PromiseRejectionHandlingState::Handled) {
+ if (state == JS::PromiseRejectionHandlingState::Handled) {
/* This happens when catching an exception from an await expression. */
_gjs_context_unregister_unhandled_promise_rejection(gjs_context, id);
return;
@@ -295,7 +291,7 @@ gjs_create_js_context(GjsContext *js_context)
JS_AddFinalizeCallback(cx, gjs_finalize_callback, js_context);
JS_SetGCCallback(cx, on_garbage_collect, js_context);
- JS_SetLocaleCallbacks(cx, &gjs_locale_callbacks);
+ JS_SetLocaleCallbacks(JS_GetRuntime(cx), &gjs_locale_callbacks);
JS::SetWarningReporter(cx, gjs_warning_reporter);
JS::SetGetIncumbentGlobalCallback(cx, gjs_get_import_global);
JS::SetEnqueuePromiseJobCallback(cx, on_enqueue_promise_job, js_context);
diff --git a/gjs/global.cpp b/gjs/global.cpp
index 0cf6836f..d18e4f90 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -238,7 +238,6 @@ public:
create(JSContext *cx)
{
JS::CompartmentOptions compartment_options;
- compartment_options.behaviors().setVersion(JSVERSION_LATEST);
JS::RootedObject global(cx,
JS_NewGlobalObject(cx, &GjsGlobal::klass, nullptr,
JS::FireOnNewGlobalHook, compartment_options));
diff --git a/gjs/global.h b/gjs/global.h
index ae99b151..9cd3cbcd 100644
--- a/gjs/global.h
+++ b/gjs/global.h
@@ -61,13 +61,12 @@ bool gjs_define_global_properties(JSContext *cx,
JS::HandleObject global,
const char *bootstrap_script);
-JS::Value gjs_get_global_slot(JSContext *cx,
- GjsGlobalSlot slot);
-
void gjs_set_global_slot(JSContext *context,
GjsGlobalSlot slot,
JS::Value value);
G_END_DECLS
+JS::Value gjs_get_global_slot(JSContext* cx, GjsGlobalSlot slot);
+
#endif /* GJS_GLOBAL_H */
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 30e48894..08e40960 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -263,11 +263,11 @@ gjs_define_property_dynamic(JSContext *cx,
if (!setter_obj)
return false;
- flags |= JSPROP_SHARED | JSPROP_GETTER | JSPROP_SETTER;
+ flags |= JSPROP_GETTER | JSPROP_SETTER;
- return JS_DefineProperty(cx, proto, prop_name, JS::UndefinedHandleValue, flags,
- JS_DATA_TO_FUNC_PTR(JSNative, getter_obj.get()),
- JS_DATA_TO_FUNC_PTR(JSNative, setter_obj.get()));
+ return JS_DefineProperty(
+ cx, proto, prop_name, JS_DATA_TO_FUNC_PTR(JSNative, getter_obj.get()),
+ JS_DATA_TO_FUNC_PTR(JSNative, setter_obj.get()), flags);
}
/**
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index 785ba184..f3f862c2 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -84,10 +84,7 @@ struct GjsHeapOperation<JSObject *> {
/* If the object has been swept already, then the zone is nullptr */
if (!obj || !js::gc::detail::GetGCThingZone(uintptr_t(obj)))
return;
- /* COMPAT: Use JS::CurrentThreadIsHeapCollecting() in mozjs59 */
- JS::GCCellPtr ptr(obj, JS::TraceKind::Object);
- JS::shadow::Runtime *rt = js::gc::detail::GetCellRuntime(ptr.asCell());
- if (!rt->isHeapCollecting())
+ if (!JS::CurrentThreadIsHeapCollecting())
JS::ExposeObjectToActiveJS(obj);
}
};
diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp
index a27d1c20..a2a7f799 100644
--- a/test/gjs-test-call-args.cpp
+++ b/test/gjs-test-call-args.cpp
@@ -265,7 +265,7 @@ run_code(GjsUnitTestFixture *fx,
{
const char *script = (const char *) code;
- JS::CompileOptions options(fx->cx, JSVERSION_UNKNOWN);
+ JS::CompileOptions options(fx->cx);
options.setFileAndLine("unit test", 1);
JS::RootedValue ignored(fx->cx);
@@ -281,7 +281,7 @@ run_code_expect_exception(GjsUnitTestFixture *fx,
{
const char *script = (const char *) code;
- JS::CompileOptions options(fx->cx, JSVERSION_UNKNOWN);
+ JS::CompileOptions options(fx->cx);
options.setFileAndLine("unit test", 1);
JS::RootedValue ignored(fx->cx);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]