summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2018-03-22 13:00:33 -0400
committerRay Strode <rstrode@redhat.com>2018-03-28 16:46:36 -0400
commit968d95b39224b6ea2f8a05c64eb238fbbcf90fb1 (patch)
tree64b70ed06675f65f39d597280bb14838797bedde
parent16ae00ba4d7de1386cfd7c08e100740612332df8 (diff)
downloadpolkit-968d95b39224b6ea2f8a05c64eb238fbbcf90fb1.tar.gz
jsauthority: use JS::Evaluate instead of JS_EvaluateScript
JS_EvaluateScript is no longer in the API set, so use JS::Evaluate instead.
-rw-r--r--src/polkitbackend/polkitbackendjsauthority.cpp49
1 files changed, 21 insertions, 28 deletions
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 25e9343..493c37c 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -508,12 +508,12 @@ polkit_backend_js_authority_constructed (GObject *object)
js_polkit_functions))
goto fail;
- if (!JS_EvaluateScript (authority->priv->cx,
- global,
- init_js, strlen (init_js), /* init.js */
- "init.js", /* filename */
- 0, /* lineno */
- NULL)) /* rval */
+ JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
+ JS::RootedValue rval(authority->priv->cx);
+ if (!JS::Evaluate (authority->priv->cx,
+ options,
+ init_js, strlen (init_js), /* init.js */
+ &rval)) /* rval */
{
goto fail;
}
@@ -742,11 +742,11 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
PolkitIdentity *user_for_subject,
gboolean subject_is_local,
gboolean subject_is_active,
- JS::Value *out_jsval,
+ JS::MutableHandleValue out_jsval,
GError **error)
{
gboolean ret = FALSE;
- JS::Value ret_jsval;
+ JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
const char *src;
JS::RootedObject obj(authority->priv->cx);
pid_t pid;
@@ -759,17 +759,16 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
src = "new Subject();";
- if (!JS_EvaluateScript (authority->priv->cx,
- global,
- src, strlen (src),
- __FILE__, __LINE__,
- &ret_jsval))
+ if (!JS::Evaluate (authority->priv->cx,
+ options,
+ src, strlen (src),
+ out_jsval))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src);
goto out;
}
- obj = ret_jsval.toObjectOrNull();
+ obj = out_jsval.toObjectOrNull();
if (POLKIT_IS_UNIX_PROCESS (subject))
{
@@ -860,9 +859,6 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
if (groups != NULL)
g_ptr_array_unref (groups);
- if (ret && out_jsval != NULL)
- *out_jsval = ret_jsval;
-
return ret;
}
@@ -873,11 +869,11 @@ static gboolean
action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
const gchar *action_id,
PolkitDetails *details,
- JS::Value *out_jsval,
+ JS::MutableHandleValue out_jsval,
GError **error)
{
gboolean ret = FALSE;
- JS::Value ret_jsval;
+ JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN);
const char *src;
JS::RootedObject obj(authority->priv->cx);
gchar **keys;
@@ -885,17 +881,17 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
JS::RootedObject global(authority->priv->cx, authority->priv->js_global->get ());
src = "new Action();";
- if (!JS_EvaluateScript (authority->priv->cx,
- global,
- src, strlen (src),
- __FILE__, __LINE__,
- &ret_jsval))
+
+ if (!JS::Evaluate (authority->priv->cx,
+ options,
+ src, strlen (src),
+ out_jsval))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Evaluating '%s' failed", src);
goto out;
}
- obj = ret_jsval.toObjectOrNull();
+ obj = out_jsval.toObjectOrNull();
set_property_str (authority, obj, "id", action_id);
@@ -914,9 +910,6 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority,
ret = TRUE;
out:
- if (ret && out_jsval != NULL)
- *out_jsval = ret_jsval;
-
return ret;
}