Bug 1127443 - Move some JS_NewObject callers to JS_NewObjectWithGiveProto

This commit is contained in:
Tom Schuster 2015-01-31 16:18:51 +01:00
parent 3d6b52a702
commit 3374698e65
6 changed files with 18 additions and 18 deletions

View File

@ -6154,7 +6154,7 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
}
if (!aOptions.mPrototype) {
protoObject = JS_NewObject(aCx, nullptr, htmlProto, JS::NullPtr());
protoObject = JS_NewObjectWithGivenProto(aCx, nullptr, htmlProto, JS::NullPtr());
if (!protoObject) {
rv.Throw(NS_ERROR_UNEXPECTED);
return;

View File

@ -481,8 +481,8 @@ CreateInterfaceObject(JSContext* cx, JS::Handle<JSObject*> global,
JS::Rooted<JSObject*> constructor(cx);
if (constructorClass) {
MOZ_ASSERT(constructorProto);
constructor = JS_NewObject(cx, Jsvalify(constructorClass), constructorProto,
global);
constructor = JS_NewObjectWithGivenProto(cx, Jsvalify(constructorClass),
constructorProto, global);
} else {
MOZ_ASSERT(constructorNative);
MOZ_ASSERT(constructorProto == JS_GetFunctionPrototype(cx, global));

View File

@ -2798,7 +2798,7 @@ public:
JS::Handle<JSObject*> aProto, JS::Handle<JSObject*> aParent,
T* aNative, JS::MutableHandle<JSObject*> aReflector)
{
aReflector.set(JS_NewObject(aCx, aClass, aProto, aParent));
aReflector.set(JS_NewObjectWithGivenProto(aCx, aClass, aProto, aParent));
if (aReflector) {
js::SetReservedSlot(aReflector, DOM_OBJECT_SLOT, JS::PrivateValue(aNative));
mNative = aNative;

View File

@ -909,7 +909,7 @@ InitCTypeClass(JSContext* cx, HandleObject parent)
MOZ_ASSERT(fnproto);
// Set up ctypes.CType.prototype.
RootedObject prototype(cx, JS_NewObject(cx, &sCTypeProtoClass, fnproto, parent));
RootedObject prototype(cx, JS_NewObjectWithGivenProto(cx, &sCTypeProtoClass, fnproto, parent));
if (!prototype)
return nullptr;
@ -1029,7 +1029,7 @@ InitTypeConstructor(JSContext* cx,
return false;
// Set up the .prototype and .prototype.constructor properties.
typeProto.set(JS_NewObject(cx, &sCTypeProtoClass, CTypeProto, parent));
typeProto.set(JS_NewObjectWithGivenProto(cx, &sCTypeProtoClass, CTypeProto, parent));
if (!typeProto)
return false;
@ -1056,7 +1056,7 @@ InitTypeConstructor(JSContext* cx,
// created from the given type constructor. This has ctypes.CData.prototype
// as its prototype, such that it inherits the properties and functions
// common to all CDatas.
dataProto.set(JS_NewObject(cx, &sCDataProtoClass, CDataProto, parent));
dataProto.set(JS_NewObjectWithGivenProto(cx, &sCDataProtoClass, CDataProto, parent));
if (!dataProto)
return false;
@ -3301,7 +3301,7 @@ CType::Create(JSContext* cx,
// * 'constructor' property === 't'
// * Additional properties specified by 'ps', as appropriate for the
// specific type instance 't'.
RootedObject typeObj(cx, JS_NewObject(cx, &sCTypeClass, typeProto, parent));
RootedObject typeObj(cx, JS_NewObjectWithGivenProto(cx, &sCTypeClass, typeProto, parent));
if (!typeObj)
return nullptr;
@ -3316,7 +3316,7 @@ CType::Create(JSContext* cx,
if (dataProto) {
// Set up the 'prototype' and 'prototype.constructor' properties.
RootedObject prototype(cx, JS_NewObject(cx, &sCDataProtoClass, dataProto, parent));
RootedObject prototype(cx, JS_NewObjectWithGivenProto(cx, &sCDataProtoClass, dataProto, parent));
if (!prototype)
return nullptr;
@ -4868,7 +4868,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb
// Set up the 'prototype' and 'prototype.constructor' properties.
// The prototype will reflect the struct fields as properties on CData objects
// created from this type.
RootedObject prototype(cx, JS_NewObject(cx, &sCDataProtoClass, dataProto, NullPtr()));
RootedObject prototype(cx, JS_NewObjectWithGivenProto(cx, &sCDataProtoClass, dataProto, NullPtr()));
if (!prototype)
return false;
@ -6377,7 +6377,7 @@ CData::Create(JSContext* cx,
RootedObject parent(cx, JS_GetParent(typeObj));
MOZ_ASSERT(parent);
RootedObject dataObj(cx, JS_NewObject(cx, &sCDataClass, proto, parent));
RootedObject dataObj(cx, JS_NewObjectWithGivenProto(cx, &sCDataClass, proto, parent));
if (!dataObj)
return nullptr;
@ -6958,7 +6958,8 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp)
// Get arguments
if (args.length() == 0) { // Special case: the empty (already finalized) object
JSObject *objResult = JS_NewObject(cx, &sCDataFinalizerClass, objProto, NullPtr());
JSObject *objResult = JS_NewObjectWithGivenProto(cx, &sCDataFinalizerClass, objProto,
NullPtr());
args.rval().setObject(*objResult);
return true;
}
@ -7057,7 +7058,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp)
// 5. Create |objResult|
JSObject *objResult = JS_NewObject(cx, &sCDataFinalizerClass, objProto, NullPtr());
JSObject *objResult = JS_NewObjectWithGivenProto(cx, &sCDataFinalizerClass, objProto, NullPtr());
if (!objResult) {
return false;
}
@ -7357,7 +7358,7 @@ Int64Base::Construct(JSContext* cx,
{
const JSClass* clasp = isUnsigned ? &sUInt64Class : &sInt64Class;
RootedObject parent(cx, JS_GetParent(proto));
RootedObject result(cx, JS_NewObject(cx, clasp, proto, parent));
RootedObject result(cx, JS_NewObjectWithGivenProto(cx, clasp, proto, parent));
if (!result)
return nullptr;

View File

@ -5092,7 +5092,7 @@ dom_constructor(JSContext* cx, unsigned argc, JS::Value *vp)
}
RootedObject proto(cx, &protov.toObject());
RootedObject domObj(cx, JS_NewObject(cx, &dom_class, proto, JS::NullPtr()));
RootedObject domObj(cx, JS_NewObjectWithGivenProto(cx, &dom_class, proto, JS::NullPtr()));
if (!domObj)
return false;

View File

@ -808,7 +808,7 @@ XPCWrappedNative::Init(HandleObject parent,
return false;
}
mFlatJSObject = JS_NewObject(cx, jsclazz, protoJSObject, parent);
mFlatJSObject = JS_NewObjectWithGivenProto(cx, jsclazz, protoJSObject, parent);
if (!mFlatJSObject) {
mFlatJSObject.unsetFlags(FLAT_JS_OBJECT_VALID);
return false;
@ -1573,9 +1573,8 @@ XPCWrappedNative::InitTearOffJSObject(XPCWrappedNativeTearOff* to)
AutoJSContext cx;
RootedObject parent(cx, mFlatJSObject);
RootedObject proto(cx, JS_GetObjectPrototype(cx, parent));
JSObject* obj = JS_NewObject(cx, Jsvalify(&XPC_WN_Tearoff_JSClass),
proto, parent);
JS::NullPtr(), parent);
if (!obj)
return false;