]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/base/internal/cef_bind_internal.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / base / internal / cef_bind_internal.h
1 // Copyright (c) 2011 Google Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
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
12 // distribution.
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.
17 //
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.
29
30 // Do not include this header file directly. Use base/cef_bind.h instead.
31
32 #ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_
33 #define CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_
34
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"
41
42 #if defined(OS_WIN)
43 #include "include/base/internal/cef_bind_internal_win.h"
44 #endif
45
46 namespace base {
47 namespace cef_internal {
48
49 // See base/callback.h for user documentation.
50 //
51 //
52 // CONCEPTS:
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.
72 //
73 // Types:
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.
102
103 // RunnableAdapter<>
104 //
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
110 // times.
111 //
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
114 // mem_fun().
115 //
116 // This class also exposes a RunType typedef that is the function type of the
117 // Run() function.
118 //
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.
122
123 template <typename Functor>
124 class RunnableAdapter;
125
126 // Function: Arity 0.
127 template <typename R>
128 class RunnableAdapter<R(*)()> {
129  public:
130   typedef R (RunType)();
131
132   explicit RunnableAdapter(R(*function)())
133       : function_(function) {
134   }
135
136   R Run() {
137     return function_();
138   }
139
140  private:
141   R (*function_)();
142 };
143
144 // Method: Arity 0.
145 template <typename R, typename T>
146 class RunnableAdapter<R(T::*)()> {
147  public:
148   typedef R (RunType)(T*);
149   typedef true_type IsMethod;
150
151   explicit RunnableAdapter(R(T::*method)())
152       : method_(method) {
153   }
154
155   R Run(T* object) {
156     return (object->*method_)();
157   }
158
159  private:
160   R (T::*method_)();
161 };
162
163 // Const Method: Arity 0.
164 template <typename R, typename T>
165 class RunnableAdapter<R(T::*)() const> {
166  public:
167   typedef R (RunType)(const T*);
168   typedef true_type IsMethod;
169
170   explicit RunnableAdapter(R(T::*method)() const)
171       : method_(method) {
172   }
173
174   R Run(const T* object) {
175     return (object->*method_)();
176   }
177
178  private:
179   R (T::*method_)() const;
180 };
181
182 // Function: Arity 1.
183 template <typename R, typename A1>
184 class RunnableAdapter<R(*)(A1)> {
185  public:
186   typedef R (RunType)(A1);
187
188   explicit RunnableAdapter(R(*function)(A1))
189       : function_(function) {
190   }
191
192   R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
193     return function_(CallbackForward(a1));
194   }
195
196  private:
197   R (*function_)(A1);
198 };
199
200 // Method: Arity 1.
201 template <typename R, typename T, typename A1>
202 class RunnableAdapter<R(T::*)(A1)> {
203  public:
204   typedef R (RunType)(T*, A1);
205   typedef true_type IsMethod;
206
207   explicit RunnableAdapter(R(T::*method)(A1))
208       : method_(method) {
209   }
210
211   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
212     return (object->*method_)(CallbackForward(a1));
213   }
214
215  private:
216   R (T::*method_)(A1);
217 };
218
219 // Const Method: Arity 1.
220 template <typename R, typename T, typename A1>
221 class RunnableAdapter<R(T::*)(A1) const> {
222  public:
223   typedef R (RunType)(const T*, A1);
224   typedef true_type IsMethod;
225
226   explicit RunnableAdapter(R(T::*method)(A1) const)
227       : method_(method) {
228   }
229
230   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
231     return (object->*method_)(CallbackForward(a1));
232   }
233
234  private:
235   R (T::*method_)(A1) const;
236 };
237
238 // Function: Arity 2.
239 template <typename R, typename A1, typename A2>
240 class RunnableAdapter<R(*)(A1, A2)> {
241  public:
242   typedef R (RunType)(A1, A2);
243
244   explicit RunnableAdapter(R(*function)(A1, A2))
245       : function_(function) {
246   }
247
248   R Run(typename CallbackParamTraits<A1>::ForwardType a1,
249       typename CallbackParamTraits<A2>::ForwardType a2) {
250     return function_(CallbackForward(a1), CallbackForward(a2));
251   }
252
253  private:
254   R (*function_)(A1, A2);
255 };
256
257 // Method: Arity 2.
258 template <typename R, typename T, typename A1, typename A2>
259 class RunnableAdapter<R(T::*)(A1, A2)> {
260  public:
261   typedef R (RunType)(T*, A1, A2);
262   typedef true_type IsMethod;
263
264   explicit RunnableAdapter(R(T::*method)(A1, A2))
265       : method_(method) {
266   }
267
268   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
269       typename CallbackParamTraits<A2>::ForwardType a2) {
270     return (object->*method_)(CallbackForward(a1), CallbackForward(a2));
271   }
272
273  private:
274   R (T::*method_)(A1, A2);
275 };
276
277 // Const Method: Arity 2.
278 template <typename R, typename T, typename A1, typename A2>
279 class RunnableAdapter<R(T::*)(A1, A2) const> {
280  public:
281   typedef R (RunType)(const T*, A1, A2);
282   typedef true_type IsMethod;
283
284   explicit RunnableAdapter(R(T::*method)(A1, A2) const)
285       : method_(method) {
286   }
287
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));
291   }
292
293  private:
294   R (T::*method_)(A1, A2) const;
295 };
296
297 // Function: Arity 3.
298 template <typename R, typename A1, typename A2, typename A3>
299 class RunnableAdapter<R(*)(A1, A2, A3)> {
300  public:
301   typedef R (RunType)(A1, A2, A3);
302
303   explicit RunnableAdapter(R(*function)(A1, A2, A3))
304       : function_(function) {
305   }
306
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));
312   }
313
314  private:
315   R (*function_)(A1, A2, A3);
316 };
317
318 // Method: Arity 3.
319 template <typename R, typename T, typename A1, typename A2, typename A3>
320 class RunnableAdapter<R(T::*)(A1, A2, A3)> {
321  public:
322   typedef R (RunType)(T*, A1, A2, A3);
323   typedef true_type IsMethod;
324
325   explicit RunnableAdapter(R(T::*method)(A1, A2, A3))
326       : method_(method) {
327   }
328
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));
334   }
335
336  private:
337   R (T::*method_)(A1, A2, A3);
338 };
339
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> {
343  public:
344   typedef R (RunType)(const T*, A1, A2, A3);
345   typedef true_type IsMethod;
346
347   explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const)
348       : method_(method) {
349   }
350
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));
356   }
357
358  private:
359   R (T::*method_)(A1, A2, A3) const;
360 };
361
362 // Function: Arity 4.
363 template <typename R, typename A1, typename A2, typename A3, typename A4>
364 class RunnableAdapter<R(*)(A1, A2, A3, A4)> {
365  public:
366   typedef R (RunType)(A1, A2, A3, A4);
367
368   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4))
369       : function_(function) {
370   }
371
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));
378   }
379
380  private:
381   R (*function_)(A1, A2, A3, A4);
382 };
383
384 // Method: Arity 4.
385 template <typename R, typename T, typename A1, typename A2, typename A3,
386     typename A4>
387 class RunnableAdapter<R(T::*)(A1, A2, A3, A4)> {
388  public:
389   typedef R (RunType)(T*, A1, A2, A3, A4);
390   typedef true_type IsMethod;
391
392   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4))
393       : method_(method) {
394   }
395
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));
402   }
403
404  private:
405   R (T::*method_)(A1, A2, A3, A4);
406 };
407
408 // Const Method: Arity 4.
409 template <typename R, typename T, typename A1, typename A2, typename A3,
410     typename A4>
411 class RunnableAdapter<R(T::*)(A1, A2, A3, A4) const> {
412  public:
413   typedef R (RunType)(const T*, A1, A2, A3, A4);
414   typedef true_type IsMethod;
415
416   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const)
417       : method_(method) {
418   }
419
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));
426   }
427
428  private:
429   R (T::*method_)(A1, A2, A3, A4) const;
430 };
431
432 // Function: Arity 5.
433 template <typename R, typename A1, typename A2, typename A3, typename A4,
434     typename A5>
435 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5)> {
436  public:
437   typedef R (RunType)(A1, A2, A3, A4, A5);
438
439   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5))
440       : function_(function) {
441   }
442
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));
450   }
451
452  private:
453   R (*function_)(A1, A2, A3, A4, A5);
454 };
455
456 // Method: Arity 5.
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)> {
460  public:
461   typedef R (RunType)(T*, A1, A2, A3, A4, A5);
462   typedef true_type IsMethod;
463
464   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5))
465       : method_(method) {
466   }
467
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));
475   }
476
477  private:
478   R (T::*method_)(A1, A2, A3, A4, A5);
479 };
480
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> {
485  public:
486   typedef R (RunType)(const T*, A1, A2, A3, A4, A5);
487   typedef true_type IsMethod;
488
489   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const)
490       : method_(method) {
491   }
492
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));
500   }
501
502  private:
503   R (T::*method_)(A1, A2, A3, A4, A5) const;
504 };
505
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)> {
510  public:
511   typedef R (RunType)(A1, A2, A3, A4, A5, A6);
512
513   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6))
514       : function_(function) {
515   }
516
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));
526   }
527
528  private:
529   R (*function_)(A1, A2, A3, A4, A5, A6);
530 };
531
532 // Method: Arity 6.
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)> {
536  public:
537   typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6);
538   typedef true_type IsMethod;
539
540   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6))
541       : method_(method) {
542   }
543
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));
553   }
554
555  private:
556   R (T::*method_)(A1, A2, A3, A4, A5, A6);
557 };
558
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> {
563  public:
564   typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6);
565   typedef true_type IsMethod;
566
567   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const)
568       : method_(method) {
569   }
570
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));
580   }
581
582  private:
583   R (T::*method_)(A1, A2, A3, A4, A5, A6) const;
584 };
585
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)> {
590  public:
591   typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
592
593   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7))
594       : function_(function) {
595   }
596
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));
607   }
608
609  private:
610   R (*function_)(A1, A2, A3, A4, A5, A6, A7);
611 };
612
613 // Method: Arity 7.
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)> {
617  public:
618   typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7);
619   typedef true_type IsMethod;
620
621   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7))
622       : method_(method) {
623   }
624
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));
635   }
636
637  private:
638   R (T::*method_)(A1, A2, A3, A4, A5, A6, A7);
639 };
640
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> {
645  public:
646   typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7);
647   typedef true_type IsMethod;
648
649   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const)
650       : method_(method) {
651   }
652
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));
663   }
664
665  private:
666   R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const;
667 };
668
669
670 // FunctionTraits<>
671 //
672 // Breaks a function signature apart into typedefs for easier introspection.
673 template <typename Sig>
674 struct FunctionTraits;
675
676 template <typename R>
677 struct FunctionTraits<R()> {
678   typedef R ReturnType;
679 };
680
681 template <typename R, typename A1>
682 struct FunctionTraits<R(A1)> {
683   typedef R ReturnType;
684   typedef A1 A1Type;
685 };
686
687 template <typename R, typename A1, typename A2>
688 struct FunctionTraits<R(A1, A2)> {
689   typedef R ReturnType;
690   typedef A1 A1Type;
691   typedef A2 A2Type;
692 };
693
694 template <typename R, typename A1, typename A2, typename A3>
695 struct FunctionTraits<R(A1, A2, A3)> {
696   typedef R ReturnType;
697   typedef A1 A1Type;
698   typedef A2 A2Type;
699   typedef A3 A3Type;
700 };
701
702 template <typename R, typename A1, typename A2, typename A3, typename A4>
703 struct FunctionTraits<R(A1, A2, A3, A4)> {
704   typedef R ReturnType;
705   typedef A1 A1Type;
706   typedef A2 A2Type;
707   typedef A3 A3Type;
708   typedef A4 A4Type;
709 };
710
711 template <typename R, typename A1, typename A2, typename A3, typename A4,
712     typename A5>
713 struct FunctionTraits<R(A1, A2, A3, A4, A5)> {
714   typedef R ReturnType;
715   typedef A1 A1Type;
716   typedef A2 A2Type;
717   typedef A3 A3Type;
718   typedef A4 A4Type;
719   typedef A5 A5Type;
720 };
721
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;
726   typedef A1 A1Type;
727   typedef A2 A2Type;
728   typedef A3 A3Type;
729   typedef A4 A4Type;
730   typedef A5 A5Type;
731   typedef A6 A6Type;
732 };
733
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;
738   typedef A1 A1Type;
739   typedef A2 A2Type;
740   typedef A3 A3Type;
741   typedef A4 A4Type;
742   typedef A5 A5Type;
743   typedef A6 A6Type;
744   typedef A7 A7Type;
745 };
746
747
748 // ForceVoidReturn<>
749 //
750 // Set of templates that support forcing the function return type to void.
751 template <typename Sig>
752 struct ForceVoidReturn;
753
754 template <typename R>
755 struct ForceVoidReturn<R()> {
756   typedef void(RunType)();
757 };
758
759 template <typename R, typename A1>
760 struct ForceVoidReturn<R(A1)> {
761   typedef void(RunType)(A1);
762 };
763
764 template <typename R, typename A1, typename A2>
765 struct ForceVoidReturn<R(A1, A2)> {
766   typedef void(RunType)(A1, A2);
767 };
768
769 template <typename R, typename A1, typename A2, typename A3>
770 struct ForceVoidReturn<R(A1, A2, A3)> {
771   typedef void(RunType)(A1, A2, A3);
772 };
773
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);
777 };
778
779 template <typename R, typename A1, typename A2, typename A3, typename A4,
780     typename A5>
781 struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> {
782   typedef void(RunType)(A1, A2, A3, A4, A5);
783 };
784
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);
789 };
790
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);
795 };
796
797
798 // FunctorTraits<>
799 //
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;
805 };
806
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;
812 };
813
814 template <typename T>
815 struct FunctorTraits<Callback<T> > {
816   typedef Callback<T> RunnableType;
817   typedef typename Callback<T>::RunType RunType;
818 };
819
820
821 // MakeRunnable<>
822 //
823 // Converts a passed in functor to a RunnableType using type inference.
824
825 template <typename T>
826 typename FunctorTraits<T>::RunnableType MakeRunnable(const T& t) {
827   return RunnableAdapter<T>(t);
828 }
829
830 template <typename T>
831 typename FunctorTraits<T>::RunnableType
832 MakeRunnable(const IgnoreResultHelper<T>& t) {
833   return MakeRunnable(t.functor_);
834 }
835
836 template <typename T>
837 const typename FunctorTraits<Callback<T> >::RunnableType&
838 MakeRunnable(const Callback<T>& t) {
839   DCHECK(!t.is_null());
840   return t;
841 }
842
843
844 // InvokeHelper<>
845 //
846 // There are 3 logical InvokeHelper<> specializations: normal, void-return,
847 // WeakCalls.
848 //
849 // The normal type just calls the underlying runnable.
850 //
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.
858 //
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,
862           typename ArgsType>
863 struct InvokeHelper;
864
865 template <typename ReturnType, typename Runnable>
866 struct InvokeHelper<false, ReturnType, Runnable,
867     void()>  {
868   static ReturnType MakeItSo(Runnable runnable) {
869     return runnable.Run();
870   }
871 };
872
873 template <typename Runnable>
874 struct InvokeHelper<false, void, Runnable,
875     void()>  {
876   static void MakeItSo(Runnable runnable) {
877     runnable.Run();
878   }
879 };
880
881 template <typename ReturnType, typename Runnable,typename A1>
882 struct InvokeHelper<false, ReturnType, Runnable,
883     void(A1)>  {
884   static ReturnType MakeItSo(Runnable runnable, A1 a1) {
885     return runnable.Run(CallbackForward(a1));
886   }
887 };
888
889 template <typename Runnable,typename A1>
890 struct InvokeHelper<false, void, Runnable,
891     void(A1)>  {
892   static void MakeItSo(Runnable runnable, A1 a1) {
893     runnable.Run(CallbackForward(a1));
894   }
895 };
896
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()) {
902       return;
903     }
904     runnable.Run(weak_ptr.get());
905   }
906 };
907
908 template <typename ReturnType, typename Runnable,typename A1, typename A2>
909 struct InvokeHelper<false, ReturnType, Runnable,
910     void(A1, A2)>  {
911   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) {
912     return runnable.Run(CallbackForward(a1), CallbackForward(a2));
913   }
914 };
915
916 template <typename Runnable,typename A1, typename A2>
917 struct InvokeHelper<false, void, Runnable,
918     void(A1, A2)>  {
919   static void MakeItSo(Runnable runnable, A1 a1, A2 a2) {
920     runnable.Run(CallbackForward(a1), CallbackForward(a2));
921   }
922 };
923
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()) {
929       return;
930     }
931     runnable.Run(weak_ptr.get(), CallbackForward(a2));
932   }
933 };
934
935 template <typename ReturnType, typename Runnable,typename A1, typename A2,
936     typename A3>
937 struct InvokeHelper<false, ReturnType, Runnable,
938     void(A1, A2, A3)>  {
939   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
940     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
941         CallbackForward(a3));
942   }
943 };
944
945 template <typename Runnable,typename A1, typename A2, typename A3>
946 struct InvokeHelper<false, void, Runnable,
947     void(A1, A2, A3)>  {
948   static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
949     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3));
950   }
951 };
952
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()) {
958       return;
959     }
960     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3));
961   }
962 };
963
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));
971   }
972 };
973
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));
980   }
981 };
982
983 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
984     typename A4>
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,
988       A4 a4) {
989     if (!weak_ptr.get()) {
990       return;
991     }
992     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
993         CallbackForward(a4));
994   }
995 };
996
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,
1002       A5 a5) {
1003     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
1004         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
1005   }
1006 };
1007
1008 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
1009     typename A5>
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));
1015   }
1016 };
1017
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,
1023       A4 a4, A5 a5) {
1024     if (!weak_ptr.get()) {
1025       return;
1026     }
1027     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
1028         CallbackForward(a4), CallbackForward(a5));
1029   }
1030 };
1031
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,
1037       A5 a5, A6 a6) {
1038     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
1039         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
1040         CallbackForward(a6));
1041   }
1042 };
1043
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,
1049       A6 a6) {
1050     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
1051         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6));
1052   }
1053 };
1054
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()) {
1062       return;
1063     }
1064     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
1065         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6));
1066   }
1067 };
1068
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));
1078   }
1079 };
1080
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,
1086       A6 a6, A7 a7) {
1087     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
1088         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6),
1089         CallbackForward(a7));
1090   }
1091 };
1092
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()) {
1100       return;
1101     }
1102     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
1103         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6),
1104         CallbackForward(a7));
1105   }
1106 };
1107
1108 #if !defined(_MSC_VER)
1109
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<>
1114   // is invalidated.
1115   COMPILE_ASSERT(is_void<ReturnType>::value,
1116                  weak_ptrs_can_only_bind_to_methods_without_return_values);
1117 };
1118
1119 #endif
1120
1121 // Invoker<>
1122 //
1123 // See description at the top of the file.
1124 template <int NumBound, typename Storage, typename RunType>
1125 struct Invoker;
1126
1127 // Arity 0 -> 0.
1128 template <typename StorageType, typename R>
1129 struct Invoker<0, StorageType, R()> {
1130   typedef R(RunType)(BindStateBase*);
1131
1132   typedef R(UnboundRunType)();
1133
1134   static R Run(BindStateBase* base) {
1135     StorageType* storage = static_cast<StorageType*>(base);
1136
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.
1140
1141     return InvokeHelper<StorageType::IsWeakCall::value, R,
1142            typename StorageType::RunnableType,
1143            void()>
1144                ::MakeItSo(storage->runnable_);
1145   }
1146 };
1147
1148 // Arity 1 -> 1.
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);
1153
1154   typedef R(UnboundRunType)(X1);
1155
1156   static R Run(BindStateBase* base,
1157       typename CallbackParamTraits<X1>::ForwardType x1) {
1158     StorageType* storage = static_cast<StorageType*>(base);
1159
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.
1163
1164     return InvokeHelper<StorageType::IsWeakCall::value, R,
1165            typename StorageType::RunnableType,
1166            void(typename CallbackParamTraits<X1>::ForwardType x1)>
1167                ::MakeItSo(storage->runnable_, CallbackForward(x1));
1168   }
1169 };
1170
1171 // Arity 1 -> 0.
1172 template <typename StorageType, typename R,typename X1>
1173 struct Invoker<1, StorageType, R(X1)> {
1174   typedef R(RunType)(BindStateBase*);
1175
1176   typedef R(UnboundRunType)();
1177
1178   static R Run(BindStateBase* base) {
1179     StorageType* storage = static_cast<StorageType*>(base);
1180
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;
1185
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));
1192   }
1193 };
1194
1195 // Arity 2 -> 2.
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);
1201
1202   typedef R(UnboundRunType)(X1, X2);
1203
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);
1208
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.
1212
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));
1219   }
1220 };
1221
1222 // Arity 2 -> 1.
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);
1227
1228   typedef R(UnboundRunType)(X2);
1229
1230   static R Run(BindStateBase* base,
1231       typename CallbackParamTraits<X2>::ForwardType x2) {
1232     StorageType* storage = static_cast<StorageType*>(base);
1233
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;
1238
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));
1247   }
1248 };
1249
1250 // Arity 2 -> 0.
1251 template <typename StorageType, typename R,typename X1, typename X2>
1252 struct Invoker<2, StorageType, R(X1, X2)> {
1253   typedef R(RunType)(BindStateBase*);
1254
1255   typedef R(UnboundRunType)();
1256
1257   static R Run(BindStateBase* base) {
1258     StorageType* storage = static_cast<StorageType*>(base);
1259
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;
1265
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));
1276   }
1277 };
1278
1279 // Arity 3 -> 3.
1280 template <typename StorageType, typename R,typename X1, typename X2,
1281     typename X3>
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);
1287
1288   typedef R(UnboundRunType)(X1, X2, X3);
1289
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);
1295
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.
1299
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));
1307   }
1308 };
1309
1310 // Arity 3 -> 2.
1311 template <typename StorageType, typename R,typename X1, typename X2,
1312     typename X3>
1313 struct Invoker<1, StorageType, R(X1, X2, X3)> {
1314   typedef R(RunType)(BindStateBase*,
1315       typename CallbackParamTraits<X2>::ForwardType,
1316       typename CallbackParamTraits<X3>::ForwardType);
1317
1318   typedef R(UnboundRunType)(X2, X3);
1319
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);
1324
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;
1329
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));
1339   }
1340 };
1341
1342 // Arity 3 -> 1.
1343 template <typename StorageType, typename R,typename X1, typename X2,
1344     typename X3>
1345 struct Invoker<2, StorageType, R(X1, X2, X3)> {
1346   typedef R(RunType)(BindStateBase*,
1347       typename CallbackParamTraits<X3>::ForwardType);
1348
1349   typedef R(UnboundRunType)(X3);
1350
1351   static R Run(BindStateBase* base,
1352       typename CallbackParamTraits<X3>::ForwardType x3) {
1353     StorageType* storage = static_cast<StorageType*>(base);
1354
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;
1360
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));
1372   }
1373 };
1374
1375 // Arity 3 -> 0.
1376 template <typename StorageType, typename R,typename X1, typename X2,
1377     typename X3>
1378 struct Invoker<3, StorageType, R(X1, X2, X3)> {
1379   typedef R(RunType)(BindStateBase*);
1380
1381   typedef R(UnboundRunType)();
1382
1383   static R Run(BindStateBase* base) {
1384     StorageType* storage = static_cast<StorageType*>(base);
1385
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;
1392
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));
1406   }
1407 };
1408
1409 // Arity 4 -> 4.
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);
1418
1419   typedef R(UnboundRunType)(X1, X2, X3, X4);
1420
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);
1427
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.
1431
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));
1441   }
1442 };
1443
1444 // Arity 4 -> 3.
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);
1452
1453   typedef R(UnboundRunType)(X2, X3, X4);
1454
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);
1460
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;
1465
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));
1477   }
1478 };
1479
1480 // Arity 4 -> 2.
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);
1487
1488   typedef R(UnboundRunType)(X3, X4);
1489
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);
1494
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;
1500
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));
1514   }
1515 };
1516
1517 // Arity 4 -> 1.
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);
1523
1524   typedef R(UnboundRunType)(X4);
1525
1526   static R Run(BindStateBase* base,
1527       typename CallbackParamTraits<X4>::ForwardType x4) {
1528     StorageType* storage = static_cast<StorageType*>(base);
1529
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;
1536
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));
1552   }
1553 };
1554
1555 // Arity 4 -> 0.
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*);
1560
1561   typedef R(UnboundRunType)();
1562
1563   static R Run(BindStateBase* base) {
1564     StorageType* storage = static_cast<StorageType*>(base);
1565
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;
1573
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));
1591   }
1592 };
1593
1594 // Arity 5 -> 5.
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);
1604
1605   typedef R(UnboundRunType)(X1, X2, X3, X4, X5);
1606
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);
1614
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.
1618
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));
1629   }
1630 };
1631
1632 // Arity 5 -> 4.
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);
1641
1642   typedef R(UnboundRunType)(X2, X3, X4, X5);
1643
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);
1650
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;
1655
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));
1668   }
1669 };
1670
1671 // Arity 5 -> 3.
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);
1679
1680   typedef R(UnboundRunType)(X3, X4, X5);
1681
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);
1687
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;
1693
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));
1708   }
1709 };
1710
1711 // Arity 5 -> 2.
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);
1718
1719   typedef R(UnboundRunType)(X4, X5);
1720
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);
1725
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;
1732
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));
1749   }
1750 };
1751
1752 // Arity 5 -> 1.
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);
1758
1759   typedef R(UnboundRunType)(X5);
1760
1761   static R Run(BindStateBase* base,
1762       typename CallbackParamTraits<X5>::ForwardType x5) {
1763     StorageType* storage = static_cast<StorageType*>(base);
1764
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;
1772
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));
1791   }
1792 };
1793
1794 // Arity 5 -> 0.
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*);
1799
1800   typedef R(UnboundRunType)();
1801
1802   static R Run(BindStateBase* base) {
1803     StorageType* storage = static_cast<StorageType*>(base);
1804
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;
1813
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));
1834   }
1835 };
1836
1837 // Arity 6 -> 6.
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);
1848
1849   typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6);
1850
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);
1859
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.
1863
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));
1876   }
1877 };
1878
1879 // Arity 6 -> 5.
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);
1889
1890   typedef R(UnboundRunType)(X2, X3, X4, X5, X6);
1891
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);
1899
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;
1904
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));
1919   }
1920 };
1921
1922 // Arity 6 -> 4.
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);
1931
1932   typedef R(UnboundRunType)(X3, X4, X5, X6);
1933
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);
1940
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;
1946
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));
1963   }
1964 };
1965
1966 // Arity 6 -> 3.
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);
1974
1975   typedef R(UnboundRunType)(X4, X5, X6);
1976
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);
1982
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;
1989
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));
2008   }
2009 };
2010
2011 // Arity 6 -> 2.
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);
2018
2019   typedef R(UnboundRunType)(X5, X6);
2020
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);
2025
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;
2033
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));
2054   }
2055 };
2056
2057 // Arity 6 -> 1.
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);
2063
2064   typedef R(UnboundRunType)(X6);
2065
2066   static R Run(BindStateBase* base,
2067       typename CallbackParamTraits<X6>::ForwardType x6) {
2068     StorageType* storage = static_cast<StorageType*>(base);
2069
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;
2078
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));
2101   }
2102 };
2103
2104 // Arity 6 -> 0.
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*);
2109
2110   typedef R(UnboundRunType)();
2111
2112   static R Run(BindStateBase* base) {
2113     StorageType* storage = static_cast<StorageType*>(base);
2114
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;
2124
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));
2149   }
2150 };
2151
2152 // Arity 7 -> 7.
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);
2164
2165   typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7);
2166
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);
2176
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.
2180
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));
2194   }
2195 };
2196
2197 // Arity 7 -> 6.
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);
2208
2209   typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7);
2210
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);
2219
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;
2224
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));
2240   }
2241 };
2242
2243 // Arity 7 -> 5.
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);
2253
2254   typedef R(UnboundRunType)(X3, X4, X5, X6, X7);
2255
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);
2263
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;
2269
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));
2287   }
2288 };
2289
2290 // Arity 7 -> 4.
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);
2299
2300   typedef R(UnboundRunType)(X4, X5, X6, X7);
2301
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);
2308
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;
2315
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));
2335   }
2336 };
2337
2338 // Arity 7 -> 3.
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);
2346
2347   typedef R(UnboundRunType)(X5, X6, X7);
2348
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);
2354
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;
2362
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));
2384   }
2385 };
2386
2387 // Arity 7 -> 2.
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);
2394
2395   typedef R(UnboundRunType)(X6, X7);
2396
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);
2401
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;
2410
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));
2434   }
2435 };
2436
2437 // Arity 7 -> 1.
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);
2443
2444   typedef R(UnboundRunType)(X7);
2445
2446   static R Run(BindStateBase* base,
2447       typename CallbackParamTraits<X7>::ForwardType x7) {
2448     StorageType* storage = static_cast<StorageType*>(base);
2449
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;
2459
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));
2485   }
2486 };
2487
2488 // Arity 7 -> 0.
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*);
2493
2494   typedef R(UnboundRunType)();
2495
2496   static R Run(BindStateBase* base) {
2497     StorageType* storage = static_cast<StorageType*>(base);
2498
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;
2509
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));
2537   }
2538 };
2539
2540
2541 // BindState<>
2542 //
2543 // This stores all the state passed into Bind() and is also where most
2544 // of the template resolution magic occurs.
2545 //
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.
2550 //
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>
2554 struct BindState;
2555
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) {
2564   }
2565
2566   virtual ~BindState() {  }
2567
2568   RunnableType runnable_;
2569 };
2570
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;
2577
2578   // Convenience typedefs for bound argument types.
2579   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2580
2581   BindState(const Runnable& runnable, const P1& p1)
2582       : runnable_(runnable),
2583         p1_(p1) {
2584     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2585   }
2586
2587   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
2588       P1>::Release(p1_);  }
2589
2590   RunnableType runnable_;
2591   P1 p1_;
2592 };
2593
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;
2600
2601   // Convenience typedefs for bound argument types.
2602   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2603   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2604
2605   BindState(const Runnable& runnable, const P1& p1, const P2& p2)
2606       : runnable_(runnable),
2607         p1_(p1),
2608         p2_(p2) {
2609     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2610   }
2611
2612   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
2613       P1>::Release(p1_);  }
2614
2615   RunnableType runnable_;
2616   P1 p1_;
2617   P2 p2_;
2618 };
2619
2620 template <typename Runnable, typename RunType, typename P1, typename P2,
2621     typename P3>
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;
2627
2628   // Convenience typedefs for bound argument types.
2629   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2630   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2631   typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2632
2633   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3)
2634       : runnable_(runnable),
2635         p1_(p1),
2636         p2_(p2),
2637         p3_(p3) {
2638     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2639   }
2640
2641   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
2642       P1>::Release(p1_);  }
2643
2644   RunnableType runnable_;
2645   P1 p1_;
2646   P2 p2_;
2647   P3 p3_;
2648 };
2649
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;
2658
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;
2664
2665   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2666       const P4& p4)
2667       : runnable_(runnable),
2668         p1_(p1),
2669         p2_(p2),
2670         p3_(p3),
2671         p4_(p4) {
2672     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2673   }
2674
2675   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
2676       P1>::Release(p1_);  }
2677
2678   RunnableType runnable_;
2679   P1 p1_;
2680   P2 p2_;
2681   P3 p3_;
2682   P4 p4_;
2683 };
2684
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;
2693
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;
2700
2701   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2702       const P4& p4, const P5& p5)
2703       : runnable_(runnable),
2704         p1_(p1),
2705         p2_(p2),
2706         p3_(p3),
2707         p4_(p4),
2708         p5_(p5) {
2709     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2710   }
2711
2712   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
2713       P1>::Release(p1_);  }
2714
2715   RunnableType runnable_;
2716   P1 p1_;
2717   P2 p2_;
2718   P3 p3_;
2719   P4 p4_;
2720   P5 p5_;
2721 };
2722
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;
2731
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;
2739
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),
2743         p1_(p1),
2744         p2_(p2),
2745         p3_(p3),
2746         p4_(p4),
2747         p5_(p5),
2748         p6_(p6) {
2749     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2750   }
2751
2752   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
2753       P1>::Release(p1_);  }
2754
2755   RunnableType runnable_;
2756   P1 p1_;
2757   P2 p2_;
2758   P3 p3_;
2759   P4 p4_;
2760   P5 p5_;
2761   P6 p6_;
2762 };
2763
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;
2772
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;
2781
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),
2785         p1_(p1),
2786         p2_(p2),
2787         p3_(p3),
2788         p4_(p4),
2789         p5_(p5),
2790         p6_(p6),
2791         p7_(p7) {
2792     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2793   }
2794
2795   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
2796       P1>::Release(p1_);  }
2797
2798   RunnableType runnable_;
2799   P1 p1_;
2800   P2 p2_;
2801   P3 p3_;
2802   P4 p4_;
2803   P5 p5_;
2804   P6 p6_;
2805   P7 p7_;
2806 };
2807
2808 }  // namespace cef_internal
2809 }  // namespace base
2810
2811 #endif  // CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_