AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [G_ENCODE_VERSION(2,34)],
[Notify us when we'll need to transition away from g_type_init()])
-PKG_CHECK_MODULES(LIBJS, [mozjs185])
+AC_ARG_WITH(mozjs, AS_HELP_STRING([--with-mozjs=@<:@mozjs185/mozjs-17.0|auto@:>@],
+ [Specify version of Spidermonkey to use]),,
+ with_mozjs=auto)
+AS_IF([test x${with_mozjs} != xauto], [
+ PKG_CHECK_MODULES(LIBJS, ${with_mozjs})
+], [
+ PKG_CHECK_MODULES(LIBJS, [mozjs185], have_mozjs185=yes, have_mozjs185=no)
+ AS_IF([test x${have_mozjs185} = xno], [
+ PKG_CHECK_MODULES(LIBJS, [mozjs-17.0], have_mozjs17=yes,
+ [AC_MSG_ERROR([Could not find mozjs185 or mozjs-17.0; see http://ftp.mozilla.org/pub/mozilla.org/js/])])
+ ])
+])
AC_SUBST(LIBJS_CFLAGS)
AC_SUBST(LIBJS_LIBS)
};
static JSBool execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
+#if JS_VERSION == 186
+ JSScript *script,
+#else
JSObject *script,
+#endif
jsval *rval);
static void utils_spawn (const gchar *const *argv,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
+#if JS_VERSION == 186
+ NULL,
+#else
JS_FinalizeStub,
+#endif
JSCLASS_NO_OPTIONAL_MEMBERS
};
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
+#if JS_VERSION == 186
+ NULL,
+#else
JS_FinalizeStub,
+#endif
JSCLASS_NO_OPTIONAL_MEMBERS
};
for (l = files; l != NULL; l = l->next)
{
const gchar *filename = l->data;
+#if JS_VERSION == 186
+ JSScript *script;
+#else
JSObject *script;
-
+#endif
+
+#if JS_VERSION == 186
+ script = JS_CompileUTF8File (authority->priv->cx,
+ authority->priv->js_global,
+ filename);
+
+#else
script = JS_CompileFile (authority->priv->cx,
- authority->priv->js_global,
- filename);
+ authority->priv->js_global,
+ filename);
+#endif
if (script == NULL)
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Collecting garbage unconditionally...");
+#if JS_VERSION == 186
+ JS_GC (authority->priv->rt);
+#else
JS_GC (authority->priv->cx);
+#endif
load_scripts (authority);
JS_SetErrorReporter(authority->priv->cx, report_error);
JS_SetContextPrivate (authority->priv->cx, authority);
- authority->priv->js_global = JS_NewCompartmentAndGlobalObject (authority->priv->cx,
- &js_global_class,
- NULL);
+ authority->priv->js_global =
+#if JS_VERSION == 186
+ JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL);
+#else
+ JS_NewCompartmentAndGlobalObject (authority->priv->cx, &js_global_class, NULL);
+#endif
+
if (authority->priv->js_global == NULL)
goto fail;
PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (user_data);
/* Supposedly this is thread-safe... */
+#if JS_VERSION == 186
+ JS_TriggerOperationCallback (authority->priv->rt);
+#else
JS_TriggerOperationCallback (authority->priv->cx);
+#endif
/* keep source around so we keep trying to kill even if the JS bit catches the exception
* thrown in js_operation_callback()
static JSBool
execute_script_with_runaway_killer (PolkitBackendJsAuthority *authority,
+#if JS_VERSION == 186
+ JSScript *script,
+#else
JSObject *script,
+#endif
jsval *rval)
{
JSBool ret;