| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Hash table deleted values, which are only constructed and never copied or | 63 // Hash table deleted values, which are only constructed and never copied or |
| 64 // destroyed. | 64 // destroyed. |
| 65 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) {} | 65 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) {} |
| 66 bool isHashTableDeletedValue() const { | 66 bool isHashTableDeletedValue() const { |
| 67 return m_ptr == hashTableDeletedValue(); | 67 return m_ptr == hashTableDeletedValue(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); } | 70 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); } |
| 71 | 71 |
| 72 ALWAYS_INLINE T* get() const { return m_ptr; } | 72 ALWAYS_INLINE T* get() const { return m_ptr; } |
| 73 | 73 T* leakRef() WARN_UNUSED_RESULT; |
| 74 void clear(); | 74 void clear(); |
| 75 PassRefPtr<T> release() { | 75 PassRefPtr<T> release() { |
| 76 PassRefPtr<T> tmp = adoptRef(m_ptr); | 76 PassRefPtr<T> tmp = adoptRef(m_ptr); |
| 77 m_ptr = nullptr; | 77 m_ptr = nullptr; |
| 78 return tmp; | 78 return tmp; |
| 79 } | 79 } |
| 80 | 80 |
| 81 T& operator*() const { return *m_ptr; } | 81 T& operator*() const { return *m_ptr; } |
| 82 ALWAYS_INLINE T* operator->() const { return m_ptr; } | 82 ALWAYS_INLINE T* operator->() const { return m_ptr; } |
| 83 | 83 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 T* m_ptr; | 104 T* m_ptr; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 template <typename T> | 107 template <typename T> |
| 108 template <typename U> | 108 template <typename U> |
| 109 inline RefPtr<T>::RefPtr(const PassRefPtr<U>& o, | 109 inline RefPtr<T>::RefPtr(const PassRefPtr<U>& o, |
| 110 EnsurePtrConvertibleArgDefn(U, T)) | 110 EnsurePtrConvertibleArgDefn(U, T)) |
| 111 : m_ptr(o.leakRef()) {} | 111 : m_ptr(o.leakRef()) {} |
| 112 | 112 |
| 113 template <typename T> | 113 template <typename T> |
| 114 inline T* RefPtr<T>::leakRef() { |
| 115 T* ptr = m_ptr; |
| 116 m_ptr = nullptr; |
| 117 return ptr; |
| 118 } |
| 119 |
| 120 template <typename T> |
| 114 inline void RefPtr<T>::clear() { | 121 inline void RefPtr<T>::clear() { |
| 115 T* ptr = m_ptr; | 122 T* ptr = m_ptr; |
| 116 m_ptr = nullptr; | 123 m_ptr = nullptr; |
| 117 derefIfNotNull(ptr); | 124 derefIfNotNull(ptr); |
| 118 } | 125 } |
| 119 | 126 |
| 120 template <typename T> | 127 template <typename T> |
| 121 template <typename U> | 128 template <typename U> |
| 122 inline RefPtr<T>& RefPtr<T>::operator=(RefPtrValuePeeker<U> optr) { | 129 inline RefPtr<T>& RefPtr<T>::operator=(RefPtrValuePeeker<U> optr) { |
| 123 RefPtr ptr = static_cast<U*>(optr); | 130 RefPtr ptr = static_cast<U*>(optr); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 213 |
| 207 private: | 214 private: |
| 208 T* m_ptr; | 215 T* m_ptr; |
| 209 }; | 216 }; |
| 210 | 217 |
| 211 } // namespace WTF | 218 } // namespace WTF |
| 212 | 219 |
| 213 using WTF::RefPtr; | 220 using WTF::RefPtr; |
| 214 | 221 |
| 215 #endif // WTF_RefPtr_h | 222 #endif // WTF_RefPtr_h |
| OLD | NEW |