[gjs/wip/ptomato/mozjs52: 34/37] js: Adapt to misc API changes in SpiderMonkey 52



commit 251073b5fed131615d8882225ffcfaa86bfafb30
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue May 2 22:06:58 2017 -0700

    js: Adapt to misc API changes in SpiderMonkey 52
    
    - JS::InitSelfHostedCode() is now required to be called before the first
      global object is created.
    - js::GCMethods<T>::initial was moved from the friend API to the public
      API and renamed JS::GCPolicy<T>::initial.
    - JSPropertyDescriptor was renamed JS::PropertyDescriptor.
    - JS::CloneAndExecuteScript() now takes a return value parameter, even
      though we don't use it in this case.
    - js::DumpHeapComplete() was renamed to js::DumpHeap() and takes a
      JSContext parameter instead of JSRuntime.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784196

 gjs/context.cpp       |    3 +++
 gjs/coverage.cpp      |    3 ++-
 gjs/importer.cpp      |    2 +-
 gjs/jsapi-util-root.h |    4 ++--
 modules/system.cpp    |    4 ++--
 5 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index b453fcc..4359578 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -276,6 +276,9 @@ gjs_context_constructed(GObject *object)
         g_error("Failed to create javascript context");
     js_context->context = cx;
 
+    if (!JS::InitSelfHostedCode(js_context->context))
+        g_error("Failed to intialize JS embedding");
+
     for (i = 0; i < GJS_STRING_LAST; i++) {
         js_context->const_strings[i] = new JS::PersistentRootedId(cx,
             gjs_intern_string_to_id(cx, const_strings[i]));
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 41fb681..3281ff3 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1302,7 +1302,8 @@ gjs_context_eval_file_in_compartment(GjsContext      *context,
                      &compiled_script))
         return false;
 
-    if (!JS::CloneAndExecuteScript(js_context, compiled_script)) {
+    JS::RootedValue dummy_rval(js_context);
+    if (!JS::CloneAndExecuteScript(js_context, compiled_script, &dummy_rval)) {
         g_free(script);
         gjs_log_exception(js_context);
         g_set_error(error, GJS_ERROR, GJS_ERROR_FAILED, "Failed to evaluate %s", filename);
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 6ada0d5..39ab134 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -196,7 +196,7 @@ seal_import(JSContext       *cx,
             JS::HandleId     id,
             const char      *name)
 {
-    JS::Rooted<JSPropertyDescriptor> descr(cx);
+    JS::Rooted<JS::PropertyDescriptor> descr(cx);
 
     if (!JS_GetOwnPropertyDescriptorById(cx, obj, id, &descr) ||
         descr.object() == NULL) {
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index ab31652..6c6462f 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -217,7 +217,7 @@ public:
     {
         debug("root()");
         g_assert(!m_rooted);
-        g_assert(m_heap.get() == js::GCMethods<T>::initial());
+        g_assert(m_heap.get() == JS::GCPolicy<T>::initial());
         m_rooted = true;
         m_cx = cx;
         m_notify = notify;
@@ -244,7 +244,7 @@ public:
     {
         debug("reset()");
         if (!m_rooted) {
-            m_heap = js::GCMethods<T>::initial();
+            m_heap = JS::GCPolicy<T>::initial();
             return;
         }
 
diff --git a/modules/system.cpp b/modules/system.cpp
index d499758..81b7ae3 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -112,11 +112,11 @@ gjs_dump_heap(JSContext *cx,
 
     if (filename) {
         FILE *fp = fopen(filename, "a");
-        js::DumpHeapComplete(JS_GetRuntime(cx), fp, js::IgnoreNurseryObjects);
+        js::DumpHeap(cx, fp, js::IgnoreNurseryObjects);
         fclose(fp);
         g_free(filename);
     } else {
-        js::DumpHeapComplete(JS_GetRuntime(cx), stdout, js::IgnoreNurseryObjects);
+        js::DumpHeap(cx, stdout, js::IgnoreNurseryObjects);
     }
 
     args.rval().setUndefined();


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