Bug 420837 - Calling Iterator() without parameters should throw a better error message. r=luke

This commit is contained in:
Tom Schuster 2012-05-31 23:28:39 +02:00
parent acc4f20b60
commit 8c91610c6d

View File

@ -795,11 +795,21 @@ iterator_iterator(JSContext *cx, HandleObject obj, JSBool keysonly)
static JSBool
Iterator(JSContext *cx, unsigned argc, Value *vp)
{
Value *argv = JS_ARGV(cx, vp);
bool keyonly = argc >= 2 ? js_ValueToBoolean(argv[1]) : false;
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() == 0) {
js_ReportMissingArg(cx, args.calleev(), 0);
return false;
}
bool keyonly = false;
if (args.length() >= 2)
keyonly = js_ValueToBoolean(args[1]);
unsigned flags = JSITER_OWNONLY | (keyonly ? 0 : (JSITER_FOREACH | JSITER_KEYVALUE));
*vp = argc >= 1 ? argv[0] : UndefinedValue();
return ValueToIterator(cx, flags, vp);
if (!ValueToIterator(cx, flags, &args[0]))
return false;
args.rval() = args[0];
return true;
}
JSBool