| 1 | /* |
| 2 | * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public License |
| 15 | * along with this library; see the file COPYING.LIB. If not, write to |
| 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #ifndef WTF_OwnPtr_h |
| 22 | #define WTF_OwnPtr_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnPtr.h:22:9`! |
| 23 | |
| 24 | #include "Assertions.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h`/ |
| 25 | #include "Noncopyable.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Noncopyable.h`/ |
| 26 | #include "OwnPtrCommon.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnPtrCommon.h`/ |
| 27 | #include "TypeTraits.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h`/ |
| 28 | #include <algorithm> |
| 29 | #include <memory> |
| 30 | |
| 31 | namespace WTFcxx . . $ `<built-in>:467:9`! { |
| 32 | |
| 33 | // Unlike most of our smart pointers, OwnPtr can take either the pointer type or the pointed-to type. |
| 34 | |
| 35 | template <typename T> class PassOwnPtrcxx . . $ QTWTF/PassOwnPtr#; |
| 36 | |
| 37 | template <typename T> class OwnPtrcxx . . $ QTWTF/OwnPtr# : public Noncopyablecxx . . $ Noncopyable# { |
| 38 | public: |
| 39 | typedef typename RemovePointercxx . . $ QTWTF/RemovePointer#<T>::Type ValueTypecxx . . $ QTWTF/OwnPtr#ValueType#; |
| 40 | typedef ValueTypecxx . . $ QTWTF/OwnPtr#ValueType#* PtrTypecxx . . $ QTWTF/OwnPtr#PtrType#; |
| 41 | |
| 42 | explicit OwnPtrcxx . . $ QTWTF/OwnPtr#`OwnPtr<T>`(1785726f63ed5f3e).(PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# ptr = 0) : m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.(ptr) { } |
| 43 | OwnPtrcxx . . $ QTWTF/OwnPtr#`OwnPtr<T>`(848ff1d3ce282967).(stdcxx . . $ std/::auto_ptrcxx . . $ std/auto_ptr#<ValueTypecxx . . $ QTWTF/OwnPtr#ValueType#> autoPtr) : m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.(autoPtr.releasecxx . . $ std/auto_ptr#release(155dc7f103cdb9db).()) { } |
| 44 | // See comment in PassOwnPtr.h for why this takes a const reference. |
| 45 | template <typename U> OwnPtrcxx . . $ QTWTF/OwnPtr#`OwnPtr<T>`(67fd89cba79bc0c3).(const PassOwnPtrcxx . . $ QTWTF/PassOwnPtr#<U>& o); |
| 46 | |
| 47 | // This copy constructor is used implicitly by gcc when it generates |
| 48 | // transients for assigning a PassOwnPtr<T> object to a stack-allocated |
| 49 | // OwnPtr<T> object. It should never be called explicitly and gcc |
| 50 | // should optimize away the constructor when generating code. |
| 51 | OwnPtrcxx . . $ QTWTF/OwnPtr#`OwnPtr<T>`(47007520bbb0d849).(const OwnPtrcxx . . $ QTWTF/OwnPtr#<ValueTypecxx . . $ QTWTF/OwnPtr#ValueType#>& o); |
| 52 | |
| 53 | ~cxx . . $ QTWTF/OwnPtr#`~OwnPtr<T>`(49f6e7a06ebc5aa8).OwnPtr() { deleteOwnedPtrcxx . . $ QTWTF/deleteOwnedPtr(ebd0a1552f8ce24f).(m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.); } |
| 54 | |
| 55 | PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# getcxx . . $ QTWTF/OwnPtr#get(6fc1a68e4b3baa22).() const { return m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; } |
| 56 | PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# releasecxx . . $ QTWTF/OwnPtr#release(3f181e9d4bf53bf5).() { PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# ptr = m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. = 0; return ptr; } |
| 57 | |
| 58 | // FIXME: This should be renamed to adopt. |
| 59 | void setcxx . . $ QTWTF/OwnPtr#set(1785726f63ed5f3e).(PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# ptr) { ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!ptr || m_ptr != ptr); deleteOwnedPtrcxx . . $ QTWTF/deleteOwnedPtr(ebd0a1552f8ce24f).(m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.); m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. = ptr; } |
| 60 | |
| 61 | void adoptcxx . . $ QTWTF/OwnPtr#adopt(848ff1d3ce282967).(stdcxx . . $ std/::auto_ptrcxx . . $ std/auto_ptr#<ValueTypecxx . . $ QTWTF/OwnPtr#ValueType#> autoPtr) { ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!autoPtr.get() || m_ptr != autoPtr.get()); deleteOwnedPtrcxx . . $ QTWTF/deleteOwnedPtr(ebd0a1552f8ce24f).(m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.); m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. = autoPtr.releasecxx . . $ std/auto_ptr#release(155dc7f103cdb9db).(); } |
| 62 | |
| 63 | void clearcxx . . $ QTWTF/OwnPtr#clear(49f6e7a06ebc5aa8).() { deleteOwnedPtrcxx . . $ QTWTF/deleteOwnedPtr(ebd0a1552f8ce24f).(m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.); m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. = 0; } |
| 64 | |
| 65 | ValueTypecxx . . $ QTWTF/OwnPtr#ValueType#& operatorcxx . . $ QTWTF/OwnPtr#`operator*`(f125eb21d9ff578b).*() const { ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_ptr); return *m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; } |
| 66 | PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# operatorcxx . . $ QTWTF/OwnPtr#`operator->`(6fc1a68e4b3baa22).->() const { ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_ptr); return m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; } |
| 67 | |
| 68 | bool operatorcxx . . $ QTWTF/OwnPtr#`operator!`(50ce9a9e25b4a850).!() const { return !m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; } |
| 69 | |
| 70 | // This conversion operator allows implicit conversion to bool but not to other integer types. |
| 71 | typedef PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# OwnPtrcxx . . $ QTWTF/OwnPtr#::*UnspecifiedBoolTypecxx . . $ QTWTF/OwnPtr#UnspecifiedBoolType#; |
| 72 | operatorcxx . . $ QTWTF/OwnPtr#`operator RemovePointer<type-parameter-0-0>::Type *OwnPtr<T>::*`(5d5ae7002389bdca). UnspecifiedBoolTypecxx . . $ QTWTF/OwnPtr#UnspecifiedBoolType#() const { return m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. ? &OwnPtrcxx . . $ QTWTF/OwnPtr#::m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. : 0; } |
| 73 | |
| 74 | OwnPtr& operatorcxx . . $ QTWTF/OwnPtr#`operator=`(d9b6b56736ca2e5a).=(const PassOwnPtrcxx . . $ QTWTF/PassOwnPtr#<T>&); |
| 75 | template <typename U> OwnPtr& operatorcxx . . $ QTWTF/OwnPtr#`operator=`(9ca20df68ff89852).=(const PassOwnPtrcxx . . $ QTWTF/PassOwnPtr#<U>&); |
| 76 | |
| 77 | void swapcxx . . $ QTWTF/OwnPtr#swap(18ce991cd1458433).(OwnPtr& o) { stdcxx . . $ std/::swapcxx . . $ std/swap(4f7bccc0a19c88cd).(m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr., o.m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.); } |
| 78 | |
| 79 | private: |
| 80 | PtrTypecxx . . $ QTWTF/OwnPtr#PtrType# m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; |
| 81 | }; |
| 82 | |
| 83 | template <typename T> template <typename U> inline OwnPtrcxx . . $ QTWTF/OwnPtr#<T>::OwnPtrcxx . . $ QTWTF/OwnPtr#`OwnPtr<T>`(67fd89cba79bc0c3).(const PassOwnPtrcxx . . $ QTWTF/PassOwnPtr#<U>& o) |
| 84 | : m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.(o.release()) |
| 85 | { |
| 86 | } |
| 87 | |
| 88 | template <typename T> inline OwnPtrcxx . . $ QTWTF/OwnPtr#<T>& OwnPtrcxx . . $ QTWTF/OwnPtr#<T>::operatorcxx . . $ QTWTF/OwnPtr#`operator=`(d9b6b56736ca2e5a).=(const PassOwnPtrcxx . . $ QTWTF/PassOwnPtr#<T>& o) |
| 89 | { |
| 90 | T* ptr = m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; |
| 91 | m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. = o.release(); |
| 92 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!ptr || m_ptr != ptr); |
| 93 | if (ptr) |
| 94 | deleteOwnedPtrcxx . . $ QTWTF/deleteOwnedPtr(ebd0a1552f8ce24f).(ptr); |
| 95 | return *this; |
| 96 | } |
| 97 | |
| 98 | template <typename T> template <typename U> inline OwnPtrcxx . . $ QTWTF/OwnPtr#<T>& OwnPtrcxx . . $ QTWTF/OwnPtr#<T>::operatorcxx . . $ QTWTF/OwnPtr#`operator=`(9ca20df68ff89852).=(const PassOwnPtrcxx . . $ QTWTF/PassOwnPtr#<U>& o) |
| 99 | { |
| 100 | T* ptr = m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr.; |
| 101 | m_ptrcxx . . $ QTWTF/OwnPtr#m_ptr. = o.release(); |
| 102 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!ptr || m_ptr != ptr); |
| 103 | if (ptr) |
| 104 | deleteOwnedPtrcxx . . $ QTWTF/deleteOwnedPtr(ebd0a1552f8ce24f).(ptr); |
| 105 | return *this; |
| 106 | } |
| 107 | |
| 108 | template <typename T> inline void swapcxx . . $ QTWTF/swap(f10587e1e1cab82f).(OwnPtrcxx . . $ QTWTF/OwnPtr#<T>& a, OwnPtrcxx . . $ QTWTF/OwnPtr#<T>& b) |
| 109 | { |
| 110 | a.swapcxx . . $ QTWTF/OwnPtr#swap(18ce991cd1458433).(b); |
| 111 | } |
| 112 | |
| 113 | template <typename T, typename U> inline bool operatorcxx . . $ QTWTF/`operator==`(f838b2bc7e5b4b06).==(const OwnPtrcxx . . $ QTWTF/OwnPtr#<T>& a, U* b) |
| 114 | { |
| 115 | return a.getcxx . . $ QTWTF/OwnPtr#get(6fc1a68e4b3baa22).() ==cxx . . $ QTWTF/`operator==`(80d3fa33a1df3c2c). b; |
| 116 | } |
| 117 | |
| 118 | template <typename T, typename U> inline bool operatorcxx . . $ QTWTF/`operator==`(e47811f5710122ad).==(T* a, const OwnPtrcxx . . $ QTWTF/OwnPtr#<U>& b) |
| 119 | { |
| 120 | return a ==cxx . . $ QTWTF/`operator==`(31369b2754de4004). b.getcxx . . $ QTWTF/OwnPtr#get(6fc1a68e4b3baa22).(); |
| 121 | } |
| 122 | |
| 123 | template <typename T, typename U> inline bool operatorcxx . . $ QTWTF/`operator!=`(f838b2bc7e5b4b06).!=(const OwnPtrcxx . . $ QTWTF/OwnPtr#<T>& a, U* b) |
| 124 | { |
| 125 | return a.getcxx . . $ QTWTF/OwnPtr#get(6fc1a68e4b3baa22).() !=cxx . . $ QTWTF/`operator!=`(69feba05d53a7241). b; |
| 126 | } |
| 127 | |
| 128 | template <typename T, typename U> inline bool operatorcxx . . $ QTWTF/`operator!=`(e47811f5710122ad).!=(T* a, const OwnPtrcxx . . $ QTWTF/OwnPtr#<U>& b) |
| 129 | { |
| 130 | return a !=cxx . . $ QTWTF/`operator!=`(69feba05d53a7241). b.getcxx . . $ QTWTF/OwnPtr#get(6fc1a68e4b3baa22).(); |
| 131 | } |
| 132 | |
| 133 | template <typename T> inline typename OwnPtrcxx . . $ QTWTF/OwnPtr#<T>::PtrType getPtrcxx . . $ QTWTF/getPtr(3156f71726a9fafd).(const OwnPtrcxx . . $ QTWTF/OwnPtr#<T>& p) |
| 134 | { |
| 135 | return p.getcxx . . $ QTWTF/OwnPtr#get(6fc1a68e4b3baa22).(); |
| 136 | } |
| 137 | |
| 138 | } // namespace WTF |
| 139 | |
| 140 | using WTFcxx . . $ QTWTF/::OwnPtrcxx . . $ OwnPtr#; |
| 141 | |
| 142 | #endif // WTF_OwnPtr_h |