[gjs] context: Move some JSContext setup to init_context_standard
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] context: Move some JSContext setup to init_context_standard
- Date: Wed, 15 Jan 2014 19:51:29 +0000 (UTC)
commit 6e43452a9d20488ea300c315557153fd3c577d12
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jan 15 14:41:27 2014 -0500
context: Move some JSContext setup to init_context_standard
gjs/context.cpp | 22 ----------------------
gjs/jsapi-util.cpp | 20 ++++++++++++++++++++
2 files changed, 20 insertions(+), 22 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index afa8a38..f3971d8 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -383,7 +383,6 @@ static void
gjs_context_constructed(GObject *object)
{
GjsContext *js_context = GJS_CONTEXT(object);
- guint32 options_flags;
int i;
G_OBJECT_CLASS(gjs_context_parent_class)->constructed(object);
@@ -399,24 +398,6 @@ gjs_context_constructed(GObject *object)
JS_BeginRequest(js_context->context);
- /* 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.
- *
- * JSOPTION_STRICT: Report warnings to error reporter function.
- */
- options_flags = JSOPTION_DONT_REPORT_UNCAUGHT | JSOPTION_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;
- }
-
- JS_SetOptions(js_context->context,
- JS_GetOptions(js_context->context) | options_flags);
-
- JS_SetErrorReporter(js_context->context, gjs_error_reporter);
-
/* set ourselves as the private data */
JS_SetContextPrivate(js_context->context, js_context);
@@ -432,9 +413,6 @@ gjs_context_constructed(GObject *object)
JSPROP_READONLY | JSPROP_PERMANENT))
g_error("No memory to export global object as 'window'");
- if (!JS_InitReflect(js_context->context, js_context->global))
- g_error("Failed to register Reflect Parser Api");
-
/* Define a global function called log() */
if (!JS_DefineFunction(js_context->context, js_context->global,
"log",
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 7621e74..5721943 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -92,6 +92,23 @@ gjs_init_context_standard (JSContext *context)
{
JSObject *global;
JS::CompartmentOptions options;
+ guint32 options_flags;
+
+ /* 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.
+ *
+ * JSOPTION_STRICT: Report warnings to error reporter function.
+ */
+ options_flags = JSOPTION_DONT_REPORT_UNCAUGHT | JSOPTION_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;
+ }
+
+ JS_SetOptions(context, JS_GetOptions(context) | options_flags);
+ JS_SetErrorReporter(context, gjs_error_reporter);
options.setVersion(JSVERSION_LATEST);
global = JS_NewGlobalObject(context, &global_class, NULL, options);
@@ -105,6 +122,9 @@ gjs_init_context_standard (JSContext *context)
if (!JS_InitStandardClasses(context, global))
return FALSE;
+ if (!JS_InitReflect(context, global))
+ return FALSE;
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]