[gjs/wip/ptomato/mozjs31: 17/29] js: Remove deprecated JS_{Get, Set}Options



commit 37118d9d9c119d0e765aa322e2e51293cd7599bf
Author: Philip Chimento <philip endlessm com>
Date:   Tue Oct 25 15:22:03 2016 -0700

    js: Remove deprecated JS_{Get,Set}Options
    
    The options have been shuffled around, now some apply to the runtime
    (fetched with JS::RuntimeOptionsRef()) and some apply to the context
    (fetched with JS::ContextOptionsRef()).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751252

 gjs/coverage.cpp   |    6 ++++--
 gjs/jsapi-util.cpp |   36 ++++++++++++++++++++----------------
 2 files changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 1465e8b..6133843 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1685,8 +1685,10 @@ gjs_coverage_constructed(GObject *object)
     JSContext *context = (JSContext *) gjs_context_get_native_context(priv->context);
 
     /* Before bootstrapping, turn off the JIT on the context */
-    guint32 options_flags = JS_GetOptions(context) & ~(JSOPTION_ION | JSOPTION_BASELINE | JSOPTION_ASMJS);
-    JS_SetOptions(context, options_flags);
+    JS::RuntimeOptionsRef(context)
+        .setIon(false)
+        .setBaseline(false)
+        .setAsmJS(false);
 
     if (!bootstrap_coverage(coverage)) {
         JSAutoCompartment compartment(context, gjs_get_import_global(context));
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index d6c3401..2f109f2 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -64,32 +64,36 @@ bool
 gjs_init_context_standard (JSContext              *context,
                            JS::MutableHandleObject global)
 {
-    JS::CompartmentOptions options;
-    guint32 options_flags;
+    JS::CompartmentOptions compartment_options;
 
-    /* JSOPTION_DONT_REPORT_UNCAUGHT: Don't send exceptions to our
-     * error report handler; instead leave them set.  This allows us
-     * to get at the exception object.
+    bool extra_warnings = false;
+    if (!g_getenv("GJS_DISABLE_EXTRA_WARNINGS")) {
+        gjs_debug(GJS_DEBUG_CONTEXT, "Enabling extra warnings");
+        extra_warnings = true;
+    }
+
+    /* setDontReportUncaught: Don't send exceptions to our error report handler;
+     * instead leave them set. This allows us to get at the exception object.
      *
-     * JSOPTION_STRICT: Report warnings to error reporter function.
+     * setExtraWarnings: Report warnings to error reporter function.
      */
-    options_flags = JSOPTION_DONT_REPORT_UNCAUGHT;
+    JS::ContextOptionsRef(context)
+        .setDontReportUncaught(true)
+        .setExtraWarnings(extra_warnings);
 
     if (!g_getenv("GJS_DISABLE_JIT")) {
         gjs_debug(GJS_DEBUG_CONTEXT, "Enabling JIT");
-        options_flags |= JSOPTION_TYPE_INFERENCE | JSOPTION_ION | JSOPTION_BASELINE | JSOPTION_ASMJS;
-    }
-
-    if (!g_getenv("GJS_DISABLE_EXTRA_WARNINGS")) {
-        gjs_debug(GJS_DEBUG_CONTEXT, "Enabling extra warnings");
-        options_flags |= JSOPTION_EXTRA_WARNINGS;
+        JS::RuntimeOptionsRef(context)
+            .setIon(true)
+            .setBaseline(true)
+            .setAsmJS(true);
     }
 
-    JS_SetOptions(context, JS_GetOptions(context) | options_flags);
     JS_SetErrorReporter(context, gjs_error_reporter);
 
-    options.setVersion(JSVERSION_LATEST);
-    global.set(JS_NewGlobalObject(context, &global_class, NULL, options));
+    compartment_options.setVersion(JSVERSION_LATEST);
+    global.set(JS_NewGlobalObject(context, &global_class, NULL,
+                                  compartment_options));
     if (global == NULL)
         return false;
 


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