Bug 1729602 - Templatize RootHolder in PersistentRooted to more closely match Rooted r=tcampbell,jonco

Differential Revision: https://phabricator.services.mozilla.com/D124995
This commit is contained in:
Steve Fink 2021-09-13 22:58:53 +00:00
Родитель 90d784a9bd
Коммит 2ddcc9e183
1 изменённых файлов: 10 добавлений и 21 удалений

Просмотреть файл

@ -1402,39 +1402,28 @@ class PersistentRooted
reinterpret_cast<JS::PersistentRooted<detail::RootListEntry*>*>(this));
}
// Used when JSContext type is incomplete and so it is not known to inherit
// from RootingContext.
void registerWithRootLists(JSContext* cx) {
registerWithRootLists(RootingContext::get(cx));
}
public:
using ElementType = T;
PersistentRooted() : ptr(SafelyInitialized<T>()) {}
explicit PersistentRooted(RootingContext* cx) : ptr(SafelyInitialized<T>()) {
template <typename RootHolder>
explicit PersistentRooted(const RootHolder& cx) : ptr(SafelyInitialized<T>()) {
registerWithRootLists(cx);
}
explicit PersistentRooted(JSContext* cx) : ptr(SafelyInitialized<T>()) {
registerWithRootLists(RootingContext::get(cx));
}
template <typename U>
PersistentRooted(RootingContext* cx, U&& initial)
template <typename RootHolder, typename U>
PersistentRooted(const RootHolder& cx, U&& initial)
: ptr(std::forward<U>(initial)) {
registerWithRootLists(cx);
}
template <typename U>
PersistentRooted(JSContext* cx, U&& initial) : ptr(std::forward<U>(initial)) {
registerWithRootLists(RootingContext::get(cx));
}
explicit PersistentRooted(JSRuntime* rt) : ptr(SafelyInitialized<T>()) {
registerWithRootLists(rt);
}
template <typename U>
PersistentRooted(JSRuntime* rt, U&& initial) : ptr(std::forward<U>(initial)) {
registerWithRootLists(rt);
}
PersistentRooted(const PersistentRooted& rhs)
: mozilla::LinkedListElement<PersistentRooted<T>>(), ptr(rhs.ptr) {
/*