[gjs/wip/js24: 11/12] JS_SetVersion has been removed, JS Version is now set on the compartment instead of context.
- From: Tim Lunn <timl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/js24: 11/12] JS_SetVersion has been removed, JS Version is now set on the compartment instead of context.
- Date: Tue, 29 Oct 2013 04:37:56 +0000 (UTC)
commit 745ce588b05e8e1082b1589d1f0a60c3560fbba1
Author: Tim Lunn <tim feathertop org>
Date: Tue Oct 1 09:23:48 2013 +1000
JS_SetVersion has been removed, JS Version is now set on the compartment instead of context.
https://bugzilla.gnome.org/show_bug.cgi?id=711046
gjs/context.cpp | 12 ++----------
gjs/jsapi-util.cpp | 11 +++++++++--
gjs/jsapi-util.h | 3 ++-
3 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index d0b92e4..ab7a7d9 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -608,18 +608,10 @@ gjs_context_constructor (GType type,
*/
if (js_version == JSVERSION_UNKNOWN)
js_version = JSVERSION_DEFAULT;
- /* Set the version if we need to. */
- if (js_version != JSVERSION_DEFAULT && JS_GetVersion(js_context->context) != js_version) {
- gjs_debug(GJS_DEBUG_CONTEXT,
- "Changing JavaScript version to %s from %s",
- JS_VersionToString(js_version),
- JS_VersionToString(JS_GetVersion(js_context->context)));
-
- JS_SetVersion(js_context->context, js_version);
- }
- if (!gjs_init_context_standard(js_context->context))
+ if (!gjs_init_context_standard(js_context->context, js_version))
g_error("Failed to initialize context");
+
js_context->global = JS_GetGlobalObject(js_context->context);
JSAutoCompartment ac(js_context->context, js_context->global);
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 031e7f7..c4beb7e 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -88,11 +88,18 @@ static JSClass global_class = {
* Returns: %TRUE on success, %FALSE otherwise
*/
gboolean
-gjs_init_context_standard (JSContext *context)
+gjs_init_context_standard (JSContext *context,
+ JSVersion js_version)
{
JSObject *global;
+ JS::CompartmentOptions options;
- global = JS_NewGlobalObject(context, &global_class, NULL);
+ gjs_debug(GJS_DEBUG_CONTEXT,
+ "Setting JavaScript version to %s",
+ JS_VersionToString(js_version));
+
+ options.setVersion(js_version);
+ global = JS_NewGlobalObject(context, &global_class, NULL, options);
if (global == NULL)
return FALSE;
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index a828873..5c02fe6 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -186,7 +186,8 @@ jsval gjs_##cname##_create_proto(JSContext *context, JSObject *module, const cha
return rval; \
}
-gboolean gjs_init_context_standard (JSContext *context);
+gboolean gjs_init_context_standard (JSContext *context,
+ JSVersion js_version);
JSObject* gjs_get_import_global (JSContext *context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]