diff options
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/wtf/RefPtr.h')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/wtf/RefPtr.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/RefPtr.h b/src/3rdparty/webkit/JavaScriptCore/wtf/RefPtr.h index 1a0b1fe..8388715 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/RefPtr.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/RefPtr.h @@ -30,6 +30,7 @@ namespace WTF { enum PlacementNewAdoptType { PlacementNewAdopt }; template <typename T> class PassRefPtr; + template <typename T> class NonNullPassRefPtr; enum HashTableDeletedValueType { HashTableDeletedValue }; @@ -40,6 +41,7 @@ namespace WTF { RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { T* ptr = m_ptr; refIfNotNull(ptr); } // see comment in PassRefPtr.h for why this takes const reference template <typename U> RefPtr(const PassRefPtr<U>&); + template <typename U> RefPtr(const NonNullPassRefPtr<U>&); // Special constructor for cases where we overwrite an object in place. RefPtr(PlacementNewAdoptType) { } @@ -73,8 +75,10 @@ namespace WTF { RefPtr& operator=(const RefPtr&); RefPtr& operator=(T*); RefPtr& operator=(const PassRefPtr<T>&); + RefPtr& operator=(const NonNullPassRefPtr<T>&); template <typename U> RefPtr& operator=(const RefPtr<U>&); template <typename U> RefPtr& operator=(const PassRefPtr<U>&); + template <typename U> RefPtr& operator=(const NonNullPassRefPtr<U>&); void swap(RefPtr&); @@ -89,6 +93,11 @@ namespace WTF { { } + template <typename T> template <typename U> inline RefPtr<T>::RefPtr(const NonNullPassRefPtr<U>& o) + : m_ptr(o.releaseRef()) + { + } + template <typename T> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr<T>& o) { T* optr = o.get(); @@ -126,6 +135,15 @@ namespace WTF { return *this; } + template <typename T> inline RefPtr<T>& RefPtr<T>::operator=(const NonNullPassRefPtr<T>& o) + { + T* ptr = m_ptr; + m_ptr = o.releaseRef(); + if (ptr) + ptr->deref(); + return *this; + } + template <typename T> template <typename U> inline RefPtr<T>& RefPtr<T>::operator=(const PassRefPtr<U>& o) { T* ptr = m_ptr; @@ -134,6 +152,15 @@ namespace WTF { return *this; } + template <typename T> template <typename U> inline RefPtr<T>& RefPtr<T>::operator=(const NonNullPassRefPtr<U>& o) + { + T* ptr = m_ptr; + m_ptr = o.releaseRef(); + if (ptr) + ptr->deref(); + return *this; + } + template <class T> inline void RefPtr<T>::swap(RefPtr<T>& o) { std::swap(m_ptr, o.m_ptr); |