[gjs/wip/ptomato/mozjs45prep: 16/16] js: stuff FIXME



commit e874f2230b7ce141188ce44815fab121b43897a2
Author: Philip Chimento <philip endlessm com>
Date:   Sun Mar 19 05:19:28 2017 +0000

    js: stuff FIXME

 gi/enumeration.cpp  |    2 +-
 gjs/coverage.cpp    |    9 +++++----
 gjs/jsapi-util.cpp  |   20 +++++++++++++++++---
 modules/console.cpp |   21 +++++++++++----------
 modules/system.cpp  |    3 ++-
 5 files changed, 36 insertions(+), 19 deletions(-)
---
diff --git a/gi/enumeration.cpp b/gi/enumeration.cpp
index 363f0a8..628eb60 100644
--- a/gi/enumeration.cpp
+++ b/gi/enumeration.cpp
@@ -174,7 +174,7 @@ gjs_define_enumeration(JSContext       *context,
 
     /* https://bugzilla.mozilla.org/show_bug.cgi?id=599651 means we
      * can't just pass in the global as the parent */
-    JS_SetParent(context, enum_obj, global);
+    // FIXME JS_SetParent(context, enum_obj, global);
 
     if (!gjs_define_enum_values(context, enum_obj, info))
         return false;
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 794487b..a9bfff4 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1610,10 +1610,11 @@ bootstrap_coverage(GjsCoverage *coverage)
             return false;
         }
 
-        if (!JS_InitReflect(context, debugger_compartment)) {
-            gjs_throw(context, "Failed to init Reflect");
-            return false;
-        }
+        // FIXME not needed?
+        // if (!JS_InitReflect(context, debugger_compartment)) {
+        //     gjs_throw(context, "Failed to init Reflect");
+        //     return false;
+        // }
 
         if (!JS_DefineDebuggerObject(context, debugger_compartment)) {
             gjs_throw(context, "Failed to init Debugger");
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index a835533..c187701 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -110,8 +110,9 @@ gjs_init_context_standard (JSContext              *context,
     if (!JS_InitStandardClasses(context, global))
         return false;
 
-    if (!JS_InitReflect(context, global))
-        return false;
+    // FIXME not needed?
+    // if (!JS_InitReflect(context, global))
+    //     return false;
 
     if (!JS_DefineDebuggerObject(context, global))
         return false;
@@ -934,7 +935,20 @@ gjs_eval_with_scope(JSContext             *context,
            .setFileAndLine(filename, start_line_number)
            .setSourceIsLazy(true);
 
-    if (!JS::Evaluate(context, eval_obj, options, script, script_len, retval))
+    JS::AutoObjectVector scope_chain(context);
+    scope_chain.append(eval_obj);
+
+    // FIXME don't do this!!
+    GError *error = NULL;
+    gunichar2 *uscript = g_utf8_to_utf16(script, script_len, nullptr, nullptr, &error);
+    if (!uscript) {
+        gjs_throw(context, "Failed to convert script to UTF-16 for evaluation: %s",
+                  error->message);
+        return false;
+    }
+
+    if (!JS::Evaluate(context, scope_chain, options,
+                      reinterpret_cast<char16_t *>(uscript), script_len, retval))
         return false;
 
     gjs_schedule_gc_if_needed(context);
diff --git a/modules/console.cpp b/modules/console.cpp
index 60f095b..9bc81a2 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -40,6 +40,7 @@
 
 #include "config.h"
 
+#include <iostream>
 #include <stdlib.h>
 #include <string.h>
 
@@ -99,21 +100,20 @@ gjs_console_error_reporter(JSContext *cx, const char *message, JSErrorReport *re
         fputs(prefix, stderr);
     fputs(message, stderr);
 
-    if (!report->linebuf) {
+    if (!report->linebuf()) {
         fputc('\n', stderr);
         goto out;
     }
 
+    // FIXME THIS
     /* report->linebuf usually ends with a newline. */
-    n = strlen(report->linebuf);
-    fprintf(stderr, ":\n%s%s%s%s",
-            prefix,
-            report->linebuf,
-            (n > 0 && report->linebuf[n-1] == '\n') ? "" : "\n",
-            prefix);
-    n = ((char*)report->tokenptr) - ((char*) report->linebuf);
+    n = std::char_traits<char16_t>::length(report->linebuf());
+    std::cerr << ":\n" << prefix << report->linebuf()
+        << ((n > 0 && report->linebuf()[n-1] == '\n') ? "" : "\n")
+        << prefix;
+    n = report->tokenOffset();
     for (i = j = 0; i < n; i++) {
-        if (report->linebuf[i] == '\t') {
+        if (report->linebuf()[i] == '\t') {
             for (k = (j + 8) & ~7; j < k; j++) {
                 fputc('.', stderr);
             }
@@ -196,7 +196,8 @@ gjs_console_interact(JSContext *context,
         JS::CompileOptions options(context);
         options.setUTF8(true)
                .setFileAndLine("typein", startline);
-        if (!JS::Evaluate(context, object, options, buffer->str, buffer->len,
+        // FIXME put object back in the scope chain and switch to char16_t buffer
+        if (!JS::Evaluate(context, options, buffer->str, buffer->len,
                           &result)) {
             /* If this was an uncatchable exception, throw another uncatchable
              * exception on up to the surrounding JS::Evaluate() in main(). This
diff --git a/modules/system.cpp b/modules/system.cpp
index 79ffe17..1a9d6da 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -137,7 +137,8 @@ gjs_clear_date_caches(JSContext *context,
     // localtime_r, see https://bugzilla.mozilla.org/show_bug.cgi?id=1004706
     tzset();
 
-    JS_ClearDateCaches(context);
+    // FIXME
+    //JS_ClearDateCaches(context);
     JS_EndRequest(context);
 
     rec.rval().setUndefined();


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