| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (LIKELY(ptr != 0)) | 57 if (LIKELY(ptr != 0)) |
| 58 ptr->deref(); | 58 ptr->deref(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 template <typename T> class PassRefPtr { | 61 template <typename T> class PassRefPtr { |
| 62 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 62 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 63 public: | 63 public: |
| 64 PassRefPtr() : m_ptr(nullptr) {} | 64 PassRefPtr() : m_ptr(nullptr) {} |
| 65 PassRefPtr(std::nullptr_t) : m_ptr(nullptr) {} | 65 PassRefPtr(std::nullptr_t) : m_ptr(nullptr) {} |
| 66 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } | 66 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } |
| 67 explicit PassRefPtr(T& ptr) : m_ptr(&ptr) { m_ptr->ref(); } | |
| 68 // It somewhat breaks the type system to allow transfer of ownership out of | 67 // It somewhat breaks the type system to allow transfer of ownership out of |
| 69 // a const PassRefPtr. However, it makes it much easier to work with | 68 // a const PassRefPtr. However, it makes it much easier to work with |
| 70 // PassRefPtr temporaries, and we don't have a need to use real const | 69 // PassRefPtr temporaries, and we don't have a need to use real const |
| 71 // PassRefPtrs anyway. | 70 // PassRefPtrs anyway. |
| 72 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) {} | 71 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) {} |
| 73 template <typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibl
eArgDecl(U, T)) : m_ptr(o.leakRef()) {} | 72 template <typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibl
eArgDecl(U, T)) : m_ptr(o.leakRef()) {} |
| 74 | 73 |
| 75 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } | 74 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } |
| 76 | 75 |
| 77 template <typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDe
cl(U, T)); | 76 template <typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDe
cl(U, T)); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 { | 208 { |
| 210 return p.get(); | 209 return p.get(); |
| 211 } | 210 } |
| 212 | 211 |
| 213 } // namespace WTF | 212 } // namespace WTF |
| 214 | 213 |
| 215 using WTF::PassRefPtr; | 214 using WTF::PassRefPtr; |
| 216 using WTF::adoptRef; | 215 using WTF::adoptRef; |
| 217 | 216 |
| 218 #endif // WTF_PassRefPtr_h | 217 #endif // WTF_PassRefPtr_h |
| OLD | NEW |