mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1177801 - Remove NewObjectWithProto. r=bhackett
This commit is contained in:
parent
c1cec6411f
commit
8f146f4e90
@ -340,7 +340,7 @@ CreateAndBindSimdClass(JSContext* cx, Handle<GlobalObject*> global, HandleObject
|
||||
|
||||
// Create type constructor itself and initialize its reserved slots.
|
||||
Rooted<SimdTypeDescr*> typeDescr(cx);
|
||||
typeDescr = NewObjectWithProto<SimdTypeDescr>(cx, funcProto, SingletonObject);
|
||||
typeDescr = NewObjectWithGivenProto<SimdTypeDescr>(cx, funcProto, SingletonObject);
|
||||
if (!typeDescr)
|
||||
return nullptr;
|
||||
|
||||
@ -360,7 +360,7 @@ CreateAndBindSimdClass(JSContext* cx, Handle<GlobalObject*> global, HandleObject
|
||||
if (!objProto)
|
||||
return nullptr;
|
||||
Rooted<TypedProto*> proto(cx);
|
||||
proto = NewObjectWithProto<TypedProto>(cx, objProto, SingletonObject);
|
||||
proto = NewObjectWithGivenProto<TypedProto>(cx, objProto, SingletonObject);
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
typeDescr->initReservedSlot(JS_DESCR_SLOT_TYPROTO, ObjectValue(*proto));
|
||||
|
@ -490,7 +490,7 @@ CreatePrototypeObjectForComplexTypeInstance(JSContext* cx, HandleObject ctorProt
|
||||
if (!ctorPrototypePrototype)
|
||||
return nullptr;
|
||||
|
||||
return NewObjectWithProto<TypedProto>(cx, ctorPrototypePrototype, SingletonObject);
|
||||
return NewObjectWithGivenProto<TypedProto>(cx, ctorPrototypePrototype, SingletonObject);
|
||||
}
|
||||
|
||||
const Class ArrayTypeDescr::class_ = {
|
||||
@ -586,8 +586,9 @@ ArrayMetaTypeDescr::create(JSContext* cx,
|
||||
int32_t size,
|
||||
int32_t length)
|
||||
{
|
||||
MOZ_ASSERT(arrayTypePrototype);
|
||||
Rooted<ArrayTypeDescr*> obj(cx);
|
||||
obj = NewObjectWithProto<ArrayTypeDescr>(cx, arrayTypePrototype, SingletonObject);
|
||||
obj = NewObjectWithGivenProto<ArrayTypeDescr>(cx, arrayTypePrototype, SingletonObject);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
@ -780,11 +781,11 @@ StructMetaTypeDescr::create(JSContext* cx,
|
||||
int32_t alignment = 1; // Alignment of struct.
|
||||
bool opaque = false; // Opacity of struct.
|
||||
|
||||
userFieldOffsets = NewObjectWithProto<PlainObject>(cx, nullptr, TenuredObject);
|
||||
userFieldOffsets = NewBuiltinClassInstance<PlainObject>(cx, TenuredObject);
|
||||
if (!userFieldOffsets)
|
||||
return nullptr;
|
||||
|
||||
userFieldTypes = NewObjectWithProto<PlainObject>(cx, nullptr, TenuredObject);
|
||||
userFieldTypes = NewBuiltinClassInstance<PlainObject>(cx, TenuredObject);
|
||||
if (!userFieldTypes)
|
||||
return nullptr;
|
||||
|
||||
@ -914,8 +915,7 @@ StructMetaTypeDescr::create(JSContext* cx,
|
||||
return nullptr;
|
||||
|
||||
Rooted<StructTypeDescr*> descr(cx);
|
||||
descr = NewObjectWithProto<StructTypeDescr>(cx, structTypePrototype,
|
||||
SingletonObject);
|
||||
descr = NewObjectWithGivenProto<StructTypeDescr>(cx, structTypePrototype, SingletonObject);
|
||||
if (!descr)
|
||||
return nullptr;
|
||||
|
||||
@ -1156,7 +1156,7 @@ DefineSimpleTypeDescr(JSContext* cx,
|
||||
return false;
|
||||
|
||||
Rooted<T*> descr(cx);
|
||||
descr = NewObjectWithProto<T>(cx, funcProto, SingletonObject);
|
||||
descr = NewObjectWithGivenProto<T>(cx, funcProto, SingletonObject);
|
||||
if (!descr)
|
||||
return false;
|
||||
|
||||
@ -1176,7 +1176,7 @@ DefineSimpleTypeDescr(JSContext* cx,
|
||||
// Create the typed prototype for the scalar type. This winds up
|
||||
// not being user accessible, but we still create one for consistency.
|
||||
Rooted<TypedProto*> proto(cx);
|
||||
proto = NewObjectWithProto<TypedProto>(cx, objProto, TenuredObject);
|
||||
proto = NewObjectWithGivenProto<TypedProto>(cx, objProto, TenuredObject);
|
||||
if (!proto)
|
||||
return false;
|
||||
descr->initReservedSlot(JS_DESCR_SLOT_TYPROTO, ObjectValue(*proto));
|
||||
@ -1211,8 +1211,7 @@ DefineMetaTypeDescr(JSContext* cx,
|
||||
|
||||
// Create ctor.prototype, which inherits from Function.__proto__
|
||||
|
||||
RootedObject proto(cx, NewObjectWithProto<PlainObject>(cx, funcProto,
|
||||
SingletonObject));
|
||||
RootedObject proto(cx, NewObjectWithGivenProto<PlainObject>(cx, funcProto, SingletonObject));
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
|
||||
@ -1222,7 +1221,7 @@ DefineMetaTypeDescr(JSContext* cx,
|
||||
if (!objProto)
|
||||
return nullptr;
|
||||
RootedObject protoProto(cx);
|
||||
protoProto = NewObjectWithProto<PlainObject>(cx, objProto, SingletonObject);
|
||||
protoProto = NewObjectWithGivenProto<PlainObject>(cx, objProto, SingletonObject);
|
||||
if (!protoProto)
|
||||
return nullptr;
|
||||
|
||||
@ -1269,7 +1268,7 @@ GlobalObject::initTypedObjectModule(JSContext* cx, Handle<GlobalObject*> global)
|
||||
return false;
|
||||
|
||||
Rooted<TypedObjectModuleObject*> module(cx);
|
||||
module = NewObjectWithProto<TypedObjectModuleObject>(cx, objProto);
|
||||
module = NewObjectWithGivenProto<TypedObjectModuleObject>(cx, objProto);
|
||||
if (!module)
|
||||
return false;
|
||||
|
||||
|
@ -1006,8 +1006,7 @@ js::CreateThisForFunctionWithProto(JSContext* cx, HandleObject callee, HandleObj
|
||||
|
||||
res = CreateThisForFunctionWithGroup(cx, group, newKind);
|
||||
} else {
|
||||
gc::AllocKind allocKind = NewObjectGCKind(&PlainObject::class_);
|
||||
res = NewObjectWithProto<PlainObject>(cx, proto, allocKind, newKind);
|
||||
res = NewBuiltinClassInstance<PlainObject>(cx, newKind);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
|
@ -695,24 +695,6 @@ NewObjectWithClassProto(ExclusiveContext* cx, const Class* clasp, HandleObject p
|
||||
return NewObjectWithClassProto(cx, clasp, proto, allocKind, newKind);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T*
|
||||
NewObjectWithProto(ExclusiveContext* cx, HandleObject proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
JSObject* obj = NewObjectWithClassProto(cx, &T::class_, proto, allocKind, newKind);
|
||||
return obj ? &obj->as<T>() : nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T*
|
||||
NewObjectWithProto(ExclusiveContext* cx, HandleObject proto,
|
||||
NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
JSObject* obj = NewObjectWithClassProto(cx, &T::class_, proto, newKind);
|
||||
return obj ? &obj->as<T>() : nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a native instance of the given class with parent and proto set
|
||||
* according to the context's active global.
|
||||
|
Loading…
Reference in New Issue
Block a user