Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: Source/wtf/RefPtr.h

Issue 20300002: Fix trailing whitespace in .cpp, .h, and .idl files (ex. Source/core) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/RefCountedLeakCounter.cpp ('k') | Source/wtf/RefPtrHashMap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser ved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser ved.
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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>&); 44 template<typename U> RefPtr(const PassRefPtr<U>&);
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();
55 PassRefPtr<T> release() { PassRefPtr<T> tmp = adoptRef(m_ptr); m_ptr = 0 ; return tmp; } 55 PassRefPtr<T> release() { PassRefPtr<T> tmp = adoptRef(m_ptr); m_ptr = 0 ; return tmp; }
56 56
57 T& operator*() const { return *m_ptr; } 57 T& operator*() const { return *m_ptr; }
58 ALWAYS_INLINE T* operator->() const { return m_ptr; } 58 ALWAYS_INLINE T* operator->() const { return m_ptr; }
59 59
60 bool operator!() const { return !m_ptr; } 60 bool operator!() const { return !m_ptr; }
61 61
62 // This conversion operator allows implicit conversion to bool but not t o other integer types. 62 // This conversion operator allows implicit conversion to bool but not t o other integer types.
63 typedef T* (RefPtr::*UnspecifiedBoolType); 63 typedef T* (RefPtr::*UnspecifiedBoolType);
64 operator UnspecifiedBoolType() const { return m_ptr ? &RefPtr::m_ptr : 0 ; } 64 operator UnspecifiedBoolType() const { return m_ptr ? &RefPtr::m_ptr : 0 ; }
65 65
66 RefPtr& operator=(const RefPtr&); 66 RefPtr& operator=(const RefPtr&);
67 RefPtr& operator=(T*); 67 RefPtr& operator=(T*);
68 RefPtr& operator=(const PassRefPtr<T>&); 68 RefPtr& operator=(const PassRefPtr<T>&);
69 #if !COMPILER_SUPPORTS(CXX_NULLPTR) 69 #if !COMPILER_SUPPORTS(CXX_NULLPTR)
70 RefPtr& operator=(std::nullptr_t) { clear(); return *this; } 70 RefPtr& operator=(std::nullptr_t) { clear(); return *this; }
71 #endif 71 #endif
72 template<typename U> RefPtr& operator=(const RefPtr<U>&); 72 template<typename U> RefPtr& operator=(const RefPtr<U>&);
73 template<typename U> RefPtr& operator=(const PassRefPtr<U>&); 73 template<typename U> RefPtr& 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) 83 template<typename T> template<typename U> inline RefPtr<T>::RefPtr(const Pas sRefPtr<U>& o)
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 }
94 94
95 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr<T>& o) 95 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr<T>& o)
96 { 96 {
97 T* optr = o.get(); 97 T* optr = o.get();
98 refIfNotNull(optr); 98 refIfNotNull(optr);
99 T* ptr = m_ptr; 99 T* ptr = m_ptr;
100 m_ptr = optr; 100 m_ptr = optr;
101 derefIfNotNull(ptr); 101 derefIfNotNull(ptr);
102 return *this; 102 return *this;
103 } 103 }
104 104
105 template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::opera tor=(const RefPtr<U>& o) 105 template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::opera tor=(const RefPtr<U>& o)
106 { 106 {
107 T* optr = o.get(); 107 T* optr = o.get();
108 refIfNotNull(optr); 108 refIfNotNull(optr);
109 T* ptr = m_ptr; 109 T* ptr = m_ptr;
110 m_ptr = optr; 110 m_ptr = optr;
111 derefIfNotNull(ptr); 111 derefIfNotNull(ptr);
112 return *this; 112 return *this;
113 } 113 }
114 114
115 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr) 115 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(T* optr)
116 { 116 {
117 refIfNotNull(optr); 117 refIfNotNull(optr);
118 T* ptr = m_ptr; 118 T* ptr = m_ptr;
119 m_ptr = optr; 119 m_ptr = optr;
120 derefIfNotNull(ptr); 120 derefIfNotNull(ptr);
121 return *this; 121 return *this;
122 } 122 }
123 123
124 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const PassRefPtr <T>& o) 124 template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(const PassRefPtr <T>& o)
(...skipping 16 matching lines...) Expand all
141 { 141 {
142 std::swap(m_ptr, o.m_ptr); 142 std::swap(m_ptr, o.m_ptr);
143 } 143 }
144 144
145 template<class T> inline void swap(RefPtr<T>& a, RefPtr<T>& b) 145 template<class T> inline void swap(RefPtr<T>& a, RefPtr<T>& b)
146 { 146 {
147 a.swap(b); 147 a.swap(b);
148 } 148 }
149 149
150 template<typename T, typename U> inline bool operator==(const RefPtr<T>& a, const RefPtr<U>& b) 150 template<typename T, typename U> inline bool operator==(const RefPtr<T>& a, const RefPtr<U>& b)
151 { 151 {
152 return a.get() == b.get(); 152 return a.get() == b.get();
153 } 153 }
154 154
155 template<typename T, typename U> inline bool operator==(const RefPtr<T>& a, U* b) 155 template<typename T, typename U> inline bool operator==(const RefPtr<T>& a, U* b)
156 { 156 {
157 return a.get() == b; 157 return a.get() == b;
158 } 158 }
159 159
160 template<typename T, typename U> inline bool operator==(T* a, const RefPtr<U >& b) 160 template<typename T, typename U> inline bool operator==(T* a, const RefPtr<U >& b)
161 { 161 {
162 return a == b.get(); 162 return a == b.get();
163 } 163 }
164 164
165 template<typename T, typename U> inline bool operator!=(const RefPtr<T>& a, const RefPtr<U>& b) 165 template<typename T, typename U> inline bool operator!=(const RefPtr<T>& a, const RefPtr<U>& b)
166 { 166 {
167 return a.get() != b.get(); 167 return a.get() != b.get();
168 } 168 }
169 169
170 template<typename T, typename U> inline bool operator!=(const RefPtr<T>& a, U* b) 170 template<typename T, typename U> inline bool operator!=(const RefPtr<T>& a, U* b)
171 { 171 {
172 return a.get() != b; 172 return a.get() != b;
173 } 173 }
174 174
175 template<typename T, typename U> inline bool operator!=(T* a, const RefPtr<U >& b) 175 template<typename T, typename U> inline bool operator!=(T* a, const RefPtr<U >& b)
176 { 176 {
177 return a != b.get(); 177 return a != b.get();
178 } 178 }
179 179
180 template<typename T, typename U> inline RefPtr<T> static_pointer_cast(const RefPtr<U>& p) 180 template<typename T, typename U> inline RefPtr<T> static_pointer_cast(const RefPtr<U>& p)
181 { 181 {
182 return RefPtr<T>(static_cast<T*>(p.get())); 182 return RefPtr<T>(static_cast<T*>(p.get()));
183 } 183 }
184 184
185 template<typename T, typename U> inline RefPtr<T> const_pointer_cast(const R efPtr<U>& p) 185 template<typename T, typename U> inline RefPtr<T> const_pointer_cast(const R efPtr<U>& p)
186 { 186 {
187 return RefPtr<T>(const_cast<T*>(p.get())); 187 return RefPtr<T>(const_cast<T*>(p.get()));
188 } 188 }
189 189
190 template<typename T> inline T* getPtr(const RefPtr<T>& p) 190 template<typename T> inline T* getPtr(const RefPtr<T>& p)
191 { 191 {
192 return p.get(); 192 return p.get();
193 } 193 }
194 194
195 } // namespace WTF 195 } // namespace WTF
196 196
197 using WTF::RefPtr; 197 using WTF::RefPtr;
198 using WTF::static_pointer_cast; 198 using WTF::static_pointer_cast;
199 using WTF::const_pointer_cast; 199 using WTF::const_pointer_cast;
200 200
201 #endif // WTF_RefPtr_h 201 #endif // WTF_RefPtr_h
OLDNEW
« no previous file with comments | « Source/wtf/RefCountedLeakCounter.cpp ('k') | Source/wtf/RefPtrHashMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698