зеркало из https://github.com/mozilla/gecko-dev.git
Bug 949220 - Adjust some |NewObjectWithGivenTaggedProto| overloads so fewer users must specify an object kind. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D71270
This commit is contained in:
Родитель
33993321ab
Коммит
0e06b88680
|
@ -456,8 +456,8 @@ const JSClass GlobalObject::OffThreadPlaceholderObject::class_ = {
|
|||
/* static */ GlobalObject::OffThreadPlaceholderObject*
|
||||
GlobalObject::OffThreadPlaceholderObject::New(JSContext* cx, unsigned slot) {
|
||||
Rooted<OffThreadPlaceholderObject*> placeholder(cx);
|
||||
placeholder = NewObjectWithGivenTaggedProto<OffThreadPlaceholderObject>(
|
||||
cx, AsTaggedProto(nullptr));
|
||||
placeholder =
|
||||
NewObjectWithGivenProto<OffThreadPlaceholderObject>(cx, nullptr);
|
||||
if (!placeholder) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -416,13 +416,23 @@ inline JSObject* NewObjectWithGivenTaggedProto(
|
|||
initialShapeFlags);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, NewObjectKind NewKind>
|
||||
inline T* NewObjectWithGivenTaggedProtoForKind(JSContext* cx,
|
||||
Handle<TaggedProto> proto) {
|
||||
JSObject* obj =
|
||||
NewObjectWithGivenTaggedProto(cx, &T::class_, proto, NewKind, 0);
|
||||
return obj ? &obj->as<T>() : nullptr;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T>
|
||||
inline T* NewObjectWithGivenTaggedProto(JSContext* cx,
|
||||
Handle<TaggedProto> proto,
|
||||
NewObjectKind newKind = GenericObject,
|
||||
uint32_t initialShapeFlags = 0) {
|
||||
JSObject* obj = NewObjectWithGivenTaggedProto(cx, &T::class_, proto, newKind,
|
||||
initialShapeFlags);
|
||||
Handle<TaggedProto> proto) {
|
||||
JSObject* obj =
|
||||
NewObjectWithGivenTaggedProto(cx, &T::class_, proto, GenericObject, 0);
|
||||
return obj ? &obj->as<T>() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -466,20 +476,20 @@ inline JSObject* NewSingletonObjectWithGivenProto(JSContext* cx,
|
|||
|
||||
template <typename T>
|
||||
inline T* NewObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto),
|
||||
GenericObject);
|
||||
return detail::NewObjectWithGivenTaggedProtoForKind<T, GenericObject>(
|
||||
cx, AsTaggedProto(proto));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* NewSingletonObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto),
|
||||
SingletonObject);
|
||||
return detail::NewObjectWithGivenTaggedProtoForKind<T, SingletonObject>(
|
||||
cx, AsTaggedProto(proto));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* NewTenuredObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto),
|
||||
TenuredObject);
|
||||
return detail::NewObjectWithGivenTaggedProtoForKind<T, TenuredObject>(
|
||||
cx, AsTaggedProto(proto));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
Загрузка…
Ссылка в новой задаче