OLD | NEW |
---|---|
(Empty) | |
1 // This file was GENERATED by command: | |
2 // pump.py prebind.h.pump | |
3 // DO NOT EDIT BY HAND!!! | |
4 | |
5 | |
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 | |
8 // found in the LICENSE file. | |
9 | |
10 #ifndef BASE_PREBIND_H_ | |
11 #define BASE_PREBIND_H_ | |
12 #pragma once | |
13 | |
14 #include "base/prebind_helpers.h" | |
15 #include "base/template_util.h" | |
16 #include "base/uber_callback.h" | |
17 | |
18 namespace base { | |
19 namespace internal { | |
20 | |
21 // The method by which a function is invoked is determined by 3 different | |
22 // dimensions: | |
23 // | |
24 // 1) The type of function (normal, method, const-method) | |
25 // 2) The arity of the function | |
26 // 3) The number of bound parameters. | |
27 // | |
28 // The FunctionTraitsN classes unwrap the function signature type to | |
29 // specialize based on the first two dimensions. The N in FunctionTraitsN | |
30 // specifies the 3rd dimension. We could have specified the unbound parameters | |
31 // via template parameters, but this method looked cleaner. | |
32 // | |
33 // The FunctionTraitsN contains a static DoInvoke() function that is the key to | |
34 // implementing type erasure in the Callback() classes. DoInvoke() is a static | |
35 // function with a fixed signature that is indepenent of StorageType; its first | |
willchan no longer on Chromium
2011/02/07 20:51:48
independent
awong
2011/02/08 18:52:26
Done.
| |
36 // argument is a pointer to the non-templated common baseclass of StorageType. | |
37 // This lets us store pointer to DoInvoke() in a function pointer that has | |
38 // knowledge of the specific StorageType, and thus no knowledge of the bound | |
39 // function and bound parameter types. | |
40 // | |
41 // 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 | |
43 // safe. | |
44 | |
45 template <typename StorageType, typename Sig> | |
46 struct FunctionTraits0; | |
47 | |
48 // Function: Arity 0 -> 0. | |
49 template <typename StorageType, typename R> | |
50 struct FunctionTraits0<StorageType, R(*)()> { | |
51 typedef base::false_type ShouldRef; | |
52 | |
53 static R DoInvoke(internal::InvokerStorageBase* base) { | |
54 StorageType* invoker = static_cast<StorageType*>(base); | |
55 return invoker->f_(); | |
56 } | |
57 }; | |
58 | |
59 // Function: Arity 1 -> 1. | |
60 template <typename StorageType, typename R,typename X1> | |
61 struct FunctionTraits0<StorageType, R(*)(X1)> { | |
62 COMPILE_ASSERT( | |
63 !( is_non_const_reference<X1>::value ), | |
64 do_not_prebind_functions_with_nonconst_ref); | |
65 | |
66 typedef base::false_type ShouldRef; | |
67 | |
68 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1) { | |
69 StorageType* invoker = static_cast<StorageType*>(base); | |
70 return invoker->f_(x1); | |
71 } | |
72 }; | |
73 | |
74 // Function: Arity 2 -> 2. | |
75 template <typename StorageType, typename R,typename X1, typename X2> | |
76 struct FunctionTraits0<StorageType, R(*)(X1, X2)> { | |
77 COMPILE_ASSERT( | |
78 !( is_non_const_reference<X1>::value || | |
79 is_non_const_reference<X2>::value ), | |
80 do_not_prebind_functions_with_nonconst_ref); | |
81 | |
82 typedef base::false_type ShouldRef; | |
83 | |
84 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
85 const X2& x2) { | |
86 StorageType* invoker = static_cast<StorageType*>(base); | |
87 return invoker->f_(x1, x2); | |
88 } | |
89 }; | |
90 | |
91 // Function: Arity 3 -> 3. | |
92 template <typename StorageType, typename R,typename X1, typename X2, | |
93 typename X3> | |
94 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3)> { | |
95 COMPILE_ASSERT( | |
96 !( is_non_const_reference<X1>::value || | |
97 is_non_const_reference<X2>::value || | |
98 is_non_const_reference<X3>::value ), | |
99 do_not_prebind_functions_with_nonconst_ref); | |
100 | |
101 typedef base::false_type ShouldRef; | |
102 | |
103 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
104 const X2& x2, const X3& x3) { | |
105 StorageType* invoker = static_cast<StorageType*>(base); | |
106 return invoker->f_(x1, x2, x3); | |
107 } | |
108 }; | |
109 | |
110 // Function: Arity 4 -> 4. | |
111 template <typename StorageType, typename R,typename X1, typename X2, | |
112 typename X3, typename X4> | |
113 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4)> { | |
114 COMPILE_ASSERT( | |
115 !( is_non_const_reference<X1>::value || | |
116 is_non_const_reference<X2>::value || | |
117 is_non_const_reference<X3>::value || | |
118 is_non_const_reference<X4>::value ), | |
119 do_not_prebind_functions_with_nonconst_ref); | |
120 | |
121 typedef base::false_type ShouldRef; | |
122 | |
123 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
124 const X2& x2, const X3& x3, const X4& x4) { | |
125 StorageType* invoker = static_cast<StorageType*>(base); | |
126 return invoker->f_(x1, x2, x3, x4); | |
127 } | |
128 }; | |
129 | |
130 // Function: Arity 5 -> 5. | |
131 template <typename StorageType, typename R,typename X1, typename X2, | |
132 typename X3, typename X4, typename X5> | |
133 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
134 COMPILE_ASSERT( | |
135 !( is_non_const_reference<X1>::value || | |
136 is_non_const_reference<X2>::value || | |
137 is_non_const_reference<X3>::value || | |
138 is_non_const_reference<X4>::value || | |
139 is_non_const_reference<X5>::value ), | |
140 do_not_prebind_functions_with_nonconst_ref); | |
141 | |
142 typedef base::false_type ShouldRef; | |
143 | |
144 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
145 const X2& x2, const X3& x3, const X4& x4, const X5& x5) { | |
146 StorageType* invoker = static_cast<StorageType*>(base); | |
147 return invoker->f_(x1, x2, x3, x4, x5); | |
148 } | |
149 }; | |
150 | |
151 // Function: Arity 6 -> 6. | |
152 template <typename StorageType, typename R,typename X1, typename X2, | |
153 typename X3, typename X4, typename X5, typename X6> | |
154 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | |
155 COMPILE_ASSERT( | |
156 !( is_non_const_reference<X1>::value || | |
157 is_non_const_reference<X2>::value || | |
158 is_non_const_reference<X3>::value || | |
159 is_non_const_reference<X4>::value || | |
160 is_non_const_reference<X5>::value || | |
161 is_non_const_reference<X6>::value ), | |
162 do_not_prebind_functions_with_nonconst_ref); | |
163 | |
164 typedef base::false_type ShouldRef; | |
165 | |
166 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
167 const X2& x2, const X3& x3, const X4& x4, const X5& x5, const X6& x6) { | |
168 StorageType* invoker = static_cast<StorageType*>(base); | |
169 return invoker->f_(x1, x2, x3, x4, x5, x6); | |
170 } | |
171 }; | |
172 | |
173 template <typename StorageType, typename Sig> | |
174 struct FunctionTraits1; | |
175 | |
176 // Function: Arity 1 -> 0. | |
177 template <typename StorageType, typename R,typename X1> | |
178 struct FunctionTraits1<StorageType, R(*)(X1)> { | |
179 COMPILE_ASSERT( | |
180 !( is_non_const_reference<X1>::value ), | |
181 do_not_prebind_functions_with_nonconst_ref); | |
182 | |
183 typedef base::false_type ShouldRef; | |
184 | |
185 static R DoInvoke(internal::InvokerStorageBase* base) { | |
186 StorageType* invoker = static_cast<StorageType*>(base); | |
187 return invoker->f_(Unwrap(invoker->p1_)); | |
188 } | |
189 }; | |
190 | |
191 // Method: Arity 0 -> 0. | |
192 template <typename StorageType, typename R, typename T> | |
193 struct FunctionTraits1<StorageType, R(T::*)()> { | |
194 typedef base::true_type ShouldRef; | |
195 static R DoInvoke(internal::InvokerStorageBase* base) { | |
196 StorageType* invoker = static_cast<StorageType*>(base); | |
197 return (Unwrap(invoker->p1_)->*invoker->f_)(); | |
198 } | |
199 }; | |
200 | |
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 ShouldRef; | |
205 static R DoInvoke(internal::InvokerStorageBase* base ) { | |
206 StorageType* invoker = static_cast<StorageType*>(base); | |
207 return (Unwrap(invoker->p1_)->*invoker->f_)(); | |
208 } | |
209 }; | |
210 | |
211 // Function: Arity 2 -> 1. | |
212 template <typename StorageType, typename R,typename X1, typename X2> | |
213 struct FunctionTraits1<StorageType, R(*)(X1, X2)> { | |
214 COMPILE_ASSERT( | |
215 !( is_non_const_reference<X1>::value || | |
216 is_non_const_reference<X2>::value ), | |
217 do_not_prebind_functions_with_nonconst_ref); | |
218 | |
219 typedef base::false_type ShouldRef; | |
220 | |
221 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2) { | |
222 StorageType* invoker = static_cast<StorageType*>(base); | |
223 return invoker->f_(Unwrap(invoker->p1_), x2); | |
224 } | |
225 }; | |
226 | |
227 // Method: Arity 1 -> 1. | |
228 template <typename StorageType, typename R, typename T, typename X1> | |
229 struct FunctionTraits1<StorageType, R(T::*)(X1)> { | |
230 typedef base::true_type ShouldRef; | |
231 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1) { | |
232 StorageType* invoker = static_cast<StorageType*>(base); | |
233 return (Unwrap(invoker->p1_)->*invoker->f_)(x1); | |
234 } | |
235 }; | |
236 | |
237 // Const Method: Arity 1 -> 1. | |
238 template <typename StorageType, typename R, typename T, typename X1> | |
239 struct FunctionTraits1<StorageType, R(T::*)(X1) const> { | |
240 typedef base::true_type ShouldRef; | |
241 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1) { | |
242 StorageType* invoker = static_cast<StorageType*>(base); | |
243 return (Unwrap(invoker->p1_)->*invoker->f_)(x1); | |
244 } | |
245 }; | |
246 | |
247 // Function: Arity 3 -> 2. | |
248 template <typename StorageType, typename R,typename X1, typename X2, | |
249 typename X3> | |
250 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3)> { | |
251 COMPILE_ASSERT( | |
252 !( is_non_const_reference<X1>::value || | |
253 is_non_const_reference<X2>::value || | |
254 is_non_const_reference<X3>::value ), | |
255 do_not_prebind_functions_with_nonconst_ref); | |
256 | |
257 typedef base::false_type ShouldRef; | |
258 | |
259 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
260 const X3& x3) { | |
261 StorageType* invoker = static_cast<StorageType*>(base); | |
262 return invoker->f_(Unwrap(invoker->p1_), x2, x3); | |
263 } | |
264 }; | |
265 | |
266 // Method: Arity 2 -> 2. | |
267 template <typename StorageType, typename R, typename T, typename X1, | |
268 typename X2> | |
269 struct FunctionTraits1<StorageType, R(T::*)(X1, X2)> { | |
270 typedef base::true_type ShouldRef; | |
271 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
272 const X2& x2) { | |
273 StorageType* invoker = static_cast<StorageType*>(base); | |
274 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); | |
275 } | |
276 }; | |
277 | |
278 // Const Method: Arity 2 -> 2. | |
279 template <typename StorageType, typename R, typename T, typename X1, | |
280 typename X2> | |
281 struct FunctionTraits1<StorageType, R(T::*)(X1, X2) const> { | |
282 typedef base::true_type ShouldRef; | |
283 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
284 const X2& x2) { | |
285 StorageType* invoker = static_cast<StorageType*>(base); | |
286 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); | |
287 } | |
288 }; | |
289 | |
290 // Function: Arity 4 -> 3. | |
291 template <typename StorageType, typename R,typename X1, typename X2, | |
292 typename X3, typename X4> | |
293 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4)> { | |
294 COMPILE_ASSERT( | |
295 !( is_non_const_reference<X1>::value || | |
296 is_non_const_reference<X2>::value || | |
297 is_non_const_reference<X3>::value || | |
298 is_non_const_reference<X4>::value ), | |
299 do_not_prebind_functions_with_nonconst_ref); | |
300 | |
301 typedef base::false_type ShouldRef; | |
302 | |
303 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
304 const X3& x3, const X4& x4) { | |
305 StorageType* invoker = static_cast<StorageType*>(base); | |
306 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4); | |
307 } | |
308 }; | |
309 | |
310 // Method: Arity 3 -> 3. | |
311 template <typename StorageType, typename R, typename T, typename X1, | |
312 typename X2, typename X3> | |
313 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3)> { | |
314 typedef base::true_type ShouldRef; | |
315 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
316 const X2& x2, const X3& x3) { | |
317 StorageType* invoker = static_cast<StorageType*>(base); | |
318 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); | |
319 } | |
320 }; | |
321 | |
322 // Const Method: Arity 3 -> 3. | |
323 template <typename StorageType, typename R, typename T, typename X1, | |
324 typename X2, typename X3> | |
325 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3) const> { | |
326 typedef base::true_type ShouldRef; | |
327 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
328 const X2& x2, const X3& x3) { | |
329 StorageType* invoker = static_cast<StorageType*>(base); | |
330 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); | |
331 } | |
332 }; | |
333 | |
334 // Function: Arity 5 -> 4. | |
335 template <typename StorageType, typename R,typename X1, typename X2, | |
336 typename X3, typename X4, typename X5> | |
337 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
338 COMPILE_ASSERT( | |
339 !( is_non_const_reference<X1>::value || | |
340 is_non_const_reference<X2>::value || | |
341 is_non_const_reference<X3>::value || | |
342 is_non_const_reference<X4>::value || | |
343 is_non_const_reference<X5>::value ), | |
344 do_not_prebind_functions_with_nonconst_ref); | |
345 | |
346 typedef base::false_type ShouldRef; | |
347 | |
348 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
349 const X3& x3, const X4& x4, const X5& x5) { | |
350 StorageType* invoker = static_cast<StorageType*>(base); | |
351 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5); | |
352 } | |
353 }; | |
354 | |
355 // Method: Arity 4 -> 4. | |
356 template <typename StorageType, typename R, typename T, typename X1, | |
357 typename X2, typename X3, typename X4> | |
358 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4)> { | |
359 typedef base::true_type ShouldRef; | |
360 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
361 const X2& x2, const X3& x3, const X4& x4) { | |
362 StorageType* invoker = static_cast<StorageType*>(base); | |
363 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); | |
364 } | |
365 }; | |
366 | |
367 // Const Method: Arity 4 -> 4. | |
368 template <typename StorageType, typename R, typename T, typename X1, | |
369 typename X2, typename X3, typename X4> | |
370 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
371 typedef base::true_type ShouldRef; | |
372 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
373 const X2& x2, const X3& x3, const X4& x4) { | |
374 StorageType* invoker = static_cast<StorageType*>(base); | |
375 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); | |
376 } | |
377 }; | |
378 | |
379 // Function: Arity 6 -> 5. | |
380 template <typename StorageType, typename R,typename X1, typename X2, | |
381 typename X3, typename X4, typename X5, typename X6> | |
382 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | |
383 COMPILE_ASSERT( | |
384 !( is_non_const_reference<X1>::value || | |
385 is_non_const_reference<X2>::value || | |
386 is_non_const_reference<X3>::value || | |
387 is_non_const_reference<X4>::value || | |
388 is_non_const_reference<X5>::value || | |
389 is_non_const_reference<X6>::value ), | |
390 do_not_prebind_functions_with_nonconst_ref); | |
391 | |
392 typedef base::false_type ShouldRef; | |
393 | |
394 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
395 const X3& x3, const X4& x4, const X5& x5, const X6& x6) { | |
396 StorageType* invoker = static_cast<StorageType*>(base); | |
397 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6); | |
398 } | |
399 }; | |
400 | |
401 // Method: Arity 5 -> 5. | |
402 template <typename StorageType, typename R, typename T, typename X1, | |
403 typename X2, typename X3, typename X4, typename X5> | |
404 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | |
405 typedef base::true_type ShouldRef; | |
406 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
407 const X2& x2, const X3& x3, const X4& x4, const X5& x5) { | |
408 StorageType* invoker = static_cast<StorageType*>(base); | |
409 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); | |
410 } | |
411 }; | |
412 | |
413 // Const Method: Arity 5 -> 5. | |
414 template <typename StorageType, typename R, typename T, typename X1, | |
415 typename X2, typename X3, typename X4, typename X5> | |
416 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
417 typedef base::true_type ShouldRef; | |
418 static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, | |
419 const X2& x2, const X3& x3, const X4& x4, const X5& x5) { | |
420 StorageType* invoker = static_cast<StorageType*>(base); | |
421 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); | |
422 } | |
423 }; | |
424 | |
425 template <typename StorageType, typename Sig> | |
426 struct FunctionTraits2; | |
427 | |
428 // Function: Arity 2 -> 0. | |
429 template <typename StorageType, typename R,typename X1, typename X2> | |
430 struct FunctionTraits2<StorageType, R(*)(X1, X2)> { | |
431 COMPILE_ASSERT( | |
432 !( is_non_const_reference<X1>::value || | |
433 is_non_const_reference<X2>::value ), | |
434 do_not_prebind_functions_with_nonconst_ref); | |
435 | |
436 typedef base::false_type ShouldRef; | |
437 | |
438 static R DoInvoke(internal::InvokerStorageBase* base) { | |
439 StorageType* invoker = static_cast<StorageType*>(base); | |
440 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_)); | |
441 } | |
442 }; | |
443 | |
444 // Method: Arity 1 -> 0. | |
445 template <typename StorageType, typename R, typename T, typename X1> | |
446 struct FunctionTraits2<StorageType, R(T::*)(X1)> { | |
447 typedef base::true_type ShouldRef; | |
448 static R DoInvoke(internal::InvokerStorageBase* base) { | |
449 StorageType* invoker = static_cast<StorageType*>(base); | |
450 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); | |
451 } | |
452 }; | |
453 | |
454 // Const Method: Arity 1 -> 0. | |
455 template <typename StorageType, typename R, typename T, typename X1> | |
456 struct FunctionTraits2<StorageType, R(T::*)(X1) const> { | |
457 typedef base::true_type ShouldRef; | |
458 static R DoInvoke(internal::InvokerStorageBase* base ) { | |
459 StorageType* invoker = static_cast<StorageType*>(base); | |
460 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); | |
461 } | |
462 }; | |
463 | |
464 // Function: Arity 3 -> 1. | |
465 template <typename StorageType, typename R,typename X1, typename X2, | |
466 typename X3> | |
467 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3)> { | |
468 COMPILE_ASSERT( | |
469 !( is_non_const_reference<X1>::value || | |
470 is_non_const_reference<X2>::value || | |
471 is_non_const_reference<X3>::value ), | |
472 do_not_prebind_functions_with_nonconst_ref); | |
473 | |
474 typedef base::false_type ShouldRef; | |
475 | |
476 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3) { | |
477 StorageType* invoker = static_cast<StorageType*>(base); | |
478 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3); | |
479 } | |
480 }; | |
481 | |
482 // Method: Arity 2 -> 1. | |
483 template <typename StorageType, typename R, typename T, typename X1, | |
484 typename X2> | |
485 struct FunctionTraits2<StorageType, R(T::*)(X1, X2)> { | |
486 typedef base::true_type ShouldRef; | |
487 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2) { | |
488 StorageType* invoker = static_cast<StorageType*>(base); | |
489 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); | |
490 } | |
491 }; | |
492 | |
493 // Const Method: Arity 2 -> 1. | |
494 template <typename StorageType, typename R, typename T, typename X1, | |
495 typename X2> | |
496 struct FunctionTraits2<StorageType, R(T::*)(X1, X2) const> { | |
497 typedef base::true_type ShouldRef; | |
498 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2) { | |
499 StorageType* invoker = static_cast<StorageType*>(base); | |
500 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); | |
501 } | |
502 }; | |
503 | |
504 // Function: Arity 4 -> 2. | |
505 template <typename StorageType, typename R,typename X1, typename X2, | |
506 typename X3, typename X4> | |
507 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4)> { | |
508 COMPILE_ASSERT( | |
509 !( is_non_const_reference<X1>::value || | |
510 is_non_const_reference<X2>::value || | |
511 is_non_const_reference<X3>::value || | |
512 is_non_const_reference<X4>::value ), | |
513 do_not_prebind_functions_with_nonconst_ref); | |
514 | |
515 typedef base::false_type ShouldRef; | |
516 | |
517 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, | |
518 const X4& x4) { | |
519 StorageType* invoker = static_cast<StorageType*>(base); | |
520 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4); | |
521 } | |
522 }; | |
523 | |
524 // Method: Arity 3 -> 2. | |
525 template <typename StorageType, typename R, typename T, typename X1, | |
526 typename X2, typename X3> | |
527 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3)> { | |
528 typedef base::true_type ShouldRef; | |
529 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
530 const X3& x3) { | |
531 StorageType* invoker = static_cast<StorageType*>(base); | |
532 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); | |
533 } | |
534 }; | |
535 | |
536 // Const Method: Arity 3 -> 2. | |
537 template <typename StorageType, typename R, typename T, typename X1, | |
538 typename X2, typename X3> | |
539 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3) const> { | |
540 typedef base::true_type ShouldRef; | |
541 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
542 const X3& x3) { | |
543 StorageType* invoker = static_cast<StorageType*>(base); | |
544 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); | |
545 } | |
546 }; | |
547 | |
548 // Function: Arity 5 -> 3. | |
549 template <typename StorageType, typename R,typename X1, typename X2, | |
550 typename X3, typename X4, typename X5> | |
551 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
552 COMPILE_ASSERT( | |
553 !( is_non_const_reference<X1>::value || | |
554 is_non_const_reference<X2>::value || | |
555 is_non_const_reference<X3>::value || | |
556 is_non_const_reference<X4>::value || | |
557 is_non_const_reference<X5>::value ), | |
558 do_not_prebind_functions_with_nonconst_ref); | |
559 | |
560 typedef base::false_type ShouldRef; | |
561 | |
562 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, | |
563 const X4& x4, const X5& x5) { | |
564 StorageType* invoker = static_cast<StorageType*>(base); | |
565 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5); | |
566 } | |
567 }; | |
568 | |
569 // Method: Arity 4 -> 3. | |
570 template <typename StorageType, typename R, typename T, typename X1, | |
571 typename X2, typename X3, typename X4> | |
572 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4)> { | |
573 typedef base::true_type ShouldRef; | |
574 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
575 const X3& x3, const X4& x4) { | |
576 StorageType* invoker = static_cast<StorageType*>(base); | |
577 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | |
578 x4); | |
579 } | |
580 }; | |
581 | |
582 // Const Method: Arity 4 -> 3. | |
583 template <typename StorageType, typename R, typename T, typename X1, | |
584 typename X2, typename X3, typename X4> | |
585 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
586 typedef base::true_type ShouldRef; | |
587 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
588 const X3& x3, const X4& x4) { | |
589 StorageType* invoker = static_cast<StorageType*>(base); | |
590 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | |
591 x4); | |
592 } | |
593 }; | |
594 | |
595 // Function: Arity 6 -> 4. | |
596 template <typename StorageType, typename R,typename X1, typename X2, | |
597 typename X3, typename X4, typename X5, typename X6> | |
598 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | |
599 COMPILE_ASSERT( | |
600 !( is_non_const_reference<X1>::value || | |
601 is_non_const_reference<X2>::value || | |
602 is_non_const_reference<X3>::value || | |
603 is_non_const_reference<X4>::value || | |
604 is_non_const_reference<X5>::value || | |
605 is_non_const_reference<X6>::value ), | |
606 do_not_prebind_functions_with_nonconst_ref); | |
607 | |
608 typedef base::false_type ShouldRef; | |
609 | |
610 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, | |
611 const X4& x4, const X5& x5, const X6& x6) { | |
612 StorageType* invoker = static_cast<StorageType*>(base); | |
613 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5, | |
614 x6); | |
615 } | |
616 }; | |
617 | |
618 // Method: Arity 5 -> 4. | |
619 template <typename StorageType, typename R, typename T, typename X1, | |
620 typename X2, typename X3, typename X4, typename X5> | |
621 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | |
622 typedef base::true_type ShouldRef; | |
623 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
624 const X3& x3, const X4& x4, const X5& x5) { | |
625 StorageType* invoker = static_cast<StorageType*>(base); | |
626 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | |
627 x4, x5); | |
628 } | |
629 }; | |
630 | |
631 // Const Method: Arity 5 -> 4. | |
632 template <typename StorageType, typename R, typename T, typename X1, | |
633 typename X2, typename X3, typename X4, typename X5> | |
634 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
635 typedef base::true_type ShouldRef; | |
636 static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, | |
637 const X3& x3, const X4& x4, const X5& x5) { | |
638 StorageType* invoker = static_cast<StorageType*>(base); | |
639 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | |
640 x4, x5); | |
641 } | |
642 }; | |
643 | |
644 template <typename StorageType, typename Sig> | |
645 struct FunctionTraits3; | |
646 | |
647 // Function: Arity 3 -> 0. | |
648 template <typename StorageType, typename R,typename X1, typename X2, | |
649 typename X3> | |
650 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3)> { | |
651 COMPILE_ASSERT( | |
652 !( is_non_const_reference<X1>::value || | |
653 is_non_const_reference<X2>::value || | |
654 is_non_const_reference<X3>::value ), | |
655 do_not_prebind_functions_with_nonconst_ref); | |
656 | |
657 typedef base::false_type ShouldRef; | |
658 | |
659 static R DoInvoke(internal::InvokerStorageBase* base) { | |
660 StorageType* invoker = static_cast<StorageType*>(base); | |
661 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
662 Unwrap(invoker->p3_)); | |
663 } | |
664 }; | |
665 | |
666 // Method: Arity 2 -> 0. | |
667 template <typename StorageType, typename R, typename T, typename X1, | |
668 typename X2> | |
669 struct FunctionTraits3<StorageType, R(T::*)(X1, X2)> { | |
670 typedef base::true_type ShouldRef; | |
671 static R DoInvoke(internal::InvokerStorageBase* base) { | |
672 StorageType* invoker = static_cast<StorageType*>(base); | |
673 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
674 Unwrap(invoker->p3_)); | |
675 } | |
676 }; | |
677 | |
678 // Const Method: Arity 2 -> 0. | |
679 template <typename StorageType, typename R, typename T, typename X1, | |
680 typename X2> | |
681 struct FunctionTraits3<StorageType, R(T::*)(X1, X2) const> { | |
682 typedef base::true_type ShouldRef; | |
683 static R DoInvoke(internal::InvokerStorageBase* base ) { | |
684 StorageType* invoker = static_cast<StorageType*>(base); | |
685 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
686 Unwrap(invoker->p3_)); | |
687 } | |
688 }; | |
689 | |
690 // Function: Arity 4 -> 1. | |
691 template <typename StorageType, typename R,typename X1, typename X2, | |
692 typename X3, typename X4> | |
693 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4)> { | |
694 COMPILE_ASSERT( | |
695 !( is_non_const_reference<X1>::value || | |
696 is_non_const_reference<X2>::value || | |
697 is_non_const_reference<X3>::value || | |
698 is_non_const_reference<X4>::value ), | |
699 do_not_prebind_functions_with_nonconst_ref); | |
700 | |
701 typedef base::false_type ShouldRef; | |
702 | |
703 static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4) { | |
704 StorageType* invoker = static_cast<StorageType*>(base); | |
705 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
706 Unwrap(invoker->p3_), x4); | |
707 } | |
708 }; | |
709 | |
710 // Method: Arity 3 -> 1. | |
711 template <typename StorageType, typename R, typename T, typename X1, | |
712 typename X2, typename X3> | |
713 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3)> { | |
714 typedef base::true_type ShouldRef; | |
715 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3) { | |
716 StorageType* invoker = static_cast<StorageType*>(base); | |
717 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
718 Unwrap(invoker->p3_), x3); | |
719 } | |
720 }; | |
721 | |
722 // Const Method: Arity 3 -> 1. | |
723 template <typename StorageType, typename R, typename T, typename X1, | |
724 typename X2, typename X3> | |
725 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3) const> { | |
726 typedef base::true_type ShouldRef; | |
727 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3) { | |
728 StorageType* invoker = static_cast<StorageType*>(base); | |
729 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
730 Unwrap(invoker->p3_), x3); | |
731 } | |
732 }; | |
733 | |
734 // Function: Arity 5 -> 2. | |
735 template <typename StorageType, typename R,typename X1, typename X2, | |
736 typename X3, typename X4, typename X5> | |
737 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
738 COMPILE_ASSERT( | |
739 !( is_non_const_reference<X1>::value || | |
740 is_non_const_reference<X2>::value || | |
741 is_non_const_reference<X3>::value || | |
742 is_non_const_reference<X4>::value || | |
743 is_non_const_reference<X5>::value ), | |
744 do_not_prebind_functions_with_nonconst_ref); | |
745 | |
746 typedef base::false_type ShouldRef; | |
747 | |
748 static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, | |
749 const X5& x5) { | |
750 StorageType* invoker = static_cast<StorageType*>(base); | |
751 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
752 Unwrap(invoker->p3_), x4, x5); | |
753 } | |
754 }; | |
755 | |
756 // Method: Arity 4 -> 2. | |
757 template <typename StorageType, typename R, typename T, typename X1, | |
758 typename X2, typename X3, typename X4> | |
759 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4)> { | |
760 typedef base::true_type ShouldRef; | |
761 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, | |
762 const X4& x4) { | |
763 StorageType* invoker = static_cast<StorageType*>(base); | |
764 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
765 Unwrap(invoker->p3_), x3, x4); | |
766 } | |
767 }; | |
768 | |
769 // Const Method: Arity 4 -> 2. | |
770 template <typename StorageType, typename R, typename T, typename X1, | |
771 typename X2, typename X3, typename X4> | |
772 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
773 typedef base::true_type ShouldRef; | |
774 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, | |
775 const X4& x4) { | |
776 StorageType* invoker = static_cast<StorageType*>(base); | |
777 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
778 Unwrap(invoker->p3_), x3, x4); | |
779 } | |
780 }; | |
781 | |
782 // Function: Arity 6 -> 3. | |
783 template <typename StorageType, typename R,typename X1, typename X2, | |
784 typename X3, typename X4, typename X5, typename X6> | |
785 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | |
786 COMPILE_ASSERT( | |
787 !( is_non_const_reference<X1>::value || | |
788 is_non_const_reference<X2>::value || | |
789 is_non_const_reference<X3>::value || | |
790 is_non_const_reference<X4>::value || | |
791 is_non_const_reference<X5>::value || | |
792 is_non_const_reference<X6>::value ), | |
793 do_not_prebind_functions_with_nonconst_ref); | |
794 | |
795 typedef base::false_type ShouldRef; | |
796 | |
797 static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, | |
798 const X5& x5, const X6& x6) { | |
799 StorageType* invoker = static_cast<StorageType*>(base); | |
800 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
801 Unwrap(invoker->p3_), x4, x5, x6); | |
802 } | |
803 }; | |
804 | |
805 // Method: Arity 5 -> 3. | |
806 template <typename StorageType, typename R, typename T, typename X1, | |
807 typename X2, typename X3, typename X4, typename X5> | |
808 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | |
809 typedef base::true_type ShouldRef; | |
810 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, | |
811 const X4& x4, const X5& x5) { | |
812 StorageType* invoker = static_cast<StorageType*>(base); | |
813 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
814 Unwrap(invoker->p3_), x3, x4, x5); | |
815 } | |
816 }; | |
817 | |
818 // Const Method: Arity 5 -> 3. | |
819 template <typename StorageType, typename R, typename T, typename X1, | |
820 typename X2, typename X3, typename X4, typename X5> | |
821 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
822 typedef base::true_type ShouldRef; | |
823 static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, | |
824 const X4& x4, const X5& x5) { | |
825 StorageType* invoker = static_cast<StorageType*>(base); | |
826 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
827 Unwrap(invoker->p3_), x3, x4, x5); | |
828 } | |
829 }; | |
830 | |
831 template <typename StorageType, typename Sig> | |
832 struct FunctionTraits4; | |
833 | |
834 // Function: Arity 4 -> 0. | |
835 template <typename StorageType, typename R,typename X1, typename X2, | |
836 typename X3, typename X4> | |
837 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4)> { | |
838 COMPILE_ASSERT( | |
839 !( is_non_const_reference<X1>::value || | |
840 is_non_const_reference<X2>::value || | |
841 is_non_const_reference<X3>::value || | |
842 is_non_const_reference<X4>::value ), | |
843 do_not_prebind_functions_with_nonconst_ref); | |
844 | |
845 typedef base::false_type ShouldRef; | |
846 | |
847 static R DoInvoke(internal::InvokerStorageBase* base) { | |
848 StorageType* invoker = static_cast<StorageType*>(base); | |
849 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
850 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | |
851 } | |
852 }; | |
853 | |
854 // Method: Arity 3 -> 0. | |
855 template <typename StorageType, typename R, typename T, typename X1, | |
856 typename X2, typename X3> | |
857 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3)> { | |
858 typedef base::true_type ShouldRef; | |
859 static R DoInvoke(internal::InvokerStorageBase* base) { | |
860 StorageType* invoker = static_cast<StorageType*>(base); | |
861 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
862 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | |
863 } | |
864 }; | |
865 | |
866 // Const Method: Arity 3 -> 0. | |
867 template <typename StorageType, typename R, typename T, typename X1, | |
868 typename X2, typename X3> | |
869 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3) const> { | |
870 typedef base::true_type ShouldRef; | |
871 static R DoInvoke(internal::InvokerStorageBase* base ) { | |
872 StorageType* invoker = static_cast<StorageType*>(base); | |
873 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
874 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | |
875 } | |
876 }; | |
877 | |
878 // Function: Arity 5 -> 1. | |
879 template <typename StorageType, typename R,typename X1, typename X2, | |
880 typename X3, typename X4, typename X5> | |
881 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
882 COMPILE_ASSERT( | |
883 !( is_non_const_reference<X1>::value || | |
884 is_non_const_reference<X2>::value || | |
885 is_non_const_reference<X3>::value || | |
886 is_non_const_reference<X4>::value || | |
887 is_non_const_reference<X5>::value ), | |
888 do_not_prebind_functions_with_nonconst_ref); | |
889 | |
890 typedef base::false_type ShouldRef; | |
891 | |
892 static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5) { | |
893 StorageType* invoker = static_cast<StorageType*>(base); | |
894 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
895 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5); | |
896 } | |
897 }; | |
898 | |
899 // Method: Arity 4 -> 1. | |
900 template <typename StorageType, typename R, typename T, typename X1, | |
901 typename X2, typename X3, typename X4> | |
902 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4)> { | |
903 typedef base::true_type ShouldRef; | |
904 static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4) { | |
905 StorageType* invoker = static_cast<StorageType*>(base); | |
906 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
907 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); | |
908 } | |
909 }; | |
910 | |
911 // Const Method: Arity 4 -> 1. | |
912 template <typename StorageType, typename R, typename T, typename X1, | |
913 typename X2, typename X3, typename X4> | |
914 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
915 typedef base::true_type ShouldRef; | |
916 static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4) { | |
917 StorageType* invoker = static_cast<StorageType*>(base); | |
918 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
919 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); | |
920 } | |
921 }; | |
922 | |
923 // Function: Arity 6 -> 2. | |
924 template <typename StorageType, typename R,typename X1, typename X2, | |
925 typename X3, typename X4, typename X5, typename X6> | |
926 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | |
927 COMPILE_ASSERT( | |
928 !( is_non_const_reference<X1>::value || | |
929 is_non_const_reference<X2>::value || | |
930 is_non_const_reference<X3>::value || | |
931 is_non_const_reference<X4>::value || | |
932 is_non_const_reference<X5>::value || | |
933 is_non_const_reference<X6>::value ), | |
934 do_not_prebind_functions_with_nonconst_ref); | |
935 | |
936 typedef base::false_type ShouldRef; | |
937 | |
938 static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5, | |
939 const X6& x6) { | |
940 StorageType* invoker = static_cast<StorageType*>(base); | |
941 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
942 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5, x6); | |
943 } | |
944 }; | |
945 | |
946 // Method: Arity 5 -> 2. | |
947 template <typename StorageType, typename R, typename T, typename X1, | |
948 typename X2, typename X3, typename X4, typename X5> | |
949 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | |
950 typedef base::true_type ShouldRef; | |
951 static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, | |
952 const X5& x5) { | |
953 StorageType* invoker = static_cast<StorageType*>(base); | |
954 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
955 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); | |
956 } | |
957 }; | |
958 | |
959 // Const Method: Arity 5 -> 2. | |
960 template <typename StorageType, typename R, typename T, typename X1, | |
961 typename X2, typename X3, typename X4, typename X5> | |
962 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
963 typedef base::true_type ShouldRef; | |
964 static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, | |
965 const X5& x5) { | |
966 StorageType* invoker = static_cast<StorageType*>(base); | |
967 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
968 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); | |
969 } | |
970 }; | |
971 | |
972 template <typename StorageType, typename Sig> | |
973 struct FunctionTraits5; | |
974 | |
975 // Function: Arity 5 -> 0. | |
976 template <typename StorageType, typename R,typename X1, typename X2, | |
977 typename X3, typename X4, typename X5> | |
978 struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
979 COMPILE_ASSERT( | |
980 !( is_non_const_reference<X1>::value || | |
981 is_non_const_reference<X2>::value || | |
982 is_non_const_reference<X3>::value || | |
983 is_non_const_reference<X4>::value || | |
984 is_non_const_reference<X5>::value ), | |
985 do_not_prebind_functions_with_nonconst_ref); | |
986 | |
987 typedef base::false_type ShouldRef; | |
988 | |
989 static R DoInvoke(internal::InvokerStorageBase* base) { | |
990 StorageType* invoker = static_cast<StorageType*>(base); | |
991 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
992 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | |
993 } | |
994 }; | |
995 | |
996 // Method: Arity 4 -> 0. | |
997 template <typename StorageType, typename R, typename T, typename X1, | |
998 typename X2, typename X3, typename X4> | |
999 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4)> { | |
1000 typedef base::true_type ShouldRef; | |
1001 static R DoInvoke(internal::InvokerStorageBase* base) { | |
1002 StorageType* invoker = static_cast<StorageType*>(base); | |
1003 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1004 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | |
1005 } | |
1006 }; | |
1007 | |
1008 // Const Method: Arity 4 -> 0. | |
1009 template <typename StorageType, typename R, typename T, typename X1, | |
1010 typename X2, typename X3, typename X4> | |
1011 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4) const> { | |
1012 typedef base::true_type ShouldRef; | |
1013 static R DoInvoke(internal::InvokerStorageBase* base ) { | |
1014 StorageType* invoker = static_cast<StorageType*>(base); | |
1015 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1016 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | |
1017 } | |
1018 }; | |
1019 | |
1020 // Function: Arity 6 -> 1. | |
1021 template <typename StorageType, typename R,typename X1, typename X2, | |
1022 typename X3, typename X4, typename X5, typename X6> | |
1023 struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | |
1024 COMPILE_ASSERT( | |
1025 !( is_non_const_reference<X1>::value || | |
1026 is_non_const_reference<X2>::value || | |
1027 is_non_const_reference<X3>::value || | |
1028 is_non_const_reference<X4>::value || | |
1029 is_non_const_reference<X5>::value || | |
1030 is_non_const_reference<X6>::value ), | |
1031 do_not_prebind_functions_with_nonconst_ref); | |
1032 | |
1033 typedef base::false_type ShouldRef; | |
1034 | |
1035 static R DoInvoke(internal::InvokerStorageBase* base, const X6& x6) { | |
1036 StorageType* invoker = static_cast<StorageType*>(base); | |
1037 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
1038 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x6); | |
1039 } | |
1040 }; | |
1041 | |
1042 // Method: Arity 5 -> 1. | |
1043 template <typename StorageType, typename R, typename T, typename X1, | |
1044 typename X2, typename X3, typename X4, typename X5> | |
1045 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | |
1046 typedef base::true_type ShouldRef; | |
1047 static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5) { | |
1048 StorageType* invoker = static_cast<StorageType*>(base); | |
1049 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1050 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); | |
1051 } | |
1052 }; | |
1053 | |
1054 // Const Method: Arity 5 -> 1. | |
1055 template <typename StorageType, typename R, typename T, typename X1, | |
1056 typename X2, typename X3, typename X4, typename X5> | |
1057 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
1058 typedef base::true_type ShouldRef; | |
1059 static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5) { | |
1060 StorageType* invoker = static_cast<StorageType*>(base); | |
1061 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1062 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); | |
1063 } | |
1064 }; | |
1065 | |
1066 template <typename StorageType, typename Sig> | |
1067 struct FunctionTraits6; | |
1068 | |
1069 // Function: Arity 6 -> 0. | |
1070 template <typename StorageType, typename R,typename X1, typename X2, | |
1071 typename X3, typename X4, typename X5, typename X6> | |
1072 struct FunctionTraits6<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | |
1073 COMPILE_ASSERT( | |
1074 !( is_non_const_reference<X1>::value || | |
1075 is_non_const_reference<X2>::value || | |
1076 is_non_const_reference<X3>::value || | |
1077 is_non_const_reference<X4>::value || | |
1078 is_non_const_reference<X5>::value || | |
1079 is_non_const_reference<X6>::value ), | |
1080 do_not_prebind_functions_with_nonconst_ref); | |
1081 | |
1082 typedef base::false_type ShouldRef; | |
1083 | |
1084 static R DoInvoke(internal::InvokerStorageBase* base) { | |
1085 StorageType* invoker = static_cast<StorageType*>(base); | |
1086 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
1087 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | |
1088 Unwrap(invoker->p6_)); | |
1089 } | |
1090 }; | |
1091 | |
1092 // Method: Arity 5 -> 0. | |
1093 template <typename StorageType, typename R, typename T, typename X1, | |
1094 typename X2, typename X3, typename X4, typename X5> | |
1095 struct FunctionTraits6<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | |
1096 typedef base::true_type ShouldRef; | |
1097 static R DoInvoke(internal::InvokerStorageBase* base) { | |
1098 StorageType* invoker = static_cast<StorageType*>(base); | |
1099 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1100 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | |
1101 Unwrap(invoker->p6_)); | |
1102 } | |
1103 }; | |
1104 | |
1105 // Const Method: Arity 5 -> 0. | |
1106 template <typename StorageType, typename R, typename T, typename X1, | |
1107 typename X2, typename X3, typename X4, typename X5> | |
1108 struct FunctionTraits6<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { | |
1109 typedef base::true_type ShouldRef; | |
1110 static R DoInvoke(internal::InvokerStorageBase* base ) { | |
1111 StorageType* invoker = static_cast<StorageType*>(base); | |
1112 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
1113 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | |
1114 Unwrap(invoker->p6_)); | |
1115 } | |
1116 }; | |
1117 | |
1118 | |
1119 // These are the actual storage classes for the invokers. | |
1120 | |
1121 template <typename Sig> | |
1122 class InvokerStorage0 : public internal::InvokerStorageBase { | |
1123 public: | |
1124 typedef InvokerStorage0 StorageType; | |
1125 typedef FunctionTraits0<StorageType, Sig> FunctionTraits; | |
1126 typedef typename FunctionTraits::ShouldRef ShouldRef; | |
1127 | |
1128 InvokerStorage0(Sig f) | |
1129 : f_(f) { | |
1130 } | |
1131 | |
1132 virtual ~InvokerStorage0() { } | |
1133 | |
1134 Sig f_; | |
1135 }; | |
1136 | |
1137 template <typename Sig, typename P1> | |
1138 class InvokerStorage1 : public internal::InvokerStorageBase { | |
1139 public: | |
1140 typedef InvokerStorage1 StorageType; | |
1141 typedef FunctionTraits1<StorageType, Sig> FunctionTraits; | |
1142 typedef typename FunctionTraits::ShouldRef ShouldRef; | |
1143 | |
1144 COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, | |
1145 first_bound_argument_to_method_cannot_be_array); | |
1146 | |
1147 InvokerStorage1(Sig f, const P1& p1) | |
1148 : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)) { | |
1149 MaybeRefcount<ShouldRef, P1>::AddRef(p1_); | |
1150 } | |
1151 | |
1152 virtual ~InvokerStorage1() { | |
1153 MaybeRefcount<ShouldRef, P1>::Release(p1_); | |
1154 } | |
1155 | |
willchan no longer on Chromium
2011/02/07 20:51:48
These should be private. Perhaps you need to add a
awong
2011/02/08 18:52:26
:-/
Really, if I had my way, I'd make InvokerStor
| |
1156 Sig f_; | |
1157 typename PrebindType<P1>::StorageType p1_; | |
1158 }; | |
1159 | |
1160 template <typename Sig, typename P1, typename P2> | |
1161 class InvokerStorage2 : public internal::InvokerStorageBase { | |
1162 public: | |
1163 typedef InvokerStorage2 StorageType; | |
1164 typedef FunctionTraits2<StorageType, Sig> FunctionTraits; | |
1165 typedef typename FunctionTraits::ShouldRef ShouldRef; | |
1166 | |
1167 COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, | |
1168 first_bound_argument_to_method_cannot_be_array); | |
1169 | |
1170 InvokerStorage2(Sig f, const P1& p1, const P2& p2) | |
1171 : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), | |
1172 p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)) { | |
1173 MaybeRefcount<ShouldRef, P1>::AddRef(p1_); | |
1174 } | |
1175 | |
1176 virtual ~InvokerStorage2() { | |
1177 MaybeRefcount<ShouldRef, P1>::Release(p1_); | |
1178 } | |
1179 | |
1180 Sig f_; | |
1181 typename PrebindType<P1>::StorageType p1_; | |
1182 typename PrebindType<P2>::StorageType p2_; | |
1183 }; | |
1184 | |
1185 template <typename Sig, typename P1, typename P2, typename P3> | |
1186 class InvokerStorage3 : public internal::InvokerStorageBase { | |
1187 public: | |
1188 typedef InvokerStorage3 StorageType; | |
1189 typedef FunctionTraits3<StorageType, Sig> FunctionTraits; | |
1190 typedef typename FunctionTraits::ShouldRef ShouldRef; | |
1191 | |
1192 COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, | |
1193 first_bound_argument_to_method_cannot_be_array); | |
1194 | |
1195 InvokerStorage3(Sig f, const P1& p1, const P2& p2, const P3& p3) | |
1196 : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), | |
1197 p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), | |
1198 p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)) { | |
1199 MaybeRefcount<ShouldRef, P1>::AddRef(p1_); | |
1200 } | |
1201 | |
1202 virtual ~InvokerStorage3() { | |
1203 MaybeRefcount<ShouldRef, P1>::Release(p1_); | |
1204 } | |
1205 | |
1206 Sig f_; | |
1207 typename PrebindType<P1>::StorageType p1_; | |
1208 typename PrebindType<P2>::StorageType p2_; | |
1209 typename PrebindType<P3>::StorageType p3_; | |
1210 }; | |
1211 | |
1212 template <typename Sig, typename P1, typename P2, typename P3, typename P4> | |
1213 class InvokerStorage4 : public internal::InvokerStorageBase { | |
1214 public: | |
1215 typedef InvokerStorage4 StorageType; | |
1216 typedef FunctionTraits4<StorageType, Sig> FunctionTraits; | |
1217 typedef typename FunctionTraits::ShouldRef ShouldRef; | |
1218 | |
1219 COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, | |
1220 first_bound_argument_to_method_cannot_be_array); | |
1221 | |
1222 InvokerStorage4(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4) | |
1223 : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), | |
1224 p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), | |
1225 p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)), | |
1226 p4_(static_cast<typename PrebindType<P4>::StorageType>(p4)) { | |
1227 MaybeRefcount<ShouldRef, P1>::AddRef(p1_); | |
1228 } | |
1229 | |
1230 virtual ~InvokerStorage4() { | |
1231 MaybeRefcount<ShouldRef, P1>::Release(p1_); | |
1232 } | |
1233 | |
1234 Sig f_; | |
1235 typename PrebindType<P1>::StorageType p1_; | |
1236 typename PrebindType<P2>::StorageType p2_; | |
1237 typename PrebindType<P3>::StorageType p3_; | |
1238 typename PrebindType<P4>::StorageType p4_; | |
1239 }; | |
1240 | |
1241 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | |
1242 typename P5> | |
1243 class InvokerStorage5 : public internal::InvokerStorageBase { | |
1244 public: | |
1245 typedef InvokerStorage5 StorageType; | |
1246 typedef FunctionTraits5<StorageType, Sig> FunctionTraits; | |
1247 typedef typename FunctionTraits::ShouldRef ShouldRef; | |
1248 | |
1249 COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, | |
1250 first_bound_argument_to_method_cannot_be_array); | |
1251 | |
1252 InvokerStorage5(Sig f, const P1& p1, const P2& p2, const P3& p3, | |
1253 const P4& p4, const P5& p5) | |
1254 : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), | |
1255 p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), | |
1256 p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)), | |
1257 p4_(static_cast<typename PrebindType<P4>::StorageType>(p4)), | |
1258 p5_(static_cast<typename PrebindType<P5>::StorageType>(p5)) { | |
1259 MaybeRefcount<ShouldRef, P1>::AddRef(p1_); | |
1260 } | |
1261 | |
1262 virtual ~InvokerStorage5() { | |
1263 MaybeRefcount<ShouldRef, P1>::Release(p1_); | |
1264 } | |
1265 | |
1266 Sig f_; | |
1267 typename PrebindType<P1>::StorageType p1_; | |
1268 typename PrebindType<P2>::StorageType p2_; | |
1269 typename PrebindType<P3>::StorageType p3_; | |
1270 typename PrebindType<P4>::StorageType p4_; | |
1271 typename PrebindType<P5>::StorageType p5_; | |
1272 }; | |
1273 | |
1274 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | |
1275 typename P5, typename P6> | |
1276 class InvokerStorage6 : public internal::InvokerStorageBase { | |
willchan no longer on Chromium
2011/02/07 23:25:15
You shouldn't need internal:: since you're already
awong
2011/02/08 18:52:26
Done.
| |
1277 public: | |
1278 typedef InvokerStorage6 StorageType; | |
1279 typedef FunctionTraits6<StorageType, Sig> FunctionTraits; | |
1280 typedef typename FunctionTraits::ShouldRef ShouldRef; | |
1281 | |
1282 COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, | |
1283 first_bound_argument_to_method_cannot_be_array); | |
1284 | |
1285 InvokerStorage6(Sig f, const P1& p1, const P2& p2, const P3& p3, | |
1286 const P4& p4, const P5& p5, const P6& p6) | |
1287 : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), | |
1288 p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), | |
1289 p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)), | |
1290 p4_(static_cast<typename PrebindType<P4>::StorageType>(p4)), | |
1291 p5_(static_cast<typename PrebindType<P5>::StorageType>(p5)), | |
1292 p6_(static_cast<typename PrebindType<P6>::StorageType>(p6)) { | |
1293 MaybeRefcount<ShouldRef, P1>::AddRef(p1_); | |
1294 } | |
1295 | |
1296 virtual ~InvokerStorage6() { | |
1297 MaybeRefcount<ShouldRef, P1>::Release(p1_); | |
1298 } | |
1299 | |
1300 Sig f_; | |
1301 typename PrebindType<P1>::StorageType p1_; | |
1302 typename PrebindType<P2>::StorageType p2_; | |
1303 typename PrebindType<P3>::StorageType p3_; | |
1304 typename PrebindType<P4>::StorageType p4_; | |
1305 typename PrebindType<P5>::StorageType p5_; | |
1306 typename PrebindType<P6>::StorageType p6_; | |
1307 }; | |
1308 | |
1309 } // namespace internal | |
1310 | |
1311 template <typename Sig> | |
1312 internal::InvokerStorageHolder<internal::InvokerStorage0<Sig> > | |
1313 Prebind(Sig f) { | |
1314 return internal::MakeInvokerStorageHolder( | |
1315 new internal::InvokerStorage0<Sig>(f)); | |
1316 } | |
1317 | |
1318 template <typename Sig, typename P1> | |
1319 internal::InvokerStorageHolder<internal::InvokerStorage1<Sig,P1> > | |
1320 Prebind(Sig f, const P1& p1) { | |
1321 return internal::MakeInvokerStorageHolder( | |
1322 new internal::InvokerStorage1<Sig, P1>( | |
1323 f, p1)); | |
1324 } | |
1325 | |
1326 template <typename Sig, typename P1, typename P2> | |
1327 internal::InvokerStorageHolder<internal::InvokerStorage2<Sig,P1, P2> > | |
1328 Prebind(Sig f, const P1& p1, const P2& p2) { | |
1329 return internal::MakeInvokerStorageHolder( | |
1330 new internal::InvokerStorage2<Sig, P1, P2>( | |
1331 f, p1, p2)); | |
1332 } | |
1333 | |
1334 template <typename Sig, typename P1, typename P2, typename P3> | |
1335 internal::InvokerStorageHolder<internal::InvokerStorage3<Sig,P1, P2, P3> > | |
1336 Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3) { | |
1337 return internal::MakeInvokerStorageHolder( | |
1338 new internal::InvokerStorage3<Sig, P1, P2, P3>( | |
1339 f, p1, p2, p3)); | |
1340 } | |
1341 | |
1342 template <typename Sig, typename P1, typename P2, typename P3, typename P4> | |
1343 internal::InvokerStorageHolder<internal::InvokerStorage4<Sig,P1, P2, P3, P4> > | |
1344 Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { | |
1345 return internal::MakeInvokerStorageHolder( | |
1346 new internal::InvokerStorage4<Sig, P1, P2, P3, P4>( | |
1347 f, p1, p2, p3, p4)); | |
1348 } | |
1349 | |
1350 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | |
1351 typename P5> | |
1352 internal::InvokerStorageHolder<internal::InvokerStorage5<Sig,P1, P2, P3, P4, | |
1353 P5> > | |
1354 Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4, | |
1355 const P5& p5) { | |
1356 return internal::MakeInvokerStorageHolder( | |
1357 new internal::InvokerStorage5<Sig, P1, P2, P3, P4, P5>( | |
1358 f, p1, p2, p3, p4, p5)); | |
1359 } | |
1360 | |
1361 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | |
1362 typename P5, typename P6> | |
1363 internal::InvokerStorageHolder<internal::InvokerStorage6<Sig,P1, P2, P3, P4, | |
1364 P5, P6> > | |
1365 Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4, | |
1366 const P5& p5, const P6& p6) { | |
1367 return internal::MakeInvokerStorageHolder( | |
1368 new internal::InvokerStorage6<Sig, P1, P2, P3, P4, P5, P6>( | |
1369 f, p1, p2, p3, p4, p5, p6)); | |
1370 } | |
1371 | |
1372 } // namespace base | |
1373 | |
1374 #endif // BASE_PREBIND_H_ | |
OLD | NEW |