| OLD | NEW |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 template<typename T> ALWAYS_INLINE void derefIfNotNull(T* ptr) | 53 template<typename T> ALWAYS_INLINE void derefIfNotNull(T* ptr) |
| 54 { | 54 { |
| 55 if (LIKELY(ptr != 0)) | 55 if (LIKELY(ptr != 0)) |
| 56 ptr->deref(); | 56 ptr->deref(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 template<typename T> class PassRefPtr { | 59 template<typename T> class PassRefPtr { |
| 60 public: | 60 public: |
| 61 PassRefPtr() : m_ptr(0) { } | 61 PassRefPtr() : m_ptr(0) { } |
| 62 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } | 62 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } |
| 63 explicit PassRefPtr(T& ptr) : m_ptr(&ptr) { m_ptr->ref(); } |
| 63 // It somewhat breaks the type system to allow transfer of ownership out
of | 64 // It somewhat breaks the type system to allow transfer of ownership out
of |
| 64 // a const PassRefPtr. However, it makes it much easier to work with Pas
sRefPtr | 65 // a const PassRefPtr. However, it makes it much easier to work with Pas
sRefPtr |
| 65 // temporaries, and we don't have a need to use real const PassRefPtrs a
nyway. | 66 // temporaries, and we don't have a need to use real const PassRefPtrs a
nyway. |
| 66 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) { } | 67 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) { } |
| 67 template<typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvert
ibleArgDecl(U, T)) : m_ptr(o.leakRef()) { } | 68 template<typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvert
ibleArgDecl(U, T)) : m_ptr(o.leakRef()) { } |
| 68 | 69 |
| 69 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } | 70 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } |
| 70 | 71 |
| 71 template<typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleAr
gDecl(U, T)); | 72 template<typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleAr
gDecl(U, T)); |
| 72 | 73 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 return p.get(); | 175 return p.get(); |
| 175 } | 176 } |
| 176 | 177 |
| 177 } // namespace WTF | 178 } // namespace WTF |
| 178 | 179 |
| 179 using WTF::PassRefPtr; | 180 using WTF::PassRefPtr; |
| 180 using WTF::adoptRef; | 181 using WTF::adoptRef; |
| 181 using WTF::static_pointer_cast; | 182 using WTF::static_pointer_cast; |
| 182 | 183 |
| 183 #endif // WTF_PassRefPtr_h | 184 #endif // WTF_PassRefPtr_h |
| OLD | NEW |