Bug 1140573 part 1. Drop the parent argument from JS_NewFunction. r=waldo

This commit is contained in:
Boris Zbarsky 2015-03-09 12:50:03 -04:00
parent 8ece71391b
commit 7f7b76aa0c
12 changed files with 20 additions and 19 deletions

View File

@ -6375,7 +6375,7 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
// Create constructor to return. Store the name of the custom element as the
// name of the function.
JSFunction* constructor = JS_NewFunction(aCx, nsDocument::CustomElementConstructor, 0,
JSFUN_CONSTRUCTOR, JS::NullPtr(),
JSFUN_CONSTRUCTOR,
NS_ConvertUTF16toUTF8(lcType).get());
if (!constructor) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);

View File

@ -1392,7 +1392,7 @@ XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
if (IdEquals(id, "toString") && !JS_ObjectIsFunction(cx, obj)) {
MOZ_ASSERT(IsDOMIfaceAndProtoClass(js::GetObjectClass(obj)));
JS::Rooted<JSFunction*> toString(cx, JS_NewFunction(cx, InterfaceObjectToString, 0, 0, wrapper, "toString"));
JS::Rooted<JSFunction*> toString(cx, JS_NewFunction(cx, InterfaceObjectToString, 0, 0, "toString"));
if (!toString) {
return false;
}

View File

@ -421,7 +421,8 @@ WrapperOwner::get(JSContext *cx, HandleObject proxy, HandleObject receiver,
if (idVar.type() == JSIDVariant::TnsString &&
idVar.get_nsString().EqualsLiteral("toString")) {
RootedFunction toString(cx, JS_NewFunction(cx, CPOWToString, 0, 0, proxy, "toString"));
RootedFunction toString(cx, JS_NewFunction(cx, CPOWToString, 0, 0,
"toString"));
if (!toString)
return false;

View File

@ -6,10 +6,10 @@ FRAGMENT(JSObject, simple) {
JS::Rooted<JSObject *> plain(cx, JS_NewPlainObject(cx));
JS::Rooted<JSObject *> global(cx, JS::CurrentGlobalOrNull(cx));
JS::Rooted<JSObject *> func(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0,
global, "dys"));
JS::Rooted<JSObject *> anon(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0, global, 0));
"dys"));
JS::Rooted<JSObject *> anon(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0, nullptr));
JS::Rooted<JSFunction *> funcPtr(cx, JS_NewFunction(cx, (JSNative) 1, 0, 0,
global, "formFollows"));
"formFollows"));
JSObject &plainRef = *plain;
JSFunction &funcRef = *funcPtr;

View File

@ -45,7 +45,7 @@ BEGIN_TEST(test_CallNonGenericMethodOnProxy)
JS_SetReservedSlot(customA, CUSTOM_SLOT, Int32Value(17));
JS::RootedFunction customMethodA(cx, JS_NewFunction(cx, CustomMethod, 0, 0,
customA, "customMethodA"));
"customMethodA"));
CHECK(customMethodA);
JS::RootedValue rval(cx);
@ -64,7 +64,8 @@ BEGIN_TEST(test_CallNonGenericMethodOnProxy)
CHECK(customB);
JS_SetReservedSlot(customB, CUSTOM_SLOT, Int32Value(42));
JS::RootedFunction customMethodB(cx, JS_NewFunction(cx, CustomMethod, 0, 0, customB, "customMethodB"));
JS::RootedFunction customMethodB(cx, JS_NewFunction(cx, CustomMethod, 0, 0,
"customMethodB"));
CHECK(customMethodB);
JS::RootedValue rval(cx);

View File

@ -167,7 +167,7 @@ BEGIN_TEST(testChromeBuffer)
trusted_fun = JS_GetFunctionObject(fun);
}
JS::RootedFunction fun(cx, JS_NewFunction(cx, CallTrusted, 0, 0, global, "callTrusted"));
JS::RootedFunction fun(cx, JS_NewFunction(cx, CallTrusted, 0, 0, "callTrusted"));
JS::RootedObject callTrusted(cx, JS_GetFunctionObject(fun));
const char *paramName = "f";

View File

@ -22,12 +22,12 @@ BEGIN_TEST(testDefineGetterSetterNonEnumerable)
CHECK(obj);
vobj = OBJECT_TO_JSVAL(obj);
JSFunction *funGet = JS_NewFunction(cx, NativeGetterSetter, 0, 0, JS::NullPtr(), "get");
JSFunction *funGet = JS_NewFunction(cx, NativeGetterSetter, 0, 0, "get");
CHECK(funGet);
JS::RootedObject funGetObj(cx, JS_GetFunctionObject(funGet));
JS::RootedValue vget(cx, OBJECT_TO_JSVAL(funGetObj));
JSFunction *funSet = JS_NewFunction(cx, NativeGetterSetter, 1, 0, JS::NullPtr(), "set");
JSFunction *funSet = JS_NewFunction(cx, NativeGetterSetter, 1, 0, "set");
CHECK(funSet);
JS::RootedObject funSetObj(cx, JS_GetFunctionObject(funSet));
JS::RootedValue vset(cx, OBJECT_TO_JSVAL(funSetObj));

View File

@ -338,7 +338,7 @@ Censor(JSContext *cx, unsigned argc, jsval *vp)
BEGIN_TEST(testParseJSON_reviver)
{
JSFunction *fun = JS_NewFunction(cx, Censor, 0, 0, global, "censor");
JSFunction *fun = JS_NewFunction(cx, Censor, 0, 0, "censor");
CHECK(fun);
JS::RootedValue filter(cx, OBJECT_TO_JSVAL(JS_GetFunctionObject(fun)));

View File

@ -3136,13 +3136,12 @@ JS_InitDestroyPrincipalsCallback(JSRuntime *rt, JSDestroyPrincipalsOp destroyPri
JS_PUBLIC_API(JSFunction *)
JS_NewFunction(JSContext *cx, JSNative native, unsigned nargs, unsigned flags,
HandleObject parent, const char *name)
const char *name)
{
MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, parent);
RootedAtom atom(cx);
if (name) {
@ -3152,7 +3151,7 @@ JS_NewFunction(JSContext *cx, JSNative native, unsigned nargs, unsigned flags,
}
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags);
return NewFunction(cx, NullPtr(), native, nargs, funFlags, parent, atom);
return NewFunction(cx, NullPtr(), native, nargs, funFlags, NullPtr(), atom);
}
JS_PUBLIC_API(JSFunction *)

View File

@ -3067,7 +3067,7 @@ JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v);
*/
extern JS_PUBLIC_API(JSFunction *)
JS_NewFunction(JSContext *cx, JSNative call, unsigned nargs, unsigned flags,
JS::Handle<JSObject*> parent, const char *name);
const char *name);
/*
* Create the function with the name given by the id. JSID_IS_STRING(id) must

View File

@ -242,7 +242,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
call = nullptr;
if (call) {
RootedFunction fun(ccx, JS_NewFunction(ccx, call, 0, 0, obj, name));
RootedFunction fun(ccx, JS_NewFunction(ccx, call, 0, 0, name));
if (!fun) {
JS_ReportOutOfMemory(ccx);
return false;
@ -299,7 +299,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
name = rt->GetStringName(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
fun = JS_NewFunction(ccx, XPC_WN_DoubleWrappedGetter,
0, 0, obj, name);
0, 0, name);
if (!fun)
return false;

View File

@ -1205,7 +1205,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
if (id != nsXPConnect::GetRuntimeInstance()->GetStringID(XPCJSRuntime::IDX_TO_STRING))
return true;
JSFunction *toString = JS_NewFunction(cx, XrayToString, 0, 0, holder, "toString");
JSFunction *toString = JS_NewFunction(cx, XrayToString, 0, 0, "toString");
if (!toString)
return false;