summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2018-03-23 15:22:59 -0400
committerRay Strode <rstrode@redhat.com>2018-04-03 10:50:18 -0400
commitc51b8102eee7344756ebc11611e3b95090c674dd (patch)
tree95469cec125eebaed7f2ee5b1e8122c502ad39c9
parentcda7a100f38eb93e2ff1b93a1505ae33bb0c0cac (diff)
downloadpolkit-c51b8102eee7344756ebc11611e3b95090c674dd.tar.gz
jsauthority: switch from JS_ConvertArguments to JS::CallArgsFromVp
Signed-off-by: Ray Strode <rstrode@redhat.com> https://bugs.freedesktop.org/show_bug.cgi?id=105865
-rw-r--r--src/polkitbackend/polkitbackendjsauthority.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 686de3f..ef1a900 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1290,20 +1290,18 @@ js_polkit_log (JSContext *cx,
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
- JSString *str;
char *s;
- if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "S", &str))
- goto out;
+ JS::CallArgs args = JS::CallArgsFromVp (argc, vp);
- s = JS_EncodeString (cx, str);
+ s = JS_EncodeString (cx, args[0].toString ());
JS_ReportWarningUTF8 (cx, s);
JS_free (cx, s);
ret = true;
- JS_SET_RVAL (cx, vp, JS::UndefinedValue()); /* return undefined */
- out:
+ args.rval ().setUndefined (); /* return undefined */
+
return ret;
}
@@ -1375,7 +1373,7 @@ js_polkit_spawn (JSContext *cx,
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
- JSObject *array_object;
+ JS::RootedObject array_object(cx);
gchar *standard_output = NULL;
gchar *standard_error = NULL;
gint exit_status;
@@ -1388,8 +1386,8 @@ js_polkit_spawn (JSContext *cx,
SpawnData data = {0};
guint n;
- if (!JS_ConvertArguments (cx, js_argc, JS_ARGV (cx, vp), "o", &array_object))
- goto out;
+ JS::CallArgs args = JS::CallArgsFromVp (js_argc, vp);
+ array_object = &args[0].toObject();
if (!JS_GetArrayLength (cx, array_object, &array_len))
{
@@ -1400,7 +1398,7 @@ js_polkit_spawn (JSContext *cx,
argv = g_new0 (gchar*, array_len + 1);
for (n = 0; n < array_len; n++)
{
- JS::Value elem_val;
+ JS::RootedValue elem_val(cx);
char *s;
if (!JS_GetElement (cx, array_object, n, &elem_val))
@@ -1474,7 +1472,7 @@ js_polkit_spawn (JSContext *cx,
ret = true;
ret_jsstr = JS_NewStringCopyZ (cx, standard_output);
- JS_SET_RVAL (cx, vp, JS::StringValue (ret_jsstr));
+ args.rval ().setString (ret_jsstr);
out:
g_strfreev (argv);
@@ -1498,17 +1496,14 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
{
/* PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); */
bool ret = false;
- JSString *user_str;
- JSString *netgroup_str;
char *user;
char *netgroup;
bool is_in_netgroup = false;
- if (!JS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str))
- goto out;
+ JS::CallArgs args = JS::CallArgsFromVp (argc, vp);
- user = JS_EncodeString (cx, user_str);
- netgroup = JS_EncodeString (cx, netgroup_str);
+ user = JS_EncodeString (cx, args[0].toString());
+ netgroup = JS_EncodeString (cx, args[1].toString());
if (innetgr (netgroup,
NULL, /* host */
@@ -1523,8 +1518,8 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
ret = true;
- JS_SET_RVAL (cx, vp, JS::BooleanValue (is_in_netgroup));
- out:
+ args.rval ().setBoolean (is_in_netgroup);
+
return ret;
}