[gjs/wip/ptomato/mozjs38: 17/17] WIP - mozjs38



commit 65ffdd565b48fbe8d1611ef96e293e1dd73efad7
Author: Philip Chimento <philip endlessm com>
Date:   Thu Jan 19 19:08:37 2017 -0800

    WIP - mozjs38

 gi/boxed.cpp       |   60 +++++++++++++++++++++------------------------------
 gjs/context.cpp    |    2 +
 gjs/importer.cpp   |    3 +-
 gjs/jsapi-util.cpp |    5 +--
 gjs/runtime.cpp    |    2 +-
 5 files changed, 32 insertions(+), 40 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 5fda1ee..7b36507 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -542,13 +542,13 @@ get_field_info (JSContext *context,
 }
 
 static bool
-get_nested_interface_object (JSContext   *context,
-                             JSObject    *parent_obj,
-                             Boxed       *parent_priv,
-                             GIFieldInfo *field_info,
-                             GITypeInfo  *type_info,
-                             GIBaseInfo  *interface_info,
-                             JS::Value   *value)
+get_nested_interface_object (JSContext             *context,
+                             JSObject              *parent_obj,
+                             Boxed                 *parent_priv,
+                             GIFieldInfo           *field_info,
+                             GITypeInfo            *type_info,
+                             GIBaseInfo            *interface_info,
+                             JS::MutableHandleValue value)
 {
     JSObject *obj;
     int offset;
@@ -594,26 +594,21 @@ get_nested_interface_object (JSContext   *context,
      */
     JS_SetReservedSlot(obj, 0, JS::ObjectValue(*parent_obj));
 
-    *value = JS::ObjectValue(*obj);
+    value.setObject(*obj);
     return true;
 }
 
 static bool
-boxed_field_getter (JSContext              *context,
-                    JS::HandleObject        obj,
-                    JS::HandleId            id,
-                    JS::MutableHandleValue  value)
+boxed_field_getter (JSContext *context,
+                    unsigned   argc,
+                    JS::Value *vp)
 {
-    Boxed *priv;
+    GJS_GET_PRIV(context, argc, vp, args, obj, Boxed, priv);
     GIFieldInfo *field_info;
     GITypeInfo *type_info;
     GArgument arg;
     bool success = false;
 
-    priv = priv_from_js(context, obj);
-    if (!priv)
-        return false;
-
     field_info = get_field_info(context, priv, id);
     if (!field_info)
         return false;
@@ -637,7 +632,7 @@ boxed_field_getter (JSContext              *context,
 
             success = get_nested_interface_object (context, obj, priv,
                                                    field_info, type_info, interface_info,
-                                                   value.address());
+                                                   args.rval());
 
             g_base_info_unref ((GIBaseInfo *)interface_info);
 
@@ -654,7 +649,8 @@ boxed_field_getter (JSContext              *context,
         goto out;
     }
 
-    if (!gjs_value_from_g_argument(context, value, type_info, &arg, true))
+    if (!gjs_value_from_g_argument(context, args.rval(), type_info,
+                                   &arg, true))
         goto out;
 
     success = true;
@@ -779,19 +775,13 @@ out:
 }
 
 static bool
-boxed_field_setter (JSContext              *context,
-                    JS::HandleObject        obj,
-                    JS::HandleId            id,
-                    bool                    strict,
-                    JS::MutableHandleValue  value)
+boxed_field_setter(JSContext *context,
+                   unsigned   argc,
+                   JS::Value *vp)
 {
-    Boxed *priv;
+    GJS_GET_PRIV(context, argc, vp, args, obj, Boxed, priv);
     GIFieldInfo *field_info;
-    bool success = false;
 
-    priv = priv_from_js(context, obj);
-    if (!priv)
-        return false;
     field_info = get_field_info(context, priv, id);
     if (!field_info)
         return false;
@@ -800,14 +790,14 @@ boxed_field_setter (JSContext              *context,
         gjs_throw(context, "Can't set field %s.%s on prototype",
                   g_base_info_get_name ((GIBaseInfo *)priv->info),
                   g_base_info_get_name ((GIBaseInfo *)field_info));
-        goto out;
+        return false;
     }
 
-    success = boxed_set_field_from_value (context, priv, field_info, value);
-
-out:
+    if (!boxed_set_field_from_value(context, priv, field_info, args[0]))
+        return false;
 
-    return success;
+    args.rval().setUndefined();  /* No stored value */
+    return true;
 }
 
 static bool
@@ -845,7 +835,7 @@ define_boxed_class_fields (JSContext       *context,
         bool result;
 
         result = JS_DefineProperty(context, proto, field_name, JS::NullHandleValue,
-                                   JSPROP_PERMANENT | JSPROP_SHARED,
+                                   JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_PROPOP_ACCESSORS,
                                    boxed_field_getter, boxed_field_setter);
 
         g_base_info_unref ((GIBaseInfo *)field);
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 7c17fa5..b055ec8 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -75,6 +75,7 @@ struct _GjsContext {
 
     guint    auto_gc_id;
 
+    /* FIXME - array of PersistentRooted<jsid>? */
     jsid const_strings[GJS_STRING_LAST];
 };
 
@@ -407,6 +408,7 @@ gjs_context_dispose(GObject *object)
 
         JS_RemoveExtraGCRootsTracer(js_context->runtime, gjs_context_tracer,
                                     js_context);
+        js_context->global = NULL;
 
         /* Tear down JS */
         JS_DestroyContext(js_context->context);
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index b03f713..8f9d24f 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -213,7 +213,8 @@ seal_import(JSContext       *cx,
 
     if (!JS_DefineProperty(cx, descr.object(), name, descr.value(),
                            descr.attributes() | JSPROP_PERMANENT,
-                           descr.getter(), descr.setter())) {
+                           JS_PROPERTYOP_GETTER(descr.getter()),
+                           JS_PROPERTYOP_SETTER(descr.setter()))) {
         gjs_debug(GJS_DEBUG_IMPORTER,
                   "Failed to redefine attributes to seal '%s' in importer",
                   name);
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 32d4f37..dcf7ab9 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -89,9 +89,8 @@ gjs_init_context_standard (JSContext              *context,
      *
      * setExtraWarnings: Report warnings to error reporter function.
      */
-    JS::ContextOptionsRef(context)
-        .setDontReportUncaught(true)
-        .setExtraWarnings(extra_warnings);
+    JS::ContextOptionsRef(context).setDontReportUncaught(true);
+    JS::RuntimeOptionsRef(context).setExtraWarnings(extra_warnings);
 
     if (!g_getenv("GJS_DISABLE_JIT")) {
         gjs_debug(GJS_DEBUG_CONTEXT, "Enabling JIT");
diff --git a/gjs/runtime.cpp b/gjs/runtime.cpp
index 5ddf4b0..902fcd9 100644
--- a/gjs/runtime.cpp
+++ b/gjs/runtime.cpp
@@ -256,7 +256,7 @@ gjs_runtime_for_current_thread(void)
 
     if (!runtime) {
         g_assert(gjs_is_inited);
-        runtime = JS_NewRuntime(32*1024*1024 /* max bytes */, JS_USE_HELPER_THREADS);
+        runtime = JS_NewRuntime(32 * 1024 * 1024 /* max bytes */);
         if (runtime == NULL)
             g_error("Failed to create javascript runtime");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]