[gjs/wip/ptomato/mozjs31: 19/21] js: Call JS_Init() on startup



commit 8c078cbf6e84b505aef990b215fef29e218cd159
Author: Philip Chimento <philip endlessm com>
Date:   Fri Nov 4 19:02:55 2016 -0700

    js: Call JS_Init() on startup
    
    Starting with mozjs31, this is required. Calling JS_ShutDown() on exit is
    not required, but may become so in the future.

 configure.ac                 |    3 ++-
 gjs/console.cpp              |    5 +++++
 installed-tests/gjs-unit.cpp |    5 +++++
 test/gjs-tests.cpp           |    3 +++
 4 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2ed2240..1cd9500 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,7 @@ common_packages="gthread-2.0 gio-2.0 >= glib_required_version mozjs-31"
 gjs_packages="gobject-introspection-1.0 libffi $common_packages"
 gjs_cairo_packages="cairo cairo-gobject $common_packages"
 gjs_gdbus_packages="$GOBJECT_REQUIREMENT gio-2.0"
+gjs_console_packages="$GOBJECT_REQUIREMENT $common_packages"
 gjs_gtk_packages="gtk+-3.0 >= 3.20"
 # gjs-tests links against everything
 gjstests_packages="gio-unix-2.0 $gjs_packages"
@@ -66,7 +67,7 @@ gjstests_packages="gio-unix-2.0 $gjs_packages"
 AX_PKG_CHECK_MODULES([GJS], [$GOBJECT_REQUIREMENT], [$gjs_packages])
 dnl These don't need to be put in the .pc file so use regular PKG_CHECK_MODULES
 PKG_CHECK_MODULES([GJS_GDBUS], [$gjs_gdbus_packages])
-PKG_CHECK_MODULES([GJS_CONSOLE], [$GOBJECT_REQUIREMENT])
+PKG_CHECK_MODULES([GJS_CONSOLE], [$gjs_console_packages])
 PKG_CHECK_MODULES([GJSTESTS], [$gjstests_packages])
 
 # Optional cairo dep (enabled by default)
diff --git a/gjs/console.cpp b/gjs/console.cpp
index d60840b..0b4eef6 100644
--- a/gjs/console.cpp
+++ b/gjs/console.cpp
@@ -29,6 +29,7 @@
 #include <gjs/gjs.h>
 
 #include "coverage.h"
+#include "jsapi-wrapper.h"
 
 static char **include_path = NULL;
 static char **coverage_prefixes = NULL;
@@ -242,6 +243,9 @@ main(int argc, char **argv)
     /* This should be removed after a suitable time has passed */
     check_script_args_for_stray_gjs_args(script_argc, script_argv);
 
+    if (!JS_Init())
+        g_error("Could not initialize Javascript");
+
     js_context = (GjsContext*) g_object_new(GJS_TYPE_CONTEXT,
                                             "search-path", include_path,
                                             "program-name", program_name,
@@ -308,5 +312,6 @@ main(int argc, char **argv)
     g_strfreev(coverage_prefixes);
     g_object_unref(js_context);
     g_free(script);
+    JS_ShutDown();
     exit(code);
 }
diff --git a/installed-tests/gjs-unit.cpp b/installed-tests/gjs-unit.cpp
index 034273f..7f85cff 100644
--- a/installed-tests/gjs-unit.cpp
+++ b/installed-tests/gjs-unit.cpp
@@ -164,6 +164,9 @@ main(int argc, char **argv)
     setlocale(LC_ALL, "");
     g_test_init(&argc, &argv, NULL);
 
+    if (!JS_Init())
+        g_error("Could not initialize Javascript");
+
     /* Make sure to create the GjsContext class first, so we
      * can override the GjsPrivate lookup path.
      */
@@ -218,5 +221,7 @@ main(int argc, char **argv)
 
     g_type_class_unref (context_class);
 
+    JS_ShutDown();
+
     return retval;
 }
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index 161d0a5..cb96318 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -242,7 +242,10 @@ main(int    argc,
     gjs_test_add_tests_for_coverage ();
     gjs_test_add_tests_for_parse_call_args();
 
+    if (!JS_Init())
+        g_error("Could not initialize Javascript");
     g_test_run();
+    JS_ShutDown();
 
     return 0;
 }


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