| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 WTF_DISALLOW_ZERO_ASSIGNMENT(RefPtr); | 37 WTF_DISALLOW_ZERO_ASSIGNMENT(RefPtr); |
| 38 public: | 38 public: |
| 39 ALWAYS_INLINE RefPtr() : m_ptr(0) { } | 39 ALWAYS_INLINE RefPtr() : m_ptr(0) { } |
| 40 ALWAYS_INLINE RefPtr(std::nullptr_t) : m_ptr(0) { } | 40 ALWAYS_INLINE RefPtr(std::nullptr_t) : m_ptr(0) { } |
| 41 ALWAYS_INLINE RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } | 41 ALWAYS_INLINE RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } |
| 42 template<typename U> RefPtr(const RawPtr<U>& ptr, EnsurePtrConvertibleAr
gDecl(U, T)) : m_ptr(ptr.get()) { refIfNotNull(m_ptr); } | 42 template<typename U> RefPtr(const RawPtr<U>& ptr, EnsurePtrConvertibleAr
gDecl(U, T)) : m_ptr(ptr.get()) { refIfNotNull(m_ptr); } |
| 43 ALWAYS_INLINE explicit RefPtr(T& ref) : m_ptr(&ref) { m_ptr->ref(); } | 43 ALWAYS_INLINE explicit RefPtr(T& ref) : m_ptr(&ref) { m_ptr->ref(); } |
| 44 ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_
ptr); } | 44 ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_
ptr); } |
| 45 template<typename U> RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgD
ecl(U, T)) : m_ptr(o.get()) { refIfNotNull(m_ptr); } | 45 template<typename U> RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgD
ecl(U, T)) : m_ptr(o.get()) { refIfNotNull(m_ptr); } |
| 46 | 46 |
| 47 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) | |
| 48 RefPtr(RefPtr&& o) : m_ptr(o.m_ptr) { o.m_ptr = 0; } | 47 RefPtr(RefPtr&& o) : m_ptr(o.m_ptr) { o.m_ptr = 0; } |
| 49 RefPtr& operator=(RefPtr&&); | 48 RefPtr& operator=(RefPtr&&); |
| 50 #endif | |
| 51 | 49 |
| 52 // See comments in PassRefPtr.h for an explanation of why this takes a c
onst reference. | 50 // See comments in PassRefPtr.h for an explanation of why this takes a c
onst reference. |
| 53 template<typename U> RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleAr
gDecl(U, T)); | 51 template<typename U> RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleAr
gDecl(U, T)); |
| 54 | 52 |
| 55 // Hash table deleted values, which are only constructed and never copie
d or destroyed. | 53 // Hash table deleted values, which are only constructed and never copie
d or destroyed. |
| 56 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { } | 54 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { } |
| 57 bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedV
alue(); } | 55 bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedV
alue(); } |
| 58 | 56 |
| 59 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); } | 57 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); } |
| 60 | 58 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 derefIfNotNull(ptr); | 99 derefIfNotNull(ptr); |
| 102 } | 100 } |
| 103 | 101 |
| 104 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr& o) | 102 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr& o) |
| 105 { | 103 { |
| 106 RefPtr ptr = o; | 104 RefPtr ptr = o; |
| 107 swap(ptr); | 105 swap(ptr); |
| 108 return *this; | 106 return *this; |
| 109 } | 107 } |
| 110 | 108 |
| 111 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) | |
| 112 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(RefPtr&& o) | 109 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(RefPtr&& o) |
| 113 { | 110 { |
| 114 // FIXME: Instead of explicitly casting to RefPtr&& here, we should use
std::move, but that requires us to | 111 // FIXME: Instead of explicitly casting to RefPtr&& here, we should use
std::move, but that requires us to |
| 115 // have a standard library that supports move semantics. | 112 // have a standard library that supports move semantics. |
| 116 RefPtr ptr = static_cast<RefPtr&&>(o); | 113 RefPtr ptr = static_cast<RefPtr&&>(o); |
| 117 swap(ptr); | 114 swap(ptr); |
| 118 return *this; | 115 return *this; |
| 119 } | 116 } |
| 120 #endif | |
| 121 | 117 |
| 122 template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::opera
tor=(const RefPtr<U>& o) | 118 template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::opera
tor=(const RefPtr<U>& o) |
| 123 { | 119 { |
| 124 RefPtr ptr = o; | 120 RefPtr ptr = o; |
| 125 swap(ptr); | 121 swap(ptr); |
| 126 return *this; | 122 return *this; |
| 127 } | 123 } |
| 128 | 124 |
| 129 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr) | 125 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr) |
| 130 { | 126 { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 private: | 211 private: |
| 216 T* m_ptr; | 212 T* m_ptr; |
| 217 }; | 213 }; |
| 218 | 214 |
| 219 } // namespace WTF | 215 } // namespace WTF |
| 220 | 216 |
| 221 using WTF::RefPtr; | 217 using WTF::RefPtr; |
| 222 using WTF::static_pointer_cast; | 218 using WTF::static_pointer_cast; |
| 223 | 219 |
| 224 #endif // WTF_RefPtr_h | 220 #endif // WTF_RefPtr_h |
| OLD | NEW |