[gjs] js: Fix misc APIs for mozjs31
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] js: Fix misc APIs for mozjs31
- Date: Sat, 10 Dec 2016 03:48:31 +0000 (UTC)
commit cd355eaa081676c102fe4b369a3d8e92c78413d3
Author: Philip Chimento <philip endlessm com>
Date: Fri Nov 4 18:27:42 2016 -0700
js: Fix misc APIs for mozjs31
This commit adapts to a few miscellaneous API changes in mozjs31 that
don't fit anywhere else.
https://bugzilla.gnome.org/show_bug.cgi?id=751252
gi/function.cpp | 4 ++--
gi/object.cpp | 7 +++----
gjs/coverage.cpp | 7 ++++---
gjs/importer.cpp | 3 +--
gjs/jsapi-util.cpp | 4 ++--
5 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 71fdd5d..082e825 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -87,7 +87,7 @@ gjs_callback_trampoline_unref(GjsCallbackTrampoline *trampoline)
if (!trampoline->is_vfunc) {
JS_BeginRequest(context);
- JS_RemoveValueRoot(context, trampoline->js_function.unsafeGet());
+ JS::RemoveValueRoot(context, &trampoline->js_function);
JS_EndRequest(context);
}
@@ -456,7 +456,7 @@ gjs_callback_trampoline_new(JSContext *context,
g_base_info_ref((GIBaseInfo*)trampoline->info);
trampoline->js_function = function;
if (!is_vfunc)
- JS_AddValueRoot(context, trampoline->js_function.unsafeGet());
+ JS::AddValueRoot(context, &trampoline->js_function);
/* Analyze param types and directions, similarly to init_cached_function_data */
n_args = g_callable_info_get_n_args(trampoline->info);
diff --git a/gi/object.cpp b/gi/object.cpp
index d0ed86c..a95e8ae 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -99,6 +99,8 @@ static volatile gint pending_idle_toggles;
GJS_DEFINE_PRIV_FROM_JS(ObjectInstance, gjs_object_instance_class)
+static JS::Heap<JSObject *> *ensure_heap_wrapper(GObject *gobj);
+
static JSObject* peek_js_obj (GObject *gobj);
static void set_js_obj (GObject *gobj,
JSObject *obj);
@@ -1056,10 +1058,7 @@ wrapped_gobj_toggle_notify(gpointer data,
G_OBJECT_TYPE_NAME(gobj));
}
if (is_sweeping) {
- JSObject *object;
-
- object = peek_js_obj(gobj);
- if (JS_IsAboutToBeFinalized(&object)) {
+ if (JS_IsAboutToBeFinalized(ensure_heap_wrapper(gobj))) {
/* Ouch, the JS object is dead already. Disassociate the GObject
* and hope the GObject dies too.
*/
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 036b004..4975019 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -406,8 +406,7 @@ get_array_from_js_value(JSContext *context,
g_return_val_if_fail(out_array != NULL, false);
g_return_val_if_fail(*out_array == NULL, false);
- JS::RootedObject js_array(context, &value.toObject());
- if (!JS_IsArrayObject(context, js_array)) {
+ if (!JS_IsArrayObject(context, value)) {
g_critical("Returned object from is not an array");
return false;
}
@@ -417,6 +416,7 @@ get_array_from_js_value(JSContext *context,
* preallocate to. */
GArray *c_side_array = g_array_new(true, true, array_element_size);
u_int32_t js_array_len;
+ JS::RootedObject js_array(context, &value.toObject());
if (element_clear_func)
g_array_set_clear_func(c_side_array, element_clear_func);
@@ -1574,7 +1574,8 @@ bootstrap_coverage(GjsCoverage *coverage)
JS::CompartmentOptions options;
options.setVersion(JSVERSION_LATEST);
JS::RootedObject debugger_compartment(JS_GetRuntime(context),
- JS_NewGlobalObject(context, &coverage_global_class, NULL,
options));
+ JS_NewGlobalObject(context, &coverage_global_class, NULL,
+ JS::FireOnNewGlobalHook, options));
{
JSAutoCompartment compartment(context, debugger_compartment);
JS::RootedObject debuggeeWrapper(context, debuggee);
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index d9bb919..71dd3f6 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -158,8 +158,7 @@ seal_import(JSContext *cx,
* This also looks for properties higher up the prototype chain, but in
* practice this will always be an own property because we defined it in
* define_import(). */
- if (!JS_GetPropertyDescriptorById(cx, obj, prop_id, 0 /* flags */,
- &descr) ||
+ if (!JS_GetPropertyDescriptorById(cx, obj, prop_id, &descr) ||
descr.object() == NULL) {
gjs_debug(GJS_DEBUG_IMPORTER,
"Failed to get attributes to seal '%s' in importer",
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index d3d105b..decac55 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -104,7 +104,7 @@ gjs_init_context_standard (JSContext *context,
compartment_options.setVersion(JSVERSION_LATEST);
global.set(JS_NewGlobalObject(context, &global_class, NULL,
- compartment_options));
+ JS::FireOnNewGlobalHook, compartment_options));
if (global == NULL)
return false;
@@ -876,7 +876,7 @@ gjs_eval_with_scope(JSContext *context,
JS::CompileOptions options(context);
options.setUTF8(true)
.setFileAndLine(filename, start_line_number)
- .setSourcePolicy(JS::CompileOptions::LAZY_SOURCE);
+ .setSourceIsLazy(true);
if (!JS::Evaluate(context, eval_obj, options, script, script_len, retval))
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]