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



commit 74151d14c84c81ce8c8b18fd3664055effec235a
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.

 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 fdf3257..9d91431 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -489,6 +489,9 @@ gjs_context_constructed(GObject *object)
     if (js_context->context == NULL)
         g_error("Failed to create javascript context");
 
+    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(js_context->context,
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 6c9ed62..185143d 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1322,7 +1322,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 b2f7cda..9faf8a3 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -209,7 +209,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]