OLD | NEW |
---|---|
1 // This file was GENERATED by command: | 1 // This file was GENERATED by command: |
2 // pump.py bind_internal.h.pump | 2 // pump.py bind_internal.h.pump |
3 // DO NOT EDIT BY HAND!!! | 3 // DO NOT EDIT BY HAND!!! |
4 | 4 |
5 | 5 |
6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
7 // Use of this source code is governed by a BSD-style license that can be | 7 // Use of this source code is governed by a BSD-style license that can be |
8 // found in the LICENSE file. | 8 // found in the LICENSE file. |
9 | 9 |
10 #ifndef BASE_BIND_INTERNAL_H_ | 10 #ifndef BASE_BIND_INTERNAL_H_ |
11 #define BASE_BIND_INTERNAL_H_ | 11 #define BASE_BIND_INTERNAL_H_ |
12 #pragma once | 12 #pragma once |
13 | 13 |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
16 #include "base/template_util.h" | 16 #include "base/template_util.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 // The method by which a function is invoked is determined by 3 different | 21 // The method by which a function is invoked is determined by 3 different |
22 // dimensions: | 22 // dimensions: |
23 // | 23 // |
24 // 1) The type of function (normal, method, const-method) | 24 // 1) The type of function (normal, or method). |
willchan no longer on Chromium
2011/02/18 06:39:49
no comma
awong
2011/02/18 22:46:54
Blah.
http://en.wikipedia.org/wiki/Serial_comma
| |
25 // 2) The arity of the function | 25 // 2) The arity of the function. |
26 // 3) The number of bound parameters. | 26 // 3) The number of bound parameters. |
27 // | 27 // |
28 // The FunctionTraitsN classes unwrap the function signature type to | 28 // The templates below handle the determination of each of these dimensions. |
29 // specialize based on the first two dimensions. The N in FunctionTraitsN | 29 // In brief: |
30 // specifies the 3rd dimension. We could have specified the unbound parameters | 30 // |
31 // via template parameters, but this method looked cleaner. | 31 // FunctionTraits<> -- Provides a normalied signature, and other traits. |
32 // | 32 // InvokerN<> -- Provides a DoInvoke() function that actually executes |
33 // The FunctionTraitsN contains a static DoInvoke() function that is the key to | 33 // a calback. |
34 // implementing type erasure in the Callback() classes. DoInvoke() is a static | 34 // InvokerStorageN<> -- Provides storage for the bound parameters, and |
35 // function with a fixed signature that is independent of StorageType; its | 35 // typedefs to the above. |
36 // first argument is a pointer to the non-templated common baseclass of | 36 // |
37 // StorageType. This lets us store pointer to DoInvoke() in a function pointer | 37 // More details about the design of each class is included in a comment closer |
38 // that has knowledge of the specific StorageType, and thus no knowledge of the | 38 // to their defition. |
39 // bound function and bound parameter types. | 39 |
willchan no longer on Chromium
2011/02/18 06:39:49
Unnecessary extra newline.
awong
2011/02/18 22:46:54
Done.
| |
40 | |
41 // FunctionTraits<> | |
42 // | |
43 // The FunctionTraits<> template determines the type of function, and also | |
44 // creates a NormalizedType used to select the InvokerN classes. It turns out | |
45 // that syntactically, you only really have 2 variations when invoking a | |
46 // funciton pointer: normal, and method. One is invoked func_ptr(arg1). The | |
47 // other is invoked (*obj_->methd_ptr(arg1)). | |
willchan no longer on Chromium
2011/02/18 06:39:49
methd_ptr=>method_ptr
awong
2011/02/18 22:46:54
Done.
| |
48 // | |
49 // However, in the type system, there are many more distinctions. In standard | |
50 // C++, there's all variations of const, and volatile on the function pointer. | |
51 // In Windows, there are additional calling conventions (eg., __stdcall, | |
52 // __fastcall, etc.). FunctionTraits<> handles categorizing each of these into | |
53 // a normalized signature. | |
54 // | |
55 // Having a NoramlizedSignature signature, reduces the combinatoric | |
willchan no longer on Chromium
2011/02/18 06:39:49
NormalizedSignature
awong
2011/02/18 22:46:54
Done.
| |
56 // complexity of defintions for the InvokerN<> later. Even though there are | |
57 // only 2 syntactic variantions on invoking a function, without | |
willchan no longer on Chromium
2011/02/18 06:39:49
variations
awong
2011/02/18 22:46:54
Done.
| |
58 // normalizing the signature, there would need to be on specialization of | |
willchan no longer on Chromium
2011/02/18 06:39:49
on=>one
awong
2011/02/18 22:46:54
Done.
| |
59 // InvokerN for each unique (function_type, bound_arg, unbound_args) tuple | |
60 // in order to match all function signatures. | |
61 // | |
62 // By normalizing the function signature, we reduce function_type to exactly 2. | |
63 | |
64 template <typename Sig> | |
65 struct FunctionTraits; | |
66 | |
67 // Function: Arity 0. | |
68 template <typename R> | |
69 struct FunctionTraits<R(*)()> { | |
70 typedef R (*NormalizedSig)(); | |
71 typedef base::false_type IsMethod; | |
72 }; | |
73 | |
74 // Method: Arity 0. | |
75 template <typename R, typename T> | |
76 struct FunctionTraits<R(T::*)()> { | |
77 typedef R (T::*NormalizedSig)(); | |
78 typedef base::true_type IsMethod; | |
79 }; | |
80 | |
81 // Const Method: Arity 0. | |
82 template <typename R, typename T> | |
83 struct FunctionTraits<R(T::*)() const> { | |
84 typedef R (T::*NormalizedSig)(); | |
85 typedef base::true_type IsMethod; | |
86 }; | |
87 | |
88 // Function: Arity 1. | |
89 template <typename R, typename X1> | |
90 struct FunctionTraits<R(*)(X1)> { | |
91 typedef R (*NormalizedSig)(X1); | |
92 typedef base::false_type IsMethod; | |
93 }; | |
94 | |
95 // Method: Arity 1. | |
96 template <typename R, typename T, typename X1> | |
97 struct FunctionTraits<R(T::*)(X1)> { | |
98 typedef R (T::*NormalizedSig)(X1); | |
99 typedef base::true_type IsMethod; | |
100 }; | |
101 | |
102 // Const Method: Arity 1. | |
103 template <typename R, typename T, typename X1> | |
104 struct FunctionTraits<R(T::*)(X1) const> { | |
105 typedef R (T::*NormalizedSig)(X1); | |
106 typedef base::true_type IsMethod; | |
107 }; | |
108 | |
109 // Function: Arity 2. | |
110 template <typename R, typename X1, typename X2> | |
111 struct FunctionTraits<R(*)(X1, X2)> { | |
112 typedef R (*NormalizedSig)(X1, X2); | |
113 typedef base::false_type IsMethod; | |
114 }; | |
115 | |
116 // Method: Arity 2. | |
117 template <typename R, typename T, typename X1, typename X2> | |
118 struct FunctionTraits<R(T::*)(X1, X2)> { | |
119 typedef R (T::*NormalizedSig)(X1, X2); | |
120 typedef base::true_type IsMethod; | |
121 }; | |
122 | |
123 // Const Method: Arity 2. | |
124 template <typename R, typename T, typename X1, typename X2> | |
125 struct FunctionTraits<R(T::*)(X1, X2) const> { | |
126 typedef R (T::*NormalizedSig)(X1, X2); | |
127 typedef base::true_type IsMethod; | |
128 }; | |
129 | |
130 // Function: Arity 3. | |
131 template <typename R, typename X1, typename X2, typename X3> | |
132 struct FunctionTraits<R(*)(X1, X2, X3)> { | |
133 typedef R (*NormalizedSig)(X1, X2, X3); | |
134 typedef base::false_type IsMethod; | |
135 }; | |
136 | |
137 // Method: Arity 3. | |
138 template <typename R, typename T, typename X1, typename X2, typename X3> | |
139 struct FunctionTraits<R(T::*)(X1, X2, X3)> { | |
140 typedef R (T::*NormalizedSig)(X1, X2, X3); | |
141 typedef base::true_type IsMethod; | |
142 }; | |
143 | |
144 // Const Method: Arity 3. | |
145 template <typename R, typename T, typename X1, typename X2, typename X3> | |
146 struct FunctionTraits<R(T::*)(X1, X2, X3) const> { | |
147 typedef R (T::*NormalizedSig)(X1, X2, X3); | |
148 typedef base::true_type IsMethod; | |
149 }; | |
150 | |
151 // Function: Arity 4. | |
152 template <typename R, typename X1, typename X2, typename X3, typename X4> | |
153 struct FunctionTraits<R(*)(X1, X2, X3, X4)> { | |
154 typedef R (*NormalizedSig)(X1, X2, X3, X4); | |
155 typedef base::false_type IsMethod; | |
156 }; | |
157 | |
158 // Method: Arity 4. | |
159 template <typename R, typename T, typename X1, typename X2, typename X3, | |
160 typename X4> | |
161 struct FunctionTraits<R(T::*)(X1, X2, X3, X4)> { | |
162 typedef R (T::*NormalizedSig)(X1, X2, X3, X4); | |
163 typedef base::true_type IsMethod; | |
164 }; | |
165 | |
166 // Const Method: Arity 4. | |
167 template <typename R, typename T, typename X1, typename X2, typename X3, | |
168 typename X4> | |
169 struct FunctionTraits<R(T::*)(X1, X2, X3, X4) const> { | |
170 typedef R (T::*NormalizedSig)(X1, X2, X3, X4); | |
171 typedef base::true_type IsMethod; | |
172 }; | |
173 | |
174 // Function: Arity 5. | |
175 template <typename R, typename X1, typename X2, typename X3, typename X4, | |
176 typename X5> | |
177 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5)> { | |
178 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5); | |
179 typedef base::false_type IsMethod; | |
180 }; | |
181 | |
182 // Method: Arity 5. | |
183 template <typename R, typename T, typename X1, typename X2, typename X3, | |
184 typename X4, typename X5> | |
185 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5)> { | |
186 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); | |
187 typedef base::true_type IsMethod; | |
188 }; | |
189 | |
190 // Const Method: Arity 5. | |
191 template <typename R, typename T, typename X1, typename X2, typename X3, | |
192 typename X4, typename X5> | |
193 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5) const> { | |
194 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); | |
195 typedef base::true_type IsMethod; | |
196 }; | |
197 | |
198 // Function: Arity 6. | |
199 template <typename R, typename X1, typename X2, typename X3, typename X4, | |
200 typename X5, typename X6> | |
201 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5, X6)> { | |
202 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5, X6); | |
203 typedef base::false_type IsMethod; | |
204 }; | |
205 | |
206 // Method: Arity 6. | |
207 template <typename R, typename T, typename X1, typename X2, typename X3, | |
208 typename X4, typename X5, typename X6> | |
209 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6)> { | |
210 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); | |
211 typedef base::true_type IsMethod; | |
212 }; | |
213 | |
214 // Const Method: Arity 6. | |
215 template <typename R, typename T, typename X1, typename X2, typename X3, | |
216 typename X4, typename X5, typename X6> | |
217 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6) const> { | |
218 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); | |
219 typedef base::true_type IsMethod; | |
220 }; | |
221 | |
222 // InvokerN<> | |
223 // | |
224 // The InvokerN templates contain a static DoInvoke() function that is the key | |
225 // to implementing type erasure in the Callback() classes. | |
226 // | |
227 // DoInvoke() is a static function with a fixed signature that is independent | |
228 // of StorageType; its first argument is a pointer to the non-templated common | |
229 // baseclass of StorageType. This lets us store pointer to DoInvoke() in a | |
230 // function pointer that has knowledge of the specific StorageType, and thus | |
231 // no knowledge of the bound function and bound parameter types. | |
40 // | 232 // |
41 // As long as we ensure that DoInvoke() is only used with pointers there were | 233 // As long as we ensure that DoInvoke() is only used with pointers there were |
42 // upcasted from the correct StorageType, we can be sure that execution is | 234 // upcasted from the correct StorageType, we can be sure that execution is |
43 // safe. | 235 // safe. |
44 | 236 // |
45 template <typename StorageType, typename Sig> | 237 // The InvokerN templates are the only point that knows the number of bound |
46 struct FunctionTraits0; | 238 // and unbound arguments. This is intentional because it allows the other |
239 // templates classes in the system to only have as many specializations as | |
240 // the max arity of function we wish to support. | |
241 | |
242 template <typename StorageType, typename NormalizedSig> | |
243 struct Invoker0; | |
47 | 244 |
48 // Function: Arity 0 -> 0. | 245 // Function: Arity 0 -> 0. |
49 template <typename StorageType, typename R> | 246 template <typename StorageType, typename R> |
50 struct FunctionTraits0<StorageType, R(*)()> { | 247 struct Invoker0<StorageType, R(*)()> { |
51 typedef base::false_type IsMethod; | |
52 | |
53 static R DoInvoke(InvokerStorageBase* base) { | 248 static R DoInvoke(InvokerStorageBase* base) { |
54 StorageType* invoker = static_cast<StorageType*>(base); | 249 StorageType* invoker = static_cast<StorageType*>(base); |
55 return invoker->f_(); | 250 return invoker->f_(); |
56 } | 251 } |
57 }; | 252 }; |
58 | 253 |
59 // Function: Arity 1 -> 1. | 254 // Function: Arity 1 -> 1. |
60 template <typename StorageType, typename R,typename X1> | 255 template <typename StorageType, typename R,typename X1> |
61 struct FunctionTraits0<StorageType, R(*)(X1)> { | 256 struct Invoker0<StorageType, R(*)(X1)> { |
62 COMPILE_ASSERT( | 257 COMPILE_ASSERT( |
63 !( is_non_const_reference<X1>::value ), | 258 !( is_non_const_reference<X1>::value ), |
64 do_not_bind_functions_with_nonconst_ref); | 259 do_not_bind_functions_with_nonconst_ref); |
65 | 260 |
66 typedef base::false_type IsMethod; | |
67 | |
68 static R DoInvoke(InvokerStorageBase* base, const X1& x1) { | 261 static R DoInvoke(InvokerStorageBase* base, const X1& x1) { |
69 StorageType* invoker = static_cast<StorageType*>(base); | 262 StorageType* invoker = static_cast<StorageType*>(base); |
70 return invoker->f_(x1); | 263 return invoker->f_(x1); |
71 } | 264 } |
72 }; | 265 }; |
73 | 266 |
74 // Function: Arity 2 -> 2. | 267 // Function: Arity 2 -> 2. |
75 template <typename StorageType, typename R,typename X1, typename X2> | 268 template <typename StorageType, typename R,typename X1, typename X2> |
76 struct FunctionTraits0<StorageType, R(*)(X1, X2)> { | 269 struct Invoker0<StorageType, R(*)(X1, X2)> { |
77 COMPILE_ASSERT( | 270 COMPILE_ASSERT( |
78 !( is_non_const_reference<X1>::value || | 271 !( is_non_const_reference<X1>::value || |
79 is_non_const_reference<X2>::value ), | 272 is_non_const_reference<X2>::value ), |
80 do_not_bind_functions_with_nonconst_ref); | 273 do_not_bind_functions_with_nonconst_ref); |
81 | 274 |
82 typedef base::false_type IsMethod; | |
83 | |
84 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2) { | 275 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2) { |
85 StorageType* invoker = static_cast<StorageType*>(base); | 276 StorageType* invoker = static_cast<StorageType*>(base); |
86 return invoker->f_(x1, x2); | 277 return invoker->f_(x1, x2); |
87 } | 278 } |
88 }; | 279 }; |
89 | 280 |
90 // Function: Arity 3 -> 3. | 281 // Function: Arity 3 -> 3. |
91 template <typename StorageType, typename R,typename X1, typename X2, | 282 template <typename StorageType, typename R,typename X1, typename X2, |
92 typename X3> | 283 typename X3> |
93 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3)> { | 284 struct Invoker0<StorageType, R(*)(X1, X2, X3)> { |
94 COMPILE_ASSERT( | 285 COMPILE_ASSERT( |
95 !( is_non_const_reference<X1>::value || | 286 !( is_non_const_reference<X1>::value || |
96 is_non_const_reference<X2>::value || | 287 is_non_const_reference<X2>::value || |
97 is_non_const_reference<X3>::value ), | 288 is_non_const_reference<X3>::value ), |
98 do_not_bind_functions_with_nonconst_ref); | 289 do_not_bind_functions_with_nonconst_ref); |
99 | 290 |
100 typedef base::false_type IsMethod; | |
101 | |
102 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | 291 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, |
103 const X3& x3) { | 292 const X3& x3) { |
104 StorageType* invoker = static_cast<StorageType*>(base); | 293 StorageType* invoker = static_cast<StorageType*>(base); |
105 return invoker->f_(x1, x2, x3); | 294 return invoker->f_(x1, x2, x3); |
106 } | 295 } |
107 }; | 296 }; |
108 | 297 |
109 // Function: Arity 4 -> 4. | 298 // Function: Arity 4 -> 4. |
110 template <typename StorageType, typename R,typename X1, typename X2, | 299 template <typename StorageType, typename R,typename X1, typename X2, |
111 typename X3, typename X4> | 300 typename X3, typename X4> |
112 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4)> { | 301 struct Invoker0<StorageType, R(*)(X1, X2, X3, X4)> { |
113 COMPILE_ASSERT( | 302 COMPILE_ASSERT( |
114 !( is_non_const_reference<X1>::value || | 303 !( is_non_const_reference<X1>::value || |
115 is_non_const_reference<X2>::value || | 304 is_non_const_reference<X2>::value || |
116 is_non_const_reference<X3>::value || | 305 is_non_const_reference<X3>::value || |
117 is_non_const_reference<X4>::value ), | 306 is_non_const_reference<X4>::value ), |
118 do_not_bind_functions_with_nonconst_ref); | 307 do_not_bind_functions_with_nonconst_ref); |
119 | 308 |
120 typedef base::false_type IsMethod; | |
121 | |
122 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | 309 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, |
123 const X3& x3, const X4& x4) { | 310 const X3& x3, const X4& x4) { |
124 StorageType* invoker = static_cast<StorageType*>(base); | 311 StorageType* invoker = static_cast<StorageType*>(base); |
125 return invoker->f_(x1, x2, x3, x4); | 312 return invoker->f_(x1, x2, x3, x4); |
126 } | 313 } |
127 }; | 314 }; |
128 | 315 |
129 // Function: Arity 5 -> 5. | 316 // Function: Arity 5 -> 5. |
130 template <typename StorageType, typename R,typename X1, typename X2, | 317 template <typename StorageType, typename R,typename X1, typename X2, |
131 typename X3, typename X4, typename X5> | 318 typename X3, typename X4, typename X5> |
132 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5)> { | 319 struct Invoker0<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
133 COMPILE_ASSERT( | 320 COMPILE_ASSERT( |
134 !( is_non_const_reference<X1>::value || | 321 !( is_non_const_reference<X1>::value || |
135 is_non_const_reference<X2>::value || | 322 is_non_const_reference<X2>::value || |
136 is_non_const_reference<X3>::value || | 323 is_non_const_reference<X3>::value || |
137 is_non_const_reference<X4>::value || | 324 is_non_const_reference<X4>::value || |
138 is_non_const_reference<X5>::value ), | 325 is_non_const_reference<X5>::value ), |
139 do_not_bind_functions_with_nonconst_ref); | 326 do_not_bind_functions_with_nonconst_ref); |
140 | 327 |
141 typedef base::false_type IsMethod; | |
142 | |
143 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | 328 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, |
144 const X3& x3, const X4& x4, const X5& x5) { | 329 const X3& x3, const X4& x4, const X5& x5) { |
145 StorageType* invoker = static_cast<StorageType*>(base); | 330 StorageType* invoker = static_cast<StorageType*>(base); |
146 return invoker->f_(x1, x2, x3, x4, x5); | 331 return invoker->f_(x1, x2, x3, x4, x5); |
147 } | 332 } |
148 }; | 333 }; |
149 | 334 |
150 // Function: Arity 6 -> 6. | 335 // Function: Arity 6 -> 6. |
151 template <typename StorageType, typename R,typename X1, typename X2, | 336 template <typename StorageType, typename R,typename X1, typename X2, |
152 typename X3, typename X4, typename X5, typename X6> | 337 typename X3, typename X4, typename X5, typename X6> |
153 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 338 struct Invoker0<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
154 COMPILE_ASSERT( | 339 COMPILE_ASSERT( |
155 !( is_non_const_reference<X1>::value || | 340 !( is_non_const_reference<X1>::value || |
156 is_non_const_reference<X2>::value || | 341 is_non_const_reference<X2>::value || |
157 is_non_const_reference<X3>::value || | 342 is_non_const_reference<X3>::value || |
158 is_non_const_reference<X4>::value || | 343 is_non_const_reference<X4>::value || |
159 is_non_const_reference<X5>::value || | 344 is_non_const_reference<X5>::value || |
160 is_non_const_reference<X6>::value ), | 345 is_non_const_reference<X6>::value ), |
161 do_not_bind_functions_with_nonconst_ref); | 346 do_not_bind_functions_with_nonconst_ref); |
162 | 347 |
163 typedef base::false_type IsMethod; | |
164 | |
165 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | 348 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, |
166 const X3& x3, const X4& x4, const X5& x5, const X6& x6) { | 349 const X3& x3, const X4& x4, const X5& x5, const X6& x6) { |
167 StorageType* invoker = static_cast<StorageType*>(base); | 350 StorageType* invoker = static_cast<StorageType*>(base); |
168 return invoker->f_(x1, x2, x3, x4, x5, x6); | 351 return invoker->f_(x1, x2, x3, x4, x5, x6); |
169 } | 352 } |
170 }; | 353 }; |
171 | 354 |
172 template <typename StorageType, typename Sig> | 355 template <typename StorageType, typename NormalizedSig> |
173 struct FunctionTraits1; | 356 struct Invoker1; |
174 | 357 |
175 // Function: Arity 1 -> 0. | 358 // Function: Arity 1 -> 0. |
176 template <typename StorageType, typename R,typename X1> | 359 template <typename StorageType, typename R,typename X1> |
177 struct FunctionTraits1<StorageType, R(*)(X1)> { | 360 struct Invoker1<StorageType, R(*)(X1)> { |
178 COMPILE_ASSERT( | 361 COMPILE_ASSERT( |
179 !( is_non_const_reference<X1>::value ), | 362 !( is_non_const_reference<X1>::value ), |
180 do_not_bind_functions_with_nonconst_ref); | 363 do_not_bind_functions_with_nonconst_ref); |
181 | 364 |
182 typedef base::false_type IsMethod; | |
183 | |
184 static R DoInvoke(InvokerStorageBase* base) { | 365 static R DoInvoke(InvokerStorageBase* base) { |
185 StorageType* invoker = static_cast<StorageType*>(base); | 366 StorageType* invoker = static_cast<StorageType*>(base); |
186 return invoker->f_(Unwrap(invoker->p1_)); | 367 return invoker->f_(Unwrap(invoker->p1_)); |
187 } | 368 } |
188 }; | 369 }; |
189 | 370 |
190 // Method: Arity 0 -> 0. | 371 // Method: Arity 0 -> 0. |
191 template <typename StorageType, typename R, typename T> | 372 template <typename StorageType, typename R, typename T> |
192 struct FunctionTraits1<StorageType, R(T::*)()> { | 373 struct Invoker1<StorageType, R(T::*)()> { |
193 typedef base::true_type IsMethod; | |
194 | |
195 static R DoInvoke(InvokerStorageBase* base) { | 374 static R DoInvoke(InvokerStorageBase* base) { |
196 StorageType* invoker = static_cast<StorageType*>(base); | 375 StorageType* invoker = static_cast<StorageType*>(base); |
197 return (Unwrap(invoker->p1_)->*invoker->f_)(); | 376 return (Unwrap(invoker->p1_)->*invoker->f_)(); |
198 } | 377 } |
199 }; | 378 }; |
200 | 379 |
201 // Const Method: Arity 0 -> 0. | |
202 template <typename StorageType, typename R, typename T> | |
203 struct FunctionTraits1<StorageType, R(T::*)() const> { | |
204 typedef base::true_type IsMethod; | |
205 | |
206 static R DoInvoke(InvokerStorageBase* base ) { | |
207 StorageType* invoker = static_cast<StorageType*>(base); | |
208 return (Unwrap(invoker->p1_)->*invoker->f_)(); | |
209 } | |
210 }; | |
211 | |
212 // Function: Arity 2 -> 1. | 380 // Function: Arity 2 -> 1. |
213 template <typename StorageType, typename R,typename X1, typename X2> | 381 template <typename StorageType, typename R,typename X1, typename X2> |
214 struct FunctionTraits1<StorageType, R(*)(X1, X2)> { | 382 struct Invoker1<StorageType, R(*)(X1, X2)> { |
215 COMPILE_ASSERT( | 383 COMPILE_ASSERT( |
216 !( is_non_const_reference<X1>::value || | 384 !( is_non_const_reference<X1>::value || |
217 is_non_const_reference<X2>::value ), | 385 is_non_const_reference<X2>::value ), |
218 do_not_bind_functions_with_nonconst_ref); | 386 do_not_bind_functions_with_nonconst_ref); |
219 | 387 |
220 typedef base::false_type IsMethod; | |
221 | |
222 static R DoInvoke(InvokerStorageBase* base, const X2& x2) { | 388 static R DoInvoke(InvokerStorageBase* base, const X2& x2) { |
223 StorageType* invoker = static_cast<StorageType*>(base); | 389 StorageType* invoker = static_cast<StorageType*>(base); |
224 return invoker->f_(Unwrap(invoker->p1_), x2); | 390 return invoker->f_(Unwrap(invoker->p1_), x2); |
225 } | 391 } |
226 }; | 392 }; |
227 | 393 |
228 // Method: Arity 1 -> 1. | 394 // Method: Arity 1 -> 1. |
229 template <typename StorageType, typename R, typename T, typename X1> | 395 template <typename StorageType, typename R, typename T, typename X1> |
230 struct FunctionTraits1<StorageType, R(T::*)(X1)> { | 396 struct Invoker1<StorageType, R(T::*)(X1)> { |
231 COMPILE_ASSERT( | 397 COMPILE_ASSERT( |
232 !( is_non_const_reference<X1>::value ), | 398 !( is_non_const_reference<X1>::value ), |
233 do_not_bind_functions_with_nonconst_ref); | 399 do_not_bind_functions_with_nonconst_ref); |
234 | 400 |
235 typedef base::true_type IsMethod; | |
236 | |
237 static R DoInvoke(InvokerStorageBase* base, const X1& x1) { | 401 static R DoInvoke(InvokerStorageBase* base, const X1& x1) { |
238 StorageType* invoker = static_cast<StorageType*>(base); | 402 StorageType* invoker = static_cast<StorageType*>(base); |
239 return (Unwrap(invoker->p1_)->*invoker->f_)(x1); | 403 return (Unwrap(invoker->p1_)->*invoker->f_)(x1); |
240 } | 404 } |
241 }; | 405 }; |
242 | 406 |
243 // Const Method: Arity 1 -> 1. | |
244 template <typename StorageType, typename R, typename T, typename X1> | |
245 struct FunctionTraits1<StorageType, R(T::*)(X1) const> { | |
246 COMPILE_ASSERT( | |
247 !(is_non_const_reference<X1>::value ), | |
248 do_not_bind_functions_with_nonconst_ref); | |
249 | |
250 typedef base::true_type IsMethod; | |
251 | |
252 static R DoInvoke(InvokerStorageBase* base, const X1& x1) { | |
253 StorageType* invoker = static_cast<StorageType*>(base); | |
254 return (Unwrap(invoker->p1_)->*invoker->f_)(x1); | |
255 } | |
256 }; | |
257 | |
258 // Function: Arity 3 -> 2. | 407 // Function: Arity 3 -> 2. |
259 template <typename StorageType, typename R,typename X1, typename X2, | 408 template <typename StorageType, typename R,typename X1, typename X2, |
260 typename X3> | 409 typename X3> |
261 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3)> { | 410 struct Invoker1<StorageType, R(*)(X1, X2, X3)> { |
262 COMPILE_ASSERT( | 411 COMPILE_ASSERT( |
263 !( is_non_const_reference<X1>::value || | 412 !( is_non_const_reference<X1>::value || |
264 is_non_const_reference<X2>::value || | 413 is_non_const_reference<X2>::value || |
265 is_non_const_reference<X3>::value ), | 414 is_non_const_reference<X3>::value ), |
266 do_not_bind_functions_with_nonconst_ref); | 415 do_not_bind_functions_with_nonconst_ref); |
267 | 416 |
268 typedef base::false_type IsMethod; | |
269 | |
270 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3) { | 417 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3) { |
271 StorageType* invoker = static_cast<StorageType*>(base); | 418 StorageType* invoker = static_cast<StorageType*>(base); |
272 return invoker->f_(Unwrap(invoker->p1_), x2, x3); | 419 return invoker->f_(Unwrap(invoker->p1_), x2, x3); |
273 } | 420 } |
274 }; | 421 }; |
275 | 422 |
276 // Method: Arity 2 -> 2. | 423 // Method: Arity 2 -> 2. |
277 template <typename StorageType, typename R, typename T, typename X1, | 424 template <typename StorageType, typename R, typename T, typename X1, |
278 typename X2> | 425 typename X2> |
279 struct FunctionTraits1<StorageType, R(T::*)(X1, X2)> { | 426 struct Invoker1<StorageType, R(T::*)(X1, X2)> { |
280 COMPILE_ASSERT( | 427 COMPILE_ASSERT( |
281 !( is_non_const_reference<X1>::value || | 428 !( is_non_const_reference<X1>::value || |
282 is_non_const_reference<X2>::value ), | 429 is_non_const_reference<X2>::value ), |
283 do_not_bind_functions_with_nonconst_ref); | 430 do_not_bind_functions_with_nonconst_ref); |
284 | 431 |
285 typedef base::true_type IsMethod; | |
286 | |
287 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2) { | 432 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2) { |
288 StorageType* invoker = static_cast<StorageType*>(base); | 433 StorageType* invoker = static_cast<StorageType*>(base); |
289 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); | 434 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); |
290 } | 435 } |
291 }; | 436 }; |
292 | 437 |
293 // Const Method: Arity 2 -> 2. | |
294 template <typename StorageType, typename R, typename T, typename X1, | |
295 typename X2> | |
296 struct FunctionTraits1<StorageType, R(T::*)(X1, X2) const> { | |
297 COMPILE_ASSERT( | |
298 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
299 ), | |
300 do_not_bind_functions_with_nonconst_ref); | |
301 | |
302 typedef base::true_type IsMethod; | |
303 | |
304 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2) { | |
305 StorageType* invoker = static_cast<StorageType*>(base); | |
306 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); | |
307 } | |
308 }; | |
309 | |
310 // Function: Arity 4 -> 3. | 438 // Function: Arity 4 -> 3. |
311 template <typename StorageType, typename R,typename X1, typename X2, | 439 template <typename StorageType, typename R,typename X1, typename X2, |
312 typename X3, typename X4> | 440 typename X3, typename X4> |
313 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4)> { | 441 struct Invoker1<StorageType, R(*)(X1, X2, X3, X4)> { |
314 COMPILE_ASSERT( | 442 COMPILE_ASSERT( |
315 !( is_non_const_reference<X1>::value || | 443 !( is_non_const_reference<X1>::value || |
316 is_non_const_reference<X2>::value || | 444 is_non_const_reference<X2>::value || |
317 is_non_const_reference<X3>::value || | 445 is_non_const_reference<X3>::value || |
318 is_non_const_reference<X4>::value ), | 446 is_non_const_reference<X4>::value ), |
319 do_not_bind_functions_with_nonconst_ref); | 447 do_not_bind_functions_with_nonconst_ref); |
320 | 448 |
321 typedef base::false_type IsMethod; | |
322 | |
323 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, | 449 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, |
324 const X4& x4) { | 450 const X4& x4) { |
325 StorageType* invoker = static_cast<StorageType*>(base); | 451 StorageType* invoker = static_cast<StorageType*>(base); |
326 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4); | 452 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4); |
327 } | 453 } |
328 }; | 454 }; |
329 | 455 |
330 // Method: Arity 3 -> 3. | 456 // Method: Arity 3 -> 3. |
331 template <typename StorageType, typename R, typename T, typename X1, | 457 template <typename StorageType, typename R, typename T, typename X1, |
332 typename X2, typename X3> | 458 typename X2, typename X3> |
333 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3)> { | 459 struct Invoker1<StorageType, R(T::*)(X1, X2, X3)> { |
334 COMPILE_ASSERT( | 460 COMPILE_ASSERT( |
335 !( is_non_const_reference<X1>::value || | 461 !( is_non_const_reference<X1>::value || |
336 is_non_const_reference<X2>::value || | 462 is_non_const_reference<X2>::value || |
337 is_non_const_reference<X3>::value ), | 463 is_non_const_reference<X3>::value ), |
338 do_not_bind_functions_with_nonconst_ref); | 464 do_not_bind_functions_with_nonconst_ref); |
339 | 465 |
340 typedef base::true_type IsMethod; | |
341 | |
342 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | 466 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, |
343 const X3& x3) { | 467 const X3& x3) { |
344 StorageType* invoker = static_cast<StorageType*>(base); | 468 StorageType* invoker = static_cast<StorageType*>(base); |
345 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); | 469 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); |
346 } | 470 } |
347 }; | 471 }; |
348 | 472 |
349 // Const Method: Arity 3 -> 3. | |
350 template <typename StorageType, typename R, typename T, typename X1, | |
351 typename X2, typename X3> | |
352 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3) const> { | |
353 COMPILE_ASSERT( | |
354 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
355 || is_non_const_reference<X3>::value ), | |
356 do_not_bind_functions_with_nonconst_ref); | |
357 | |
358 typedef base::true_type IsMethod; | |
359 | |
360 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | |
361 const X3& x3) { | |
362 StorageType* invoker = static_cast<StorageType*>(base); | |
363 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); | |
364 } | |
365 }; | |
366 | |
367 // Function: Arity 5 -> 4. | 473 // Function: Arity 5 -> 4. |
368 template <typename StorageType, typename R,typename X1, typename X2, | 474 template <typename StorageType, typename R,typename X1, typename X2, |
369 typename X3, typename X4, typename X5> | 475 typename X3, typename X4, typename X5> |
370 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5)> { | 476 struct Invoker1<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
371 COMPILE_ASSERT( | 477 COMPILE_ASSERT( |
372 !( is_non_const_reference<X1>::value || | 478 !( is_non_const_reference<X1>::value || |
373 is_non_const_reference<X2>::value || | 479 is_non_const_reference<X2>::value || |
374 is_non_const_reference<X3>::value || | 480 is_non_const_reference<X3>::value || |
375 is_non_const_reference<X4>::value || | 481 is_non_const_reference<X4>::value || |
376 is_non_const_reference<X5>::value ), | 482 is_non_const_reference<X5>::value ), |
377 do_not_bind_functions_with_nonconst_ref); | 483 do_not_bind_functions_with_nonconst_ref); |
378 | 484 |
379 typedef base::false_type IsMethod; | |
380 | |
381 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, | 485 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, |
382 const X4& x4, const X5& x5) { | 486 const X4& x4, const X5& x5) { |
383 StorageType* invoker = static_cast<StorageType*>(base); | 487 StorageType* invoker = static_cast<StorageType*>(base); |
384 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5); | 488 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5); |
385 } | 489 } |
386 }; | 490 }; |
387 | 491 |
388 // Method: Arity 4 -> 4. | 492 // Method: Arity 4 -> 4. |
389 template <typename StorageType, typename R, typename T, typename X1, | 493 template <typename StorageType, typename R, typename T, typename X1, |
390 typename X2, typename X3, typename X4> | 494 typename X2, typename X3, typename X4> |
391 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4)> { | 495 struct Invoker1<StorageType, R(T::*)(X1, X2, X3, X4)> { |
392 COMPILE_ASSERT( | 496 COMPILE_ASSERT( |
393 !( is_non_const_reference<X1>::value || | 497 !( is_non_const_reference<X1>::value || |
394 is_non_const_reference<X2>::value || | 498 is_non_const_reference<X2>::value || |
395 is_non_const_reference<X3>::value || | 499 is_non_const_reference<X3>::value || |
396 is_non_const_reference<X4>::value ), | 500 is_non_const_reference<X4>::value ), |
397 do_not_bind_functions_with_nonconst_ref); | 501 do_not_bind_functions_with_nonconst_ref); |
398 | 502 |
399 typedef base::true_type IsMethod; | |
400 | |
401 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | 503 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, |
402 const X3& x3, const X4& x4) { | 504 const X3& x3, const X4& x4) { |
403 StorageType* invoker = static_cast<StorageType*>(base); | 505 StorageType* invoker = static_cast<StorageType*>(base); |
404 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); | 506 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); |
405 } | 507 } |
406 }; | 508 }; |
407 | 509 |
408 // Const Method: Arity 4 -> 4. | |
409 template <typename StorageType, typename R, typename T, typename X1, | |
410 typename X2, typename X3, typename X4> | |
411 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
412 COMPILE_ASSERT( | |
413 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
414 || is_non_const_reference<X3>::value || | |
415 is_non_const_reference<X4>::value ), | |
416 do_not_bind_functions_with_nonconst_ref); | |
417 | |
418 typedef base::true_type IsMethod; | |
419 | |
420 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | |
421 const X3& x3, const X4& x4) { | |
422 StorageType* invoker = static_cast<StorageType*>(base); | |
423 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); | |
424 } | |
425 }; | |
426 | |
427 // Function: Arity 6 -> 5. | 510 // Function: Arity 6 -> 5. |
428 template <typename StorageType, typename R,typename X1, typename X2, | 511 template <typename StorageType, typename R,typename X1, typename X2, |
429 typename X3, typename X4, typename X5, typename X6> | 512 typename X3, typename X4, typename X5, typename X6> |
430 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 513 struct Invoker1<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
431 COMPILE_ASSERT( | 514 COMPILE_ASSERT( |
432 !( is_non_const_reference<X1>::value || | 515 !( is_non_const_reference<X1>::value || |
433 is_non_const_reference<X2>::value || | 516 is_non_const_reference<X2>::value || |
434 is_non_const_reference<X3>::value || | 517 is_non_const_reference<X3>::value || |
435 is_non_const_reference<X4>::value || | 518 is_non_const_reference<X4>::value || |
436 is_non_const_reference<X5>::value || | 519 is_non_const_reference<X5>::value || |
437 is_non_const_reference<X6>::value ), | 520 is_non_const_reference<X6>::value ), |
438 do_not_bind_functions_with_nonconst_ref); | 521 do_not_bind_functions_with_nonconst_ref); |
439 | 522 |
440 typedef base::false_type IsMethod; | |
441 | |
442 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, | 523 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, |
443 const X4& x4, const X5& x5, const X6& x6) { | 524 const X4& x4, const X5& x5, const X6& x6) { |
444 StorageType* invoker = static_cast<StorageType*>(base); | 525 StorageType* invoker = static_cast<StorageType*>(base); |
445 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6); | 526 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6); |
446 } | 527 } |
447 }; | 528 }; |
448 | 529 |
449 // Method: Arity 5 -> 5. | 530 // Method: Arity 5 -> 5. |
450 template <typename StorageType, typename R, typename T, typename X1, | 531 template <typename StorageType, typename R, typename T, typename X1, |
451 typename X2, typename X3, typename X4, typename X5> | 532 typename X2, typename X3, typename X4, typename X5> |
452 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 533 struct Invoker1<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
453 COMPILE_ASSERT( | 534 COMPILE_ASSERT( |
454 !( is_non_const_reference<X1>::value || | 535 !( is_non_const_reference<X1>::value || |
455 is_non_const_reference<X2>::value || | 536 is_non_const_reference<X2>::value || |
456 is_non_const_reference<X3>::value || | 537 is_non_const_reference<X3>::value || |
457 is_non_const_reference<X4>::value || | 538 is_non_const_reference<X4>::value || |
458 is_non_const_reference<X5>::value ), | 539 is_non_const_reference<X5>::value ), |
459 do_not_bind_functions_with_nonconst_ref); | 540 do_not_bind_functions_with_nonconst_ref); |
460 | 541 |
461 typedef base::true_type IsMethod; | |
462 | |
463 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | 542 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, |
464 const X3& x3, const X4& x4, const X5& x5) { | 543 const X3& x3, const X4& x4, const X5& x5) { |
465 StorageType* invoker = static_cast<StorageType*>(base); | 544 StorageType* invoker = static_cast<StorageType*>(base); |
466 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); | 545 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); |
467 } | 546 } |
468 }; | 547 }; |
469 | 548 |
470 // Const Method: Arity 5 -> 5. | 549 template <typename StorageType, typename NormalizedSig> |
471 template <typename StorageType, typename R, typename T, typename X1, | 550 struct Invoker2; |
472 typename X2, typename X3, typename X4, typename X5> | |
473 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
474 COMPILE_ASSERT( | |
475 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
476 || is_non_const_reference<X3>::value || | |
477 is_non_const_reference<X4>::value || | |
478 is_non_const_reference<X5>::value ), | |
479 do_not_bind_functions_with_nonconst_ref); | |
480 | |
481 typedef base::true_type IsMethod; | |
482 | |
483 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2, | |
484 const X3& x3, const X4& x4, const X5& x5) { | |
485 StorageType* invoker = static_cast<StorageType*>(base); | |
486 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); | |
487 } | |
488 }; | |
489 | |
490 template <typename StorageType, typename Sig> | |
491 struct FunctionTraits2; | |
492 | 551 |
493 // Function: Arity 2 -> 0. | 552 // Function: Arity 2 -> 0. |
494 template <typename StorageType, typename R,typename X1, typename X2> | 553 template <typename StorageType, typename R,typename X1, typename X2> |
495 struct FunctionTraits2<StorageType, R(*)(X1, X2)> { | 554 struct Invoker2<StorageType, R(*)(X1, X2)> { |
496 COMPILE_ASSERT( | 555 COMPILE_ASSERT( |
497 !( is_non_const_reference<X1>::value || | 556 !( is_non_const_reference<X1>::value || |
498 is_non_const_reference<X2>::value ), | 557 is_non_const_reference<X2>::value ), |
499 do_not_bind_functions_with_nonconst_ref); | 558 do_not_bind_functions_with_nonconst_ref); |
500 | 559 |
501 typedef base::false_type IsMethod; | |
502 | |
503 static R DoInvoke(InvokerStorageBase* base) { | 560 static R DoInvoke(InvokerStorageBase* base) { |
504 StorageType* invoker = static_cast<StorageType*>(base); | 561 StorageType* invoker = static_cast<StorageType*>(base); |
505 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_)); | 562 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_)); |
506 } | 563 } |
507 }; | 564 }; |
508 | 565 |
509 // Method: Arity 1 -> 0. | 566 // Method: Arity 1 -> 0. |
510 template <typename StorageType, typename R, typename T, typename X1> | 567 template <typename StorageType, typename R, typename T, typename X1> |
511 struct FunctionTraits2<StorageType, R(T::*)(X1)> { | 568 struct Invoker2<StorageType, R(T::*)(X1)> { |
512 COMPILE_ASSERT( | 569 COMPILE_ASSERT( |
513 !( is_non_const_reference<X1>::value ), | 570 !( is_non_const_reference<X1>::value ), |
514 do_not_bind_functions_with_nonconst_ref); | 571 do_not_bind_functions_with_nonconst_ref); |
515 | 572 |
516 typedef base::true_type IsMethod; | |
517 | |
518 static R DoInvoke(InvokerStorageBase* base) { | 573 static R DoInvoke(InvokerStorageBase* base) { |
519 StorageType* invoker = static_cast<StorageType*>(base); | 574 StorageType* invoker = static_cast<StorageType*>(base); |
520 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); | 575 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); |
521 } | 576 } |
522 }; | 577 }; |
523 | 578 |
524 // Const Method: Arity 1 -> 0. | |
525 template <typename StorageType, typename R, typename T, typename X1> | |
526 struct FunctionTraits2<StorageType, R(T::*)(X1) const> { | |
527 COMPILE_ASSERT( | |
528 !(is_non_const_reference<X1>::value ), | |
529 do_not_bind_functions_with_nonconst_ref); | |
530 | |
531 typedef base::true_type IsMethod; | |
532 | |
533 static R DoInvoke(InvokerStorageBase* base ) { | |
534 StorageType* invoker = static_cast<StorageType*>(base); | |
535 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); | |
536 } | |
537 }; | |
538 | |
539 // Function: Arity 3 -> 1. | 579 // Function: Arity 3 -> 1. |
540 template <typename StorageType, typename R,typename X1, typename X2, | 580 template <typename StorageType, typename R,typename X1, typename X2, |
541 typename X3> | 581 typename X3> |
542 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3)> { | 582 struct Invoker2<StorageType, R(*)(X1, X2, X3)> { |
543 COMPILE_ASSERT( | 583 COMPILE_ASSERT( |
544 !( is_non_const_reference<X1>::value || | 584 !( is_non_const_reference<X1>::value || |
545 is_non_const_reference<X2>::value || | 585 is_non_const_reference<X2>::value || |
546 is_non_const_reference<X3>::value ), | 586 is_non_const_reference<X3>::value ), |
547 do_not_bind_functions_with_nonconst_ref); | 587 do_not_bind_functions_with_nonconst_ref); |
548 | 588 |
549 typedef base::false_type IsMethod; | |
550 | |
551 static R DoInvoke(InvokerStorageBase* base, const X3& x3) { | 589 static R DoInvoke(InvokerStorageBase* base, const X3& x3) { |
552 StorageType* invoker = static_cast<StorageType*>(base); | 590 StorageType* invoker = static_cast<StorageType*>(base); |
553 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3); | 591 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3); |
554 } | 592 } |
555 }; | 593 }; |
556 | 594 |
557 // Method: Arity 2 -> 1. | 595 // Method: Arity 2 -> 1. |
558 template <typename StorageType, typename R, typename T, typename X1, | 596 template <typename StorageType, typename R, typename T, typename X1, |
559 typename X2> | 597 typename X2> |
560 struct FunctionTraits2<StorageType, R(T::*)(X1, X2)> { | 598 struct Invoker2<StorageType, R(T::*)(X1, X2)> { |
561 COMPILE_ASSERT( | 599 COMPILE_ASSERT( |
562 !( is_non_const_reference<X1>::value || | 600 !( is_non_const_reference<X1>::value || |
563 is_non_const_reference<X2>::value ), | 601 is_non_const_reference<X2>::value ), |
564 do_not_bind_functions_with_nonconst_ref); | 602 do_not_bind_functions_with_nonconst_ref); |
565 | 603 |
566 typedef base::true_type IsMethod; | |
567 | |
568 static R DoInvoke(InvokerStorageBase* base, const X2& x2) { | 604 static R DoInvoke(InvokerStorageBase* base, const X2& x2) { |
569 StorageType* invoker = static_cast<StorageType*>(base); | 605 StorageType* invoker = static_cast<StorageType*>(base); |
570 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); | 606 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); |
571 } | 607 } |
572 }; | 608 }; |
573 | 609 |
574 // Const Method: Arity 2 -> 1. | |
575 template <typename StorageType, typename R, typename T, typename X1, | |
576 typename X2> | |
577 struct FunctionTraits2<StorageType, R(T::*)(X1, X2) const> { | |
578 COMPILE_ASSERT( | |
579 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
580 ), | |
581 do_not_bind_functions_with_nonconst_ref); | |
582 | |
583 typedef base::true_type IsMethod; | |
584 | |
585 static R DoInvoke(InvokerStorageBase* base, const X2& x2) { | |
586 StorageType* invoker = static_cast<StorageType*>(base); | |
587 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); | |
588 } | |
589 }; | |
590 | |
591 // Function: Arity 4 -> 2. | 610 // Function: Arity 4 -> 2. |
592 template <typename StorageType, typename R,typename X1, typename X2, | 611 template <typename StorageType, typename R,typename X1, typename X2, |
593 typename X3, typename X4> | 612 typename X3, typename X4> |
594 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4)> { | 613 struct Invoker2<StorageType, R(*)(X1, X2, X3, X4)> { |
595 COMPILE_ASSERT( | 614 COMPILE_ASSERT( |
596 !( is_non_const_reference<X1>::value || | 615 !( is_non_const_reference<X1>::value || |
597 is_non_const_reference<X2>::value || | 616 is_non_const_reference<X2>::value || |
598 is_non_const_reference<X3>::value || | 617 is_non_const_reference<X3>::value || |
599 is_non_const_reference<X4>::value ), | 618 is_non_const_reference<X4>::value ), |
600 do_not_bind_functions_with_nonconst_ref); | 619 do_not_bind_functions_with_nonconst_ref); |
601 | 620 |
602 typedef base::false_type IsMethod; | |
603 | |
604 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4) { | 621 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4) { |
605 StorageType* invoker = static_cast<StorageType*>(base); | 622 StorageType* invoker = static_cast<StorageType*>(base); |
606 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4); | 623 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4); |
607 } | 624 } |
608 }; | 625 }; |
609 | 626 |
610 // Method: Arity 3 -> 2. | 627 // Method: Arity 3 -> 2. |
611 template <typename StorageType, typename R, typename T, typename X1, | 628 template <typename StorageType, typename R, typename T, typename X1, |
612 typename X2, typename X3> | 629 typename X2, typename X3> |
613 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3)> { | 630 struct Invoker2<StorageType, R(T::*)(X1, X2, X3)> { |
614 COMPILE_ASSERT( | 631 COMPILE_ASSERT( |
615 !( is_non_const_reference<X1>::value || | 632 !( is_non_const_reference<X1>::value || |
616 is_non_const_reference<X2>::value || | 633 is_non_const_reference<X2>::value || |
617 is_non_const_reference<X3>::value ), | 634 is_non_const_reference<X3>::value ), |
618 do_not_bind_functions_with_nonconst_ref); | 635 do_not_bind_functions_with_nonconst_ref); |
619 | 636 |
620 typedef base::true_type IsMethod; | |
621 | |
622 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3) { | 637 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3) { |
623 StorageType* invoker = static_cast<StorageType*>(base); | 638 StorageType* invoker = static_cast<StorageType*>(base); |
624 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); | 639 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); |
625 } | 640 } |
626 }; | 641 }; |
627 | 642 |
628 // Const Method: Arity 3 -> 2. | |
629 template <typename StorageType, typename R, typename T, typename X1, | |
630 typename X2, typename X3> | |
631 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3) const> { | |
632 COMPILE_ASSERT( | |
633 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
634 || is_non_const_reference<X3>::value ), | |
635 do_not_bind_functions_with_nonconst_ref); | |
636 | |
637 typedef base::true_type IsMethod; | |
638 | |
639 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3) { | |
640 StorageType* invoker = static_cast<StorageType*>(base); | |
641 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); | |
642 } | |
643 }; | |
644 | |
645 // Function: Arity 5 -> 3. | 643 // Function: Arity 5 -> 3. |
646 template <typename StorageType, typename R,typename X1, typename X2, | 644 template <typename StorageType, typename R,typename X1, typename X2, |
647 typename X3, typename X4, typename X5> | 645 typename X3, typename X4, typename X5> |
648 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5)> { | 646 struct Invoker2<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
649 COMPILE_ASSERT( | 647 COMPILE_ASSERT( |
650 !( is_non_const_reference<X1>::value || | 648 !( is_non_const_reference<X1>::value || |
651 is_non_const_reference<X2>::value || | 649 is_non_const_reference<X2>::value || |
652 is_non_const_reference<X3>::value || | 650 is_non_const_reference<X3>::value || |
653 is_non_const_reference<X4>::value || | 651 is_non_const_reference<X4>::value || |
654 is_non_const_reference<X5>::value ), | 652 is_non_const_reference<X5>::value ), |
655 do_not_bind_functions_with_nonconst_ref); | 653 do_not_bind_functions_with_nonconst_ref); |
656 | 654 |
657 typedef base::false_type IsMethod; | |
658 | |
659 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4, | 655 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4, |
660 const X5& x5) { | 656 const X5& x5) { |
661 StorageType* invoker = static_cast<StorageType*>(base); | 657 StorageType* invoker = static_cast<StorageType*>(base); |
662 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5); | 658 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5); |
663 } | 659 } |
664 }; | 660 }; |
665 | 661 |
666 // Method: Arity 4 -> 3. | 662 // Method: Arity 4 -> 3. |
667 template <typename StorageType, typename R, typename T, typename X1, | 663 template <typename StorageType, typename R, typename T, typename X1, |
668 typename X2, typename X3, typename X4> | 664 typename X2, typename X3, typename X4> |
669 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4)> { | 665 struct Invoker2<StorageType, R(T::*)(X1, X2, X3, X4)> { |
670 COMPILE_ASSERT( | 666 COMPILE_ASSERT( |
671 !( is_non_const_reference<X1>::value || | 667 !( is_non_const_reference<X1>::value || |
672 is_non_const_reference<X2>::value || | 668 is_non_const_reference<X2>::value || |
673 is_non_const_reference<X3>::value || | 669 is_non_const_reference<X3>::value || |
674 is_non_const_reference<X4>::value ), | 670 is_non_const_reference<X4>::value ), |
675 do_not_bind_functions_with_nonconst_ref); | 671 do_not_bind_functions_with_nonconst_ref); |
676 | 672 |
677 typedef base::true_type IsMethod; | |
678 | |
679 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, | 673 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, |
680 const X4& x4) { | 674 const X4& x4) { |
681 StorageType* invoker = static_cast<StorageType*>(base); | 675 StorageType* invoker = static_cast<StorageType*>(base); |
682 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | 676 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
683 x4); | 677 x4); |
684 } | 678 } |
685 }; | 679 }; |
686 | 680 |
687 // Const Method: Arity 4 -> 3. | |
688 template <typename StorageType, typename R, typename T, typename X1, | |
689 typename X2, typename X3, typename X4> | |
690 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
691 COMPILE_ASSERT( | |
692 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
693 || is_non_const_reference<X3>::value || | |
694 is_non_const_reference<X4>::value ), | |
695 do_not_bind_functions_with_nonconst_ref); | |
696 | |
697 typedef base::true_type IsMethod; | |
698 | |
699 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, | |
700 const X4& x4) { | |
701 StorageType* invoker = static_cast<StorageType*>(base); | |
702 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | |
703 x4); | |
704 } | |
705 }; | |
706 | |
707 // Function: Arity 6 -> 4. | 681 // Function: Arity 6 -> 4. |
708 template <typename StorageType, typename R,typename X1, typename X2, | 682 template <typename StorageType, typename R,typename X1, typename X2, |
709 typename X3, typename X4, typename X5, typename X6> | 683 typename X3, typename X4, typename X5, typename X6> |
710 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 684 struct Invoker2<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
711 COMPILE_ASSERT( | 685 COMPILE_ASSERT( |
712 !( is_non_const_reference<X1>::value || | 686 !( is_non_const_reference<X1>::value || |
713 is_non_const_reference<X2>::value || | 687 is_non_const_reference<X2>::value || |
714 is_non_const_reference<X3>::value || | 688 is_non_const_reference<X3>::value || |
715 is_non_const_reference<X4>::value || | 689 is_non_const_reference<X4>::value || |
716 is_non_const_reference<X5>::value || | 690 is_non_const_reference<X5>::value || |
717 is_non_const_reference<X6>::value ), | 691 is_non_const_reference<X6>::value ), |
718 do_not_bind_functions_with_nonconst_ref); | 692 do_not_bind_functions_with_nonconst_ref); |
719 | 693 |
720 typedef base::false_type IsMethod; | |
721 | |
722 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4, | 694 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4, |
723 const X5& x5, const X6& x6) { | 695 const X5& x5, const X6& x6) { |
724 StorageType* invoker = static_cast<StorageType*>(base); | 696 StorageType* invoker = static_cast<StorageType*>(base); |
725 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5, | 697 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5, |
726 x6); | 698 x6); |
727 } | 699 } |
728 }; | 700 }; |
729 | 701 |
730 // Method: Arity 5 -> 4. | 702 // Method: Arity 5 -> 4. |
731 template <typename StorageType, typename R, typename T, typename X1, | 703 template <typename StorageType, typename R, typename T, typename X1, |
732 typename X2, typename X3, typename X4, typename X5> | 704 typename X2, typename X3, typename X4, typename X5> |
733 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 705 struct Invoker2<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
734 COMPILE_ASSERT( | 706 COMPILE_ASSERT( |
735 !( is_non_const_reference<X1>::value || | 707 !( is_non_const_reference<X1>::value || |
736 is_non_const_reference<X2>::value || | 708 is_non_const_reference<X2>::value || |
737 is_non_const_reference<X3>::value || | 709 is_non_const_reference<X3>::value || |
738 is_non_const_reference<X4>::value || | 710 is_non_const_reference<X4>::value || |
739 is_non_const_reference<X5>::value ), | 711 is_non_const_reference<X5>::value ), |
740 do_not_bind_functions_with_nonconst_ref); | 712 do_not_bind_functions_with_nonconst_ref); |
741 | 713 |
742 typedef base::true_type IsMethod; | |
743 | |
744 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, | 714 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, |
745 const X4& x4, const X5& x5) { | 715 const X4& x4, const X5& x5) { |
746 StorageType* invoker = static_cast<StorageType*>(base); | 716 StorageType* invoker = static_cast<StorageType*>(base); |
747 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | 717 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
748 x4, x5); | 718 x4, x5); |
749 } | 719 } |
750 }; | 720 }; |
751 | 721 |
752 // Const Method: Arity 5 -> 4. | 722 template <typename StorageType, typename NormalizedSig> |
753 template <typename StorageType, typename R, typename T, typename X1, | 723 struct Invoker3; |
754 typename X2, typename X3, typename X4, typename X5> | |
755 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
756 COMPILE_ASSERT( | |
757 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
758 || is_non_const_reference<X3>::value || | |
759 is_non_const_reference<X4>::value || | |
760 is_non_const_reference<X5>::value ), | |
761 do_not_bind_functions_with_nonconst_ref); | |
762 | |
763 typedef base::true_type IsMethod; | |
764 | |
765 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3, | |
766 const X4& x4, const X5& x5) { | |
767 StorageType* invoker = static_cast<StorageType*>(base); | |
768 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | |
769 x4, x5); | |
770 } | |
771 }; | |
772 | |
773 template <typename StorageType, typename Sig> | |
774 struct FunctionTraits3; | |
775 | 724 |
776 // Function: Arity 3 -> 0. | 725 // Function: Arity 3 -> 0. |
777 template <typename StorageType, typename R,typename X1, typename X2, | 726 template <typename StorageType, typename R,typename X1, typename X2, |
778 typename X3> | 727 typename X3> |
779 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3)> { | 728 struct Invoker3<StorageType, R(*)(X1, X2, X3)> { |
780 COMPILE_ASSERT( | 729 COMPILE_ASSERT( |
781 !( is_non_const_reference<X1>::value || | 730 !( is_non_const_reference<X1>::value || |
782 is_non_const_reference<X2>::value || | 731 is_non_const_reference<X2>::value || |
783 is_non_const_reference<X3>::value ), | 732 is_non_const_reference<X3>::value ), |
784 do_not_bind_functions_with_nonconst_ref); | 733 do_not_bind_functions_with_nonconst_ref); |
785 | 734 |
786 typedef base::false_type IsMethod; | |
787 | |
788 static R DoInvoke(InvokerStorageBase* base) { | 735 static R DoInvoke(InvokerStorageBase* base) { |
789 StorageType* invoker = static_cast<StorageType*>(base); | 736 StorageType* invoker = static_cast<StorageType*>(base); |
790 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 737 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
791 Unwrap(invoker->p3_)); | 738 Unwrap(invoker->p3_)); |
792 } | 739 } |
793 }; | 740 }; |
794 | 741 |
795 // Method: Arity 2 -> 0. | 742 // Method: Arity 2 -> 0. |
796 template <typename StorageType, typename R, typename T, typename X1, | 743 template <typename StorageType, typename R, typename T, typename X1, |
797 typename X2> | 744 typename X2> |
798 struct FunctionTraits3<StorageType, R(T::*)(X1, X2)> { | 745 struct Invoker3<StorageType, R(T::*)(X1, X2)> { |
799 COMPILE_ASSERT( | 746 COMPILE_ASSERT( |
800 !( is_non_const_reference<X1>::value || | 747 !( is_non_const_reference<X1>::value || |
801 is_non_const_reference<X2>::value ), | 748 is_non_const_reference<X2>::value ), |
802 do_not_bind_functions_with_nonconst_ref); | 749 do_not_bind_functions_with_nonconst_ref); |
803 | 750 |
804 typedef base::true_type IsMethod; | |
805 | |
806 static R DoInvoke(InvokerStorageBase* base) { | 751 static R DoInvoke(InvokerStorageBase* base) { |
807 StorageType* invoker = static_cast<StorageType*>(base); | 752 StorageType* invoker = static_cast<StorageType*>(base); |
808 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 753 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
809 Unwrap(invoker->p3_)); | 754 Unwrap(invoker->p3_)); |
810 } | 755 } |
811 }; | 756 }; |
812 | 757 |
813 // Const Method: Arity 2 -> 0. | |
814 template <typename StorageType, typename R, typename T, typename X1, | |
815 typename X2> | |
816 struct FunctionTraits3<StorageType, R(T::*)(X1, X2) const> { | |
817 COMPILE_ASSERT( | |
818 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
819 ), | |
820 do_not_bind_functions_with_nonconst_ref); | |
821 | |
822 typedef base::true_type IsMethod; | |
823 | |
824 static R DoInvoke(InvokerStorageBase* base ) { | |
825 StorageType* invoker = static_cast<StorageType*>(base); | |
826 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
827 Unwrap(invoker->p3_)); | |
828 } | |
829 }; | |
830 | |
831 // Function: Arity 4 -> 1. | 758 // Function: Arity 4 -> 1. |
832 template <typename StorageType, typename R,typename X1, typename X2, | 759 template <typename StorageType, typename R,typename X1, typename X2, |
833 typename X3, typename X4> | 760 typename X3, typename X4> |
834 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4)> { | 761 struct Invoker3<StorageType, R(*)(X1, X2, X3, X4)> { |
835 COMPILE_ASSERT( | 762 COMPILE_ASSERT( |
836 !( is_non_const_reference<X1>::value || | 763 !( is_non_const_reference<X1>::value || |
837 is_non_const_reference<X2>::value || | 764 is_non_const_reference<X2>::value || |
838 is_non_const_reference<X3>::value || | 765 is_non_const_reference<X3>::value || |
839 is_non_const_reference<X4>::value ), | 766 is_non_const_reference<X4>::value ), |
840 do_not_bind_functions_with_nonconst_ref); | 767 do_not_bind_functions_with_nonconst_ref); |
841 | 768 |
842 typedef base::false_type IsMethod; | |
843 | |
844 static R DoInvoke(InvokerStorageBase* base, const X4& x4) { | 769 static R DoInvoke(InvokerStorageBase* base, const X4& x4) { |
845 StorageType* invoker = static_cast<StorageType*>(base); | 770 StorageType* invoker = static_cast<StorageType*>(base); |
846 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 771 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
847 Unwrap(invoker->p3_), x4); | 772 Unwrap(invoker->p3_), x4); |
848 } | 773 } |
849 }; | 774 }; |
850 | 775 |
851 // Method: Arity 3 -> 1. | 776 // Method: Arity 3 -> 1. |
852 template <typename StorageType, typename R, typename T, typename X1, | 777 template <typename StorageType, typename R, typename T, typename X1, |
853 typename X2, typename X3> | 778 typename X2, typename X3> |
854 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3)> { | 779 struct Invoker3<StorageType, R(T::*)(X1, X2, X3)> { |
855 COMPILE_ASSERT( | 780 COMPILE_ASSERT( |
856 !( is_non_const_reference<X1>::value || | 781 !( is_non_const_reference<X1>::value || |
857 is_non_const_reference<X2>::value || | 782 is_non_const_reference<X2>::value || |
858 is_non_const_reference<X3>::value ), | 783 is_non_const_reference<X3>::value ), |
859 do_not_bind_functions_with_nonconst_ref); | 784 do_not_bind_functions_with_nonconst_ref); |
860 | 785 |
861 typedef base::true_type IsMethod; | |
862 | |
863 static R DoInvoke(InvokerStorageBase* base, const X3& x3) { | 786 static R DoInvoke(InvokerStorageBase* base, const X3& x3) { |
864 StorageType* invoker = static_cast<StorageType*>(base); | 787 StorageType* invoker = static_cast<StorageType*>(base); |
865 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 788 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
866 Unwrap(invoker->p3_), x3); | 789 Unwrap(invoker->p3_), x3); |
867 } | 790 } |
868 }; | 791 }; |
869 | 792 |
870 // Const Method: Arity 3 -> 1. | |
871 template <typename StorageType, typename R, typename T, typename X1, | |
872 typename X2, typename X3> | |
873 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3) const> { | |
874 COMPILE_ASSERT( | |
875 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
876 || is_non_const_reference<X3>::value ), | |
877 do_not_bind_functions_with_nonconst_ref); | |
878 | |
879 typedef base::true_type IsMethod; | |
880 | |
881 static R DoInvoke(InvokerStorageBase* base, const X3& x3) { | |
882 StorageType* invoker = static_cast<StorageType*>(base); | |
883 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
884 Unwrap(invoker->p3_), x3); | |
885 } | |
886 }; | |
887 | |
888 // Function: Arity 5 -> 2. | 793 // Function: Arity 5 -> 2. |
889 template <typename StorageType, typename R,typename X1, typename X2, | 794 template <typename StorageType, typename R,typename X1, typename X2, |
890 typename X3, typename X4, typename X5> | 795 typename X3, typename X4, typename X5> |
891 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5)> { | 796 struct Invoker3<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
892 COMPILE_ASSERT( | 797 COMPILE_ASSERT( |
893 !( is_non_const_reference<X1>::value || | 798 !( is_non_const_reference<X1>::value || |
894 is_non_const_reference<X2>::value || | 799 is_non_const_reference<X2>::value || |
895 is_non_const_reference<X3>::value || | 800 is_non_const_reference<X3>::value || |
896 is_non_const_reference<X4>::value || | 801 is_non_const_reference<X4>::value || |
897 is_non_const_reference<X5>::value ), | 802 is_non_const_reference<X5>::value ), |
898 do_not_bind_functions_with_nonconst_ref); | 803 do_not_bind_functions_with_nonconst_ref); |
899 | 804 |
900 typedef base::false_type IsMethod; | |
901 | |
902 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5) { | 805 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5) { |
903 StorageType* invoker = static_cast<StorageType*>(base); | 806 StorageType* invoker = static_cast<StorageType*>(base); |
904 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 807 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
905 Unwrap(invoker->p3_), x4, x5); | 808 Unwrap(invoker->p3_), x4, x5); |
906 } | 809 } |
907 }; | 810 }; |
908 | 811 |
909 // Method: Arity 4 -> 2. | 812 // Method: Arity 4 -> 2. |
910 template <typename StorageType, typename R, typename T, typename X1, | 813 template <typename StorageType, typename R, typename T, typename X1, |
911 typename X2, typename X3, typename X4> | 814 typename X2, typename X3, typename X4> |
912 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4)> { | 815 struct Invoker3<StorageType, R(T::*)(X1, X2, X3, X4)> { |
913 COMPILE_ASSERT( | 816 COMPILE_ASSERT( |
914 !( is_non_const_reference<X1>::value || | 817 !( is_non_const_reference<X1>::value || |
915 is_non_const_reference<X2>::value || | 818 is_non_const_reference<X2>::value || |
916 is_non_const_reference<X3>::value || | 819 is_non_const_reference<X3>::value || |
917 is_non_const_reference<X4>::value ), | 820 is_non_const_reference<X4>::value ), |
918 do_not_bind_functions_with_nonconst_ref); | 821 do_not_bind_functions_with_nonconst_ref); |
919 | 822 |
920 typedef base::true_type IsMethod; | |
921 | |
922 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4) { | 823 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4) { |
923 StorageType* invoker = static_cast<StorageType*>(base); | 824 StorageType* invoker = static_cast<StorageType*>(base); |
924 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 825 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
925 Unwrap(invoker->p3_), x3, x4); | 826 Unwrap(invoker->p3_), x3, x4); |
926 } | 827 } |
927 }; | 828 }; |
928 | 829 |
929 // Const Method: Arity 4 -> 2. | |
930 template <typename StorageType, typename R, typename T, typename X1, | |
931 typename X2, typename X3, typename X4> | |
932 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
933 COMPILE_ASSERT( | |
934 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
935 || is_non_const_reference<X3>::value || | |
936 is_non_const_reference<X4>::value ), | |
937 do_not_bind_functions_with_nonconst_ref); | |
938 | |
939 typedef base::true_type IsMethod; | |
940 | |
941 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4) { | |
942 StorageType* invoker = static_cast<StorageType*>(base); | |
943 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
944 Unwrap(invoker->p3_), x3, x4); | |
945 } | |
946 }; | |
947 | |
948 // Function: Arity 6 -> 3. | 830 // Function: Arity 6 -> 3. |
949 template <typename StorageType, typename R,typename X1, typename X2, | 831 template <typename StorageType, typename R,typename X1, typename X2, |
950 typename X3, typename X4, typename X5, typename X6> | 832 typename X3, typename X4, typename X5, typename X6> |
951 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 833 struct Invoker3<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
952 COMPILE_ASSERT( | 834 COMPILE_ASSERT( |
953 !( is_non_const_reference<X1>::value || | 835 !( is_non_const_reference<X1>::value || |
954 is_non_const_reference<X2>::value || | 836 is_non_const_reference<X2>::value || |
955 is_non_const_reference<X3>::value || | 837 is_non_const_reference<X3>::value || |
956 is_non_const_reference<X4>::value || | 838 is_non_const_reference<X4>::value || |
957 is_non_const_reference<X5>::value || | 839 is_non_const_reference<X5>::value || |
958 is_non_const_reference<X6>::value ), | 840 is_non_const_reference<X6>::value ), |
959 do_not_bind_functions_with_nonconst_ref); | 841 do_not_bind_functions_with_nonconst_ref); |
960 | 842 |
961 typedef base::false_type IsMethod; | |
962 | |
963 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5, | 843 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5, |
964 const X6& x6) { | 844 const X6& x6) { |
965 StorageType* invoker = static_cast<StorageType*>(base); | 845 StorageType* invoker = static_cast<StorageType*>(base); |
966 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 846 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
967 Unwrap(invoker->p3_), x4, x5, x6); | 847 Unwrap(invoker->p3_), x4, x5, x6); |
968 } | 848 } |
969 }; | 849 }; |
970 | 850 |
971 // Method: Arity 5 -> 3. | 851 // Method: Arity 5 -> 3. |
972 template <typename StorageType, typename R, typename T, typename X1, | 852 template <typename StorageType, typename R, typename T, typename X1, |
973 typename X2, typename X3, typename X4, typename X5> | 853 typename X2, typename X3, typename X4, typename X5> |
974 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 854 struct Invoker3<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
975 COMPILE_ASSERT( | 855 COMPILE_ASSERT( |
976 !( is_non_const_reference<X1>::value || | 856 !( is_non_const_reference<X1>::value || |
977 is_non_const_reference<X2>::value || | 857 is_non_const_reference<X2>::value || |
978 is_non_const_reference<X3>::value || | 858 is_non_const_reference<X3>::value || |
979 is_non_const_reference<X4>::value || | 859 is_non_const_reference<X4>::value || |
980 is_non_const_reference<X5>::value ), | 860 is_non_const_reference<X5>::value ), |
981 do_not_bind_functions_with_nonconst_ref); | 861 do_not_bind_functions_with_nonconst_ref); |
982 | 862 |
983 typedef base::true_type IsMethod; | |
984 | |
985 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4, | 863 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4, |
986 const X5& x5) { | 864 const X5& x5) { |
987 StorageType* invoker = static_cast<StorageType*>(base); | 865 StorageType* invoker = static_cast<StorageType*>(base); |
988 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 866 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
989 Unwrap(invoker->p3_), x3, x4, x5); | 867 Unwrap(invoker->p3_), x3, x4, x5); |
990 } | 868 } |
991 }; | 869 }; |
992 | 870 |
993 // Const Method: Arity 5 -> 3. | 871 template <typename StorageType, typename NormalizedSig> |
994 template <typename StorageType, typename R, typename T, typename X1, | 872 struct Invoker4; |
995 typename X2, typename X3, typename X4, typename X5> | |
996 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
997 COMPILE_ASSERT( | |
998 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
999 || is_non_const_reference<X3>::value || | |
1000 is_non_const_reference<X4>::value || | |
1001 is_non_const_reference<X5>::value ), | |
1002 do_not_bind_functions_with_nonconst_ref); | |
1003 | |
1004 typedef base::true_type IsMethod; | |
1005 | |
1006 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4, | |
1007 const X5& x5) { | |
1008 StorageType* invoker = static_cast<StorageType*>(base); | |
1009 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1010 Unwrap(invoker->p3_), x3, x4, x5); | |
1011 } | |
1012 }; | |
1013 | |
1014 template <typename StorageType, typename Sig> | |
1015 struct FunctionTraits4; | |
1016 | 873 |
1017 // Function: Arity 4 -> 0. | 874 // Function: Arity 4 -> 0. |
1018 template <typename StorageType, typename R,typename X1, typename X2, | 875 template <typename StorageType, typename R,typename X1, typename X2, |
1019 typename X3, typename X4> | 876 typename X3, typename X4> |
1020 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4)> { | 877 struct Invoker4<StorageType, R(*)(X1, X2, X3, X4)> { |
1021 COMPILE_ASSERT( | 878 COMPILE_ASSERT( |
1022 !( is_non_const_reference<X1>::value || | 879 !( is_non_const_reference<X1>::value || |
1023 is_non_const_reference<X2>::value || | 880 is_non_const_reference<X2>::value || |
1024 is_non_const_reference<X3>::value || | 881 is_non_const_reference<X3>::value || |
1025 is_non_const_reference<X4>::value ), | 882 is_non_const_reference<X4>::value ), |
1026 do_not_bind_functions_with_nonconst_ref); | 883 do_not_bind_functions_with_nonconst_ref); |
1027 | 884 |
1028 typedef base::false_type IsMethod; | |
1029 | |
1030 static R DoInvoke(InvokerStorageBase* base) { | 885 static R DoInvoke(InvokerStorageBase* base) { |
1031 StorageType* invoker = static_cast<StorageType*>(base); | 886 StorageType* invoker = static_cast<StorageType*>(base); |
1032 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 887 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
1033 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | 888 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); |
1034 } | 889 } |
1035 }; | 890 }; |
1036 | 891 |
1037 // Method: Arity 3 -> 0. | 892 // Method: Arity 3 -> 0. |
1038 template <typename StorageType, typename R, typename T, typename X1, | 893 template <typename StorageType, typename R, typename T, typename X1, |
1039 typename X2, typename X3> | 894 typename X2, typename X3> |
1040 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3)> { | 895 struct Invoker4<StorageType, R(T::*)(X1, X2, X3)> { |
1041 COMPILE_ASSERT( | 896 COMPILE_ASSERT( |
1042 !( is_non_const_reference<X1>::value || | 897 !( is_non_const_reference<X1>::value || |
1043 is_non_const_reference<X2>::value || | 898 is_non_const_reference<X2>::value || |
1044 is_non_const_reference<X3>::value ), | 899 is_non_const_reference<X3>::value ), |
1045 do_not_bind_functions_with_nonconst_ref); | 900 do_not_bind_functions_with_nonconst_ref); |
1046 | 901 |
1047 typedef base::true_type IsMethod; | |
1048 | |
1049 static R DoInvoke(InvokerStorageBase* base) { | 902 static R DoInvoke(InvokerStorageBase* base) { |
1050 StorageType* invoker = static_cast<StorageType*>(base); | 903 StorageType* invoker = static_cast<StorageType*>(base); |
1051 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 904 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
1052 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | 905 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); |
1053 } | 906 } |
1054 }; | 907 }; |
1055 | 908 |
1056 // Const Method: Arity 3 -> 0. | |
1057 template <typename StorageType, typename R, typename T, typename X1, | |
1058 typename X2, typename X3> | |
1059 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3) const> { | |
1060 COMPILE_ASSERT( | |
1061 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
1062 || is_non_const_reference<X3>::value ), | |
1063 do_not_bind_functions_with_nonconst_ref); | |
1064 | |
1065 typedef base::true_type IsMethod; | |
1066 | |
1067 static R DoInvoke(InvokerStorageBase* base ) { | |
1068 StorageType* invoker = static_cast<StorageType*>(base); | |
1069 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1070 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | |
1071 } | |
1072 }; | |
1073 | |
1074 // Function: Arity 5 -> 1. | 909 // Function: Arity 5 -> 1. |
1075 template <typename StorageType, typename R,typename X1, typename X2, | 910 template <typename StorageType, typename R,typename X1, typename X2, |
1076 typename X3, typename X4, typename X5> | 911 typename X3, typename X4, typename X5> |
1077 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5)> { | 912 struct Invoker4<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
1078 COMPILE_ASSERT( | 913 COMPILE_ASSERT( |
1079 !( is_non_const_reference<X1>::value || | 914 !( is_non_const_reference<X1>::value || |
1080 is_non_const_reference<X2>::value || | 915 is_non_const_reference<X2>::value || |
1081 is_non_const_reference<X3>::value || | 916 is_non_const_reference<X3>::value || |
1082 is_non_const_reference<X4>::value || | 917 is_non_const_reference<X4>::value || |
1083 is_non_const_reference<X5>::value ), | 918 is_non_const_reference<X5>::value ), |
1084 do_not_bind_functions_with_nonconst_ref); | 919 do_not_bind_functions_with_nonconst_ref); |
1085 | 920 |
1086 typedef base::false_type IsMethod; | |
1087 | |
1088 static R DoInvoke(InvokerStorageBase* base, const X5& x5) { | 921 static R DoInvoke(InvokerStorageBase* base, const X5& x5) { |
1089 StorageType* invoker = static_cast<StorageType*>(base); | 922 StorageType* invoker = static_cast<StorageType*>(base); |
1090 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 923 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
1091 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5); | 924 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5); |
1092 } | 925 } |
1093 }; | 926 }; |
1094 | 927 |
1095 // Method: Arity 4 -> 1. | 928 // Method: Arity 4 -> 1. |
1096 template <typename StorageType, typename R, typename T, typename X1, | 929 template <typename StorageType, typename R, typename T, typename X1, |
1097 typename X2, typename X3, typename X4> | 930 typename X2, typename X3, typename X4> |
1098 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4)> { | 931 struct Invoker4<StorageType, R(T::*)(X1, X2, X3, X4)> { |
1099 COMPILE_ASSERT( | 932 COMPILE_ASSERT( |
1100 !( is_non_const_reference<X1>::value || | 933 !( is_non_const_reference<X1>::value || |
1101 is_non_const_reference<X2>::value || | 934 is_non_const_reference<X2>::value || |
1102 is_non_const_reference<X3>::value || | 935 is_non_const_reference<X3>::value || |
1103 is_non_const_reference<X4>::value ), | 936 is_non_const_reference<X4>::value ), |
1104 do_not_bind_functions_with_nonconst_ref); | 937 do_not_bind_functions_with_nonconst_ref); |
1105 | 938 |
1106 typedef base::true_type IsMethod; | |
1107 | |
1108 static R DoInvoke(InvokerStorageBase* base, const X4& x4) { | 939 static R DoInvoke(InvokerStorageBase* base, const X4& x4) { |
1109 StorageType* invoker = static_cast<StorageType*>(base); | 940 StorageType* invoker = static_cast<StorageType*>(base); |
1110 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 941 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
1111 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); | 942 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); |
1112 } | 943 } |
1113 }; | 944 }; |
1114 | 945 |
1115 // Const Method: Arity 4 -> 1. | |
1116 template <typename StorageType, typename R, typename T, typename X1, | |
1117 typename X2, typename X3, typename X4> | |
1118 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
1119 COMPILE_ASSERT( | |
1120 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
1121 || is_non_const_reference<X3>::value || | |
1122 is_non_const_reference<X4>::value ), | |
1123 do_not_bind_functions_with_nonconst_ref); | |
1124 | |
1125 typedef base::true_type IsMethod; | |
1126 | |
1127 static R DoInvoke(InvokerStorageBase* base, const X4& x4) { | |
1128 StorageType* invoker = static_cast<StorageType*>(base); | |
1129 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1130 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); | |
1131 } | |
1132 }; | |
1133 | |
1134 // Function: Arity 6 -> 2. | 946 // Function: Arity 6 -> 2. |
1135 template <typename StorageType, typename R,typename X1, typename X2, | 947 template <typename StorageType, typename R,typename X1, typename X2, |
1136 typename X3, typename X4, typename X5, typename X6> | 948 typename X3, typename X4, typename X5, typename X6> |
1137 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 949 struct Invoker4<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
1138 COMPILE_ASSERT( | 950 COMPILE_ASSERT( |
1139 !( is_non_const_reference<X1>::value || | 951 !( is_non_const_reference<X1>::value || |
1140 is_non_const_reference<X2>::value || | 952 is_non_const_reference<X2>::value || |
1141 is_non_const_reference<X3>::value || | 953 is_non_const_reference<X3>::value || |
1142 is_non_const_reference<X4>::value || | 954 is_non_const_reference<X4>::value || |
1143 is_non_const_reference<X5>::value || | 955 is_non_const_reference<X5>::value || |
1144 is_non_const_reference<X6>::value ), | 956 is_non_const_reference<X6>::value ), |
1145 do_not_bind_functions_with_nonconst_ref); | 957 do_not_bind_functions_with_nonconst_ref); |
1146 | 958 |
1147 typedef base::false_type IsMethod; | |
1148 | |
1149 static R DoInvoke(InvokerStorageBase* base, const X5& x5, const X6& x6) { | 959 static R DoInvoke(InvokerStorageBase* base, const X5& x5, const X6& x6) { |
1150 StorageType* invoker = static_cast<StorageType*>(base); | 960 StorageType* invoker = static_cast<StorageType*>(base); |
1151 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 961 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
1152 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5, x6); | 962 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5, x6); |
1153 } | 963 } |
1154 }; | 964 }; |
1155 | 965 |
1156 // Method: Arity 5 -> 2. | 966 // Method: Arity 5 -> 2. |
1157 template <typename StorageType, typename R, typename T, typename X1, | 967 template <typename StorageType, typename R, typename T, typename X1, |
1158 typename X2, typename X3, typename X4, typename X5> | 968 typename X2, typename X3, typename X4, typename X5> |
1159 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 969 struct Invoker4<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
1160 COMPILE_ASSERT( | 970 COMPILE_ASSERT( |
1161 !( is_non_const_reference<X1>::value || | 971 !( is_non_const_reference<X1>::value || |
1162 is_non_const_reference<X2>::value || | 972 is_non_const_reference<X2>::value || |
1163 is_non_const_reference<X3>::value || | 973 is_non_const_reference<X3>::value || |
1164 is_non_const_reference<X4>::value || | 974 is_non_const_reference<X4>::value || |
1165 is_non_const_reference<X5>::value ), | 975 is_non_const_reference<X5>::value ), |
1166 do_not_bind_functions_with_nonconst_ref); | 976 do_not_bind_functions_with_nonconst_ref); |
1167 | 977 |
1168 typedef base::true_type IsMethod; | |
1169 | |
1170 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5) { | 978 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5) { |
1171 StorageType* invoker = static_cast<StorageType*>(base); | 979 StorageType* invoker = static_cast<StorageType*>(base); |
1172 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 980 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
1173 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); | 981 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); |
1174 } | 982 } |
1175 }; | 983 }; |
1176 | 984 |
1177 // Const Method: Arity 5 -> 2. | 985 template <typename StorageType, typename NormalizedSig> |
1178 template <typename StorageType, typename R, typename T, typename X1, | 986 struct Invoker5; |
1179 typename X2, typename X3, typename X4, typename X5> | |
1180 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
1181 COMPILE_ASSERT( | |
1182 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
1183 || is_non_const_reference<X3>::value || | |
1184 is_non_const_reference<X4>::value || | |
1185 is_non_const_reference<X5>::value ), | |
1186 do_not_bind_functions_with_nonconst_ref); | |
1187 | |
1188 typedef base::true_type IsMethod; | |
1189 | |
1190 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5) { | |
1191 StorageType* invoker = static_cast<StorageType*>(base); | |
1192 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1193 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); | |
1194 } | |
1195 }; | |
1196 | |
1197 template <typename StorageType, typename Sig> | |
1198 struct FunctionTraits5; | |
1199 | 987 |
1200 // Function: Arity 5 -> 0. | 988 // Function: Arity 5 -> 0. |
1201 template <typename StorageType, typename R,typename X1, typename X2, | 989 template <typename StorageType, typename R,typename X1, typename X2, |
1202 typename X3, typename X4, typename X5> | 990 typename X3, typename X4, typename X5> |
1203 struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5)> { | 991 struct Invoker5<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
1204 COMPILE_ASSERT( | 992 COMPILE_ASSERT( |
1205 !( is_non_const_reference<X1>::value || | 993 !( is_non_const_reference<X1>::value || |
1206 is_non_const_reference<X2>::value || | 994 is_non_const_reference<X2>::value || |
1207 is_non_const_reference<X3>::value || | 995 is_non_const_reference<X3>::value || |
1208 is_non_const_reference<X4>::value || | 996 is_non_const_reference<X4>::value || |
1209 is_non_const_reference<X5>::value ), | 997 is_non_const_reference<X5>::value ), |
1210 do_not_bind_functions_with_nonconst_ref); | 998 do_not_bind_functions_with_nonconst_ref); |
1211 | 999 |
1212 typedef base::false_type IsMethod; | |
1213 | |
1214 static R DoInvoke(InvokerStorageBase* base) { | 1000 static R DoInvoke(InvokerStorageBase* base) { |
1215 StorageType* invoker = static_cast<StorageType*>(base); | 1001 StorageType* invoker = static_cast<StorageType*>(base); |
1216 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 1002 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
1217 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | 1003 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
1218 } | 1004 } |
1219 }; | 1005 }; |
1220 | 1006 |
1221 // Method: Arity 4 -> 0. | 1007 // Method: Arity 4 -> 0. |
1222 template <typename StorageType, typename R, typename T, typename X1, | 1008 template <typename StorageType, typename R, typename T, typename X1, |
1223 typename X2, typename X3, typename X4> | 1009 typename X2, typename X3, typename X4> |
1224 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4)> { | 1010 struct Invoker5<StorageType, R(T::*)(X1, X2, X3, X4)> { |
1225 COMPILE_ASSERT( | 1011 COMPILE_ASSERT( |
1226 !( is_non_const_reference<X1>::value || | 1012 !( is_non_const_reference<X1>::value || |
1227 is_non_const_reference<X2>::value || | 1013 is_non_const_reference<X2>::value || |
1228 is_non_const_reference<X3>::value || | 1014 is_non_const_reference<X3>::value || |
1229 is_non_const_reference<X4>::value ), | 1015 is_non_const_reference<X4>::value ), |
1230 do_not_bind_functions_with_nonconst_ref); | 1016 do_not_bind_functions_with_nonconst_ref); |
1231 | 1017 |
1232 typedef base::true_type IsMethod; | |
1233 | |
1234 static R DoInvoke(InvokerStorageBase* base) { | 1018 static R DoInvoke(InvokerStorageBase* base) { |
1235 StorageType* invoker = static_cast<StorageType*>(base); | 1019 StorageType* invoker = static_cast<StorageType*>(base); |
1236 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 1020 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
1237 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | 1021 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
1238 } | 1022 } |
1239 }; | 1023 }; |
1240 | 1024 |
1241 // Const Method: Arity 4 -> 0. | |
1242 template <typename StorageType, typename R, typename T, typename X1, | |
1243 typename X2, typename X3, typename X4> | |
1244 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
1245 COMPILE_ASSERT( | |
1246 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
1247 || is_non_const_reference<X3>::value || | |
1248 is_non_const_reference<X4>::value ), | |
1249 do_not_bind_functions_with_nonconst_ref); | |
1250 | |
1251 typedef base::true_type IsMethod; | |
1252 | |
1253 static R DoInvoke(InvokerStorageBase* base ) { | |
1254 StorageType* invoker = static_cast<StorageType*>(base); | |
1255 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1256 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | |
1257 } | |
1258 }; | |
1259 | |
1260 // Function: Arity 6 -> 1. | 1025 // Function: Arity 6 -> 1. |
1261 template <typename StorageType, typename R,typename X1, typename X2, | 1026 template <typename StorageType, typename R,typename X1, typename X2, |
1262 typename X3, typename X4, typename X5, typename X6> | 1027 typename X3, typename X4, typename X5, typename X6> |
1263 struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1028 struct Invoker5<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
1264 COMPILE_ASSERT( | 1029 COMPILE_ASSERT( |
1265 !( is_non_const_reference<X1>::value || | 1030 !( is_non_const_reference<X1>::value || |
1266 is_non_const_reference<X2>::value || | 1031 is_non_const_reference<X2>::value || |
1267 is_non_const_reference<X3>::value || | 1032 is_non_const_reference<X3>::value || |
1268 is_non_const_reference<X4>::value || | 1033 is_non_const_reference<X4>::value || |
1269 is_non_const_reference<X5>::value || | 1034 is_non_const_reference<X5>::value || |
1270 is_non_const_reference<X6>::value ), | 1035 is_non_const_reference<X6>::value ), |
1271 do_not_bind_functions_with_nonconst_ref); | 1036 do_not_bind_functions_with_nonconst_ref); |
1272 | 1037 |
1273 typedef base::false_type IsMethod; | |
1274 | |
1275 static R DoInvoke(InvokerStorageBase* base, const X6& x6) { | 1038 static R DoInvoke(InvokerStorageBase* base, const X6& x6) { |
1276 StorageType* invoker = static_cast<StorageType*>(base); | 1039 StorageType* invoker = static_cast<StorageType*>(base); |
1277 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 1040 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
1278 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x6); | 1041 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x6); |
1279 } | 1042 } |
1280 }; | 1043 }; |
1281 | 1044 |
1282 // Method: Arity 5 -> 1. | 1045 // Method: Arity 5 -> 1. |
1283 template <typename StorageType, typename R, typename T, typename X1, | 1046 template <typename StorageType, typename R, typename T, typename X1, |
1284 typename X2, typename X3, typename X4, typename X5> | 1047 typename X2, typename X3, typename X4, typename X5> |
1285 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1048 struct Invoker5<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
1286 COMPILE_ASSERT( | 1049 COMPILE_ASSERT( |
1287 !( is_non_const_reference<X1>::value || | 1050 !( is_non_const_reference<X1>::value || |
1288 is_non_const_reference<X2>::value || | 1051 is_non_const_reference<X2>::value || |
1289 is_non_const_reference<X3>::value || | 1052 is_non_const_reference<X3>::value || |
1290 is_non_const_reference<X4>::value || | 1053 is_non_const_reference<X4>::value || |
1291 is_non_const_reference<X5>::value ), | 1054 is_non_const_reference<X5>::value ), |
1292 do_not_bind_functions_with_nonconst_ref); | 1055 do_not_bind_functions_with_nonconst_ref); |
1293 | 1056 |
1294 typedef base::true_type IsMethod; | |
1295 | |
1296 static R DoInvoke(InvokerStorageBase* base, const X5& x5) { | 1057 static R DoInvoke(InvokerStorageBase* base, const X5& x5) { |
1297 StorageType* invoker = static_cast<StorageType*>(base); | 1058 StorageType* invoker = static_cast<StorageType*>(base); |
1298 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 1059 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
1299 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); | 1060 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); |
1300 } | 1061 } |
1301 }; | 1062 }; |
1302 | 1063 |
1303 // Const Method: Arity 5 -> 1. | 1064 template <typename StorageType, typename NormalizedSig> |
1304 template <typename StorageType, typename R, typename T, typename X1, | 1065 struct Invoker6; |
1305 typename X2, typename X3, typename X4, typename X5> | |
1306 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
1307 COMPILE_ASSERT( | |
1308 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
1309 || is_non_const_reference<X3>::value || | |
1310 is_non_const_reference<X4>::value || | |
1311 is_non_const_reference<X5>::value ), | |
1312 do_not_bind_functions_with_nonconst_ref); | |
1313 | |
1314 typedef base::true_type IsMethod; | |
1315 | |
1316 static R DoInvoke(InvokerStorageBase* base, const X5& x5) { | |
1317 StorageType* invoker = static_cast<StorageType*>(base); | |
1318 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1319 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); | |
1320 } | |
1321 }; | |
1322 | |
1323 template <typename StorageType, typename Sig> | |
1324 struct FunctionTraits6; | |
1325 | 1066 |
1326 // Function: Arity 6 -> 0. | 1067 // Function: Arity 6 -> 0. |
1327 template <typename StorageType, typename R,typename X1, typename X2, | 1068 template <typename StorageType, typename R,typename X1, typename X2, |
1328 typename X3, typename X4, typename X5, typename X6> | 1069 typename X3, typename X4, typename X5, typename X6> |
1329 struct FunctionTraits6<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1070 struct Invoker6<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
1330 COMPILE_ASSERT( | 1071 COMPILE_ASSERT( |
1331 !( is_non_const_reference<X1>::value || | 1072 !( is_non_const_reference<X1>::value || |
1332 is_non_const_reference<X2>::value || | 1073 is_non_const_reference<X2>::value || |
1333 is_non_const_reference<X3>::value || | 1074 is_non_const_reference<X3>::value || |
1334 is_non_const_reference<X4>::value || | 1075 is_non_const_reference<X4>::value || |
1335 is_non_const_reference<X5>::value || | 1076 is_non_const_reference<X5>::value || |
1336 is_non_const_reference<X6>::value ), | 1077 is_non_const_reference<X6>::value ), |
1337 do_not_bind_functions_with_nonconst_ref); | 1078 do_not_bind_functions_with_nonconst_ref); |
1338 | 1079 |
1339 typedef base::false_type IsMethod; | |
1340 | |
1341 static R DoInvoke(InvokerStorageBase* base) { | 1080 static R DoInvoke(InvokerStorageBase* base) { |
1342 StorageType* invoker = static_cast<StorageType*>(base); | 1081 StorageType* invoker = static_cast<StorageType*>(base); |
1343 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 1082 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
1344 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | 1083 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), |
1345 Unwrap(invoker->p6_)); | 1084 Unwrap(invoker->p6_)); |
1346 } | 1085 } |
1347 }; | 1086 }; |
1348 | 1087 |
1349 // Method: Arity 5 -> 0. | 1088 // Method: Arity 5 -> 0. |
1350 template <typename StorageType, typename R, typename T, typename X1, | 1089 template <typename StorageType, typename R, typename T, typename X1, |
1351 typename X2, typename X3, typename X4, typename X5> | 1090 typename X2, typename X3, typename X4, typename X5> |
1352 struct FunctionTraits6<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1091 struct Invoker6<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
1353 COMPILE_ASSERT( | 1092 COMPILE_ASSERT( |
1354 !( is_non_const_reference<X1>::value || | 1093 !( is_non_const_reference<X1>::value || |
1355 is_non_const_reference<X2>::value || | 1094 is_non_const_reference<X2>::value || |
1356 is_non_const_reference<X3>::value || | 1095 is_non_const_reference<X3>::value || |
1357 is_non_const_reference<X4>::value || | 1096 is_non_const_reference<X4>::value || |
1358 is_non_const_reference<X5>::value ), | 1097 is_non_const_reference<X5>::value ), |
1359 do_not_bind_functions_with_nonconst_ref); | 1098 do_not_bind_functions_with_nonconst_ref); |
1360 | 1099 |
1361 typedef base::true_type IsMethod; | |
1362 | |
1363 static R DoInvoke(InvokerStorageBase* base) { | 1100 static R DoInvoke(InvokerStorageBase* base) { |
1364 StorageType* invoker = static_cast<StorageType*>(base); | 1101 StorageType* invoker = static_cast<StorageType*>(base); |
1365 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 1102 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
1366 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | 1103 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), |
1367 Unwrap(invoker->p6_)); | 1104 Unwrap(invoker->p6_)); |
1368 } | 1105 } |
1369 }; | 1106 }; |
1370 | 1107 |
1371 // Const Method: Arity 5 -> 0. | |
1372 template <typename StorageType, typename R, typename T, typename X1, | |
1373 typename X2, typename X3, typename X4, typename X5> | |
1374 struct FunctionTraits6<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
1375 COMPILE_ASSERT( | |
1376 !(is_non_const_reference<X1>::value || is_non_const_reference<X2>::value | |
1377 || is_non_const_reference<X3>::value || | |
1378 is_non_const_reference<X4>::value || | |
1379 is_non_const_reference<X5>::value ), | |
1380 do_not_bind_functions_with_nonconst_ref); | |
1381 | |
1382 typedef base::true_type IsMethod; | |
1383 | |
1384 static R DoInvoke(InvokerStorageBase* base ) { | |
1385 StorageType* invoker = static_cast<StorageType*>(base); | |
1386 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1387 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | |
1388 Unwrap(invoker->p6_)); | |
1389 } | |
1390 }; | |
1391 | |
1392 | 1108 |
1393 // These are the actual storage classes for the invokers. | 1109 // InvokerStorageN<> |
1110 // | |
1111 // These are the actual storage classes for the Invokers. | |
1394 // | 1112 // |
1395 // Though these types are "classes", they are being used as structs with | 1113 // Though these types are "classes", they are being used as structs with |
1396 // all member variable public. We cannot make it a struct because it inherits | 1114 // all member variable public. We cannot make it a struct because it inherits |
1397 // from a class which causes a compiler warning. We cannot add a "Run()" method | 1115 // from a class which causes a compiler warning. We cannot add a "Run()" method |
1398 // that forwards the unbound arguments because that would require we unwrap the | 1116 // that forwards the unbound arguments because that would require we unwrap the |
1399 // Sig type like in FunctionTraitsN above to know the return type, and the arity | 1117 // Sig type like in InvokerN above to know the return type, and the arity |
1400 // of Run(). | 1118 // of Run(). |
1401 // | 1119 // |
1402 // An alternate solution would be to merge FunctionTraitsN and InvokerStorageN, | 1120 // An alternate solution would be to merge InvokerN and InvokerStorageN, |
1403 // but the generated code seemed harder to read. | 1121 // but the generated code seemed harder to read. |
1404 | 1122 |
1405 template <typename Sig> | 1123 template <typename Sig> |
1406 class InvokerStorage0 : public InvokerStorageBase { | 1124 class InvokerStorage0 : public InvokerStorageBase { |
1407 public: | 1125 public: |
1408 typedef InvokerStorage0 StorageType; | 1126 typedef InvokerStorage0 StorageType; |
1409 typedef FunctionTraits0<StorageType, Sig> FunctionTraits; | 1127 typedef FunctionTraits<Sig> TargetTraits; |
1410 typedef typename FunctionTraits::IsMethod IsMethod; | 1128 typedef Invoker0<StorageType, typename TargetTraits::NormalizedSig> Invoker; |
1411 | 1129 typedef typename TargetTraits::IsMethod IsMethod; |
1412 | 1130 |
1413 | 1131 |
1414 InvokerStorage0(Sig f) | 1132 InvokerStorage0(Sig f) |
1415 : f_(f) { | 1133 : f_(f) { |
1416 } | 1134 } |
1417 | 1135 |
1418 virtual ~InvokerStorage0() { } | 1136 virtual ~InvokerStorage0() { } |
1419 | 1137 |
1420 Sig f_; | 1138 Sig f_; |
1421 }; | 1139 }; |
1422 | 1140 |
1423 template <typename Sig, typename P1> | 1141 template <typename Sig, typename P1> |
1424 class InvokerStorage1 : public InvokerStorageBase { | 1142 class InvokerStorage1 : public InvokerStorageBase { |
1425 public: | 1143 public: |
1426 typedef InvokerStorage1 StorageType; | 1144 typedef InvokerStorage1 StorageType; |
1427 typedef FunctionTraits1<StorageType, Sig> FunctionTraits; | 1145 typedef FunctionTraits<Sig> TargetTraits; |
1428 typedef typename FunctionTraits::IsMethod IsMethod; | 1146 typedef Invoker1<StorageType, typename TargetTraits::NormalizedSig> Invoker; |
1429 | 1147 typedef typename TargetTraits::IsMethod IsMethod; |
1430 // For methods, we need to be careful for parameter 1. We skip the | 1148 // For methods, we need to be careful for parameter 1. We skip the |
1431 // scoped_refptr check because the binder itself takes care of this. We also | 1149 // scoped_refptr check because the binder itself takes care of this. We also |
1432 // disallow binding of an array as the method's target object. | 1150 // disallow binding of an array as the method's target object. |
1433 COMPILE_ASSERT(IsMethod::value || | 1151 COMPILE_ASSERT(IsMethod::value || |
1434 !internal::UnsafeBindtoRefCountedArg<P1>::value, | 1152 !internal::UnsafeBindtoRefCountedArg<P1>::value, |
1435 p1_is_refcounted_type_and_needs_scoped_refptr); | 1153 p1_is_refcounted_type_and_needs_scoped_refptr); |
1436 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 1154 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
1437 first_bound_argument_to_method_cannot_be_array); | 1155 first_bound_argument_to_method_cannot_be_array); |
1438 | 1156 |
1439 | 1157 |
1440 InvokerStorage1(Sig f, const P1& p1) | 1158 InvokerStorage1(Sig f, const P1& p1) |
1441 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)) { | 1159 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)) { |
1442 MaybeRefcount<IsMethod, P1>::AddRef(p1_); | 1160 MaybeRefcount<IsMethod, P1>::AddRef(p1_); |
1443 } | 1161 } |
1444 | 1162 |
1445 virtual ~InvokerStorage1() { | 1163 virtual ~InvokerStorage1() { |
1446 MaybeRefcount<IsMethod, P1>::Release(p1_); | 1164 MaybeRefcount<IsMethod, P1>::Release(p1_); |
1447 } | 1165 } |
1448 | 1166 |
1449 Sig f_; | 1167 Sig f_; |
1450 typename BindType<P1>::StorageType p1_; | 1168 typename BindType<P1>::StorageType p1_; |
1451 }; | 1169 }; |
1452 | 1170 |
1453 template <typename Sig, typename P1, typename P2> | 1171 template <typename Sig, typename P1, typename P2> |
1454 class InvokerStorage2 : public InvokerStorageBase { | 1172 class InvokerStorage2 : public InvokerStorageBase { |
1455 public: | 1173 public: |
1456 typedef InvokerStorage2 StorageType; | 1174 typedef InvokerStorage2 StorageType; |
1457 typedef FunctionTraits2<StorageType, Sig> FunctionTraits; | 1175 typedef FunctionTraits<Sig> TargetTraits; |
1458 typedef typename FunctionTraits::IsMethod IsMethod; | 1176 typedef Invoker2<StorageType, typename TargetTraits::NormalizedSig> Invoker; |
1459 | 1177 typedef typename TargetTraits::IsMethod IsMethod; |
1460 // For methods, we need to be careful for parameter 1. We skip the | 1178 // For methods, we need to be careful for parameter 1. We skip the |
1461 // scoped_refptr check because the binder itself takes care of this. We also | 1179 // scoped_refptr check because the binder itself takes care of this. We also |
1462 // disallow binding of an array as the method's target object. | 1180 // disallow binding of an array as the method's target object. |
1463 COMPILE_ASSERT(IsMethod::value || | 1181 COMPILE_ASSERT(IsMethod::value || |
1464 !internal::UnsafeBindtoRefCountedArg<P1>::value, | 1182 !internal::UnsafeBindtoRefCountedArg<P1>::value, |
1465 p1_is_refcounted_type_and_needs_scoped_refptr); | 1183 p1_is_refcounted_type_and_needs_scoped_refptr); |
1466 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 1184 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
1467 first_bound_argument_to_method_cannot_be_array); | 1185 first_bound_argument_to_method_cannot_be_array); |
1468 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, | 1186 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, |
1469 p2_is_refcounted_type_and_needs_scoped_refptr); | 1187 p2_is_refcounted_type_and_needs_scoped_refptr); |
(...skipping 11 matching lines...) Expand all Loading... | |
1481 | 1199 |
1482 Sig f_; | 1200 Sig f_; |
1483 typename BindType<P1>::StorageType p1_; | 1201 typename BindType<P1>::StorageType p1_; |
1484 typename BindType<P2>::StorageType p2_; | 1202 typename BindType<P2>::StorageType p2_; |
1485 }; | 1203 }; |
1486 | 1204 |
1487 template <typename Sig, typename P1, typename P2, typename P3> | 1205 template <typename Sig, typename P1, typename P2, typename P3> |
1488 class InvokerStorage3 : public InvokerStorageBase { | 1206 class InvokerStorage3 : public InvokerStorageBase { |
1489 public: | 1207 public: |
1490 typedef InvokerStorage3 StorageType; | 1208 typedef InvokerStorage3 StorageType; |
1491 typedef FunctionTraits3<StorageType, Sig> FunctionTraits; | 1209 typedef FunctionTraits<Sig> TargetTraits; |
1492 typedef typename FunctionTraits::IsMethod IsMethod; | 1210 typedef Invoker3<StorageType, typename TargetTraits::NormalizedSig> Invoker; |
1493 | 1211 typedef typename TargetTraits::IsMethod IsMethod; |
1494 // For methods, we need to be careful for parameter 1. We skip the | 1212 // For methods, we need to be careful for parameter 1. We skip the |
1495 // scoped_refptr check because the binder itself takes care of this. We also | 1213 // scoped_refptr check because the binder itself takes care of this. We also |
1496 // disallow binding of an array as the method's target object. | 1214 // disallow binding of an array as the method's target object. |
1497 COMPILE_ASSERT(IsMethod::value || | 1215 COMPILE_ASSERT(IsMethod::value || |
1498 !internal::UnsafeBindtoRefCountedArg<P1>::value, | 1216 !internal::UnsafeBindtoRefCountedArg<P1>::value, |
1499 p1_is_refcounted_type_and_needs_scoped_refptr); | 1217 p1_is_refcounted_type_and_needs_scoped_refptr); |
1500 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 1218 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
1501 first_bound_argument_to_method_cannot_be_array); | 1219 first_bound_argument_to_method_cannot_be_array); |
1502 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, | 1220 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, |
1503 p2_is_refcounted_type_and_needs_scoped_refptr); | 1221 p2_is_refcounted_type_and_needs_scoped_refptr); |
(...skipping 15 matching lines...) Expand all Loading... | |
1519 Sig f_; | 1237 Sig f_; |
1520 typename BindType<P1>::StorageType p1_; | 1238 typename BindType<P1>::StorageType p1_; |
1521 typename BindType<P2>::StorageType p2_; | 1239 typename BindType<P2>::StorageType p2_; |
1522 typename BindType<P3>::StorageType p3_; | 1240 typename BindType<P3>::StorageType p3_; |
1523 }; | 1241 }; |
1524 | 1242 |
1525 template <typename Sig, typename P1, typename P2, typename P3, typename P4> | 1243 template <typename Sig, typename P1, typename P2, typename P3, typename P4> |
1526 class InvokerStorage4 : public InvokerStorageBase { | 1244 class InvokerStorage4 : public InvokerStorageBase { |
1527 public: | 1245 public: |
1528 typedef InvokerStorage4 StorageType; | 1246 typedef InvokerStorage4 StorageType; |
1529 typedef FunctionTraits4<StorageType, Sig> FunctionTraits; | 1247 typedef FunctionTraits<Sig> TargetTraits; |
1530 typedef typename FunctionTraits::IsMethod IsMethod; | 1248 typedef Invoker4<StorageType, typename TargetTraits::NormalizedSig> Invoker; |
1531 | 1249 typedef typename TargetTraits::IsMethod IsMethod; |
1532 // For methods, we need to be careful for parameter 1. We skip the | 1250 // For methods, we need to be careful for parameter 1. We skip the |
1533 // scoped_refptr check because the binder itself takes care of this. We also | 1251 // scoped_refptr check because the binder itself takes care of this. We also |
1534 // disallow binding of an array as the method's target object. | 1252 // disallow binding of an array as the method's target object. |
1535 COMPILE_ASSERT(IsMethod::value || | 1253 COMPILE_ASSERT(IsMethod::value || |
1536 !internal::UnsafeBindtoRefCountedArg<P1>::value, | 1254 !internal::UnsafeBindtoRefCountedArg<P1>::value, |
1537 p1_is_refcounted_type_and_needs_scoped_refptr); | 1255 p1_is_refcounted_type_and_needs_scoped_refptr); |
1538 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 1256 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
1539 first_bound_argument_to_method_cannot_be_array); | 1257 first_bound_argument_to_method_cannot_be_array); |
1540 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, | 1258 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, |
1541 p2_is_refcounted_type_and_needs_scoped_refptr); | 1259 p2_is_refcounted_type_and_needs_scoped_refptr); |
(...skipping 20 matching lines...) Expand all Loading... | |
1562 typename BindType<P2>::StorageType p2_; | 1280 typename BindType<P2>::StorageType p2_; |
1563 typename BindType<P3>::StorageType p3_; | 1281 typename BindType<P3>::StorageType p3_; |
1564 typename BindType<P4>::StorageType p4_; | 1282 typename BindType<P4>::StorageType p4_; |
1565 }; | 1283 }; |
1566 | 1284 |
1567 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | 1285 template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
1568 typename P5> | 1286 typename P5> |
1569 class InvokerStorage5 : public InvokerStorageBase { | 1287 class InvokerStorage5 : public InvokerStorageBase { |
1570 public: | 1288 public: |
1571 typedef InvokerStorage5 StorageType; | 1289 typedef InvokerStorage5 StorageType; |
1572 typedef FunctionTraits5<StorageType, Sig> FunctionTraits; | 1290 typedef FunctionTraits<Sig> TargetTraits; |
1573 typedef typename FunctionTraits::IsMethod IsMethod; | 1291 typedef Invoker5<StorageType, typename TargetTraits::NormalizedSig> Invoker; |
1574 | 1292 typedef typename TargetTraits::IsMethod IsMethod; |
1575 // For methods, we need to be careful for parameter 1. We skip the | 1293 // For methods, we need to be careful for parameter 1. We skip the |
1576 // scoped_refptr check because the binder itself takes care of this. We also | 1294 // scoped_refptr check because the binder itself takes care of this. We also |
1577 // disallow binding of an array as the method's target object. | 1295 // disallow binding of an array as the method's target object. |
1578 COMPILE_ASSERT(IsMethod::value || | 1296 COMPILE_ASSERT(IsMethod::value || |
1579 !internal::UnsafeBindtoRefCountedArg<P1>::value, | 1297 !internal::UnsafeBindtoRefCountedArg<P1>::value, |
1580 p1_is_refcounted_type_and_needs_scoped_refptr); | 1298 p1_is_refcounted_type_and_needs_scoped_refptr); |
1581 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 1299 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
1582 first_bound_argument_to_method_cannot_be_array); | 1300 first_bound_argument_to_method_cannot_be_array); |
1583 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, | 1301 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, |
1584 p2_is_refcounted_type_and_needs_scoped_refptr); | 1302 p2_is_refcounted_type_and_needs_scoped_refptr); |
(...skipping 25 matching lines...) Expand all Loading... | |
1610 typename BindType<P3>::StorageType p3_; | 1328 typename BindType<P3>::StorageType p3_; |
1611 typename BindType<P4>::StorageType p4_; | 1329 typename BindType<P4>::StorageType p4_; |
1612 typename BindType<P5>::StorageType p5_; | 1330 typename BindType<P5>::StorageType p5_; |
1613 }; | 1331 }; |
1614 | 1332 |
1615 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | 1333 template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
1616 typename P5, typename P6> | 1334 typename P5, typename P6> |
1617 class InvokerStorage6 : public InvokerStorageBase { | 1335 class InvokerStorage6 : public InvokerStorageBase { |
1618 public: | 1336 public: |
1619 typedef InvokerStorage6 StorageType; | 1337 typedef InvokerStorage6 StorageType; |
1620 typedef FunctionTraits6<StorageType, Sig> FunctionTraits; | 1338 typedef FunctionTraits<Sig> TargetTraits; |
1621 typedef typename FunctionTraits::IsMethod IsMethod; | 1339 typedef Invoker6<StorageType, typename TargetTraits::NormalizedSig> Invoker; |
1622 | 1340 typedef typename TargetTraits::IsMethod IsMethod; |
1623 // For methods, we need to be careful for parameter 1. We skip the | 1341 // For methods, we need to be careful for parameter 1. We skip the |
1624 // scoped_refptr check because the binder itself takes care of this. We also | 1342 // scoped_refptr check because the binder itself takes care of this. We also |
1625 // disallow binding of an array as the method's target object. | 1343 // disallow binding of an array as the method's target object. |
1626 COMPILE_ASSERT(IsMethod::value || | 1344 COMPILE_ASSERT(IsMethod::value || |
1627 !internal::UnsafeBindtoRefCountedArg<P1>::value, | 1345 !internal::UnsafeBindtoRefCountedArg<P1>::value, |
1628 p1_is_refcounted_type_and_needs_scoped_refptr); | 1346 p1_is_refcounted_type_and_needs_scoped_refptr); |
1629 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 1347 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
1630 first_bound_argument_to_method_cannot_be_array); | 1348 first_bound_argument_to_method_cannot_be_array); |
1631 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, | 1349 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value, |
1632 p2_is_refcounted_type_and_needs_scoped_refptr); | 1350 p2_is_refcounted_type_and_needs_scoped_refptr); |
(...skipping 28 matching lines...) Expand all Loading... | |
1661 typename BindType<P3>::StorageType p3_; | 1379 typename BindType<P3>::StorageType p3_; |
1662 typename BindType<P4>::StorageType p4_; | 1380 typename BindType<P4>::StorageType p4_; |
1663 typename BindType<P5>::StorageType p5_; | 1381 typename BindType<P5>::StorageType p5_; |
1664 typename BindType<P6>::StorageType p6_; | 1382 typename BindType<P6>::StorageType p6_; |
1665 }; | 1383 }; |
1666 | 1384 |
1667 } // namespace internal | 1385 } // namespace internal |
1668 } // namespace base | 1386 } // namespace base |
1669 | 1387 |
1670 #endif // BASE_BIND_INTERNAL_H_ | 1388 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |