Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: base/bind_internal.h

Issue 6109007: Unified callback system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Address Will's comments. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/bind_helpers.h ('k') | base/bind_internal.h.pump » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // This file was GENERATED by command:
2 // pump.py bind_internal.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_BIND_INTERNAL_H_
11 #define BASE_BIND_INTERNAL_H_
12 #pragma once
13
14 #include "base/bind_helpers.h"
15 #include "base/callback_helpers.h"
16 #include "base/template_util.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 independent of StorageType; its
36 // first argument is a pointer to the non-templated common baseclass of
37 // StorageType. This lets us store pointer to DoInvoke() in a function pointer
38 // that has knowledge of the specific StorageType, and thus no knowledge of the
39 // bound 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 IsMethod;
52
53 static R DoInvoke(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_bind_functions_with_nonconst_ref);
65
66 typedef base::false_type IsMethod;
67
68 static R DoInvoke(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_bind_functions_with_nonconst_ref);
81
82 typedef base::false_type IsMethod;
83
84 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2) {
85 StorageType* invoker = static_cast<StorageType*>(base);
86 return invoker->f_(x1, x2);
87 }
88 };
89
90 // Function: Arity 3 -> 3.
91 template <typename StorageType, typename R,typename X1, typename X2,
92 typename X3>
93 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3)> {
94 COMPILE_ASSERT(
95 !( is_non_const_reference<X1>::value ||
96 is_non_const_reference<X2>::value ||
97 is_non_const_reference<X3>::value ),
98 do_not_bind_functions_with_nonconst_ref);
99
100 typedef base::false_type IsMethod;
101
102 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2,
103 const X3& x3) {
104 StorageType* invoker = static_cast<StorageType*>(base);
105 return invoker->f_(x1, x2, x3);
106 }
107 };
108
109 // Function: Arity 4 -> 4.
110 template <typename StorageType, typename R,typename X1, typename X2,
111 typename X3, typename X4>
112 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4)> {
113 COMPILE_ASSERT(
114 !( is_non_const_reference<X1>::value ||
115 is_non_const_reference<X2>::value ||
116 is_non_const_reference<X3>::value ||
117 is_non_const_reference<X4>::value ),
118 do_not_bind_functions_with_nonconst_ref);
119
120 typedef base::false_type IsMethod;
121
122 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2,
123 const X3& x3, const X4& x4) {
124 StorageType* invoker = static_cast<StorageType*>(base);
125 return invoker->f_(x1, x2, x3, x4);
126 }
127 };
128
129 // Function: Arity 5 -> 5.
130 template <typename StorageType, typename R,typename X1, typename X2,
131 typename X3, typename X4, typename X5>
132 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5)> {
133 COMPILE_ASSERT(
134 !( is_non_const_reference<X1>::value ||
135 is_non_const_reference<X2>::value ||
136 is_non_const_reference<X3>::value ||
137 is_non_const_reference<X4>::value ||
138 is_non_const_reference<X5>::value ),
139 do_not_bind_functions_with_nonconst_ref);
140
141 typedef base::false_type IsMethod;
142
143 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2,
144 const X3& x3, const X4& x4, const X5& x5) {
145 StorageType* invoker = static_cast<StorageType*>(base);
146 return invoker->f_(x1, x2, x3, x4, x5);
147 }
148 };
149
150 // Function: Arity 6 -> 6.
151 template <typename StorageType, typename R,typename X1, typename X2,
152 typename X3, typename X4, typename X5, typename X6>
153 struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> {
154 COMPILE_ASSERT(
155 !( is_non_const_reference<X1>::value ||
156 is_non_const_reference<X2>::value ||
157 is_non_const_reference<X3>::value ||
158 is_non_const_reference<X4>::value ||
159 is_non_const_reference<X5>::value ||
160 is_non_const_reference<X6>::value ),
161 do_not_bind_functions_with_nonconst_ref);
162
163 typedef base::false_type IsMethod;
164
165 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2,
166 const X3& x3, const X4& x4, const X5& x5, const X6& x6) {
167 StorageType* invoker = static_cast<StorageType*>(base);
168 return invoker->f_(x1, x2, x3, x4, x5, x6);
169 }
170 };
171
172 template <typename StorageType, typename Sig>
173 struct FunctionTraits1;
174
175 // Function: Arity 1 -> 0.
176 template <typename StorageType, typename R,typename X1>
177 struct FunctionTraits1<StorageType, R(*)(X1)> {
178 COMPILE_ASSERT(
179 !( is_non_const_reference<X1>::value ),
180 do_not_bind_functions_with_nonconst_ref);
181
182 typedef base::false_type IsMethod;
183
184 static R DoInvoke(InvokerStorageBase* base) {
185 StorageType* invoker = static_cast<StorageType*>(base);
186 return invoker->f_(Unwrap(invoker->p1_));
187 }
188 };
189
190 // Method: Arity 0 -> 0.
191 template <typename StorageType, typename R, typename T>
192 struct FunctionTraits1<StorageType, R(T::*)()> {
193 typedef base::true_type IsMethod;
194
195 static R DoInvoke(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 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.
213 template <typename StorageType, typename R,typename X1, typename X2>
214 struct FunctionTraits1<StorageType, R(*)(X1, X2)> {
215 COMPILE_ASSERT(
216 !( is_non_const_reference<X1>::value ||
217 is_non_const_reference<X2>::value ),
218 do_not_bind_functions_with_nonconst_ref);
219
220 typedef base::false_type IsMethod;
221
222 static R DoInvoke(InvokerStorageBase* base, const X2& x2) {
223 StorageType* invoker = static_cast<StorageType*>(base);
224 return invoker->f_(Unwrap(invoker->p1_), x2);
225 }
226 };
227
228 // Method: Arity 1 -> 1.
229 template <typename StorageType, typename R, typename T, typename X1>
230 struct FunctionTraits1<StorageType, R(T::*)(X1)> {
231 COMPILE_ASSERT(
232 !( is_non_const_reference<X1>::value ),
233 do_not_bind_functions_with_nonconst_ref);
234
235 typedef base::true_type IsMethod;
236
237 static R DoInvoke(InvokerStorageBase* base, const X1& x1) {
238 StorageType* invoker = static_cast<StorageType*>(base);
239 return (Unwrap(invoker->p1_)->*invoker->f_)(x1);
240 }
241 };
242
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.
259 template <typename StorageType, typename R,typename X1, typename X2,
260 typename X3>
261 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3)> {
262 COMPILE_ASSERT(
263 !( is_non_const_reference<X1>::value ||
264 is_non_const_reference<X2>::value ||
265 is_non_const_reference<X3>::value ),
266 do_not_bind_functions_with_nonconst_ref);
267
268 typedef base::false_type IsMethod;
269
270 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3) {
271 StorageType* invoker = static_cast<StorageType*>(base);
272 return invoker->f_(Unwrap(invoker->p1_), x2, x3);
273 }
274 };
275
276 // Method: Arity 2 -> 2.
277 template <typename StorageType, typename R, typename T, typename X1,
278 typename X2>
279 struct FunctionTraits1<StorageType, R(T::*)(X1, X2)> {
280 COMPILE_ASSERT(
281 !( is_non_const_reference<X1>::value ||
282 is_non_const_reference<X2>::value ),
283 do_not_bind_functions_with_nonconst_ref);
284
285 typedef base::true_type IsMethod;
286
287 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2) {
288 StorageType* invoker = static_cast<StorageType*>(base);
289 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2);
290 }
291 };
292
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.
311 template <typename StorageType, typename R,typename X1, typename X2,
312 typename X3, typename X4>
313 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4)> {
314 COMPILE_ASSERT(
315 !( is_non_const_reference<X1>::value ||
316 is_non_const_reference<X2>::value ||
317 is_non_const_reference<X3>::value ||
318 is_non_const_reference<X4>::value ),
319 do_not_bind_functions_with_nonconst_ref);
320
321 typedef base::false_type IsMethod;
322
323 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3,
324 const X4& x4) {
325 StorageType* invoker = static_cast<StorageType*>(base);
326 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4);
327 }
328 };
329
330 // Method: Arity 3 -> 3.
331 template <typename StorageType, typename R, typename T, typename X1,
332 typename X2, typename X3>
333 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3)> {
334 COMPILE_ASSERT(
335 !( is_non_const_reference<X1>::value ||
336 is_non_const_reference<X2>::value ||
337 is_non_const_reference<X3>::value ),
338 do_not_bind_functions_with_nonconst_ref);
339
340 typedef base::true_type IsMethod;
341
342 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2,
343 const X3& x3) {
344 StorageType* invoker = static_cast<StorageType*>(base);
345 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3);
346 }
347 };
348
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.
368 template <typename StorageType, typename R,typename X1, typename X2,
369 typename X3, typename X4, typename X5>
370 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5)> {
371 COMPILE_ASSERT(
372 !( is_non_const_reference<X1>::value ||
373 is_non_const_reference<X2>::value ||
374 is_non_const_reference<X3>::value ||
375 is_non_const_reference<X4>::value ||
376 is_non_const_reference<X5>::value ),
377 do_not_bind_functions_with_nonconst_ref);
378
379 typedef base::false_type IsMethod;
380
381 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3,
382 const X4& x4, const X5& x5) {
383 StorageType* invoker = static_cast<StorageType*>(base);
384 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5);
385 }
386 };
387
388 // Method: Arity 4 -> 4.
389 template <typename StorageType, typename R, typename T, typename X1,
390 typename X2, typename X3, typename X4>
391 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4)> {
392 COMPILE_ASSERT(
393 !( is_non_const_reference<X1>::value ||
394 is_non_const_reference<X2>::value ||
395 is_non_const_reference<X3>::value ||
396 is_non_const_reference<X4>::value ),
397 do_not_bind_functions_with_nonconst_ref);
398
399 typedef base::true_type IsMethod;
400
401 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2,
402 const X3& x3, const X4& x4) {
403 StorageType* invoker = static_cast<StorageType*>(base);
404 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4);
405 }
406 };
407
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.
428 template <typename StorageType, typename R,typename X1, typename X2,
429 typename X3, typename X4, typename X5, typename X6>
430 struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> {
431 COMPILE_ASSERT(
432 !( is_non_const_reference<X1>::value ||
433 is_non_const_reference<X2>::value ||
434 is_non_const_reference<X3>::value ||
435 is_non_const_reference<X4>::value ||
436 is_non_const_reference<X5>::value ||
437 is_non_const_reference<X6>::value ),
438 do_not_bind_functions_with_nonconst_ref);
439
440 typedef base::false_type IsMethod;
441
442 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3,
443 const X4& x4, const X5& x5, const X6& x6) {
444 StorageType* invoker = static_cast<StorageType*>(base);
445 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6);
446 }
447 };
448
449 // Method: Arity 5 -> 5.
450 template <typename StorageType, typename R, typename T, typename X1,
451 typename X2, typename X3, typename X4, typename X5>
452 struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4, X5)> {
453 COMPILE_ASSERT(
454 !( is_non_const_reference<X1>::value ||
455 is_non_const_reference<X2>::value ||
456 is_non_const_reference<X3>::value ||
457 is_non_const_reference<X4>::value ||
458 is_non_const_reference<X5>::value ),
459 do_not_bind_functions_with_nonconst_ref);
460
461 typedef base::true_type IsMethod;
462
463 static R DoInvoke(InvokerStorageBase* base, const X1& x1, const X2& x2,
464 const X3& x3, const X4& x4, const X5& x5) {
465 StorageType* invoker = static_cast<StorageType*>(base);
466 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5);
467 }
468 };
469
470 // Const Method: Arity 5 -> 5.
471 template <typename StorageType, typename R, typename T, typename X1,
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
493 // Function: Arity 2 -> 0.
494 template <typename StorageType, typename R,typename X1, typename X2>
495 struct FunctionTraits2<StorageType, R(*)(X1, X2)> {
496 COMPILE_ASSERT(
497 !( is_non_const_reference<X1>::value ||
498 is_non_const_reference<X2>::value ),
499 do_not_bind_functions_with_nonconst_ref);
500
501 typedef base::false_type IsMethod;
502
503 static R DoInvoke(InvokerStorageBase* base) {
504 StorageType* invoker = static_cast<StorageType*>(base);
505 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_));
506 }
507 };
508
509 // Method: Arity 1 -> 0.
510 template <typename StorageType, typename R, typename T, typename X1>
511 struct FunctionTraits2<StorageType, R(T::*)(X1)> {
512 COMPILE_ASSERT(
513 !( is_non_const_reference<X1>::value ),
514 do_not_bind_functions_with_nonconst_ref);
515
516 typedef base::true_type IsMethod;
517
518 static R DoInvoke(InvokerStorageBase* base) {
519 StorageType* invoker = static_cast<StorageType*>(base);
520 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_));
521 }
522 };
523
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.
540 template <typename StorageType, typename R,typename X1, typename X2,
541 typename X3>
542 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3)> {
543 COMPILE_ASSERT(
544 !( is_non_const_reference<X1>::value ||
545 is_non_const_reference<X2>::value ||
546 is_non_const_reference<X3>::value ),
547 do_not_bind_functions_with_nonconst_ref);
548
549 typedef base::false_type IsMethod;
550
551 static R DoInvoke(InvokerStorageBase* base, const X3& x3) {
552 StorageType* invoker = static_cast<StorageType*>(base);
553 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3);
554 }
555 };
556
557 // Method: Arity 2 -> 1.
558 template <typename StorageType, typename R, typename T, typename X1,
559 typename X2>
560 struct FunctionTraits2<StorageType, R(T::*)(X1, X2)> {
561 COMPILE_ASSERT(
562 !( is_non_const_reference<X1>::value ||
563 is_non_const_reference<X2>::value ),
564 do_not_bind_functions_with_nonconst_ref);
565
566 typedef base::true_type IsMethod;
567
568 static R DoInvoke(InvokerStorageBase* base, const X2& x2) {
569 StorageType* invoker = static_cast<StorageType*>(base);
570 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2);
571 }
572 };
573
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.
592 template <typename StorageType, typename R,typename X1, typename X2,
593 typename X3, typename X4>
594 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4)> {
595 COMPILE_ASSERT(
596 !( is_non_const_reference<X1>::value ||
597 is_non_const_reference<X2>::value ||
598 is_non_const_reference<X3>::value ||
599 is_non_const_reference<X4>::value ),
600 do_not_bind_functions_with_nonconst_ref);
601
602 typedef base::false_type IsMethod;
603
604 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4) {
605 StorageType* invoker = static_cast<StorageType*>(base);
606 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4);
607 }
608 };
609
610 // Method: Arity 3 -> 2.
611 template <typename StorageType, typename R, typename T, typename X1,
612 typename X2, typename X3>
613 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3)> {
614 COMPILE_ASSERT(
615 !( is_non_const_reference<X1>::value ||
616 is_non_const_reference<X2>::value ||
617 is_non_const_reference<X3>::value ),
618 do_not_bind_functions_with_nonconst_ref);
619
620 typedef base::true_type IsMethod;
621
622 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3) {
623 StorageType* invoker = static_cast<StorageType*>(base);
624 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3);
625 }
626 };
627
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.
646 template <typename StorageType, typename R,typename X1, typename X2,
647 typename X3, typename X4, typename X5>
648 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5)> {
649 COMPILE_ASSERT(
650 !( is_non_const_reference<X1>::value ||
651 is_non_const_reference<X2>::value ||
652 is_non_const_reference<X3>::value ||
653 is_non_const_reference<X4>::value ||
654 is_non_const_reference<X5>::value ),
655 do_not_bind_functions_with_nonconst_ref);
656
657 typedef base::false_type IsMethod;
658
659 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4,
660 const X5& x5) {
661 StorageType* invoker = static_cast<StorageType*>(base);
662 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5);
663 }
664 };
665
666 // Method: Arity 4 -> 3.
667 template <typename StorageType, typename R, typename T, typename X1,
668 typename X2, typename X3, typename X4>
669 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4)> {
670 COMPILE_ASSERT(
671 !( is_non_const_reference<X1>::value ||
672 is_non_const_reference<X2>::value ||
673 is_non_const_reference<X3>::value ||
674 is_non_const_reference<X4>::value ),
675 do_not_bind_functions_with_nonconst_ref);
676
677 typedef base::true_type IsMethod;
678
679 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3,
680 const X4& x4) {
681 StorageType* invoker = static_cast<StorageType*>(base);
682 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3,
683 x4);
684 }
685 };
686
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.
708 template <typename StorageType, typename R,typename X1, typename X2,
709 typename X3, typename X4, typename X5, typename X6>
710 struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> {
711 COMPILE_ASSERT(
712 !( is_non_const_reference<X1>::value ||
713 is_non_const_reference<X2>::value ||
714 is_non_const_reference<X3>::value ||
715 is_non_const_reference<X4>::value ||
716 is_non_const_reference<X5>::value ||
717 is_non_const_reference<X6>::value ),
718 do_not_bind_functions_with_nonconst_ref);
719
720 typedef base::false_type IsMethod;
721
722 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4,
723 const X5& x5, const X6& x6) {
724 StorageType* invoker = static_cast<StorageType*>(base);
725 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5,
726 x6);
727 }
728 };
729
730 // Method: Arity 5 -> 4.
731 template <typename StorageType, typename R, typename T, typename X1,
732 typename X2, typename X3, typename X4, typename X5>
733 struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4, X5)> {
734 COMPILE_ASSERT(
735 !( is_non_const_reference<X1>::value ||
736 is_non_const_reference<X2>::value ||
737 is_non_const_reference<X3>::value ||
738 is_non_const_reference<X4>::value ||
739 is_non_const_reference<X5>::value ),
740 do_not_bind_functions_with_nonconst_ref);
741
742 typedef base::true_type IsMethod;
743
744 static R DoInvoke(InvokerStorageBase* base, const X2& x2, const X3& x3,
745 const X4& x4, const X5& x5) {
746 StorageType* invoker = static_cast<StorageType*>(base);
747 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3,
748 x4, x5);
749 }
750 };
751
752 // Const Method: Arity 5 -> 4.
753 template <typename StorageType, typename R, typename T, typename X1,
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
776 // Function: Arity 3 -> 0.
777 template <typename StorageType, typename R,typename X1, typename X2,
778 typename X3>
779 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3)> {
780 COMPILE_ASSERT(
781 !( is_non_const_reference<X1>::value ||
782 is_non_const_reference<X2>::value ||
783 is_non_const_reference<X3>::value ),
784 do_not_bind_functions_with_nonconst_ref);
785
786 typedef base::false_type IsMethod;
787
788 static R DoInvoke(InvokerStorageBase* base) {
789 StorageType* invoker = static_cast<StorageType*>(base);
790 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
791 Unwrap(invoker->p3_));
792 }
793 };
794
795 // Method: Arity 2 -> 0.
796 template <typename StorageType, typename R, typename T, typename X1,
797 typename X2>
798 struct FunctionTraits3<StorageType, R(T::*)(X1, X2)> {
799 COMPILE_ASSERT(
800 !( is_non_const_reference<X1>::value ||
801 is_non_const_reference<X2>::value ),
802 do_not_bind_functions_with_nonconst_ref);
803
804 typedef base::true_type IsMethod;
805
806 static R DoInvoke(InvokerStorageBase* base) {
807 StorageType* invoker = static_cast<StorageType*>(base);
808 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
809 Unwrap(invoker->p3_));
810 }
811 };
812
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.
832 template <typename StorageType, typename R,typename X1, typename X2,
833 typename X3, typename X4>
834 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4)> {
835 COMPILE_ASSERT(
836 !( is_non_const_reference<X1>::value ||
837 is_non_const_reference<X2>::value ||
838 is_non_const_reference<X3>::value ||
839 is_non_const_reference<X4>::value ),
840 do_not_bind_functions_with_nonconst_ref);
841
842 typedef base::false_type IsMethod;
843
844 static R DoInvoke(InvokerStorageBase* base, const X4& x4) {
845 StorageType* invoker = static_cast<StorageType*>(base);
846 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
847 Unwrap(invoker->p3_), x4);
848 }
849 };
850
851 // Method: Arity 3 -> 1.
852 template <typename StorageType, typename R, typename T, typename X1,
853 typename X2, typename X3>
854 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3)> {
855 COMPILE_ASSERT(
856 !( is_non_const_reference<X1>::value ||
857 is_non_const_reference<X2>::value ||
858 is_non_const_reference<X3>::value ),
859 do_not_bind_functions_with_nonconst_ref);
860
861 typedef base::true_type IsMethod;
862
863 static R DoInvoke(InvokerStorageBase* base, const X3& x3) {
864 StorageType* invoker = static_cast<StorageType*>(base);
865 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
866 Unwrap(invoker->p3_), x3);
867 }
868 };
869
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.
889 template <typename StorageType, typename R,typename X1, typename X2,
890 typename X3, typename X4, typename X5>
891 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5)> {
892 COMPILE_ASSERT(
893 !( is_non_const_reference<X1>::value ||
894 is_non_const_reference<X2>::value ||
895 is_non_const_reference<X3>::value ||
896 is_non_const_reference<X4>::value ||
897 is_non_const_reference<X5>::value ),
898 do_not_bind_functions_with_nonconst_ref);
899
900 typedef base::false_type IsMethod;
901
902 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5) {
903 StorageType* invoker = static_cast<StorageType*>(base);
904 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
905 Unwrap(invoker->p3_), x4, x5);
906 }
907 };
908
909 // Method: Arity 4 -> 2.
910 template <typename StorageType, typename R, typename T, typename X1,
911 typename X2, typename X3, typename X4>
912 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4)> {
913 COMPILE_ASSERT(
914 !( is_non_const_reference<X1>::value ||
915 is_non_const_reference<X2>::value ||
916 is_non_const_reference<X3>::value ||
917 is_non_const_reference<X4>::value ),
918 do_not_bind_functions_with_nonconst_ref);
919
920 typedef base::true_type IsMethod;
921
922 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4) {
923 StorageType* invoker = static_cast<StorageType*>(base);
924 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
925 Unwrap(invoker->p3_), x3, x4);
926 }
927 };
928
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.
949 template <typename StorageType, typename R,typename X1, typename X2,
950 typename X3, typename X4, typename X5, typename X6>
951 struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> {
952 COMPILE_ASSERT(
953 !( is_non_const_reference<X1>::value ||
954 is_non_const_reference<X2>::value ||
955 is_non_const_reference<X3>::value ||
956 is_non_const_reference<X4>::value ||
957 is_non_const_reference<X5>::value ||
958 is_non_const_reference<X6>::value ),
959 do_not_bind_functions_with_nonconst_ref);
960
961 typedef base::false_type IsMethod;
962
963 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5,
964 const X6& x6) {
965 StorageType* invoker = static_cast<StorageType*>(base);
966 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
967 Unwrap(invoker->p3_), x4, x5, x6);
968 }
969 };
970
971 // Method: Arity 5 -> 3.
972 template <typename StorageType, typename R, typename T, typename X1,
973 typename X2, typename X3, typename X4, typename X5>
974 struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4, X5)> {
975 COMPILE_ASSERT(
976 !( is_non_const_reference<X1>::value ||
977 is_non_const_reference<X2>::value ||
978 is_non_const_reference<X3>::value ||
979 is_non_const_reference<X4>::value ||
980 is_non_const_reference<X5>::value ),
981 do_not_bind_functions_with_nonconst_ref);
982
983 typedef base::true_type IsMethod;
984
985 static R DoInvoke(InvokerStorageBase* base, const X3& x3, const X4& x4,
986 const X5& x5) {
987 StorageType* invoker = static_cast<StorageType*>(base);
988 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
989 Unwrap(invoker->p3_), x3, x4, x5);
990 }
991 };
992
993 // Const Method: Arity 5 -> 3.
994 template <typename StorageType, typename R, typename T, typename X1,
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
1017 // Function: Arity 4 -> 0.
1018 template <typename StorageType, typename R,typename X1, typename X2,
1019 typename X3, typename X4>
1020 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4)> {
1021 COMPILE_ASSERT(
1022 !( is_non_const_reference<X1>::value ||
1023 is_non_const_reference<X2>::value ||
1024 is_non_const_reference<X3>::value ||
1025 is_non_const_reference<X4>::value ),
1026 do_not_bind_functions_with_nonconst_ref);
1027
1028 typedef base::false_type IsMethod;
1029
1030 static R DoInvoke(InvokerStorageBase* base) {
1031 StorageType* invoker = static_cast<StorageType*>(base);
1032 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
1033 Unwrap(invoker->p3_), Unwrap(invoker->p4_));
1034 }
1035 };
1036
1037 // Method: Arity 3 -> 0.
1038 template <typename StorageType, typename R, typename T, typename X1,
1039 typename X2, typename X3>
1040 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3)> {
1041 COMPILE_ASSERT(
1042 !( is_non_const_reference<X1>::value ||
1043 is_non_const_reference<X2>::value ||
1044 is_non_const_reference<X3>::value ),
1045 do_not_bind_functions_with_nonconst_ref);
1046
1047 typedef base::true_type IsMethod;
1048
1049 static R DoInvoke(InvokerStorageBase* base) {
1050 StorageType* invoker = static_cast<StorageType*>(base);
1051 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
1052 Unwrap(invoker->p3_), Unwrap(invoker->p4_));
1053 }
1054 };
1055
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.
1075 template <typename StorageType, typename R,typename X1, typename X2,
1076 typename X3, typename X4, typename X5>
1077 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5)> {
1078 COMPILE_ASSERT(
1079 !( is_non_const_reference<X1>::value ||
1080 is_non_const_reference<X2>::value ||
1081 is_non_const_reference<X3>::value ||
1082 is_non_const_reference<X4>::value ||
1083 is_non_const_reference<X5>::value ),
1084 do_not_bind_functions_with_nonconst_ref);
1085
1086 typedef base::false_type IsMethod;
1087
1088 static R DoInvoke(InvokerStorageBase* base, const X5& x5) {
1089 StorageType* invoker = static_cast<StorageType*>(base);
1090 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
1091 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5);
1092 }
1093 };
1094
1095 // Method: Arity 4 -> 1.
1096 template <typename StorageType, typename R, typename T, typename X1,
1097 typename X2, typename X3, typename X4>
1098 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4)> {
1099 COMPILE_ASSERT(
1100 !( is_non_const_reference<X1>::value ||
1101 is_non_const_reference<X2>::value ||
1102 is_non_const_reference<X3>::value ||
1103 is_non_const_reference<X4>::value ),
1104 do_not_bind_functions_with_nonconst_ref);
1105
1106 typedef base::true_type IsMethod;
1107
1108 static R DoInvoke(InvokerStorageBase* base, const X4& x4) {
1109 StorageType* invoker = static_cast<StorageType*>(base);
1110 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
1111 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4);
1112 }
1113 };
1114
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.
1135 template <typename StorageType, typename R,typename X1, typename X2,
1136 typename X3, typename X4, typename X5, typename X6>
1137 struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> {
1138 COMPILE_ASSERT(
1139 !( is_non_const_reference<X1>::value ||
1140 is_non_const_reference<X2>::value ||
1141 is_non_const_reference<X3>::value ||
1142 is_non_const_reference<X4>::value ||
1143 is_non_const_reference<X5>::value ||
1144 is_non_const_reference<X6>::value ),
1145 do_not_bind_functions_with_nonconst_ref);
1146
1147 typedef base::false_type IsMethod;
1148
1149 static R DoInvoke(InvokerStorageBase* base, const X5& x5, const X6& x6) {
1150 StorageType* invoker = static_cast<StorageType*>(base);
1151 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
1152 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5, x6);
1153 }
1154 };
1155
1156 // Method: Arity 5 -> 2.
1157 template <typename StorageType, typename R, typename T, typename X1,
1158 typename X2, typename X3, typename X4, typename X5>
1159 struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4, X5)> {
1160 COMPILE_ASSERT(
1161 !( is_non_const_reference<X1>::value ||
1162 is_non_const_reference<X2>::value ||
1163 is_non_const_reference<X3>::value ||
1164 is_non_const_reference<X4>::value ||
1165 is_non_const_reference<X5>::value ),
1166 do_not_bind_functions_with_nonconst_ref);
1167
1168 typedef base::true_type IsMethod;
1169
1170 static R DoInvoke(InvokerStorageBase* base, const X4& x4, const X5& x5) {
1171 StorageType* invoker = static_cast<StorageType*>(base);
1172 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
1173 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5);
1174 }
1175 };
1176
1177 // Const Method: Arity 5 -> 2.
1178 template <typename StorageType, typename R, typename T, typename X1,
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
1200 // Function: Arity 5 -> 0.
1201 template <typename StorageType, typename R,typename X1, typename X2,
1202 typename X3, typename X4, typename X5>
1203 struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5)> {
1204 COMPILE_ASSERT(
1205 !( is_non_const_reference<X1>::value ||
1206 is_non_const_reference<X2>::value ||
1207 is_non_const_reference<X3>::value ||
1208 is_non_const_reference<X4>::value ||
1209 is_non_const_reference<X5>::value ),
1210 do_not_bind_functions_with_nonconst_ref);
1211
1212 typedef base::false_type IsMethod;
1213
1214 static R DoInvoke(InvokerStorageBase* base) {
1215 StorageType* invoker = static_cast<StorageType*>(base);
1216 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
1217 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_));
1218 }
1219 };
1220
1221 // Method: Arity 4 -> 0.
1222 template <typename StorageType, typename R, typename T, typename X1,
1223 typename X2, typename X3, typename X4>
1224 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4)> {
1225 COMPILE_ASSERT(
1226 !( is_non_const_reference<X1>::value ||
1227 is_non_const_reference<X2>::value ||
1228 is_non_const_reference<X3>::value ||
1229 is_non_const_reference<X4>::value ),
1230 do_not_bind_functions_with_nonconst_ref);
1231
1232 typedef base::true_type IsMethod;
1233
1234 static R DoInvoke(InvokerStorageBase* base) {
1235 StorageType* invoker = static_cast<StorageType*>(base);
1236 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
1237 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_));
1238 }
1239 };
1240
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.
1261 template <typename StorageType, typename R,typename X1, typename X2,
1262 typename X3, typename X4, typename X5, typename X6>
1263 struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> {
1264 COMPILE_ASSERT(
1265 !( is_non_const_reference<X1>::value ||
1266 is_non_const_reference<X2>::value ||
1267 is_non_const_reference<X3>::value ||
1268 is_non_const_reference<X4>::value ||
1269 is_non_const_reference<X5>::value ||
1270 is_non_const_reference<X6>::value ),
1271 do_not_bind_functions_with_nonconst_ref);
1272
1273 typedef base::false_type IsMethod;
1274
1275 static R DoInvoke(InvokerStorageBase* base, const X6& x6) {
1276 StorageType* invoker = static_cast<StorageType*>(base);
1277 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
1278 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x6);
1279 }
1280 };
1281
1282 // Method: Arity 5 -> 1.
1283 template <typename StorageType, typename R, typename T, typename X1,
1284 typename X2, typename X3, typename X4, typename X5>
1285 struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4, X5)> {
1286 COMPILE_ASSERT(
1287 !( is_non_const_reference<X1>::value ||
1288 is_non_const_reference<X2>::value ||
1289 is_non_const_reference<X3>::value ||
1290 is_non_const_reference<X4>::value ||
1291 is_non_const_reference<X5>::value ),
1292 do_not_bind_functions_with_nonconst_ref);
1293
1294 typedef base::true_type IsMethod;
1295
1296 static R DoInvoke(InvokerStorageBase* base, const X5& x5) {
1297 StorageType* invoker = static_cast<StorageType*>(base);
1298 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
1299 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5);
1300 }
1301 };
1302
1303 // Const Method: Arity 5 -> 1.
1304 template <typename StorageType, typename R, typename T, typename X1,
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
1326 // Function: Arity 6 -> 0.
1327 template <typename StorageType, typename R,typename X1, typename X2,
1328 typename X3, typename X4, typename X5, typename X6>
1329 struct FunctionTraits6<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> {
1330 COMPILE_ASSERT(
1331 !( is_non_const_reference<X1>::value ||
1332 is_non_const_reference<X2>::value ||
1333 is_non_const_reference<X3>::value ||
1334 is_non_const_reference<X4>::value ||
1335 is_non_const_reference<X5>::value ||
1336 is_non_const_reference<X6>::value ),
1337 do_not_bind_functions_with_nonconst_ref);
1338
1339 typedef base::false_type IsMethod;
1340
1341 static R DoInvoke(InvokerStorageBase* base) {
1342 StorageType* invoker = static_cast<StorageType*>(base);
1343 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_),
1344 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_),
1345 Unwrap(invoker->p6_));
1346 }
1347 };
1348
1349 // Method: Arity 5 -> 0.
1350 template <typename StorageType, typename R, typename T, typename X1,
1351 typename X2, typename X3, typename X4, typename X5>
1352 struct FunctionTraits6<StorageType, R(T::*)(X1, X2, X3, X4, X5)> {
1353 COMPILE_ASSERT(
1354 !( is_non_const_reference<X1>::value ||
1355 is_non_const_reference<X2>::value ||
1356 is_non_const_reference<X3>::value ||
1357 is_non_const_reference<X4>::value ||
1358 is_non_const_reference<X5>::value ),
1359 do_not_bind_functions_with_nonconst_ref);
1360
1361 typedef base::true_type IsMethod;
1362
1363 static R DoInvoke(InvokerStorageBase* base) {
1364 StorageType* invoker = static_cast<StorageType*>(base);
1365 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_),
1366 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_),
1367 Unwrap(invoker->p6_));
1368 }
1369 };
1370
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
1393 // These are the actual storage classes for the invokers.
1394 //
1395 // 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
1397 // 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
1399 // Sig type like in FunctionTraitsN above to know the return type, and the arity
1400 // of Run().
1401 //
1402 // An alternate solution would be to merge FunctionTraitsN and InvokerStorageN,
1403 // but the generated code seemed harder to read.
1404
1405 template <typename Sig>
1406 class InvokerStorage0 : public InvokerStorageBase {
1407 public:
1408 typedef InvokerStorage0 StorageType;
1409 typedef FunctionTraits0<StorageType, Sig> FunctionTraits;
1410 typedef typename FunctionTraits::IsMethod IsMethod;
1411
1412
1413
1414 InvokerStorage0(Sig f)
1415 : f_(f) {
1416 }
1417
1418 virtual ~InvokerStorage0() { }
1419
1420 Sig f_;
1421 };
1422
1423 template <typename Sig, typename P1>
1424 class InvokerStorage1 : public InvokerStorageBase {
1425 public:
1426 typedef InvokerStorage1 StorageType;
1427 typedef FunctionTraits1<StorageType, Sig> FunctionTraits;
1428 typedef typename FunctionTraits::IsMethod IsMethod;
1429
1430 // 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
1432 // disallow binding of an array as the method's target object.
1433 COMPILE_ASSERT(IsMethod::value ||
1434 !internal::UnsafeBindtoRefCountedArg<P1>::value,
1435 p1_is_refcounted_type_and_needs_scoped_refptr);
1436 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value,
1437 first_bound_argument_to_method_cannot_be_array);
1438
1439
1440 InvokerStorage1(Sig f, const P1& p1)
1441 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)) {
1442 MaybeRefcount<IsMethod, P1>::AddRef(p1_);
1443 }
1444
1445 virtual ~InvokerStorage1() {
1446 MaybeRefcount<IsMethod, P1>::Release(p1_);
1447 }
1448
1449 Sig f_;
1450 typename BindType<P1>::StorageType p1_;
1451 };
1452
1453 template <typename Sig, typename P1, typename P2>
1454 class InvokerStorage2 : public InvokerStorageBase {
1455 public:
1456 typedef InvokerStorage2 StorageType;
1457 typedef FunctionTraits2<StorageType, Sig> FunctionTraits;
1458 typedef typename FunctionTraits::IsMethod IsMethod;
1459
1460 // 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
1462 // disallow binding of an array as the method's target object.
1463 COMPILE_ASSERT(IsMethod::value ||
1464 !internal::UnsafeBindtoRefCountedArg<P1>::value,
1465 p1_is_refcounted_type_and_needs_scoped_refptr);
1466 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value,
1467 first_bound_argument_to_method_cannot_be_array);
1468 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value,
1469 p2_is_refcounted_type_and_needs_scoped_refptr);
1470
1471
1472 InvokerStorage2(Sig f, const P1& p1, const P2& p2)
1473 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)),
1474 p2_(static_cast<typename BindType<P2>::StorageType>(p2)) {
1475 MaybeRefcount<IsMethod, P1>::AddRef(p1_);
1476 }
1477
1478 virtual ~InvokerStorage2() {
1479 MaybeRefcount<IsMethod, P1>::Release(p1_);
1480 }
1481
1482 Sig f_;
1483 typename BindType<P1>::StorageType p1_;
1484 typename BindType<P2>::StorageType p2_;
1485 };
1486
1487 template <typename Sig, typename P1, typename P2, typename P3>
1488 class InvokerStorage3 : public InvokerStorageBase {
1489 public:
1490 typedef InvokerStorage3 StorageType;
1491 typedef FunctionTraits3<StorageType, Sig> FunctionTraits;
1492 typedef typename FunctionTraits::IsMethod IsMethod;
1493
1494 // 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
1496 // disallow binding of an array as the method's target object.
1497 COMPILE_ASSERT(IsMethod::value ||
1498 !internal::UnsafeBindtoRefCountedArg<P1>::value,
1499 p1_is_refcounted_type_and_needs_scoped_refptr);
1500 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value,
1501 first_bound_argument_to_method_cannot_be_array);
1502 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value,
1503 p2_is_refcounted_type_and_needs_scoped_refptr);
1504 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P3>::value,
1505 p3_is_refcounted_type_and_needs_scoped_refptr);
1506
1507
1508 InvokerStorage3(Sig f, const P1& p1, const P2& p2, const P3& p3)
1509 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)),
1510 p2_(static_cast<typename BindType<P2>::StorageType>(p2)),
1511 p3_(static_cast<typename BindType<P3>::StorageType>(p3)) {
1512 MaybeRefcount<IsMethod, P1>::AddRef(p1_);
1513 }
1514
1515 virtual ~InvokerStorage3() {
1516 MaybeRefcount<IsMethod, P1>::Release(p1_);
1517 }
1518
1519 Sig f_;
1520 typename BindType<P1>::StorageType p1_;
1521 typename BindType<P2>::StorageType p2_;
1522 typename BindType<P3>::StorageType p3_;
1523 };
1524
1525 template <typename Sig, typename P1, typename P2, typename P3, typename P4>
1526 class InvokerStorage4 : public InvokerStorageBase {
1527 public:
1528 typedef InvokerStorage4 StorageType;
1529 typedef FunctionTraits4<StorageType, Sig> FunctionTraits;
1530 typedef typename FunctionTraits::IsMethod IsMethod;
1531
1532 // 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
1534 // disallow binding of an array as the method's target object.
1535 COMPILE_ASSERT(IsMethod::value ||
1536 !internal::UnsafeBindtoRefCountedArg<P1>::value,
1537 p1_is_refcounted_type_and_needs_scoped_refptr);
1538 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value,
1539 first_bound_argument_to_method_cannot_be_array);
1540 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value,
1541 p2_is_refcounted_type_and_needs_scoped_refptr);
1542 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P3>::value,
1543 p3_is_refcounted_type_and_needs_scoped_refptr);
1544 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P4>::value,
1545 p4_is_refcounted_type_and_needs_scoped_refptr);
1546
1547
1548 InvokerStorage4(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4)
1549 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)),
1550 p2_(static_cast<typename BindType<P2>::StorageType>(p2)),
1551 p3_(static_cast<typename BindType<P3>::StorageType>(p3)),
1552 p4_(static_cast<typename BindType<P4>::StorageType>(p4)) {
1553 MaybeRefcount<IsMethod, P1>::AddRef(p1_);
1554 }
1555
1556 virtual ~InvokerStorage4() {
1557 MaybeRefcount<IsMethod, P1>::Release(p1_);
1558 }
1559
1560 Sig f_;
1561 typename BindType<P1>::StorageType p1_;
1562 typename BindType<P2>::StorageType p2_;
1563 typename BindType<P3>::StorageType p3_;
1564 typename BindType<P4>::StorageType p4_;
1565 };
1566
1567 template <typename Sig, typename P1, typename P2, typename P3, typename P4,
1568 typename P5>
1569 class InvokerStorage5 : public InvokerStorageBase {
1570 public:
1571 typedef InvokerStorage5 StorageType;
1572 typedef FunctionTraits5<StorageType, Sig> FunctionTraits;
1573 typedef typename FunctionTraits::IsMethod IsMethod;
1574
1575 // 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
1577 // disallow binding of an array as the method's target object.
1578 COMPILE_ASSERT(IsMethod::value ||
1579 !internal::UnsafeBindtoRefCountedArg<P1>::value,
1580 p1_is_refcounted_type_and_needs_scoped_refptr);
1581 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value,
1582 first_bound_argument_to_method_cannot_be_array);
1583 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value,
1584 p2_is_refcounted_type_and_needs_scoped_refptr);
1585 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P3>::value,
1586 p3_is_refcounted_type_and_needs_scoped_refptr);
1587 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P4>::value,
1588 p4_is_refcounted_type_and_needs_scoped_refptr);
1589 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P5>::value,
1590 p5_is_refcounted_type_and_needs_scoped_refptr);
1591
1592
1593 InvokerStorage5(Sig f, const P1& p1, const P2& p2, const P3& p3,
1594 const P4& p4, const P5& p5)
1595 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)),
1596 p2_(static_cast<typename BindType<P2>::StorageType>(p2)),
1597 p3_(static_cast<typename BindType<P3>::StorageType>(p3)),
1598 p4_(static_cast<typename BindType<P4>::StorageType>(p4)),
1599 p5_(static_cast<typename BindType<P5>::StorageType>(p5)) {
1600 MaybeRefcount<IsMethod, P1>::AddRef(p1_);
1601 }
1602
1603 virtual ~InvokerStorage5() {
1604 MaybeRefcount<IsMethod, P1>::Release(p1_);
1605 }
1606
1607 Sig f_;
1608 typename BindType<P1>::StorageType p1_;
1609 typename BindType<P2>::StorageType p2_;
1610 typename BindType<P3>::StorageType p3_;
1611 typename BindType<P4>::StorageType p4_;
1612 typename BindType<P5>::StorageType p5_;
1613 };
1614
1615 template <typename Sig, typename P1, typename P2, typename P3, typename P4,
1616 typename P5, typename P6>
1617 class InvokerStorage6 : public InvokerStorageBase {
1618 public:
1619 typedef InvokerStorage6 StorageType;
1620 typedef FunctionTraits6<StorageType, Sig> FunctionTraits;
1621 typedef typename FunctionTraits::IsMethod IsMethod;
1622
1623 // 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
1625 // disallow binding of an array as the method's target object.
1626 COMPILE_ASSERT(IsMethod::value ||
1627 !internal::UnsafeBindtoRefCountedArg<P1>::value,
1628 p1_is_refcounted_type_and_needs_scoped_refptr);
1629 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value,
1630 first_bound_argument_to_method_cannot_be_array);
1631 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P2>::value,
1632 p2_is_refcounted_type_and_needs_scoped_refptr);
1633 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P3>::value,
1634 p3_is_refcounted_type_and_needs_scoped_refptr);
1635 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P4>::value,
1636 p4_is_refcounted_type_and_needs_scoped_refptr);
1637 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P5>::value,
1638 p5_is_refcounted_type_and_needs_scoped_refptr);
1639 COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P6>::value,
1640 p6_is_refcounted_type_and_needs_scoped_refptr);
1641
1642
1643 InvokerStorage6(Sig f, const P1& p1, const P2& p2, const P3& p3,
1644 const P4& p4, const P5& p5, const P6& p6)
1645 : f_(f), p1_(static_cast<typename BindType<P1>::StorageType>(p1)),
1646 p2_(static_cast<typename BindType<P2>::StorageType>(p2)),
1647 p3_(static_cast<typename BindType<P3>::StorageType>(p3)),
1648 p4_(static_cast<typename BindType<P4>::StorageType>(p4)),
1649 p5_(static_cast<typename BindType<P5>::StorageType>(p5)),
1650 p6_(static_cast<typename BindType<P6>::StorageType>(p6)) {
1651 MaybeRefcount<IsMethod, P1>::AddRef(p1_);
1652 }
1653
1654 virtual ~InvokerStorage6() {
1655 MaybeRefcount<IsMethod, P1>::Release(p1_);
1656 }
1657
1658 Sig f_;
1659 typename BindType<P1>::StorageType p1_;
1660 typename BindType<P2>::StorageType p2_;
1661 typename BindType<P3>::StorageType p3_;
1662 typename BindType<P4>::StorageType p4_;
1663 typename BindType<P5>::StorageType p5_;
1664 typename BindType<P6>::StorageType p6_;
1665 };
1666
1667 } // namespace internal
1668 } // namespace base
1669
1670 #endif // BASE_BIND_INTERNAL_H_
OLDNEW
« no previous file with comments | « base/bind_helpers.h ('k') | base/bind_internal.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698