Changeset 28937 in webkit for trunk/JavaScriptCore/wtf/RefPtr.h
- Timestamp:
- Dec 21, 2007, 1:54:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/RefPtr.h
r27208 r28937 35 35 public: 36 36 RefPtr() : m_ptr(0) {} 37 RefPtr(T *ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }38 RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { if (T *ptr = m_ptr) ptr->ref(); }37 RefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); } 38 RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { if (T* ptr = m_ptr) ptr->ref(); } 39 39 // see comment in PassRefPtr.h for why this takes const reference 40 40 template <typename U> RefPtr(const PassRefPtr<U>&); … … 43 43 RefPtr(PlacementNewAdoptType) { } 44 44 45 ~RefPtr() { if (T *ptr = m_ptr) ptr->deref(); }45 ~RefPtr() { if (T* ptr = m_ptr) ptr->deref(); } 46 46 47 template <typename U> RefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T *ptr = m_ptr) ptr->ref(); }47 template <typename U> RefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); } 48 48 49 T *get() const { return m_ptr; }49 T* get() const { return m_ptr; } 50 50 51 void clear() { if (T* ptr = m_ptr) ptr->deref(); m_ptr = 0; } 51 52 PassRefPtr<T> release() { PassRefPtr<T> tmp = adoptRef(m_ptr); m_ptr = 0; return tmp; } 52 53 … … 57 58 58 59 // This conversion operator allows implicit conversion to bool but not to other integer types. 59 typedef T 60 typedef T* (RefPtr::*UnspecifiedBoolType)() const; 60 61 operator UnspecifiedBoolType() const { return m_ptr ? &RefPtr::get : 0; } 61 62 62 63 RefPtr& operator=(const RefPtr&); 63 RefPtr& operator=(T 64 RefPtr& operator=(T*); 64 65 RefPtr& operator=(const PassRefPtr<T>&); 65 66 template <typename U> RefPtr& operator=(const RefPtr<U>&); … … 172 173 template <typename T, typename U> inline RefPtr<T> static_pointer_cast(const RefPtr<U>& p) 173 174 { 174 return RefPtr<T>(static_cast<T 175 return RefPtr<T>(static_cast<T*>(p.get())); 175 176 } 176 177 177 178 template <typename T, typename U> inline RefPtr<T> const_pointer_cast(const RefPtr<U>& p) 178 179 { 179 return RefPtr<T>(const_cast<T 180 return RefPtr<T>(const_cast<T*>(p.get())); 180 181 } 181 182
Note:
See TracChangeset
for help on using the changeset viewer.