Bug 938211 - Supply copy assignment operator for Heap<T> and fix up some other classes in RootingAPI.h r=sfink

This commit is contained in:
Jon Coppeard 2013-11-18 17:21:44 +00:00
parent 4dbdfde79d
commit acdd78d61d

View File

@ -222,6 +222,11 @@ class Heap : public js::HeapBase<T>
return *this;
}
Heap<T> &operator=(const Heap<T>& other) {
set(other.get());
return *this;
}
void set(T newPtr) {
JS_ASSERT(!js::GCMethods<T>::poisoned(newPtr));
if (js::GCMethods<T>::needsPostBarrier(newPtr)) {
@ -348,6 +353,11 @@ class TenuredHeap : public js::HeapBase<T>
return *this;
}
TenuredHeap<T> &operator=(const TenuredHeap<T>& other) {
bits = other.bits;
return *this;
}
/*
* Set the pointer to a value which will cause a crash if it is
* dereferenced.
@ -576,6 +586,9 @@ class InternalHandle<T*>
: holder((void**)root.address()), offset(uintptr_t(field) - uintptr_t(root.get()))
{}
InternalHandle(const InternalHandle<T*>& other)
: holder(other.holder), offset(other.offset) {}
T *get() const { return reinterpret_cast<T*>(uintptr_t(*holder) + offset); }
const T &operator*() const { return *get(); }
@ -599,6 +612,8 @@ class InternalHandle<T*>
: holder(reinterpret_cast<void * const *>(&js::NullPtr::constNullValue)),
offset(uintptr_t(field))
{}
void operator=(InternalHandle<T*> other) MOZ_DELETE;
};
/*
@ -913,10 +928,16 @@ class FakeRooted : public RootedBase<T>
T &get() { return ptr; }
const T &get() const { return ptr; }
T &operator=(T value) {
FakeRooted<T> &operator=(T value) {
JS_ASSERT(!GCMethods<T>::poisoned(value));
ptr = value;
return ptr;
return *this;
}
FakeRooted<T> &operator=(const FakeRooted<T> &other) {
JS_ASSERT(!GCMethods<T>::poisoned(other.ptr));
ptr = other.ptr;
return *this;
}
bool operator!=(const T &other) const { return ptr != other; }
@ -961,6 +982,8 @@ class FakeMutableHandle : public js::MutableHandleBase<T>
template <typename S>
void operator=(S v) MOZ_DELETE;
void operator=(const FakeMutableHandle<T>& other) MOZ_DELETE;
};
/*