[gjs/wip/ptomato/mozjs31: 26/26] WIP - stuff



commit 8ad00a181b65f4438e2ce46e28fe1b8268ea6b4e
Author: Philip Chimento <philip endlessm com>
Date:   Fri Nov 4 18:27:42 2016 -0700

    WIP - stuff

 gi/function.cpp    |    4 ++--
 gi/object.cpp      |    7 +++----
 gjs/coverage.cpp   |    7 ++++---
 gjs/jsapi-util.cpp |    4 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 53618c2..8dffc5d 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);
         }
 
@@ -454,7 +454,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 11fff54..d374888 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -98,6 +98,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);
@@ -1065,10 +1067,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 8d45f4b..c36333e 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);
@@ -1561,7 +1561,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/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 8130e26..0c2676c 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -91,7 +91,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;
 
@@ -863,7 +863,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]