1 // Copyright (c) 2011 Google Inc. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 // Do not include this header file directly. Use base/cef_bind.h instead.
32 #ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_
33 #define CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_
35 #include "include/base/cef_bind_helpers.h"
36 #include "include/base/cef_build.h"
37 #include "include/base/cef_template_util.h"
38 #include "include/base/cef_weak_ptr.h"
39 #include "include/base/internal/cef_callback_internal.h"
40 #include "include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h"
43 #include "include/base/internal/cef_bind_internal_win.h"
47 namespace cef_internal {
49 // See base/callback.h for user documentation.
53 // Runnable -- A type (really a type class) that has a single Run() method
54 // and a RunType typedef that corresponds to the type of Run().
55 // A Runnable can declare that it should treated like a method
56 // call by including a typedef named IsMethod. The value of
57 // this typedef is NOT inspected, only the existence. When a
58 // Runnable declares itself a method, Bind() will enforce special
59 // refcounting + WeakPtr handling semantics for the first
60 // parameter which is expected to be an object.
61 // Functor -- A copyable type representing something that should be called.
62 // All function pointers, Callback<>, and Runnables are functors
63 // even if the invocation syntax differs.
64 // RunType -- A function type (as opposed to function _pointer_ type) for
65 // a Run() function. Usually just a convenience typedef.
66 // (Bound)ArgsType -- A function type that is being (ab)used to store the
67 // types of set of arguments. The "return" type is always
68 // void here. We use this hack so that we do not need
69 // a new type name for each arity of type. (eg.,
70 // BindState1, BindState2). This makes forward
71 // declarations and friending much much easier.
74 // RunnableAdapter<> -- Wraps the various "function" pointer types into an
75 // object that adheres to the Runnable interface.
76 // There are |3*ARITY| RunnableAdapter types.
77 // FunctionTraits<> -- Type traits that unwrap a function signature into a
78 // a set of easier to use typedefs. Used mainly for
79 // compile time asserts.
80 // There are |ARITY| FunctionTraits types.
81 // ForceVoidReturn<> -- Helper class for translating function signatures to
82 // equivalent forms with a "void" return type.
83 // There are |ARITY| ForceVoidReturn types.
84 // FunctorTraits<> -- Type traits used determine the correct RunType and
85 // RunnableType for a Functor. This is where function
86 // signature adapters are applied.
87 // There are |ARITY| ForceVoidReturn types.
88 // MakeRunnable<> -- Takes a Functor and returns an object in the Runnable
89 // type class that represents the underlying Functor.
90 // There are |O(1)| MakeRunnable types.
91 // InvokeHelper<> -- Take a Runnable + arguments and actully invokes it.
92 // Handle the differing syntaxes needed for WeakPtr<> support,
93 // and for ignoring return values. This is separate from
94 // Invoker to avoid creating multiple version of Invoker<>
95 // which grows at O(n^2) with the arity.
96 // There are |k*ARITY| InvokeHelper types.
97 // Invoker<> -- Unwraps the curried parameters and executes the Runnable.
98 // There are |(ARITY^2 + ARITY)/2| Invoketypes.
99 // BindState<> -- Stores the curried parameters, and is the main entry point
100 // into the Bind() system, doing most of the type resolution.
101 // There are ARITY BindState types.
105 // The RunnableAdapter<> templates provide a uniform interface for invoking
106 // a function pointer, method pointer, or const method pointer. The adapter
107 // exposes a Run() method with an appropriate signature. Using this wrapper
108 // allows for writing code that supports all three pointer types without
109 // undue repetition. Without it, a lot of code would need to be repeated 3
112 // For method pointers and const method pointers the first argument to Run()
113 // is considered to be the received of the method. This is similar to STL's
116 // This class also exposes a RunType typedef that is the function type of the
119 // If and only if the wrapper contains a method or const method pointer, an
120 // IsMethod typedef is exposed. The existence of this typedef (NOT the value)
121 // marks that the wrapper should be considered a method wrapper.
123 template <typename Functor>
124 class RunnableAdapter;
126 // Function: Arity 0.
127 template <typename R>
128 class RunnableAdapter<R(*)()> {
130 typedef R (RunType)();
132 explicit RunnableAdapter(R(*function)())
133 : function_(function) {
145 template <typename R, typename T>
146 class RunnableAdapter<R(T::*)()> {
148 typedef R (RunType)(T*);
149 typedef true_type IsMethod;
151 explicit RunnableAdapter(R(T::*method)())
156 return (object->*method_)();
163 // Const Method: Arity 0.
164 template <typename R, typename T>
165 class RunnableAdapter<R(T::*)() const> {
167 typedef R (RunType)(const T*);
168 typedef true_type IsMethod;
170 explicit RunnableAdapter(R(T::*method)() const)
174 R Run(const T* object) {
175 return (object->*method_)();
179 R (T::*method_)() const;
182 // Function: Arity 1.
183 template <typename R, typename A1>
184 class RunnableAdapter<R(*)(A1)> {
186 typedef R (RunType)(A1);
188 explicit RunnableAdapter(R(*function)(A1))
189 : function_(function) {
192 R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
193 return function_(CallbackForward(a1));
201 template <typename R, typename T, typename A1>
202 class RunnableAdapter<R(T::*)(A1)> {
204 typedef R (RunType)(T*, A1);
205 typedef true_type IsMethod;
207 explicit RunnableAdapter(R(T::*method)(A1))
211 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
212 return (object->*method_)(CallbackForward(a1));
219 // Const Method: Arity 1.
220 template <typename R, typename T, typename A1>
221 class RunnableAdapter<R(T::*)(A1) const> {
223 typedef R (RunType)(const T*, A1);
224 typedef true_type IsMethod;
226 explicit RunnableAdapter(R(T::*method)(A1) const)
230 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
231 return (object->*method_)(CallbackForward(a1));
235 R (T::*method_)(A1) const;
238 // Function: Arity 2.
239 template <typename R, typename A1, typename A2>
240 class RunnableAdapter<R(*)(A1, A2)> {
242 typedef R (RunType)(A1, A2);
244 explicit RunnableAdapter(R(*function)(A1, A2))
245 : function_(function) {
248 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
249 typename CallbackParamTraits<A2>::ForwardType a2) {
250 return function_(CallbackForward(a1), CallbackForward(a2));
254 R (*function_)(A1, A2);
258 template <typename R, typename T, typename A1, typename A2>
259 class RunnableAdapter<R(T::*)(A1, A2)> {
261 typedef R (RunType)(T*, A1, A2);
262 typedef true_type IsMethod;
264 explicit RunnableAdapter(R(T::*method)(A1, A2))
268 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
269 typename CallbackParamTraits<A2>::ForwardType a2) {
270 return (object->*method_)(CallbackForward(a1), CallbackForward(a2));
274 R (T::*method_)(A1, A2);
277 // Const Method: Arity 2.
278 template <typename R, typename T, typename A1, typename A2>
279 class RunnableAdapter<R(T::*)(A1, A2) const> {
281 typedef R (RunType)(const T*, A1, A2);
282 typedef true_type IsMethod;
284 explicit RunnableAdapter(R(T::*method)(A1, A2) const)
288 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
289 typename CallbackParamTraits<A2>::ForwardType a2) {
290 return (object->*method_)(CallbackForward(a1), CallbackForward(a2));
294 R (T::*method_)(A1, A2) const;
297 // Function: Arity 3.
298 template <typename R, typename A1, typename A2, typename A3>
299 class RunnableAdapter<R(*)(A1, A2, A3)> {
301 typedef R (RunType)(A1, A2, A3);
303 explicit RunnableAdapter(R(*function)(A1, A2, A3))
304 : function_(function) {
307 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
308 typename CallbackParamTraits<A2>::ForwardType a2,
309 typename CallbackParamTraits<A3>::ForwardType a3) {
310 return function_(CallbackForward(a1), CallbackForward(a2),
311 CallbackForward(a3));
315 R (*function_)(A1, A2, A3);
319 template <typename R, typename T, typename A1, typename A2, typename A3>
320 class RunnableAdapter<R(T::*)(A1, A2, A3)> {
322 typedef R (RunType)(T*, A1, A2, A3);
323 typedef true_type IsMethod;
325 explicit RunnableAdapter(R(T::*method)(A1, A2, A3))
329 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
330 typename CallbackParamTraits<A2>::ForwardType a2,
331 typename CallbackParamTraits<A3>::ForwardType a3) {
332 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
333 CallbackForward(a3));
337 R (T::*method_)(A1, A2, A3);
340 // Const Method: Arity 3.
341 template <typename R, typename T, typename A1, typename A2, typename A3>
342 class RunnableAdapter<R(T::*)(A1, A2, A3) const> {
344 typedef R (RunType)(const T*, A1, A2, A3);
345 typedef true_type IsMethod;
347 explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const)
351 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
352 typename CallbackParamTraits<A2>::ForwardType a2,
353 typename CallbackParamTraits<A3>::ForwardType a3) {
354 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
355 CallbackForward(a3));
359 R (T::*method_)(A1, A2, A3) const;
362 // Function: Arity 4.
363 template <typename R, typename A1, typename A2, typename A3, typename A4>
364 class RunnableAdapter<R(*)(A1, A2, A3, A4)> {
366 typedef R (RunType)(A1, A2, A3, A4);
368 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4))
369 : function_(function) {
372 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
373 typename CallbackParamTraits<A2>::ForwardType a2,
374 typename CallbackParamTraits<A3>::ForwardType a3,
375 typename CallbackParamTraits<A4>::ForwardType a4) {
376 return function_(CallbackForward(a1), CallbackForward(a2),
377 CallbackForward(a3), CallbackForward(a4));
381 R (*function_)(A1, A2, A3, A4);
385 template <typename R, typename T, typename A1, typename A2, typename A3,
387 class RunnableAdapter<R(T::*)(A1, A2, A3, A4)> {
389 typedef R (RunType)(T*, A1, A2, A3, A4);
390 typedef true_type IsMethod;
392 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4))
396 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
397 typename CallbackParamTraits<A2>::ForwardType a2,
398 typename CallbackParamTraits<A3>::ForwardType a3,
399 typename CallbackParamTraits<A4>::ForwardType a4) {
400 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
401 CallbackForward(a3), CallbackForward(a4));
405 R (T::*method_)(A1, A2, A3, A4);
408 // Const Method: Arity 4.
409 template <typename R, typename T, typename A1, typename A2, typename A3,
411 class RunnableAdapter<R(T::*)(A1, A2, A3, A4) const> {
413 typedef R (RunType)(const T*, A1, A2, A3, A4);
414 typedef true_type IsMethod;
416 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const)
420 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
421 typename CallbackParamTraits<A2>::ForwardType a2,
422 typename CallbackParamTraits<A3>::ForwardType a3,
423 typename CallbackParamTraits<A4>::ForwardType a4) {
424 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
425 CallbackForward(a3), CallbackForward(a4));
429 R (T::*method_)(A1, A2, A3, A4) const;
432 // Function: Arity 5.
433 template <typename R, typename A1, typename A2, typename A3, typename A4,
435 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5)> {
437 typedef R (RunType)(A1, A2, A3, A4, A5);
439 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5))
440 : function_(function) {
443 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
444 typename CallbackParamTraits<A2>::ForwardType a2,
445 typename CallbackParamTraits<A3>::ForwardType a3,
446 typename CallbackParamTraits<A4>::ForwardType a4,
447 typename CallbackParamTraits<A5>::ForwardType a5) {
448 return function_(CallbackForward(a1), CallbackForward(a2),
449 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
453 R (*function_)(A1, A2, A3, A4, A5);
457 template <typename R, typename T, typename A1, typename A2, typename A3,
458 typename A4, typename A5>
459 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5)> {
461 typedef R (RunType)(T*, A1, A2, A3, A4, A5);
462 typedef true_type IsMethod;
464 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5))
468 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
469 typename CallbackParamTraits<A2>::ForwardType a2,
470 typename CallbackParamTraits<A3>::ForwardType a3,
471 typename CallbackParamTraits<A4>::ForwardType a4,
472 typename CallbackParamTraits<A5>::ForwardType a5) {
473 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
474 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
478 R (T::*method_)(A1, A2, A3, A4, A5);
481 // Const Method: Arity 5.
482 template <typename R, typename T, typename A1, typename A2, typename A3,
483 typename A4, typename A5>
484 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5) const> {
486 typedef R (RunType)(const T*, A1, A2, A3, A4, A5);
487 typedef true_type IsMethod;
489 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const)
493 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
494 typename CallbackParamTraits<A2>::ForwardType a2,
495 typename CallbackParamTraits<A3>::ForwardType a3,
496 typename CallbackParamTraits<A4>::ForwardType a4,
497 typename CallbackParamTraits<A5>::ForwardType a5) {
498 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
499 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
503 R (T::*method_)(A1, A2, A3, A4, A5) const;
506 // Function: Arity 6.
507 template <typename R, typename A1, typename A2, typename A3, typename A4,
508 typename A5, typename A6>
509 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6)> {
511 typedef R (RunType)(A1, A2, A3, A4, A5, A6);
513 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6))
514 : function_(function) {
517 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
518 typename CallbackParamTraits<A2>::ForwardType a2,
519 typename CallbackParamTraits<A3>::ForwardType a3,
520 typename CallbackParamTraits<A4>::ForwardType a4,
521 typename CallbackParamTraits<A5>::ForwardType a5,
522 typename CallbackParamTraits<A6>::ForwardType a6) {
523 return function_(CallbackForward(a1), CallbackForward(a2),
524 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
525 CallbackForward(a6));
529 R (*function_)(A1, A2, A3, A4, A5, A6);
533 template <typename R, typename T, typename A1, typename A2, typename A3,
534 typename A4, typename A5, typename A6>
535 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6)> {
537 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6);
538 typedef true_type IsMethod;
540 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6))
544 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
545 typename CallbackParamTraits<A2>::ForwardType a2,
546 typename CallbackParamTraits<A3>::ForwardType a3,
547 typename CallbackParamTraits<A4>::ForwardType a4,
548 typename CallbackParamTraits<A5>::ForwardType a5,
549 typename CallbackParamTraits<A6>::ForwardType a6) {
550 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
551 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
552 CallbackForward(a6));
556 R (T::*method_)(A1, A2, A3, A4, A5, A6);
559 // Const Method: Arity 6.
560 template <typename R, typename T, typename A1, typename A2, typename A3,
561 typename A4, typename A5, typename A6>
562 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6) const> {
564 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6);
565 typedef true_type IsMethod;
567 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const)
571 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
572 typename CallbackParamTraits<A2>::ForwardType a2,
573 typename CallbackParamTraits<A3>::ForwardType a3,
574 typename CallbackParamTraits<A4>::ForwardType a4,
575 typename CallbackParamTraits<A5>::ForwardType a5,
576 typename CallbackParamTraits<A6>::ForwardType a6) {
577 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
578 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
579 CallbackForward(a6));
583 R (T::*method_)(A1, A2, A3, A4, A5, A6) const;
586 // Function: Arity 7.
587 template <typename R, typename A1, typename A2, typename A3, typename A4,
588 typename A5, typename A6, typename A7>
589 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6, A7)> {
591 typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
593 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7))
594 : function_(function) {
597 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
598 typename CallbackParamTraits<A2>::ForwardType a2,
599 typename CallbackParamTraits<A3>::ForwardType a3,
600 typename CallbackParamTraits<A4>::ForwardType a4,
601 typename CallbackParamTraits<A5>::ForwardType a5,
602 typename CallbackParamTraits<A6>::ForwardType a6,
603 typename CallbackParamTraits<A7>::ForwardType a7) {
604 return function_(CallbackForward(a1), CallbackForward(a2),
605 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
606 CallbackForward(a6), CallbackForward(a7));
610 R (*function_)(A1, A2, A3, A4, A5, A6, A7);
614 template <typename R, typename T, typename A1, typename A2, typename A3,
615 typename A4, typename A5, typename A6, typename A7>
616 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7)> {
618 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7);
619 typedef true_type IsMethod;
621 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7))
625 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
626 typename CallbackParamTraits<A2>::ForwardType a2,
627 typename CallbackParamTraits<A3>::ForwardType a3,
628 typename CallbackParamTraits<A4>::ForwardType a4,
629 typename CallbackParamTraits<A5>::ForwardType a5,
630 typename CallbackParamTraits<A6>::ForwardType a6,
631 typename CallbackParamTraits<A7>::ForwardType a7) {
632 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
633 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
634 CallbackForward(a6), CallbackForward(a7));
638 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7);
641 // Const Method: Arity 7.
642 template <typename R, typename T, typename A1, typename A2, typename A3,
643 typename A4, typename A5, typename A6, typename A7>
644 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7) const> {
646 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7);
647 typedef true_type IsMethod;
649 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const)
653 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
654 typename CallbackParamTraits<A2>::ForwardType a2,
655 typename CallbackParamTraits<A3>::ForwardType a3,
656 typename CallbackParamTraits<A4>::ForwardType a4,
657 typename CallbackParamTraits<A5>::ForwardType a5,
658 typename CallbackParamTraits<A6>::ForwardType a6,
659 typename CallbackParamTraits<A7>::ForwardType a7) {
660 return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
661 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
662 CallbackForward(a6), CallbackForward(a7));
666 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const;
672 // Breaks a function signature apart into typedefs for easier introspection.
673 template <typename Sig>
674 struct FunctionTraits;
676 template <typename R>
677 struct FunctionTraits<R()> {
678 typedef R ReturnType;
681 template <typename R, typename A1>
682 struct FunctionTraits<R(A1)> {
683 typedef R ReturnType;
687 template <typename R, typename A1, typename A2>
688 struct FunctionTraits<R(A1, A2)> {
689 typedef R ReturnType;
694 template <typename R, typename A1, typename A2, typename A3>
695 struct FunctionTraits<R(A1, A2, A3)> {
696 typedef R ReturnType;
702 template <typename R, typename A1, typename A2, typename A3, typename A4>
703 struct FunctionTraits<R(A1, A2, A3, A4)> {
704 typedef R ReturnType;
711 template <typename R, typename A1, typename A2, typename A3, typename A4,
713 struct FunctionTraits<R(A1, A2, A3, A4, A5)> {
714 typedef R ReturnType;
722 template <typename R, typename A1, typename A2, typename A3, typename A4,
723 typename A5, typename A6>
724 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6)> {
725 typedef R ReturnType;
734 template <typename R, typename A1, typename A2, typename A3, typename A4,
735 typename A5, typename A6, typename A7>
736 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6, A7)> {
737 typedef R ReturnType;
750 // Set of templates that support forcing the function return type to void.
751 template <typename Sig>
752 struct ForceVoidReturn;
754 template <typename R>
755 struct ForceVoidReturn<R()> {
756 typedef void(RunType)();
759 template <typename R, typename A1>
760 struct ForceVoidReturn<R(A1)> {
761 typedef void(RunType)(A1);
764 template <typename R, typename A1, typename A2>
765 struct ForceVoidReturn<R(A1, A2)> {
766 typedef void(RunType)(A1, A2);
769 template <typename R, typename A1, typename A2, typename A3>
770 struct ForceVoidReturn<R(A1, A2, A3)> {
771 typedef void(RunType)(A1, A2, A3);
774 template <typename R, typename A1, typename A2, typename A3, typename A4>
775 struct ForceVoidReturn<R(A1, A2, A3, A4)> {
776 typedef void(RunType)(A1, A2, A3, A4);
779 template <typename R, typename A1, typename A2, typename A3, typename A4,
781 struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> {
782 typedef void(RunType)(A1, A2, A3, A4, A5);
785 template <typename R, typename A1, typename A2, typename A3, typename A4,
786 typename A5, typename A6>
787 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> {
788 typedef void(RunType)(A1, A2, A3, A4, A5, A6);
791 template <typename R, typename A1, typename A2, typename A3, typename A4,
792 typename A5, typename A6, typename A7>
793 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6, A7)> {
794 typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7);
800 // See description at top of file.
801 template <typename T>
802 struct FunctorTraits {
803 typedef RunnableAdapter<T> RunnableType;
804 typedef typename RunnableType::RunType RunType;
807 template <typename T>
808 struct FunctorTraits<IgnoreResultHelper<T> > {
809 typedef typename FunctorTraits<T>::RunnableType RunnableType;
810 typedef typename ForceVoidReturn<
811 typename RunnableType::RunType>::RunType RunType;
814 template <typename T>
815 struct FunctorTraits<Callback<T> > {
816 typedef Callback<T> RunnableType;
817 typedef typename Callback<T>::RunType RunType;
823 // Converts a passed in functor to a RunnableType using type inference.
825 template <typename T>
826 typename FunctorTraits<T>::RunnableType MakeRunnable(const T& t) {
827 return RunnableAdapter<T>(t);
830 template <typename T>
831 typename FunctorTraits<T>::RunnableType
832 MakeRunnable(const IgnoreResultHelper<T>& t) {
833 return MakeRunnable(t.functor_);
836 template <typename T>
837 const typename FunctorTraits<Callback<T> >::RunnableType&
838 MakeRunnable(const Callback<T>& t) {
839 DCHECK(!t.is_null());
846 // There are 3 logical InvokeHelper<> specializations: normal, void-return,
849 // The normal type just calls the underlying runnable.
851 // We need a InvokeHelper to handle void return types in order to support
852 // IgnoreResult(). Normally, if the Runnable's RunType had a void return,
853 // the template system would just accept "return functor.Run()" ignoring
854 // the fact that a void function is being used with return. This piece of
855 // sugar breaks though when the Runnable's RunType is not void. Thus, we
856 // need a partial specialization to change the syntax to drop the "return"
857 // from the invocation call.
859 // WeakCalls similarly need special syntax that is applied to the first
860 // argument to check if they should no-op themselves.
861 template <bool IsWeakCall, typename ReturnType, typename Runnable,
865 template <typename ReturnType, typename Runnable>
866 struct InvokeHelper<false, ReturnType, Runnable,
868 static ReturnType MakeItSo(Runnable runnable) {
869 return runnable.Run();
873 template <typename Runnable>
874 struct InvokeHelper<false, void, Runnable,
876 static void MakeItSo(Runnable runnable) {
881 template <typename ReturnType, typename Runnable,typename A1>
882 struct InvokeHelper<false, ReturnType, Runnable,
884 static ReturnType MakeItSo(Runnable runnable, A1 a1) {
885 return runnable.Run(CallbackForward(a1));
889 template <typename Runnable,typename A1>
890 struct InvokeHelper<false, void, Runnable,
892 static void MakeItSo(Runnable runnable, A1 a1) {
893 runnable.Run(CallbackForward(a1));
897 template <typename Runnable, typename BoundWeakPtr>
898 struct InvokeHelper<true, void, Runnable,
899 void(BoundWeakPtr)> {
900 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr) {
901 if (!weak_ptr.get()) {
904 runnable.Run(weak_ptr.get());
908 template <typename ReturnType, typename Runnable,typename A1, typename A2>
909 struct InvokeHelper<false, ReturnType, Runnable,
911 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) {
912 return runnable.Run(CallbackForward(a1), CallbackForward(a2));
916 template <typename Runnable,typename A1, typename A2>
917 struct InvokeHelper<false, void, Runnable,
919 static void MakeItSo(Runnable runnable, A1 a1, A2 a2) {
920 runnable.Run(CallbackForward(a1), CallbackForward(a2));
924 template <typename Runnable, typename BoundWeakPtr, typename A2>
925 struct InvokeHelper<true, void, Runnable,
926 void(BoundWeakPtr, A2)> {
927 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2) {
928 if (!weak_ptr.get()) {
931 runnable.Run(weak_ptr.get(), CallbackForward(a2));
935 template <typename ReturnType, typename Runnable,typename A1, typename A2,
937 struct InvokeHelper<false, ReturnType, Runnable,
939 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
940 return runnable.Run(CallbackForward(a1), CallbackForward(a2),
941 CallbackForward(a3));
945 template <typename Runnable,typename A1, typename A2, typename A3>
946 struct InvokeHelper<false, void, Runnable,
948 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
949 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3));
953 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3>
954 struct InvokeHelper<true, void, Runnable,
955 void(BoundWeakPtr, A2, A3)> {
956 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3) {
957 if (!weak_ptr.get()) {
960 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3));
964 template <typename ReturnType, typename Runnable,typename A1, typename A2,
965 typename A3, typename A4>
966 struct InvokeHelper<false, ReturnType, Runnable,
967 void(A1, A2, A3, A4)> {
968 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
969 return runnable.Run(CallbackForward(a1), CallbackForward(a2),
970 CallbackForward(a3), CallbackForward(a4));
974 template <typename Runnable,typename A1, typename A2, typename A3, typename A4>
975 struct InvokeHelper<false, void, Runnable,
976 void(A1, A2, A3, A4)> {
977 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
978 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
979 CallbackForward(a4));
983 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
985 struct InvokeHelper<true, void, Runnable,
986 void(BoundWeakPtr, A2, A3, A4)> {
987 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
989 if (!weak_ptr.get()) {
992 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
993 CallbackForward(a4));
997 template <typename ReturnType, typename Runnable,typename A1, typename A2,
998 typename A3, typename A4, typename A5>
999 struct InvokeHelper<false, ReturnType, Runnable,
1000 void(A1, A2, A3, A4, A5)> {
1001 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
1003 return runnable.Run(CallbackForward(a1), CallbackForward(a2),
1004 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
1008 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
1010 struct InvokeHelper<false, void, Runnable,
1011 void(A1, A2, A3, A4, A5)> {
1012 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
1013 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
1014 CallbackForward(a4), CallbackForward(a5));
1018 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
1019 typename A4, typename A5>
1020 struct InvokeHelper<true, void, Runnable,
1021 void(BoundWeakPtr, A2, A3, A4, A5)> {
1022 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
1024 if (!weak_ptr.get()) {
1027 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
1028 CallbackForward(a4), CallbackForward(a5));
1032 template <typename ReturnType, typename Runnable,typename A1, typename A2,
1033 typename A3, typename A4, typename A5, typename A6>
1034 struct InvokeHelper<false, ReturnType, Runnable,
1035 void(A1, A2, A3, A4, A5, A6)> {
1036 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
1038 return runnable.Run(CallbackForward(a1), CallbackForward(a2),
1039 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
1040 CallbackForward(a6));
1044 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
1045 typename A5, typename A6>
1046 struct InvokeHelper<false, void, Runnable,
1047 void(A1, A2, A3, A4, A5, A6)> {
1048 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
1050 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
1051 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6));
1055 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
1056 typename A4, typename A5, typename A6>
1057 struct InvokeHelper<true, void, Runnable,
1058 void(BoundWeakPtr, A2, A3, A4, A5, A6)> {
1059 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
1060 A4 a4, A5 a5, A6 a6) {
1061 if (!weak_ptr.get()) {
1064 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
1065 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6));
1069 template <typename ReturnType, typename Runnable,typename A1, typename A2,
1070 typename A3, typename A4, typename A5, typename A6, typename A7>
1071 struct InvokeHelper<false, ReturnType, Runnable,
1072 void(A1, A2, A3, A4, A5, A6, A7)> {
1073 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
1074 A5 a5, A6 a6, A7 a7) {
1075 return runnable.Run(CallbackForward(a1), CallbackForward(a2),
1076 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
1077 CallbackForward(a6), CallbackForward(a7));
1081 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
1082 typename A5, typename A6, typename A7>
1083 struct InvokeHelper<false, void, Runnable,
1084 void(A1, A2, A3, A4, A5, A6, A7)> {
1085 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
1087 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
1088 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6),
1089 CallbackForward(a7));
1093 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
1094 typename A4, typename A5, typename A6, typename A7>
1095 struct InvokeHelper<true, void, Runnable,
1096 void(BoundWeakPtr, A2, A3, A4, A5, A6, A7)> {
1097 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
1098 A4 a4, A5 a5, A6 a6, A7 a7) {
1099 if (!weak_ptr.get()) {
1102 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
1103 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6),
1104 CallbackForward(a7));
1108 #if !defined(_MSC_VER)
1110 template <typename ReturnType, typename Runnable, typename ArgsType>
1111 struct InvokeHelper<true, ReturnType, Runnable, ArgsType> {
1112 // WeakCalls are only supported for functions with a void return type.
1113 // Otherwise, the function result would be undefined if the the WeakPtr<>
1115 COMPILE_ASSERT(is_void<ReturnType>::value,
1116 weak_ptrs_can_only_bind_to_methods_without_return_values);
1123 // See description at the top of the file.
1124 template <int NumBound, typename Storage, typename RunType>
1128 template <typename StorageType, typename R>
1129 struct Invoker<0, StorageType, R()> {
1130 typedef R(RunType)(BindStateBase*);
1132 typedef R(UnboundRunType)();
1134 static R Run(BindStateBase* base) {
1135 StorageType* storage = static_cast<StorageType*>(base);
1137 // Local references to make debugger stepping easier. If in a debugger,
1138 // you really want to warp ahead and step through the
1139 // InvokeHelper<>::MakeItSo() call below.
1141 return InvokeHelper<StorageType::IsWeakCall::value, R,
1142 typename StorageType::RunnableType,
1144 ::MakeItSo(storage->runnable_);
1149 template <typename StorageType, typename R,typename X1>
1150 struct Invoker<0, StorageType, R(X1)> {
1151 typedef R(RunType)(BindStateBase*,
1152 typename CallbackParamTraits<X1>::ForwardType);
1154 typedef R(UnboundRunType)(X1);
1156 static R Run(BindStateBase* base,
1157 typename CallbackParamTraits<X1>::ForwardType x1) {
1158 StorageType* storage = static_cast<StorageType*>(base);
1160 // Local references to make debugger stepping easier. If in a debugger,
1161 // you really want to warp ahead and step through the
1162 // InvokeHelper<>::MakeItSo() call below.
1164 return InvokeHelper<StorageType::IsWeakCall::value, R,
1165 typename StorageType::RunnableType,
1166 void(typename CallbackParamTraits<X1>::ForwardType x1)>
1167 ::MakeItSo(storage->runnable_, CallbackForward(x1));
1172 template <typename StorageType, typename R,typename X1>
1173 struct Invoker<1, StorageType, R(X1)> {
1174 typedef R(RunType)(BindStateBase*);
1176 typedef R(UnboundRunType)();
1178 static R Run(BindStateBase* base) {
1179 StorageType* storage = static_cast<StorageType*>(base);
1181 // Local references to make debugger stepping easier. If in a debugger,
1182 // you really want to warp ahead and step through the
1183 // InvokeHelper<>::MakeItSo() call below.
1184 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1186 typename Bound1UnwrapTraits::ForwardType x1 =
1187 Bound1UnwrapTraits::Unwrap(storage->p1_);
1188 return InvokeHelper<StorageType::IsWeakCall::value, R,
1189 typename StorageType::RunnableType,
1190 void(typename Bound1UnwrapTraits::ForwardType)>
1191 ::MakeItSo(storage->runnable_, CallbackForward(x1));
1196 template <typename StorageType, typename R,typename X1, typename X2>
1197 struct Invoker<0, StorageType, R(X1, X2)> {
1198 typedef R(RunType)(BindStateBase*,
1199 typename CallbackParamTraits<X1>::ForwardType,
1200 typename CallbackParamTraits<X2>::ForwardType);
1202 typedef R(UnboundRunType)(X1, X2);
1204 static R Run(BindStateBase* base,
1205 typename CallbackParamTraits<X1>::ForwardType x1,
1206 typename CallbackParamTraits<X2>::ForwardType x2) {
1207 StorageType* storage = static_cast<StorageType*>(base);
1209 // Local references to make debugger stepping easier. If in a debugger,
1210 // you really want to warp ahead and step through the
1211 // InvokeHelper<>::MakeItSo() call below.
1213 return InvokeHelper<StorageType::IsWeakCall::value, R,
1214 typename StorageType::RunnableType,
1215 void(typename CallbackParamTraits<X1>::ForwardType x1,
1216 typename CallbackParamTraits<X2>::ForwardType x2)>
1217 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1218 CallbackForward(x2));
1223 template <typename StorageType, typename R,typename X1, typename X2>
1224 struct Invoker<1, StorageType, R(X1, X2)> {
1225 typedef R(RunType)(BindStateBase*,
1226 typename CallbackParamTraits<X2>::ForwardType);
1228 typedef R(UnboundRunType)(X2);
1230 static R Run(BindStateBase* base,
1231 typename CallbackParamTraits<X2>::ForwardType x2) {
1232 StorageType* storage = static_cast<StorageType*>(base);
1234 // Local references to make debugger stepping easier. If in a debugger,
1235 // you really want to warp ahead and step through the
1236 // InvokeHelper<>::MakeItSo() call below.
1237 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1239 typename Bound1UnwrapTraits::ForwardType x1 =
1240 Bound1UnwrapTraits::Unwrap(storage->p1_);
1241 return InvokeHelper<StorageType::IsWeakCall::value, R,
1242 typename StorageType::RunnableType,
1243 void(typename Bound1UnwrapTraits::ForwardType,
1244 typename CallbackParamTraits<X2>::ForwardType x2)>
1245 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1246 CallbackForward(x2));
1251 template <typename StorageType, typename R,typename X1, typename X2>
1252 struct Invoker<2, StorageType, R(X1, X2)> {
1253 typedef R(RunType)(BindStateBase*);
1255 typedef R(UnboundRunType)();
1257 static R Run(BindStateBase* base) {
1258 StorageType* storage = static_cast<StorageType*>(base);
1260 // Local references to make debugger stepping easier. If in a debugger,
1261 // you really want to warp ahead and step through the
1262 // InvokeHelper<>::MakeItSo() call below.
1263 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1264 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1266 typename Bound1UnwrapTraits::ForwardType x1 =
1267 Bound1UnwrapTraits::Unwrap(storage->p1_);
1268 typename Bound2UnwrapTraits::ForwardType x2 =
1269 Bound2UnwrapTraits::Unwrap(storage->p2_);
1270 return InvokeHelper<StorageType::IsWeakCall::value, R,
1271 typename StorageType::RunnableType,
1272 void(typename Bound1UnwrapTraits::ForwardType,
1273 typename Bound2UnwrapTraits::ForwardType)>
1274 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1275 CallbackForward(x2));
1280 template <typename StorageType, typename R,typename X1, typename X2,
1282 struct Invoker<0, StorageType, R(X1, X2, X3)> {
1283 typedef R(RunType)(BindStateBase*,
1284 typename CallbackParamTraits<X1>::ForwardType,
1285 typename CallbackParamTraits<X2>::ForwardType,
1286 typename CallbackParamTraits<X3>::ForwardType);
1288 typedef R(UnboundRunType)(X1, X2, X3);
1290 static R Run(BindStateBase* base,
1291 typename CallbackParamTraits<X1>::ForwardType x1,
1292 typename CallbackParamTraits<X2>::ForwardType x2,
1293 typename CallbackParamTraits<X3>::ForwardType x3) {
1294 StorageType* storage = static_cast<StorageType*>(base);
1296 // Local references to make debugger stepping easier. If in a debugger,
1297 // you really want to warp ahead and step through the
1298 // InvokeHelper<>::MakeItSo() call below.
1300 return InvokeHelper<StorageType::IsWeakCall::value, R,
1301 typename StorageType::RunnableType,
1302 void(typename CallbackParamTraits<X1>::ForwardType x1,
1303 typename CallbackParamTraits<X2>::ForwardType x2,
1304 typename CallbackParamTraits<X3>::ForwardType x3)>
1305 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1306 CallbackForward(x2), CallbackForward(x3));
1311 template <typename StorageType, typename R,typename X1, typename X2,
1313 struct Invoker<1, StorageType, R(X1, X2, X3)> {
1314 typedef R(RunType)(BindStateBase*,
1315 typename CallbackParamTraits<X2>::ForwardType,
1316 typename CallbackParamTraits<X3>::ForwardType);
1318 typedef R(UnboundRunType)(X2, X3);
1320 static R Run(BindStateBase* base,
1321 typename CallbackParamTraits<X2>::ForwardType x2,
1322 typename CallbackParamTraits<X3>::ForwardType x3) {
1323 StorageType* storage = static_cast<StorageType*>(base);
1325 // Local references to make debugger stepping easier. If in a debugger,
1326 // you really want to warp ahead and step through the
1327 // InvokeHelper<>::MakeItSo() call below.
1328 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1330 typename Bound1UnwrapTraits::ForwardType x1 =
1331 Bound1UnwrapTraits::Unwrap(storage->p1_);
1332 return InvokeHelper<StorageType::IsWeakCall::value, R,
1333 typename StorageType::RunnableType,
1334 void(typename Bound1UnwrapTraits::ForwardType,
1335 typename CallbackParamTraits<X2>::ForwardType x2,
1336 typename CallbackParamTraits<X3>::ForwardType x3)>
1337 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1338 CallbackForward(x2), CallbackForward(x3));
1343 template <typename StorageType, typename R,typename X1, typename X2,
1345 struct Invoker<2, StorageType, R(X1, X2, X3)> {
1346 typedef R(RunType)(BindStateBase*,
1347 typename CallbackParamTraits<X3>::ForwardType);
1349 typedef R(UnboundRunType)(X3);
1351 static R Run(BindStateBase* base,
1352 typename CallbackParamTraits<X3>::ForwardType x3) {
1353 StorageType* storage = static_cast<StorageType*>(base);
1355 // Local references to make debugger stepping easier. If in a debugger,
1356 // you really want to warp ahead and step through the
1357 // InvokeHelper<>::MakeItSo() call below.
1358 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1359 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1361 typename Bound1UnwrapTraits::ForwardType x1 =
1362 Bound1UnwrapTraits::Unwrap(storage->p1_);
1363 typename Bound2UnwrapTraits::ForwardType x2 =
1364 Bound2UnwrapTraits::Unwrap(storage->p2_);
1365 return InvokeHelper<StorageType::IsWeakCall::value, R,
1366 typename StorageType::RunnableType,
1367 void(typename Bound1UnwrapTraits::ForwardType,
1368 typename Bound2UnwrapTraits::ForwardType,
1369 typename CallbackParamTraits<X3>::ForwardType x3)>
1370 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1371 CallbackForward(x2), CallbackForward(x3));
1376 template <typename StorageType, typename R,typename X1, typename X2,
1378 struct Invoker<3, StorageType, R(X1, X2, X3)> {
1379 typedef R(RunType)(BindStateBase*);
1381 typedef R(UnboundRunType)();
1383 static R Run(BindStateBase* base) {
1384 StorageType* storage = static_cast<StorageType*>(base);
1386 // Local references to make debugger stepping easier. If in a debugger,
1387 // you really want to warp ahead and step through the
1388 // InvokeHelper<>::MakeItSo() call below.
1389 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1390 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1391 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1393 typename Bound1UnwrapTraits::ForwardType x1 =
1394 Bound1UnwrapTraits::Unwrap(storage->p1_);
1395 typename Bound2UnwrapTraits::ForwardType x2 =
1396 Bound2UnwrapTraits::Unwrap(storage->p2_);
1397 typename Bound3UnwrapTraits::ForwardType x3 =
1398 Bound3UnwrapTraits::Unwrap(storage->p3_);
1399 return InvokeHelper<StorageType::IsWeakCall::value, R,
1400 typename StorageType::RunnableType,
1401 void(typename Bound1UnwrapTraits::ForwardType,
1402 typename Bound2UnwrapTraits::ForwardType,
1403 typename Bound3UnwrapTraits::ForwardType)>
1404 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1405 CallbackForward(x2), CallbackForward(x3));
1410 template <typename StorageType, typename R,typename X1, typename X2,
1411 typename X3, typename X4>
1412 struct Invoker<0, StorageType, R(X1, X2, X3, X4)> {
1413 typedef R(RunType)(BindStateBase*,
1414 typename CallbackParamTraits<X1>::ForwardType,
1415 typename CallbackParamTraits<X2>::ForwardType,
1416 typename CallbackParamTraits<X3>::ForwardType,
1417 typename CallbackParamTraits<X4>::ForwardType);
1419 typedef R(UnboundRunType)(X1, X2, X3, X4);
1421 static R Run(BindStateBase* base,
1422 typename CallbackParamTraits<X1>::ForwardType x1,
1423 typename CallbackParamTraits<X2>::ForwardType x2,
1424 typename CallbackParamTraits<X3>::ForwardType x3,
1425 typename CallbackParamTraits<X4>::ForwardType x4) {
1426 StorageType* storage = static_cast<StorageType*>(base);
1428 // Local references to make debugger stepping easier. If in a debugger,
1429 // you really want to warp ahead and step through the
1430 // InvokeHelper<>::MakeItSo() call below.
1432 return InvokeHelper<StorageType::IsWeakCall::value, R,
1433 typename StorageType::RunnableType,
1434 void(typename CallbackParamTraits<X1>::ForwardType x1,
1435 typename CallbackParamTraits<X2>::ForwardType x2,
1436 typename CallbackParamTraits<X3>::ForwardType x3,
1437 typename CallbackParamTraits<X4>::ForwardType x4)>
1438 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1439 CallbackForward(x2), CallbackForward(x3),
1440 CallbackForward(x4));
1445 template <typename StorageType, typename R,typename X1, typename X2,
1446 typename X3, typename X4>
1447 struct Invoker<1, StorageType, R(X1, X2, X3, X4)> {
1448 typedef R(RunType)(BindStateBase*,
1449 typename CallbackParamTraits<X2>::ForwardType,
1450 typename CallbackParamTraits<X3>::ForwardType,
1451 typename CallbackParamTraits<X4>::ForwardType);
1453 typedef R(UnboundRunType)(X2, X3, X4);
1455 static R Run(BindStateBase* base,
1456 typename CallbackParamTraits<X2>::ForwardType x2,
1457 typename CallbackParamTraits<X3>::ForwardType x3,
1458 typename CallbackParamTraits<X4>::ForwardType x4) {
1459 StorageType* storage = static_cast<StorageType*>(base);
1461 // Local references to make debugger stepping easier. If in a debugger,
1462 // you really want to warp ahead and step through the
1463 // InvokeHelper<>::MakeItSo() call below.
1464 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1466 typename Bound1UnwrapTraits::ForwardType x1 =
1467 Bound1UnwrapTraits::Unwrap(storage->p1_);
1468 return InvokeHelper<StorageType::IsWeakCall::value, R,
1469 typename StorageType::RunnableType,
1470 void(typename Bound1UnwrapTraits::ForwardType,
1471 typename CallbackParamTraits<X2>::ForwardType x2,
1472 typename CallbackParamTraits<X3>::ForwardType x3,
1473 typename CallbackParamTraits<X4>::ForwardType x4)>
1474 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1475 CallbackForward(x2), CallbackForward(x3),
1476 CallbackForward(x4));
1481 template <typename StorageType, typename R,typename X1, typename X2,
1482 typename X3, typename X4>
1483 struct Invoker<2, StorageType, R(X1, X2, X3, X4)> {
1484 typedef R(RunType)(BindStateBase*,
1485 typename CallbackParamTraits<X3>::ForwardType,
1486 typename CallbackParamTraits<X4>::ForwardType);
1488 typedef R(UnboundRunType)(X3, X4);
1490 static R Run(BindStateBase* base,
1491 typename CallbackParamTraits<X3>::ForwardType x3,
1492 typename CallbackParamTraits<X4>::ForwardType x4) {
1493 StorageType* storage = static_cast<StorageType*>(base);
1495 // Local references to make debugger stepping easier. If in a debugger,
1496 // you really want to warp ahead and step through the
1497 // InvokeHelper<>::MakeItSo() call below.
1498 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1499 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1501 typename Bound1UnwrapTraits::ForwardType x1 =
1502 Bound1UnwrapTraits::Unwrap(storage->p1_);
1503 typename Bound2UnwrapTraits::ForwardType x2 =
1504 Bound2UnwrapTraits::Unwrap(storage->p2_);
1505 return InvokeHelper<StorageType::IsWeakCall::value, R,
1506 typename StorageType::RunnableType,
1507 void(typename Bound1UnwrapTraits::ForwardType,
1508 typename Bound2UnwrapTraits::ForwardType,
1509 typename CallbackParamTraits<X3>::ForwardType x3,
1510 typename CallbackParamTraits<X4>::ForwardType x4)>
1511 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1512 CallbackForward(x2), CallbackForward(x3),
1513 CallbackForward(x4));
1518 template <typename StorageType, typename R,typename X1, typename X2,
1519 typename X3, typename X4>
1520 struct Invoker<3, StorageType, R(X1, X2, X3, X4)> {
1521 typedef R(RunType)(BindStateBase*,
1522 typename CallbackParamTraits<X4>::ForwardType);
1524 typedef R(UnboundRunType)(X4);
1526 static R Run(BindStateBase* base,
1527 typename CallbackParamTraits<X4>::ForwardType x4) {
1528 StorageType* storage = static_cast<StorageType*>(base);
1530 // Local references to make debugger stepping easier. If in a debugger,
1531 // you really want to warp ahead and step through the
1532 // InvokeHelper<>::MakeItSo() call below.
1533 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1534 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1535 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1537 typename Bound1UnwrapTraits::ForwardType x1 =
1538 Bound1UnwrapTraits::Unwrap(storage->p1_);
1539 typename Bound2UnwrapTraits::ForwardType x2 =
1540 Bound2UnwrapTraits::Unwrap(storage->p2_);
1541 typename Bound3UnwrapTraits::ForwardType x3 =
1542 Bound3UnwrapTraits::Unwrap(storage->p3_);
1543 return InvokeHelper<StorageType::IsWeakCall::value, R,
1544 typename StorageType::RunnableType,
1545 void(typename Bound1UnwrapTraits::ForwardType,
1546 typename Bound2UnwrapTraits::ForwardType,
1547 typename Bound3UnwrapTraits::ForwardType,
1548 typename CallbackParamTraits<X4>::ForwardType x4)>
1549 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1550 CallbackForward(x2), CallbackForward(x3),
1551 CallbackForward(x4));
1556 template <typename StorageType, typename R,typename X1, typename X2,
1557 typename X3, typename X4>
1558 struct Invoker<4, StorageType, R(X1, X2, X3, X4)> {
1559 typedef R(RunType)(BindStateBase*);
1561 typedef R(UnboundRunType)();
1563 static R Run(BindStateBase* base) {
1564 StorageType* storage = static_cast<StorageType*>(base);
1566 // Local references to make debugger stepping easier. If in a debugger,
1567 // you really want to warp ahead and step through the
1568 // InvokeHelper<>::MakeItSo() call below.
1569 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1570 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1571 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1572 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1574 typename Bound1UnwrapTraits::ForwardType x1 =
1575 Bound1UnwrapTraits::Unwrap(storage->p1_);
1576 typename Bound2UnwrapTraits::ForwardType x2 =
1577 Bound2UnwrapTraits::Unwrap(storage->p2_);
1578 typename Bound3UnwrapTraits::ForwardType x3 =
1579 Bound3UnwrapTraits::Unwrap(storage->p3_);
1580 typename Bound4UnwrapTraits::ForwardType x4 =
1581 Bound4UnwrapTraits::Unwrap(storage->p4_);
1582 return InvokeHelper<StorageType::IsWeakCall::value, R,
1583 typename StorageType::RunnableType,
1584 void(typename Bound1UnwrapTraits::ForwardType,
1585 typename Bound2UnwrapTraits::ForwardType,
1586 typename Bound3UnwrapTraits::ForwardType,
1587 typename Bound4UnwrapTraits::ForwardType)>
1588 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1589 CallbackForward(x2), CallbackForward(x3),
1590 CallbackForward(x4));
1595 template <typename StorageType, typename R,typename X1, typename X2,
1596 typename X3, typename X4, typename X5>
1597 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> {
1598 typedef R(RunType)(BindStateBase*,
1599 typename CallbackParamTraits<X1>::ForwardType,
1600 typename CallbackParamTraits<X2>::ForwardType,
1601 typename CallbackParamTraits<X3>::ForwardType,
1602 typename CallbackParamTraits<X4>::ForwardType,
1603 typename CallbackParamTraits<X5>::ForwardType);
1605 typedef R(UnboundRunType)(X1, X2, X3, X4, X5);
1607 static R Run(BindStateBase* base,
1608 typename CallbackParamTraits<X1>::ForwardType x1,
1609 typename CallbackParamTraits<X2>::ForwardType x2,
1610 typename CallbackParamTraits<X3>::ForwardType x3,
1611 typename CallbackParamTraits<X4>::ForwardType x4,
1612 typename CallbackParamTraits<X5>::ForwardType x5) {
1613 StorageType* storage = static_cast<StorageType*>(base);
1615 // Local references to make debugger stepping easier. If in a debugger,
1616 // you really want to warp ahead and step through the
1617 // InvokeHelper<>::MakeItSo() call below.
1619 return InvokeHelper<StorageType::IsWeakCall::value, R,
1620 typename StorageType::RunnableType,
1621 void(typename CallbackParamTraits<X1>::ForwardType x1,
1622 typename CallbackParamTraits<X2>::ForwardType x2,
1623 typename CallbackParamTraits<X3>::ForwardType x3,
1624 typename CallbackParamTraits<X4>::ForwardType x4,
1625 typename CallbackParamTraits<X5>::ForwardType x5)>
1626 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1627 CallbackForward(x2), CallbackForward(x3),
1628 CallbackForward(x4), CallbackForward(x5));
1633 template <typename StorageType, typename R,typename X1, typename X2,
1634 typename X3, typename X4, typename X5>
1635 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> {
1636 typedef R(RunType)(BindStateBase*,
1637 typename CallbackParamTraits<X2>::ForwardType,
1638 typename CallbackParamTraits<X3>::ForwardType,
1639 typename CallbackParamTraits<X4>::ForwardType,
1640 typename CallbackParamTraits<X5>::ForwardType);
1642 typedef R(UnboundRunType)(X2, X3, X4, X5);
1644 static R Run(BindStateBase* base,
1645 typename CallbackParamTraits<X2>::ForwardType x2,
1646 typename CallbackParamTraits<X3>::ForwardType x3,
1647 typename CallbackParamTraits<X4>::ForwardType x4,
1648 typename CallbackParamTraits<X5>::ForwardType x5) {
1649 StorageType* storage = static_cast<StorageType*>(base);
1651 // Local references to make debugger stepping easier. If in a debugger,
1652 // you really want to warp ahead and step through the
1653 // InvokeHelper<>::MakeItSo() call below.
1654 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1656 typename Bound1UnwrapTraits::ForwardType x1 =
1657 Bound1UnwrapTraits::Unwrap(storage->p1_);
1658 return InvokeHelper<StorageType::IsWeakCall::value, R,
1659 typename StorageType::RunnableType,
1660 void(typename Bound1UnwrapTraits::ForwardType,
1661 typename CallbackParamTraits<X2>::ForwardType x2,
1662 typename CallbackParamTraits<X3>::ForwardType x3,
1663 typename CallbackParamTraits<X4>::ForwardType x4,
1664 typename CallbackParamTraits<X5>::ForwardType x5)>
1665 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1666 CallbackForward(x2), CallbackForward(x3),
1667 CallbackForward(x4), CallbackForward(x5));
1672 template <typename StorageType, typename R,typename X1, typename X2,
1673 typename X3, typename X4, typename X5>
1674 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> {
1675 typedef R(RunType)(BindStateBase*,
1676 typename CallbackParamTraits<X3>::ForwardType,
1677 typename CallbackParamTraits<X4>::ForwardType,
1678 typename CallbackParamTraits<X5>::ForwardType);
1680 typedef R(UnboundRunType)(X3, X4, X5);
1682 static R Run(BindStateBase* base,
1683 typename CallbackParamTraits<X3>::ForwardType x3,
1684 typename CallbackParamTraits<X4>::ForwardType x4,
1685 typename CallbackParamTraits<X5>::ForwardType x5) {
1686 StorageType* storage = static_cast<StorageType*>(base);
1688 // Local references to make debugger stepping easier. If in a debugger,
1689 // you really want to warp ahead and step through the
1690 // InvokeHelper<>::MakeItSo() call below.
1691 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1692 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1694 typename Bound1UnwrapTraits::ForwardType x1 =
1695 Bound1UnwrapTraits::Unwrap(storage->p1_);
1696 typename Bound2UnwrapTraits::ForwardType x2 =
1697 Bound2UnwrapTraits::Unwrap(storage->p2_);
1698 return InvokeHelper<StorageType::IsWeakCall::value, R,
1699 typename StorageType::RunnableType,
1700 void(typename Bound1UnwrapTraits::ForwardType,
1701 typename Bound2UnwrapTraits::ForwardType,
1702 typename CallbackParamTraits<X3>::ForwardType x3,
1703 typename CallbackParamTraits<X4>::ForwardType x4,
1704 typename CallbackParamTraits<X5>::ForwardType x5)>
1705 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1706 CallbackForward(x2), CallbackForward(x3),
1707 CallbackForward(x4), CallbackForward(x5));
1712 template <typename StorageType, typename R,typename X1, typename X2,
1713 typename X3, typename X4, typename X5>
1714 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> {
1715 typedef R(RunType)(BindStateBase*,
1716 typename CallbackParamTraits<X4>::ForwardType,
1717 typename CallbackParamTraits<X5>::ForwardType);
1719 typedef R(UnboundRunType)(X4, X5);
1721 static R Run(BindStateBase* base,
1722 typename CallbackParamTraits<X4>::ForwardType x4,
1723 typename CallbackParamTraits<X5>::ForwardType x5) {
1724 StorageType* storage = static_cast<StorageType*>(base);
1726 // Local references to make debugger stepping easier. If in a debugger,
1727 // you really want to warp ahead and step through the
1728 // InvokeHelper<>::MakeItSo() call below.
1729 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1730 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1731 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1733 typename Bound1UnwrapTraits::ForwardType x1 =
1734 Bound1UnwrapTraits::Unwrap(storage->p1_);
1735 typename Bound2UnwrapTraits::ForwardType x2 =
1736 Bound2UnwrapTraits::Unwrap(storage->p2_);
1737 typename Bound3UnwrapTraits::ForwardType x3 =
1738 Bound3UnwrapTraits::Unwrap(storage->p3_);
1739 return InvokeHelper<StorageType::IsWeakCall::value, R,
1740 typename StorageType::RunnableType,
1741 void(typename Bound1UnwrapTraits::ForwardType,
1742 typename Bound2UnwrapTraits::ForwardType,
1743 typename Bound3UnwrapTraits::ForwardType,
1744 typename CallbackParamTraits<X4>::ForwardType x4,
1745 typename CallbackParamTraits<X5>::ForwardType x5)>
1746 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1747 CallbackForward(x2), CallbackForward(x3),
1748 CallbackForward(x4), CallbackForward(x5));
1753 template <typename StorageType, typename R,typename X1, typename X2,
1754 typename X3, typename X4, typename X5>
1755 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> {
1756 typedef R(RunType)(BindStateBase*,
1757 typename CallbackParamTraits<X5>::ForwardType);
1759 typedef R(UnboundRunType)(X5);
1761 static R Run(BindStateBase* base,
1762 typename CallbackParamTraits<X5>::ForwardType x5) {
1763 StorageType* storage = static_cast<StorageType*>(base);
1765 // Local references to make debugger stepping easier. If in a debugger,
1766 // you really want to warp ahead and step through the
1767 // InvokeHelper<>::MakeItSo() call below.
1768 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1769 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1770 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1771 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1773 typename Bound1UnwrapTraits::ForwardType x1 =
1774 Bound1UnwrapTraits::Unwrap(storage->p1_);
1775 typename Bound2UnwrapTraits::ForwardType x2 =
1776 Bound2UnwrapTraits::Unwrap(storage->p2_);
1777 typename Bound3UnwrapTraits::ForwardType x3 =
1778 Bound3UnwrapTraits::Unwrap(storage->p3_);
1779 typename Bound4UnwrapTraits::ForwardType x4 =
1780 Bound4UnwrapTraits::Unwrap(storage->p4_);
1781 return InvokeHelper<StorageType::IsWeakCall::value, R,
1782 typename StorageType::RunnableType,
1783 void(typename Bound1UnwrapTraits::ForwardType,
1784 typename Bound2UnwrapTraits::ForwardType,
1785 typename Bound3UnwrapTraits::ForwardType,
1786 typename Bound4UnwrapTraits::ForwardType,
1787 typename CallbackParamTraits<X5>::ForwardType x5)>
1788 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1789 CallbackForward(x2), CallbackForward(x3),
1790 CallbackForward(x4), CallbackForward(x5));
1795 template <typename StorageType, typename R,typename X1, typename X2,
1796 typename X3, typename X4, typename X5>
1797 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> {
1798 typedef R(RunType)(BindStateBase*);
1800 typedef R(UnboundRunType)();
1802 static R Run(BindStateBase* base) {
1803 StorageType* storage = static_cast<StorageType*>(base);
1805 // Local references to make debugger stepping easier. If in a debugger,
1806 // you really want to warp ahead and step through the
1807 // InvokeHelper<>::MakeItSo() call below.
1808 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1809 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1810 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1811 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1812 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
1814 typename Bound1UnwrapTraits::ForwardType x1 =
1815 Bound1UnwrapTraits::Unwrap(storage->p1_);
1816 typename Bound2UnwrapTraits::ForwardType x2 =
1817 Bound2UnwrapTraits::Unwrap(storage->p2_);
1818 typename Bound3UnwrapTraits::ForwardType x3 =
1819 Bound3UnwrapTraits::Unwrap(storage->p3_);
1820 typename Bound4UnwrapTraits::ForwardType x4 =
1821 Bound4UnwrapTraits::Unwrap(storage->p4_);
1822 typename Bound5UnwrapTraits::ForwardType x5 =
1823 Bound5UnwrapTraits::Unwrap(storage->p5_);
1824 return InvokeHelper<StorageType::IsWeakCall::value, R,
1825 typename StorageType::RunnableType,
1826 void(typename Bound1UnwrapTraits::ForwardType,
1827 typename Bound2UnwrapTraits::ForwardType,
1828 typename Bound3UnwrapTraits::ForwardType,
1829 typename Bound4UnwrapTraits::ForwardType,
1830 typename Bound5UnwrapTraits::ForwardType)>
1831 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1832 CallbackForward(x2), CallbackForward(x3),
1833 CallbackForward(x4), CallbackForward(x5));
1838 template <typename StorageType, typename R,typename X1, typename X2,
1839 typename X3, typename X4, typename X5, typename X6>
1840 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1841 typedef R(RunType)(BindStateBase*,
1842 typename CallbackParamTraits<X1>::ForwardType,
1843 typename CallbackParamTraits<X2>::ForwardType,
1844 typename CallbackParamTraits<X3>::ForwardType,
1845 typename CallbackParamTraits<X4>::ForwardType,
1846 typename CallbackParamTraits<X5>::ForwardType,
1847 typename CallbackParamTraits<X6>::ForwardType);
1849 typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6);
1851 static R Run(BindStateBase* base,
1852 typename CallbackParamTraits<X1>::ForwardType x1,
1853 typename CallbackParamTraits<X2>::ForwardType x2,
1854 typename CallbackParamTraits<X3>::ForwardType x3,
1855 typename CallbackParamTraits<X4>::ForwardType x4,
1856 typename CallbackParamTraits<X5>::ForwardType x5,
1857 typename CallbackParamTraits<X6>::ForwardType x6) {
1858 StorageType* storage = static_cast<StorageType*>(base);
1860 // Local references to make debugger stepping easier. If in a debugger,
1861 // you really want to warp ahead and step through the
1862 // InvokeHelper<>::MakeItSo() call below.
1864 return InvokeHelper<StorageType::IsWeakCall::value, R,
1865 typename StorageType::RunnableType,
1866 void(typename CallbackParamTraits<X1>::ForwardType x1,
1867 typename CallbackParamTraits<X2>::ForwardType x2,
1868 typename CallbackParamTraits<X3>::ForwardType x3,
1869 typename CallbackParamTraits<X4>::ForwardType x4,
1870 typename CallbackParamTraits<X5>::ForwardType x5,
1871 typename CallbackParamTraits<X6>::ForwardType x6)>
1872 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1873 CallbackForward(x2), CallbackForward(x3),
1874 CallbackForward(x4), CallbackForward(x5),
1875 CallbackForward(x6));
1880 template <typename StorageType, typename R,typename X1, typename X2,
1881 typename X3, typename X4, typename X5, typename X6>
1882 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1883 typedef R(RunType)(BindStateBase*,
1884 typename CallbackParamTraits<X2>::ForwardType,
1885 typename CallbackParamTraits<X3>::ForwardType,
1886 typename CallbackParamTraits<X4>::ForwardType,
1887 typename CallbackParamTraits<X5>::ForwardType,
1888 typename CallbackParamTraits<X6>::ForwardType);
1890 typedef R(UnboundRunType)(X2, X3, X4, X5, X6);
1892 static R Run(BindStateBase* base,
1893 typename CallbackParamTraits<X2>::ForwardType x2,
1894 typename CallbackParamTraits<X3>::ForwardType x3,
1895 typename CallbackParamTraits<X4>::ForwardType x4,
1896 typename CallbackParamTraits<X5>::ForwardType x5,
1897 typename CallbackParamTraits<X6>::ForwardType x6) {
1898 StorageType* storage = static_cast<StorageType*>(base);
1900 // Local references to make debugger stepping easier. If in a debugger,
1901 // you really want to warp ahead and step through the
1902 // InvokeHelper<>::MakeItSo() call below.
1903 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1905 typename Bound1UnwrapTraits::ForwardType x1 =
1906 Bound1UnwrapTraits::Unwrap(storage->p1_);
1907 return InvokeHelper<StorageType::IsWeakCall::value, R,
1908 typename StorageType::RunnableType,
1909 void(typename Bound1UnwrapTraits::ForwardType,
1910 typename CallbackParamTraits<X2>::ForwardType x2,
1911 typename CallbackParamTraits<X3>::ForwardType x3,
1912 typename CallbackParamTraits<X4>::ForwardType x4,
1913 typename CallbackParamTraits<X5>::ForwardType x5,
1914 typename CallbackParamTraits<X6>::ForwardType x6)>
1915 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1916 CallbackForward(x2), CallbackForward(x3),
1917 CallbackForward(x4), CallbackForward(x5),
1918 CallbackForward(x6));
1923 template <typename StorageType, typename R,typename X1, typename X2,
1924 typename X3, typename X4, typename X5, typename X6>
1925 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1926 typedef R(RunType)(BindStateBase*,
1927 typename CallbackParamTraits<X3>::ForwardType,
1928 typename CallbackParamTraits<X4>::ForwardType,
1929 typename CallbackParamTraits<X5>::ForwardType,
1930 typename CallbackParamTraits<X6>::ForwardType);
1932 typedef R(UnboundRunType)(X3, X4, X5, X6);
1934 static R Run(BindStateBase* base,
1935 typename CallbackParamTraits<X3>::ForwardType x3,
1936 typename CallbackParamTraits<X4>::ForwardType x4,
1937 typename CallbackParamTraits<X5>::ForwardType x5,
1938 typename CallbackParamTraits<X6>::ForwardType x6) {
1939 StorageType* storage = static_cast<StorageType*>(base);
1941 // Local references to make debugger stepping easier. If in a debugger,
1942 // you really want to warp ahead and step through the
1943 // InvokeHelper<>::MakeItSo() call below.
1944 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1945 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1947 typename Bound1UnwrapTraits::ForwardType x1 =
1948 Bound1UnwrapTraits::Unwrap(storage->p1_);
1949 typename Bound2UnwrapTraits::ForwardType x2 =
1950 Bound2UnwrapTraits::Unwrap(storage->p2_);
1951 return InvokeHelper<StorageType::IsWeakCall::value, R,
1952 typename StorageType::RunnableType,
1953 void(typename Bound1UnwrapTraits::ForwardType,
1954 typename Bound2UnwrapTraits::ForwardType,
1955 typename CallbackParamTraits<X3>::ForwardType x3,
1956 typename CallbackParamTraits<X4>::ForwardType x4,
1957 typename CallbackParamTraits<X5>::ForwardType x5,
1958 typename CallbackParamTraits<X6>::ForwardType x6)>
1959 ::MakeItSo(storage->runnable_, CallbackForward(x1),
1960 CallbackForward(x2), CallbackForward(x3),
1961 CallbackForward(x4), CallbackForward(x5),
1962 CallbackForward(x6));
1967 template <typename StorageType, typename R,typename X1, typename X2,
1968 typename X3, typename X4, typename X5, typename X6>
1969 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1970 typedef R(RunType)(BindStateBase*,
1971 typename CallbackParamTraits<X4>::ForwardType,
1972 typename CallbackParamTraits<X5>::ForwardType,
1973 typename CallbackParamTraits<X6>::ForwardType);
1975 typedef R(UnboundRunType)(X4, X5, X6);
1977 static R Run(BindStateBase* base,
1978 typename CallbackParamTraits<X4>::ForwardType x4,
1979 typename CallbackParamTraits<X5>::ForwardType x5,
1980 typename CallbackParamTraits<X6>::ForwardType x6) {
1981 StorageType* storage = static_cast<StorageType*>(base);
1983 // Local references to make debugger stepping easier. If in a debugger,
1984 // you really want to warp ahead and step through the
1985 // InvokeHelper<>::MakeItSo() call below.
1986 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1987 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1988 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1990 typename Bound1UnwrapTraits::ForwardType x1 =
1991 Bound1UnwrapTraits::Unwrap(storage->p1_);
1992 typename Bound2UnwrapTraits::ForwardType x2 =
1993 Bound2UnwrapTraits::Unwrap(storage->p2_);
1994 typename Bound3UnwrapTraits::ForwardType x3 =
1995 Bound3UnwrapTraits::Unwrap(storage->p3_);
1996 return InvokeHelper<StorageType::IsWeakCall::value, R,
1997 typename StorageType::RunnableType,
1998 void(typename Bound1UnwrapTraits::ForwardType,
1999 typename Bound2UnwrapTraits::ForwardType,
2000 typename Bound3UnwrapTraits::ForwardType,
2001 typename CallbackParamTraits<X4>::ForwardType x4,
2002 typename CallbackParamTraits<X5>::ForwardType x5,
2003 typename CallbackParamTraits<X6>::ForwardType x6)>
2004 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2005 CallbackForward(x2), CallbackForward(x3),
2006 CallbackForward(x4), CallbackForward(x5),
2007 CallbackForward(x6));
2012 template <typename StorageType, typename R,typename X1, typename X2,
2013 typename X3, typename X4, typename X5, typename X6>
2014 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> {
2015 typedef R(RunType)(BindStateBase*,
2016 typename CallbackParamTraits<X5>::ForwardType,
2017 typename CallbackParamTraits<X6>::ForwardType);
2019 typedef R(UnboundRunType)(X5, X6);
2021 static R Run(BindStateBase* base,
2022 typename CallbackParamTraits<X5>::ForwardType x5,
2023 typename CallbackParamTraits<X6>::ForwardType x6) {
2024 StorageType* storage = static_cast<StorageType*>(base);
2026 // Local references to make debugger stepping easier. If in a debugger,
2027 // you really want to warp ahead and step through the
2028 // InvokeHelper<>::MakeItSo() call below.
2029 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2030 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2031 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2032 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2034 typename Bound1UnwrapTraits::ForwardType x1 =
2035 Bound1UnwrapTraits::Unwrap(storage->p1_);
2036 typename Bound2UnwrapTraits::ForwardType x2 =
2037 Bound2UnwrapTraits::Unwrap(storage->p2_);
2038 typename Bound3UnwrapTraits::ForwardType x3 =
2039 Bound3UnwrapTraits::Unwrap(storage->p3_);
2040 typename Bound4UnwrapTraits::ForwardType x4 =
2041 Bound4UnwrapTraits::Unwrap(storage->p4_);
2042 return InvokeHelper<StorageType::IsWeakCall::value, R,
2043 typename StorageType::RunnableType,
2044 void(typename Bound1UnwrapTraits::ForwardType,
2045 typename Bound2UnwrapTraits::ForwardType,
2046 typename Bound3UnwrapTraits::ForwardType,
2047 typename Bound4UnwrapTraits::ForwardType,
2048 typename CallbackParamTraits<X5>::ForwardType x5,
2049 typename CallbackParamTraits<X6>::ForwardType x6)>
2050 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2051 CallbackForward(x2), CallbackForward(x3),
2052 CallbackForward(x4), CallbackForward(x5),
2053 CallbackForward(x6));
2058 template <typename StorageType, typename R,typename X1, typename X2,
2059 typename X3, typename X4, typename X5, typename X6>
2060 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> {
2061 typedef R(RunType)(BindStateBase*,
2062 typename CallbackParamTraits<X6>::ForwardType);
2064 typedef R(UnboundRunType)(X6);
2066 static R Run(BindStateBase* base,
2067 typename CallbackParamTraits<X6>::ForwardType x6) {
2068 StorageType* storage = static_cast<StorageType*>(base);
2070 // Local references to make debugger stepping easier. If in a debugger,
2071 // you really want to warp ahead and step through the
2072 // InvokeHelper<>::MakeItSo() call below.
2073 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2074 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2075 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2076 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2077 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2079 typename Bound1UnwrapTraits::ForwardType x1 =
2080 Bound1UnwrapTraits::Unwrap(storage->p1_);
2081 typename Bound2UnwrapTraits::ForwardType x2 =
2082 Bound2UnwrapTraits::Unwrap(storage->p2_);
2083 typename Bound3UnwrapTraits::ForwardType x3 =
2084 Bound3UnwrapTraits::Unwrap(storage->p3_);
2085 typename Bound4UnwrapTraits::ForwardType x4 =
2086 Bound4UnwrapTraits::Unwrap(storage->p4_);
2087 typename Bound5UnwrapTraits::ForwardType x5 =
2088 Bound5UnwrapTraits::Unwrap(storage->p5_);
2089 return InvokeHelper<StorageType::IsWeakCall::value, R,
2090 typename StorageType::RunnableType,
2091 void(typename Bound1UnwrapTraits::ForwardType,
2092 typename Bound2UnwrapTraits::ForwardType,
2093 typename Bound3UnwrapTraits::ForwardType,
2094 typename Bound4UnwrapTraits::ForwardType,
2095 typename Bound5UnwrapTraits::ForwardType,
2096 typename CallbackParamTraits<X6>::ForwardType x6)>
2097 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2098 CallbackForward(x2), CallbackForward(x3),
2099 CallbackForward(x4), CallbackForward(x5),
2100 CallbackForward(x6));
2105 template <typename StorageType, typename R,typename X1, typename X2,
2106 typename X3, typename X4, typename X5, typename X6>
2107 struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> {
2108 typedef R(RunType)(BindStateBase*);
2110 typedef R(UnboundRunType)();
2112 static R Run(BindStateBase* base) {
2113 StorageType* storage = static_cast<StorageType*>(base);
2115 // Local references to make debugger stepping easier. If in a debugger,
2116 // you really want to warp ahead and step through the
2117 // InvokeHelper<>::MakeItSo() call below.
2118 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2119 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2120 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2121 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2122 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2123 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2125 typename Bound1UnwrapTraits::ForwardType x1 =
2126 Bound1UnwrapTraits::Unwrap(storage->p1_);
2127 typename Bound2UnwrapTraits::ForwardType x2 =
2128 Bound2UnwrapTraits::Unwrap(storage->p2_);
2129 typename Bound3UnwrapTraits::ForwardType x3 =
2130 Bound3UnwrapTraits::Unwrap(storage->p3_);
2131 typename Bound4UnwrapTraits::ForwardType x4 =
2132 Bound4UnwrapTraits::Unwrap(storage->p4_);
2133 typename Bound5UnwrapTraits::ForwardType x5 =
2134 Bound5UnwrapTraits::Unwrap(storage->p5_);
2135 typename Bound6UnwrapTraits::ForwardType x6 =
2136 Bound6UnwrapTraits::Unwrap(storage->p6_);
2137 return InvokeHelper<StorageType::IsWeakCall::value, R,
2138 typename StorageType::RunnableType,
2139 void(typename Bound1UnwrapTraits::ForwardType,
2140 typename Bound2UnwrapTraits::ForwardType,
2141 typename Bound3UnwrapTraits::ForwardType,
2142 typename Bound4UnwrapTraits::ForwardType,
2143 typename Bound5UnwrapTraits::ForwardType,
2144 typename Bound6UnwrapTraits::ForwardType)>
2145 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2146 CallbackForward(x2), CallbackForward(x3),
2147 CallbackForward(x4), CallbackForward(x5),
2148 CallbackForward(x6));
2153 template <typename StorageType, typename R,typename X1, typename X2,
2154 typename X3, typename X4, typename X5, typename X6, typename X7>
2155 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2156 typedef R(RunType)(BindStateBase*,
2157 typename CallbackParamTraits<X1>::ForwardType,
2158 typename CallbackParamTraits<X2>::ForwardType,
2159 typename CallbackParamTraits<X3>::ForwardType,
2160 typename CallbackParamTraits<X4>::ForwardType,
2161 typename CallbackParamTraits<X5>::ForwardType,
2162 typename CallbackParamTraits<X6>::ForwardType,
2163 typename CallbackParamTraits<X7>::ForwardType);
2165 typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7);
2167 static R Run(BindStateBase* base,
2168 typename CallbackParamTraits<X1>::ForwardType x1,
2169 typename CallbackParamTraits<X2>::ForwardType x2,
2170 typename CallbackParamTraits<X3>::ForwardType x3,
2171 typename CallbackParamTraits<X4>::ForwardType x4,
2172 typename CallbackParamTraits<X5>::ForwardType x5,
2173 typename CallbackParamTraits<X6>::ForwardType x6,
2174 typename CallbackParamTraits<X7>::ForwardType x7) {
2175 StorageType* storage = static_cast<StorageType*>(base);
2177 // Local references to make debugger stepping easier. If in a debugger,
2178 // you really want to warp ahead and step through the
2179 // InvokeHelper<>::MakeItSo() call below.
2181 return InvokeHelper<StorageType::IsWeakCall::value, R,
2182 typename StorageType::RunnableType,
2183 void(typename CallbackParamTraits<X1>::ForwardType x1,
2184 typename CallbackParamTraits<X2>::ForwardType x2,
2185 typename CallbackParamTraits<X3>::ForwardType x3,
2186 typename CallbackParamTraits<X4>::ForwardType x4,
2187 typename CallbackParamTraits<X5>::ForwardType x5,
2188 typename CallbackParamTraits<X6>::ForwardType x6,
2189 typename CallbackParamTraits<X7>::ForwardType x7)>
2190 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2191 CallbackForward(x2), CallbackForward(x3),
2192 CallbackForward(x4), CallbackForward(x5),
2193 CallbackForward(x6), CallbackForward(x7));
2198 template <typename StorageType, typename R,typename X1, typename X2,
2199 typename X3, typename X4, typename X5, typename X6, typename X7>
2200 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2201 typedef R(RunType)(BindStateBase*,
2202 typename CallbackParamTraits<X2>::ForwardType,
2203 typename CallbackParamTraits<X3>::ForwardType,
2204 typename CallbackParamTraits<X4>::ForwardType,
2205 typename CallbackParamTraits<X5>::ForwardType,
2206 typename CallbackParamTraits<X6>::ForwardType,
2207 typename CallbackParamTraits<X7>::ForwardType);
2209 typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7);
2211 static R Run(BindStateBase* base,
2212 typename CallbackParamTraits<X2>::ForwardType x2,
2213 typename CallbackParamTraits<X3>::ForwardType x3,
2214 typename CallbackParamTraits<X4>::ForwardType x4,
2215 typename CallbackParamTraits<X5>::ForwardType x5,
2216 typename CallbackParamTraits<X6>::ForwardType x6,
2217 typename CallbackParamTraits<X7>::ForwardType x7) {
2218 StorageType* storage = static_cast<StorageType*>(base);
2220 // Local references to make debugger stepping easier. If in a debugger,
2221 // you really want to warp ahead and step through the
2222 // InvokeHelper<>::MakeItSo() call below.
2223 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2225 typename Bound1UnwrapTraits::ForwardType x1 =
2226 Bound1UnwrapTraits::Unwrap(storage->p1_);
2227 return InvokeHelper<StorageType::IsWeakCall::value, R,
2228 typename StorageType::RunnableType,
2229 void(typename Bound1UnwrapTraits::ForwardType,
2230 typename CallbackParamTraits<X2>::ForwardType x2,
2231 typename CallbackParamTraits<X3>::ForwardType x3,
2232 typename CallbackParamTraits<X4>::ForwardType x4,
2233 typename CallbackParamTraits<X5>::ForwardType x5,
2234 typename CallbackParamTraits<X6>::ForwardType x6,
2235 typename CallbackParamTraits<X7>::ForwardType x7)>
2236 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2237 CallbackForward(x2), CallbackForward(x3),
2238 CallbackForward(x4), CallbackForward(x5),
2239 CallbackForward(x6), CallbackForward(x7));
2244 template <typename StorageType, typename R,typename X1, typename X2,
2245 typename X3, typename X4, typename X5, typename X6, typename X7>
2246 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2247 typedef R(RunType)(BindStateBase*,
2248 typename CallbackParamTraits<X3>::ForwardType,
2249 typename CallbackParamTraits<X4>::ForwardType,
2250 typename CallbackParamTraits<X5>::ForwardType,
2251 typename CallbackParamTraits<X6>::ForwardType,
2252 typename CallbackParamTraits<X7>::ForwardType);
2254 typedef R(UnboundRunType)(X3, X4, X5, X6, X7);
2256 static R Run(BindStateBase* base,
2257 typename CallbackParamTraits<X3>::ForwardType x3,
2258 typename CallbackParamTraits<X4>::ForwardType x4,
2259 typename CallbackParamTraits<X5>::ForwardType x5,
2260 typename CallbackParamTraits<X6>::ForwardType x6,
2261 typename CallbackParamTraits<X7>::ForwardType x7) {
2262 StorageType* storage = static_cast<StorageType*>(base);
2264 // Local references to make debugger stepping easier. If in a debugger,
2265 // you really want to warp ahead and step through the
2266 // InvokeHelper<>::MakeItSo() call below.
2267 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2268 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2270 typename Bound1UnwrapTraits::ForwardType x1 =
2271 Bound1UnwrapTraits::Unwrap(storage->p1_);
2272 typename Bound2UnwrapTraits::ForwardType x2 =
2273 Bound2UnwrapTraits::Unwrap(storage->p2_);
2274 return InvokeHelper<StorageType::IsWeakCall::value, R,
2275 typename StorageType::RunnableType,
2276 void(typename Bound1UnwrapTraits::ForwardType,
2277 typename Bound2UnwrapTraits::ForwardType,
2278 typename CallbackParamTraits<X3>::ForwardType x3,
2279 typename CallbackParamTraits<X4>::ForwardType x4,
2280 typename CallbackParamTraits<X5>::ForwardType x5,
2281 typename CallbackParamTraits<X6>::ForwardType x6,
2282 typename CallbackParamTraits<X7>::ForwardType x7)>
2283 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2284 CallbackForward(x2), CallbackForward(x3),
2285 CallbackForward(x4), CallbackForward(x5),
2286 CallbackForward(x6), CallbackForward(x7));
2291 template <typename StorageType, typename R,typename X1, typename X2,
2292 typename X3, typename X4, typename X5, typename X6, typename X7>
2293 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2294 typedef R(RunType)(BindStateBase*,
2295 typename CallbackParamTraits<X4>::ForwardType,
2296 typename CallbackParamTraits<X5>::ForwardType,
2297 typename CallbackParamTraits<X6>::ForwardType,
2298 typename CallbackParamTraits<X7>::ForwardType);
2300 typedef R(UnboundRunType)(X4, X5, X6, X7);
2302 static R Run(BindStateBase* base,
2303 typename CallbackParamTraits<X4>::ForwardType x4,
2304 typename CallbackParamTraits<X5>::ForwardType x5,
2305 typename CallbackParamTraits<X6>::ForwardType x6,
2306 typename CallbackParamTraits<X7>::ForwardType x7) {
2307 StorageType* storage = static_cast<StorageType*>(base);
2309 // Local references to make debugger stepping easier. If in a debugger,
2310 // you really want to warp ahead and step through the
2311 // InvokeHelper<>::MakeItSo() call below.
2312 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2313 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2314 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2316 typename Bound1UnwrapTraits::ForwardType x1 =
2317 Bound1UnwrapTraits::Unwrap(storage->p1_);
2318 typename Bound2UnwrapTraits::ForwardType x2 =
2319 Bound2UnwrapTraits::Unwrap(storage->p2_);
2320 typename Bound3UnwrapTraits::ForwardType x3 =
2321 Bound3UnwrapTraits::Unwrap(storage->p3_);
2322 return InvokeHelper<StorageType::IsWeakCall::value, R,
2323 typename StorageType::RunnableType,
2324 void(typename Bound1UnwrapTraits::ForwardType,
2325 typename Bound2UnwrapTraits::ForwardType,
2326 typename Bound3UnwrapTraits::ForwardType,
2327 typename CallbackParamTraits<X4>::ForwardType x4,
2328 typename CallbackParamTraits<X5>::ForwardType x5,
2329 typename CallbackParamTraits<X6>::ForwardType x6,
2330 typename CallbackParamTraits<X7>::ForwardType x7)>
2331 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2332 CallbackForward(x2), CallbackForward(x3),
2333 CallbackForward(x4), CallbackForward(x5),
2334 CallbackForward(x6), CallbackForward(x7));
2339 template <typename StorageType, typename R,typename X1, typename X2,
2340 typename X3, typename X4, typename X5, typename X6, typename X7>
2341 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2342 typedef R(RunType)(BindStateBase*,
2343 typename CallbackParamTraits<X5>::ForwardType,
2344 typename CallbackParamTraits<X6>::ForwardType,
2345 typename CallbackParamTraits<X7>::ForwardType);
2347 typedef R(UnboundRunType)(X5, X6, X7);
2349 static R Run(BindStateBase* base,
2350 typename CallbackParamTraits<X5>::ForwardType x5,
2351 typename CallbackParamTraits<X6>::ForwardType x6,
2352 typename CallbackParamTraits<X7>::ForwardType x7) {
2353 StorageType* storage = static_cast<StorageType*>(base);
2355 // Local references to make debugger stepping easier. If in a debugger,
2356 // you really want to warp ahead and step through the
2357 // InvokeHelper<>::MakeItSo() call below.
2358 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2359 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2360 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2361 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2363 typename Bound1UnwrapTraits::ForwardType x1 =
2364 Bound1UnwrapTraits::Unwrap(storage->p1_);
2365 typename Bound2UnwrapTraits::ForwardType x2 =
2366 Bound2UnwrapTraits::Unwrap(storage->p2_);
2367 typename Bound3UnwrapTraits::ForwardType x3 =
2368 Bound3UnwrapTraits::Unwrap(storage->p3_);
2369 typename Bound4UnwrapTraits::ForwardType x4 =
2370 Bound4UnwrapTraits::Unwrap(storage->p4_);
2371 return InvokeHelper<StorageType::IsWeakCall::value, R,
2372 typename StorageType::RunnableType,
2373 void(typename Bound1UnwrapTraits::ForwardType,
2374 typename Bound2UnwrapTraits::ForwardType,
2375 typename Bound3UnwrapTraits::ForwardType,
2376 typename Bound4UnwrapTraits::ForwardType,
2377 typename CallbackParamTraits<X5>::ForwardType x5,
2378 typename CallbackParamTraits<X6>::ForwardType x6,
2379 typename CallbackParamTraits<X7>::ForwardType x7)>
2380 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2381 CallbackForward(x2), CallbackForward(x3),
2382 CallbackForward(x4), CallbackForward(x5),
2383 CallbackForward(x6), CallbackForward(x7));
2388 template <typename StorageType, typename R,typename X1, typename X2,
2389 typename X3, typename X4, typename X5, typename X6, typename X7>
2390 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2391 typedef R(RunType)(BindStateBase*,
2392 typename CallbackParamTraits<X6>::ForwardType,
2393 typename CallbackParamTraits<X7>::ForwardType);
2395 typedef R(UnboundRunType)(X6, X7);
2397 static R Run(BindStateBase* base,
2398 typename CallbackParamTraits<X6>::ForwardType x6,
2399 typename CallbackParamTraits<X7>::ForwardType x7) {
2400 StorageType* storage = static_cast<StorageType*>(base);
2402 // Local references to make debugger stepping easier. If in a debugger,
2403 // you really want to warp ahead and step through the
2404 // InvokeHelper<>::MakeItSo() call below.
2405 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2406 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2407 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2408 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2409 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2411 typename Bound1UnwrapTraits::ForwardType x1 =
2412 Bound1UnwrapTraits::Unwrap(storage->p1_);
2413 typename Bound2UnwrapTraits::ForwardType x2 =
2414 Bound2UnwrapTraits::Unwrap(storage->p2_);
2415 typename Bound3UnwrapTraits::ForwardType x3 =
2416 Bound3UnwrapTraits::Unwrap(storage->p3_);
2417 typename Bound4UnwrapTraits::ForwardType x4 =
2418 Bound4UnwrapTraits::Unwrap(storage->p4_);
2419 typename Bound5UnwrapTraits::ForwardType x5 =
2420 Bound5UnwrapTraits::Unwrap(storage->p5_);
2421 return InvokeHelper<StorageType::IsWeakCall::value, R,
2422 typename StorageType::RunnableType,
2423 void(typename Bound1UnwrapTraits::ForwardType,
2424 typename Bound2UnwrapTraits::ForwardType,
2425 typename Bound3UnwrapTraits::ForwardType,
2426 typename Bound4UnwrapTraits::ForwardType,
2427 typename Bound5UnwrapTraits::ForwardType,
2428 typename CallbackParamTraits<X6>::ForwardType x6,
2429 typename CallbackParamTraits<X7>::ForwardType x7)>
2430 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2431 CallbackForward(x2), CallbackForward(x3),
2432 CallbackForward(x4), CallbackForward(x5),
2433 CallbackForward(x6), CallbackForward(x7));
2438 template <typename StorageType, typename R,typename X1, typename X2,
2439 typename X3, typename X4, typename X5, typename X6, typename X7>
2440 struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2441 typedef R(RunType)(BindStateBase*,
2442 typename CallbackParamTraits<X7>::ForwardType);
2444 typedef R(UnboundRunType)(X7);
2446 static R Run(BindStateBase* base,
2447 typename CallbackParamTraits<X7>::ForwardType x7) {
2448 StorageType* storage = static_cast<StorageType*>(base);
2450 // Local references to make debugger stepping easier. If in a debugger,
2451 // you really want to warp ahead and step through the
2452 // InvokeHelper<>::MakeItSo() call below.
2453 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2454 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2455 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2456 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2457 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2458 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2460 typename Bound1UnwrapTraits::ForwardType x1 =
2461 Bound1UnwrapTraits::Unwrap(storage->p1_);
2462 typename Bound2UnwrapTraits::ForwardType x2 =
2463 Bound2UnwrapTraits::Unwrap(storage->p2_);
2464 typename Bound3UnwrapTraits::ForwardType x3 =
2465 Bound3UnwrapTraits::Unwrap(storage->p3_);
2466 typename Bound4UnwrapTraits::ForwardType x4 =
2467 Bound4UnwrapTraits::Unwrap(storage->p4_);
2468 typename Bound5UnwrapTraits::ForwardType x5 =
2469 Bound5UnwrapTraits::Unwrap(storage->p5_);
2470 typename Bound6UnwrapTraits::ForwardType x6 =
2471 Bound6UnwrapTraits::Unwrap(storage->p6_);
2472 return InvokeHelper<StorageType::IsWeakCall::value, R,
2473 typename StorageType::RunnableType,
2474 void(typename Bound1UnwrapTraits::ForwardType,
2475 typename Bound2UnwrapTraits::ForwardType,
2476 typename Bound3UnwrapTraits::ForwardType,
2477 typename Bound4UnwrapTraits::ForwardType,
2478 typename Bound5UnwrapTraits::ForwardType,
2479 typename Bound6UnwrapTraits::ForwardType,
2480 typename CallbackParamTraits<X7>::ForwardType x7)>
2481 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2482 CallbackForward(x2), CallbackForward(x3),
2483 CallbackForward(x4), CallbackForward(x5),
2484 CallbackForward(x6), CallbackForward(x7));
2489 template <typename StorageType, typename R,typename X1, typename X2,
2490 typename X3, typename X4, typename X5, typename X6, typename X7>
2491 struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2492 typedef R(RunType)(BindStateBase*);
2494 typedef R(UnboundRunType)();
2496 static R Run(BindStateBase* base) {
2497 StorageType* storage = static_cast<StorageType*>(base);
2499 // Local references to make debugger stepping easier. If in a debugger,
2500 // you really want to warp ahead and step through the
2501 // InvokeHelper<>::MakeItSo() call below.
2502 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2503 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2504 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2505 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2506 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2507 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2508 typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits;
2510 typename Bound1UnwrapTraits::ForwardType x1 =
2511 Bound1UnwrapTraits::Unwrap(storage->p1_);
2512 typename Bound2UnwrapTraits::ForwardType x2 =
2513 Bound2UnwrapTraits::Unwrap(storage->p2_);
2514 typename Bound3UnwrapTraits::ForwardType x3 =
2515 Bound3UnwrapTraits::Unwrap(storage->p3_);
2516 typename Bound4UnwrapTraits::ForwardType x4 =
2517 Bound4UnwrapTraits::Unwrap(storage->p4_);
2518 typename Bound5UnwrapTraits::ForwardType x5 =
2519 Bound5UnwrapTraits::Unwrap(storage->p5_);
2520 typename Bound6UnwrapTraits::ForwardType x6 =
2521 Bound6UnwrapTraits::Unwrap(storage->p6_);
2522 typename Bound7UnwrapTraits::ForwardType x7 =
2523 Bound7UnwrapTraits::Unwrap(storage->p7_);
2524 return InvokeHelper<StorageType::IsWeakCall::value, R,
2525 typename StorageType::RunnableType,
2526 void(typename Bound1UnwrapTraits::ForwardType,
2527 typename Bound2UnwrapTraits::ForwardType,
2528 typename Bound3UnwrapTraits::ForwardType,
2529 typename Bound4UnwrapTraits::ForwardType,
2530 typename Bound5UnwrapTraits::ForwardType,
2531 typename Bound6UnwrapTraits::ForwardType,
2532 typename Bound7UnwrapTraits::ForwardType)>
2533 ::MakeItSo(storage->runnable_, CallbackForward(x1),
2534 CallbackForward(x2), CallbackForward(x3),
2535 CallbackForward(x4), CallbackForward(x5),
2536 CallbackForward(x6), CallbackForward(x7));
2543 // This stores all the state passed into Bind() and is also where most
2544 // of the template resolution magic occurs.
2546 // Runnable is the functor we are binding arguments to.
2547 // RunType is type of the Run() function that the Invoker<> should use.
2548 // Normally, this is the same as the RunType of the Runnable, but it can
2549 // be different if an adapter like IgnoreResult() has been used.
2551 // BoundArgsType contains the storage type for all the bound arguments by
2552 // (ab)using a function type.
2553 template <typename Runnable, typename RunType, typename BoundArgsType>
2556 template <typename Runnable, typename RunType>
2557 struct BindState<Runnable, RunType, void()> : public BindStateBase {
2558 typedef Runnable RunnableType;
2559 typedef false_type IsWeakCall;
2560 typedef Invoker<0, BindState, RunType> InvokerType;
2561 typedef typename InvokerType::UnboundRunType UnboundRunType;
2562 explicit BindState(const Runnable& runnable)
2563 : runnable_(runnable) {
2566 virtual ~BindState() { }
2568 RunnableType runnable_;
2571 template <typename Runnable, typename RunType, typename P1>
2572 struct BindState<Runnable, RunType, void(P1)> : public BindStateBase {
2573 typedef Runnable RunnableType;
2574 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2575 typedef Invoker<1, BindState, RunType> InvokerType;
2576 typedef typename InvokerType::UnboundRunType UnboundRunType;
2578 // Convenience typedefs for bound argument types.
2579 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2581 BindState(const Runnable& runnable, const P1& p1)
2582 : runnable_(runnable),
2584 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2587 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2588 P1>::Release(p1_); }
2590 RunnableType runnable_;
2594 template <typename Runnable, typename RunType, typename P1, typename P2>
2595 struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {
2596 typedef Runnable RunnableType;
2597 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2598 typedef Invoker<2, BindState, RunType> InvokerType;
2599 typedef typename InvokerType::UnboundRunType UnboundRunType;
2601 // Convenience typedefs for bound argument types.
2602 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2603 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2605 BindState(const Runnable& runnable, const P1& p1, const P2& p2)
2606 : runnable_(runnable),
2609 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2612 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2613 P1>::Release(p1_); }
2615 RunnableType runnable_;
2620 template <typename Runnable, typename RunType, typename P1, typename P2,
2622 struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {
2623 typedef Runnable RunnableType;
2624 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2625 typedef Invoker<3, BindState, RunType> InvokerType;
2626 typedef typename InvokerType::UnboundRunType UnboundRunType;
2628 // Convenience typedefs for bound argument types.
2629 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2630 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2631 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2633 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3)
2634 : runnable_(runnable),
2638 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2641 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2642 P1>::Release(p1_); }
2644 RunnableType runnable_;
2650 template <typename Runnable, typename RunType, typename P1, typename P2,
2651 typename P3, typename P4>
2652 struct BindState<Runnable, RunType, void(P1, P2, P3,
2653 P4)> : public BindStateBase {
2654 typedef Runnable RunnableType;
2655 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2656 typedef Invoker<4, BindState, RunType> InvokerType;
2657 typedef typename InvokerType::UnboundRunType UnboundRunType;
2659 // Convenience typedefs for bound argument types.
2660 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2661 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2662 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2663 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2665 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2667 : runnable_(runnable),
2672 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2675 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2676 P1>::Release(p1_); }
2678 RunnableType runnable_;
2685 template <typename Runnable, typename RunType, typename P1, typename P2,
2686 typename P3, typename P4, typename P5>
2687 struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
2688 P5)> : public BindStateBase {
2689 typedef Runnable RunnableType;
2690 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2691 typedef Invoker<5, BindState, RunType> InvokerType;
2692 typedef typename InvokerType::UnboundRunType UnboundRunType;
2694 // Convenience typedefs for bound argument types.
2695 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2696 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2697 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2698 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2699 typedef UnwrapTraits<P5> Bound5UnwrapTraits;
2701 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2702 const P4& p4, const P5& p5)
2703 : runnable_(runnable),
2709 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2712 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2713 P1>::Release(p1_); }
2715 RunnableType runnable_;
2723 template <typename Runnable, typename RunType, typename P1, typename P2,
2724 typename P3, typename P4, typename P5, typename P6>
2725 struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
2726 P6)> : public BindStateBase {
2727 typedef Runnable RunnableType;
2728 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2729 typedef Invoker<6, BindState, RunType> InvokerType;
2730 typedef typename InvokerType::UnboundRunType UnboundRunType;
2732 // Convenience typedefs for bound argument types.
2733 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2734 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2735 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2736 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2737 typedef UnwrapTraits<P5> Bound5UnwrapTraits;
2738 typedef UnwrapTraits<P6> Bound6UnwrapTraits;
2740 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2741 const P4& p4, const P5& p5, const P6& p6)
2742 : runnable_(runnable),
2749 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2752 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2753 P1>::Release(p1_); }
2755 RunnableType runnable_;
2764 template <typename Runnable, typename RunType, typename P1, typename P2,
2765 typename P3, typename P4, typename P5, typename P6, typename P7>
2766 struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
2767 P7)> : public BindStateBase {
2768 typedef Runnable RunnableType;
2769 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2770 typedef Invoker<7, BindState, RunType> InvokerType;
2771 typedef typename InvokerType::UnboundRunType UnboundRunType;
2773 // Convenience typedefs for bound argument types.
2774 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2775 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2776 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2777 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2778 typedef UnwrapTraits<P5> Bound5UnwrapTraits;
2779 typedef UnwrapTraits<P6> Bound6UnwrapTraits;
2780 typedef UnwrapTraits<P7> Bound7UnwrapTraits;
2782 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2783 const P4& p4, const P5& p5, const P6& p6, const P7& p7)
2784 : runnable_(runnable),
2792 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2795 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2796 P1>::Release(p1_); }
2798 RunnableType runnable_;
2808 } // namespace cef_internal
2811 #endif // CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_