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 20 matching lines...) Expand all Loading... |
31 namespace WTF { | 31 namespace WTF { |
32 | 32 |
33 template<typename T> class PassRefPtr; | 33 template<typename T> class PassRefPtr; |
34 | 34 |
35 template<typename T> class RefPtr { | 35 template<typename T> class RefPtr { |
36 WTF_MAKE_FAST_ALLOCATED; | 36 WTF_MAKE_FAST_ALLOCATED; |
37 public: | 37 public: |
38 ALWAYS_INLINE RefPtr() : m_ptr(0) { } | 38 ALWAYS_INLINE RefPtr() : m_ptr(0) { } |
39 ALWAYS_INLINE RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } | 39 ALWAYS_INLINE RefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } |
40 ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_
ptr); } | 40 ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_
ptr); } |
41 template<typename U> RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgD
ecl(U, T)) : m_ptr(o.get()) { refIfNotNull(m_ptr); } | 41 template<typename U> RefPtr(const RefPtr<U>& o, EnsureRefPtrConvertibleA
rgDecl) : m_ptr(o.get()) { refIfNotNull(m_ptr); } |
42 | 42 |
43 // See comments in PassRefPtr.h for an explanation of why this takes a c
onst reference. | 43 // See comments in PassRefPtr.h for an explanation of why this takes a c
onst reference. |
44 template<typename U> RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleAr
gDecl(U, T)); | 44 template<typename U> RefPtr(const PassRefPtr<U>&, EnsureRefPtrConvertibl
eArgDecl); |
45 | 45 |
46 // Hash table deleted values, which are only constructed and never copie
d or destroyed. | 46 // Hash table deleted values, which are only constructed and never copie
d or destroyed. |
47 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { } | 47 RefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { } |
48 bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedV
alue(); } | 48 bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedV
alue(); } |
49 | 49 |
50 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); } | 50 ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); } |
51 | 51 |
52 T* get() const { return m_ptr; } | 52 T* get() const { return m_ptr; } |
53 | 53 |
54 void clear(); | 54 void clear(); |
(...skipping 18 matching lines...) Expand all Loading... |
73 template<typename U> EnsurePtrConvertibleType(RefPtr<T>&, U, T) operator
=(const PassRefPtr<U>&); | 73 template<typename U> EnsurePtrConvertibleType(RefPtr<T>&, U, T) operator
=(const PassRefPtr<U>&); |
74 | 74 |
75 void swap(RefPtr&); | 75 void swap(RefPtr&); |
76 | 76 |
77 static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); } | 77 static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); } |
78 | 78 |
79 private: | 79 private: |
80 T* m_ptr; | 80 T* m_ptr; |
81 }; | 81 }; |
82 | 82 |
83 template<typename T> template<typename U> inline RefPtr<T>::RefPtr(const Pas
sRefPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T)) | 83 template<typename T> template<typename U> inline RefPtr<T>::RefPtr(const Pas
sRefPtr<U>& o, EnsureRefPtrConvertibleArgDefn) |
84 : m_ptr(o.leakRef()) | 84 : m_ptr(o.leakRef()) |
85 { | 85 { |
86 } | 86 } |
87 | 87 |
88 template<typename T> inline void RefPtr<T>::clear() | 88 template<typename T> inline void RefPtr<T>::clear() |
89 { | 89 { |
90 T* ptr = m_ptr; | 90 T* ptr = m_ptr; |
91 m_ptr = 0; | 91 m_ptr = 0; |
92 derefIfNotNull(ptr); | 92 derefIfNotNull(ptr); |
93 } | 93 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return p.get(); | 182 return p.get(); |
183 } | 183 } |
184 | 184 |
185 } // namespace WTF | 185 } // namespace WTF |
186 | 186 |
187 using WTF::RefPtr; | 187 using WTF::RefPtr; |
188 using WTF::static_pointer_cast; | 188 using WTF::static_pointer_cast; |
189 using WTF::const_pointer_cast; | 189 using WTF::const_pointer_cast; |
190 | 190 |
191 #endif // WTF_RefPtr_h | 191 #endif // WTF_RefPtr_h |
OLD | NEW |