1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

SMJS: Use JS_THIS_OBJECT and JS_CALLEE, not argv[-1] and argv[-2]

https://developer.mozilla.org/en-US/docs/SpiderMonkey/1.8.5 mentions
that JSNative functions must not use negative indices of argv in
SpiderMonkey 1.8.5.  Use the JS_THIS_OBJECT and JS_CALLEE macros
instead.  They are documented in
https://developer.mozilla.org/en-US/docs/SpiderMonkey/JSAPI_Reference/JSNative
This commit is contained in:
Kalle Olavi Niemitalo 2012-11-19 00:32:13 +02:00 committed by Kalle Olavi Niemitalo
parent 465923e386
commit 380d910ad8
2 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,7 @@ smjs_action_fn_callback(JSContext *ctx, uintN argc, jsval *rval)
value = JSVAL_FALSE;
if (JS_TRUE != JS_ValueToObject(ctx, argv[-2], &fn_obj)) {
if (JS_TRUE != JS_ValueToObject(ctx, JS_CALLEE(ctx, rval), &fn_obj)) {
JS_SET_RVAL(ctx, rval, value);
return JS_TRUE;
}

View File

@ -671,7 +671,7 @@ smjs_session_goto_url(JSContext *ctx, uintN argc, jsval *rval)
if (argc != 1) return JS_FALSE;
this = jsval_to_object(ctx, &argv[-1]);
this = JS_THIS_OBJECT(ctx, rval);
if (!JS_InstanceOf(ctx, this, (JSClass *) &session_class, NULL))
return JS_FALSE;