From e8c411cad76c8ee973e78e8114be2a17f3351088 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 22 Mar 2018 13:00:33 -0400 Subject: jsauthority: use JS::Evaluate instead of JS_EvaluateScript JS_EvaluateScript is no longer in the API set, so use JS::Evaluate instead. Signed-off-by: Ray Strode https://bugs.freedesktop.org/show_bug.cgi?id=105865 --- src/polkitbackend/polkitbackendjsauthority.cpp | 49 +++++++++++--------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp index a19e926..022ba7c 100644 --- a/src/polkitbackend/polkitbackendjsauthority.cpp +++ b/src/polkitbackend/polkitbackendjsauthority.cpp @@ -507,12 +507,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; } @@ -731,11 +731,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; @@ -748,17 +748,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)) { @@ -849,9 +848,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; } @@ -862,11 +858,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; @@ -874,17 +870,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); @@ -903,9 +899,6 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority, ret = TRUE; out: - if (ret && out_jsval != NULL) - *out_jsval = ret_jsval; - return ret; } -- cgit v1.2.1