зеркало из 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*
|
/* static */ GlobalObject::OffThreadPlaceholderObject*
|
||||||
GlobalObject::OffThreadPlaceholderObject::New(JSContext* cx, unsigned slot) {
|
GlobalObject::OffThreadPlaceholderObject::New(JSContext* cx, unsigned slot) {
|
||||||
Rooted<OffThreadPlaceholderObject*> placeholder(cx);
|
Rooted<OffThreadPlaceholderObject*> placeholder(cx);
|
||||||
placeholder = NewObjectWithGivenTaggedProto<OffThreadPlaceholderObject>(
|
placeholder =
|
||||||
cx, AsTaggedProto(nullptr));
|
NewObjectWithGivenProto<OffThreadPlaceholderObject>(cx, nullptr);
|
||||||
if (!placeholder) {
|
if (!placeholder) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,13 +416,23 @@ inline JSObject* NewObjectWithGivenTaggedProto(
|
||||||
initialShapeFlags);
|
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>
|
template <typename T>
|
||||||
inline T* NewObjectWithGivenTaggedProto(JSContext* cx,
|
inline T* NewObjectWithGivenTaggedProto(JSContext* cx,
|
||||||
Handle<TaggedProto> proto,
|
Handle<TaggedProto> proto) {
|
||||||
NewObjectKind newKind = GenericObject,
|
JSObject* obj =
|
||||||
uint32_t initialShapeFlags = 0) {
|
NewObjectWithGivenTaggedProto(cx, &T::class_, proto, GenericObject, 0);
|
||||||
JSObject* obj = NewObjectWithGivenTaggedProto(cx, &T::class_, proto, newKind,
|
|
||||||
initialShapeFlags);
|
|
||||||
return obj ? &obj->as<T>() : nullptr;
|
return obj ? &obj->as<T>() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,20 +476,20 @@ inline JSObject* NewSingletonObjectWithGivenProto(JSContext* cx,
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T* NewObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
inline T* NewObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
||||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto),
|
return detail::NewObjectWithGivenTaggedProtoForKind<T, GenericObject>(
|
||||||
GenericObject);
|
cx, AsTaggedProto(proto));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T* NewSingletonObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
inline T* NewSingletonObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
||||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto),
|
return detail::NewObjectWithGivenTaggedProtoForKind<T, SingletonObject>(
|
||||||
SingletonObject);
|
cx, AsTaggedProto(proto));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T* NewTenuredObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
inline T* NewTenuredObjectWithGivenProto(JSContext* cx, HandleObject proto) {
|
||||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto),
|
return detail::NewObjectWithGivenTaggedProtoForKind<T, TenuredObject>(
|
||||||
TenuredObject);
|
cx, AsTaggedProto(proto));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче