Bug 959695 part 1. Make ValueToCallable take a Handle. r=terrence

This commit is contained in:
Boris Zbarsky 2014-01-14 21:46:43 -05:00
parent 4cda5403a1
commit a47081f3e7
3 changed files with 9 additions and 8 deletions

View File

@ -3300,27 +3300,28 @@ proxy_create(JSContext *cx, unsigned argc, Value *vp)
static bool
proxy_createFunction(JSContext *cx, unsigned argc, Value *vp)
{
if (argc < 2) {
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() < 2) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
"createFunction", "1", "");
return false;
}
RootedObject handler(cx, NonNullObject(cx, vp[2]));
RootedObject handler(cx, NonNullObject(cx, args[0]));
if (!handler)
return false;
RootedObject proto(cx), parent(cx);
parent = vp[0].toObject().getParent();
parent = args.callee().getParent();
proto = parent->global().getOrCreateFunctionPrototype(cx);
if (!proto)
return false;
parent = proto->getParent();
RootedObject call(cx, ValueToCallable(cx, vp[3], argc - 2));
RootedObject call(cx, ValueToCallable(cx, args[1], args.length() - 2));
if (!call)
return false;
RootedObject construct(cx, nullptr);
if (argc > 2) {
construct = ValueToCallable(cx, vp[4], argc - 3);
if (args.length() > 2) {
construct = ValueToCallable(cx, args[2], args.length() - 3);
if (!construct)
return false;
} else {

View File

@ -355,7 +355,7 @@ js::ReportIsNotFunction(JSContext *cx, const Value &v, int numToSkip, MaybeConst
}
JSObject *
js::ValueToCallable(JSContext *cx, const Value &v, int numToSkip, MaybeConstruct construct)
js::ValueToCallable(JSContext *cx, HandleValue v, int numToSkip, MaybeConstruct construct)
{
if (v.isObject()) {
JSObject *callable = &v.toObject();

View File

@ -113,7 +113,7 @@ ReportIsNotFunction(JSContext *cx, const Value &v, int numToSkip = -1,
/* See ReportIsNotFunction comment for the meaning of numToSkip. */
extern JSObject *
ValueToCallable(JSContext *cx, const Value &vp, int numToSkip = -1,
ValueToCallable(JSContext *cx, HandleValue v, int numToSkip = -1,
MaybeConstruct construct = NO_CONSTRUCT);
/*