Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/API/JSRetainPtr.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef JSRetainPtr_h
30 #define JSRetainPtr_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/API/JSRetainPtr.h:30:9`!
31
32 #include <JavaScriptCore/JSStringRef.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSStringRef.h`/
33 #include <algorithm>
34
35 inline void JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(JSStringRefcxx . . $ JSStringRef# string) { JSStringRetain(string); }
36 inline void JSReleasecxx . . $ JSRelease(1ebc78f313a0a2cd).(JSStringRefcxx . . $ JSStringRef# string) { JSStringRelease(string); }
37
38 enum AdoptTagcxx . . $ AdoptTag# { Adoptcxx . . $ Adopt. };
39
40 template <typename T> class JSRetainPtrcxx . . $ JSRetainPtr# {
41 public:
42 JSRetainPtrcxx . . $ JSRetainPtr#`JSRetainPtr<T>`(49f6e7a06ebc5aa8).() : m_ptrcxx . . $ JSRetainPtr#m_ptr.(0) {}
43 JSRetainPtrcxx . . $ JSRetainPtr#`JSRetainPtr<T>`(9b289cee16747614).(T ptr) : m_ptrcxx . . $ JSRetainPtr#m_ptr.(ptr) { if (ptr) JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(ptr); }
44
45 JSRetainPtrcxx . . $ JSRetainPtr#`JSRetainPtr<T>`(c44fcb308729c47e).(AdoptTagcxx . . $ AdoptTag#, T ptr) : m_ptrcxx . . $ JSRetainPtr#m_ptr.(ptr) { }
46
47 JSRetainPtrcxx . . $ JSRetainPtr#`JSRetainPtr<T>`(c5978eb47f4e2b3).(const JSRetainPtr& o) : m_ptrcxx . . $ JSRetainPtr#m_ptr.(o.m_ptrcxx . . $ JSRetainPtr#m_ptr.) { if (T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.) JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(ptr); }
48
49 ~cxx . . $ JSRetainPtr#`~JSRetainPtr<T>`(49f6e7a06ebc5aa8).JSRetainPtr() { if (T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.) JSReleasecxx . . $ JSRelease(1ebc78f313a0a2cd).(ptr); }
50
51 template <typename U> JSRetainPtrcxx . . $ JSRetainPtr#`JSRetainPtr<T>`(2054646abb816da8).(const JSRetainPtrcxx . . $ JSRetainPtr#<U>& o) : m_ptrcxx . . $ JSRetainPtr#m_ptr.(o.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).()) { if (T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.) JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(ptr); }
52
53 T getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).() const { return m_ptrcxx . . $ JSRetainPtr#m_ptr.; }
54
55 T releaseRefcxx . . $ JSRetainPtr#releaseRef(5f357b03ed472e5e).() { T tmp = m_ptrcxx . . $ JSRetainPtr#m_ptr.; m_ptrcxx . . $ JSRetainPtr#m_ptr. = 0; return tmp; }
56
57 T operatorcxx . . $ JSRetainPtr#`operator->`(8f5363d873dd4781).->() const { return m_ptrcxx . . $ JSRetainPtr#m_ptr.; }
58
59 bool operatorcxx . . $ JSRetainPtr#`operator!`(50ce9a9e25b4a850).!() const { return !m_ptrcxx . . $ JSRetainPtr#m_ptr.; }
60
61 // This conversion operator allows implicit conversion to bool but not to other integer types.
62 typedef T JSRetainPtrcxx . . $ JSRetainPtr#::*UnspecifiedBoolTypecxx . . $ JSRetainPtr#UnspecifiedBoolType#;
63 operatorcxx . . $ JSRetainPtr#`operator type-parameter-0-0 JSRetainPtr<T>::*`(e42d2fce3f4f29). UnspecifiedBoolTypecxx . . $ JSRetainPtr#UnspecifiedBoolType#() const { return m_ptrcxx . . $ JSRetainPtr#m_ptr. ? &JSRetainPtrcxx . . $ JSRetainPtr#::m_ptrcxx . . $ JSRetainPtr#m_ptr. : 0; }
64
65 JSRetainPtr& operatorcxx . . $ JSRetainPtr#`operator=`(c6b8d7a3edf4955a).=(const JSRetainPtr&);
66 template <typename U> JSRetainPtr& operatorcxx . . $ JSRetainPtr#`operator=`(55502125f708766e).=(const JSRetainPtrcxx . . $ JSRetainPtr#<U>&);
67 JSRetainPtr& operatorcxx . . $ JSRetainPtr#`operator=`(1d2d2d8447d12ee4).=(T);
68 template <typename U> JSRetainPtr& operatorcxx . . $ JSRetainPtr#`operator=`(2c4a8b85a1b5141).=(U*);
69
70 void adoptcxx . . $ JSRetainPtr#adopt(9b289cee16747614).(T);
71
72 void swapcxx . . $ JSRetainPtr#swap(724d780811ad6541).(JSRetainPtr&);
73
74 private:
75 T m_ptrcxx . . $ JSRetainPtr#m_ptr.;
76 };
77
78 template <typename T> inline JSRetainPtrcxx . . $ JSRetainPtr#<T>& JSRetainPtrcxx . . $ JSRetainPtr#<T>::operatorcxx . . $ JSRetainPtr#`operator=`(c6b8d7a3edf4955a).=(const JSRetainPtrcxx . . $ JSRetainPtr#<T>& o)
79 {
80 T optr = o.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).();
81 if (optr)
82 JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(optr);
83 T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.;
84 m_ptrcxx . . $ JSRetainPtr#m_ptr. = optr;
85 if (ptr)
86 JSReleasecxx . . $ JSRelease(1ebc78f313a0a2cd).(ptr);
87 return *this;
88 }
89
90 template <typename T> template <typename U> inline JSRetainPtrcxx . . $ JSRetainPtr#<T>& JSRetainPtrcxx . . $ JSRetainPtr#<T>::operatorcxx . . $ JSRetainPtr#`operator=`(55502125f708766e).=(const JSRetainPtrcxx . . $ JSRetainPtr#<U>& o)
91 {
92 T optr = o.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).();
93 if (optr)
94 JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(optr);
95 T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.;
96 m_ptrcxx . . $ JSRetainPtr#m_ptr. = optr;
97 if (ptr)
98 JSReleasecxx . . $ JSRelease(1ebc78f313a0a2cd).(ptr);
99 return *this;
100 }
101
102 template <typename T> inline JSRetainPtrcxx . . $ JSRetainPtr#<T>& JSRetainPtrcxx . . $ JSRetainPtr#<T>::operatorcxx . . $ JSRetainPtr#`operator=`(1d2d2d8447d12ee4).=(T optr)
103 {
104 if (optr)
105 JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(optr);
106 T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.;
107 m_ptrcxx . . $ JSRetainPtr#m_ptr. = optr;
108 if (ptr)
109 JSReleasecxx . . $ JSRelease(1ebc78f313a0a2cd).(ptr);
110 return *this;
111 }
112
113 template <typename T> inline void JSRetainPtrcxx . . $ JSRetainPtr#<T>::adoptcxx . . $ JSRetainPtr#adopt(9b289cee16747614).(T optr)
114 {
115 T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.;
116 m_ptrcxx . . $ JSRetainPtr#m_ptr. = optr;
117 if (ptr)
118 JSReleasecxx . . $ JSRelease(1ebc78f313a0a2cd).(ptr);
119 }
120
121 template <typename T> template <typename U> inline JSRetainPtrcxx . . $ JSRetainPtr#<T>& JSRetainPtrcxx . . $ JSRetainPtr#<T>::operatorcxx . . $ JSRetainPtr#`operator=`(2c4a8b85a1b5141).=(U* optr)
122 {
123 if (optr)
124 JSRetaincxx . . $ JSRetain(1ebc78f313a0a2cd).(optr);
125 T ptr = m_ptrcxx . . $ JSRetainPtr#m_ptr.;
126 m_ptrcxx . . $ JSRetainPtr#m_ptr. = optr;
127 if (ptr)
128 JSReleasecxx . . $ JSRelease(1ebc78f313a0a2cd).(ptr);
129 return *this;
130 }
131
132 template <class T> inline void JSRetainPtrcxx . . $ JSRetainPtr#<T>::swapcxx . . $ JSRetainPtr#swap(724d780811ad6541).(JSRetainPtrcxx . . $ JSRetainPtr#<T>& o)
133 {
134 std::swapcxx . . $ std/swap(f89c42d3de5cf18b).(m_ptrcxx . . $ JSRetainPtr#m_ptr., o.m_ptrcxx . . $ JSRetainPtr#m_ptr.);
135 }
136
137 template <class T> inline void swapcxx . . $ swap(303b9c6d27ec5bc7).(JSRetainPtrcxx . . $ JSRetainPtr#<T>& a, JSRetainPtrcxx . . $ JSRetainPtr#<T>& b)
138 {
139 a.swapcxx . . $ JSRetainPtr#swap(724d780811ad6541).(b);
140 }
141
142 template <typename T, typename U> inline bool operatorcxx . . $ `operator==`(1de8f12a89881407).==(const JSRetainPtrcxx . . $ JSRetainPtr#<T>& a, const JSRetainPtrcxx . . $ JSRetainPtr#<U>& b)
143 {
144 return a.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).() ==cxx . . $ `operator==`(1de8f12a89881407). b.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).();
145 }
146
147 template <typename T, typename U> inline bool operatorcxx . . $ `operator==`(8d3da602b8ab00fb).==(const JSRetainPtrcxx . . $ JSRetainPtr#<T>& a, U* b)
148 {
149 return a.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).() ==cxx . . $ `operator==`(8d3da602b8ab00fb). b;
150 }
151
152 template <typename T, typename U> inline bool operatorcxx . . $ `operator==`(6e1b14f8233bd4af).==(T* a, const JSRetainPtrcxx . . $ JSRetainPtr#<U>& b)
153 {
154 return a ==cxx . . $ `operator==`(6e1b14f8233bd4af). b.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).();
155 }
156
157 template <typename T, typename U> inline bool operatorcxx . . $ `operator!=`(1de8f12a89881407).!=(const JSRetainPtrcxx . . $ JSRetainPtr#<T>& a, const JSRetainPtrcxx . . $ JSRetainPtr#<U>& b)
158 {
159 return a.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).() !=cxx . . $ `operator!=`(1de8f12a89881407). b.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).();
160 }
161
162 template <typename T, typename U> inline bool operatorcxx . . $ `operator!=`(8d3da602b8ab00fb).!=(const JSRetainPtrcxx . . $ JSRetainPtr#<T>& a, U* b)
163 {
164 return a.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).() !=cxx . . $ `operator!=`(8d3da602b8ab00fb). b;
165 }
166
167 template <typename T, typename U> inline bool operatorcxx . . $ `operator!=`(6e1b14f8233bd4af).!=(T* a, const JSRetainPtrcxx . . $ JSRetainPtr#<U>& b)
168 {
169 return a !=cxx . . $ `operator!=`(6e1b14f8233bd4af). b.getcxx . . $ JSRetainPtr#get(8f5363d873dd4781).();
170 }
171
172
173 #endif // JSRetainPtr_h