blob: ccd7ab2fbb87b9bc53e5d1f2768de703bbeeed61 [file] [log] [blame]
[email protected]b38d3572011-02-15 01:27:381// This file was GENERATED by command:
2// pump.py bind_internal.h.pump
3// DO NOT EDIT BY HAND!!!
4
5
6// Copyright (c) 2011 The Chromium Authors. All rights reserved.
7// Use of this source code is governed by a BSD-style license that can be
8// found in the LICENSE file.
9
10#ifndef BASE_BIND_INTERNAL_H_
11#define BASE_BIND_INTERNAL_H_
12#pragma once
13
14#include "base/bind_helpers.h"
[email protected]59eff912011-02-18 23:29:3115#include "base/callback_internal.h"
[email protected]8217d4542011-10-01 06:31:4116#include "base/memory/raw_scoped_refptr_mismatch_checker.h"
[email protected]93540582011-05-16 22:35:1417#include "base/memory/weak_ptr.h"
[email protected]b38d3572011-02-15 01:27:3818#include "base/template_util.h"
[email protected]054ac7542011-02-27 01:25:5919#include "build/build_config.h"
20
21#if defined(OS_WIN)
22#include "base/bind_internal_win.h"
23#endif
[email protected]b38d3572011-02-15 01:27:3824
25namespace base {
26namespace internal {
27
[email protected]7296f2762011-11-21 19:23:4428// CONCEPTS:
29// Runnable -- A type (really a type class) that has a single Run() method
30// and a RunType typedef that corresponds to the type of Run().
31// A Runnable can declare that it should treated like a method
32// call by including a typedef named IsMethod. The value of
33// this typedef is NOT inspected, only the existence. When a
34// Runnable declares itself a method, Bind() will enforce special
35// refcounting + WeakPtr handling semantics for the first
36// parameter which is expected to be an object.
37// Functor -- A copyable type representing something that should be called.
38// All function pointers, Callback<>, and Runnables are functors
39// even if the invocation syntax differs.
40// RunType -- A function type (as opposed to function _pointer_ type) for
41// a Run() function. Usually just a convenience typedef.
42// (Bound)ArgsType -- A function type that is being (ab)used to store the
43// types of set of arguments. The "return" type is always
44// void here. We use this hack so that we do not need
45// a new type name for each arity of type. (eg.,
46// BindState1, BindState2). This makes forward
47// declarations and friending much much easier.
[email protected]b38d3572011-02-15 01:27:3848//
[email protected]7296f2762011-11-21 19:23:4449// Types:
50// RunnableAdapter<> -- Wraps the various "function" pointer types into an
51// object that adheres to the Runnable interface.
52// There are |3*ARITY| RunnableAdapter types.
53// FunctionTraits<> -- Type traits that unwrap a function signature into a
54// a set of easier to use typedefs. Used mainly for
55// compile time asserts.
56// There are |ARITY| FunctionTraits types.
57// ForceVoidReturn<> -- Helper class for translating function signatures to
58// equivalent forms with a "void" return type.
59// There are |ARITY| ForceVoidReturn types.
60// FunctorTraits<> -- Type traits used determine the correct RunType and
61// RunnableType for a Functor. This is where function
62// signature adapters are applied.
63// There are |ARITY| ForceVoidReturn types.
64// MakeRunnable<> -- Takes a Functor and returns an object in the Runnable
65// type class that represents the underlying Functor.
66// There are |O(1)| MakeRunnable types.
67// InvokeHelper<> -- Take a Runnable + arguments and actully invokes it.
68// Handle the differing syntaxes needed for WeakPtr<> support,
69// and for ignoring return values. This is separate from
70// Invoker to avoid creating multiple version of Invoker<>
71// which grows at O(n^2) with the arity.
72// There are |k*ARITY| InvokeHelper types.
73// Invoker<> -- Unwraps the curried parameters and executes the Runnable.
74// There are |(ARITY^2 + ARITY)/2| Invoketypes.
75// BindState<> -- Stores the curried parameters, and is the main entry point
76// into the Bind() system, doing most of the type resolution.
77// There are ARITY BindState types.
[email protected]4346ef912011-02-19 00:52:1578
[email protected]93540582011-05-16 22:35:1479
[email protected]7296f2762011-11-21 19:23:4480// RunnableAdapter<>
81//
82// The RunnableAdapter<> templates provide a uniform interface for invoking
83// a function pointer, method pointer, or const method pointer. The adapter
84// exposes a Run() method with an appropriate signature. Using this wrapper
85// allows for writing code that supports all three pointer types without
86// undue repetition. Without it, a lot of code would need to be repeated 3
87// times.
88//
89// For method pointers and const method pointers the first argument to Run()
90// is considered to be the received of the method. This is similar to STL's
91// mem_fun().
92//
93// This class also exposes a RunType typedef that is the function type of the
94// Run() function.
95//
96// If and only if the wrapper contains a method or const method pointer, an
97// IsMethod typedef is exposed. The existence of this typedef (NOT the value)
98// marks that the wrapper should be considered a method wrapper.
[email protected]93540582011-05-16 22:35:1499
[email protected]7296f2762011-11-21 19:23:44100template <typename Functor>
101class RunnableAdapter;
[email protected]4346ef912011-02-19 00:52:15102
103// Function: Arity 0.
104template <typename R>
[email protected]7296f2762011-11-21 19:23:44105class RunnableAdapter<R(*)()> {
106 public:
107 typedef R (RunType)();
[email protected]c18b1052011-03-24 02:02:17108
[email protected]7296f2762011-11-21 19:23:44109 explicit RunnableAdapter(R(*function)())
110 : function_(function) {
111 }
[email protected]93540582011-05-16 22:35:14112
[email protected]7296f2762011-11-21 19:23:44113 R Run() {
114 return function_();
115 }
116
117 private:
118 R (*function_)();
[email protected]4346ef912011-02-19 00:52:15119};
120
121// Method: Arity 0.
122template <typename R, typename T>
[email protected]7296f2762011-11-21 19:23:44123class RunnableAdapter<R(T::*)()> {
124 public:
125 typedef R (RunType)(T*);
[email protected]054ac7542011-02-27 01:25:59126 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17127
[email protected]7296f2762011-11-21 19:23:44128 explicit RunnableAdapter(R(T::*method)())
129 : method_(method) {
130 }
[email protected]93540582011-05-16 22:35:14131
[email protected]7296f2762011-11-21 19:23:44132 R Run(T* object) {
133 return (object->*method_)();
134 }
[email protected]c18b1052011-03-24 02:02:17135
[email protected]7296f2762011-11-21 19:23:44136 private:
137 R (T::*method_)();
[email protected]4346ef912011-02-19 00:52:15138};
139
140// Const Method: Arity 0.
141template <typename R, typename T>
[email protected]7296f2762011-11-21 19:23:44142class RunnableAdapter<R(T::*)() const> {
143 public:
144 typedef R (RunType)(const T*);
[email protected]054ac7542011-02-27 01:25:59145 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17146
[email protected]7296f2762011-11-21 19:23:44147 explicit RunnableAdapter(R(T::*method)() const)
148 : method_(method) {
149 }
[email protected]93540582011-05-16 22:35:14150
[email protected]7296f2762011-11-21 19:23:44151 R Run(const T* object) {
152 return (object->*method_)();
153 }
[email protected]c18b1052011-03-24 02:02:17154
[email protected]7296f2762011-11-21 19:23:44155 private:
156 R (T::*method_)() const;
[email protected]4346ef912011-02-19 00:52:15157};
158
159// Function: Arity 1.
[email protected]7296f2762011-11-21 19:23:44160template <typename R, typename A1>
161class RunnableAdapter<R(*)(A1)> {
162 public:
163 typedef R (RunType)(A1);
[email protected]93540582011-05-16 22:35:14164
[email protected]7296f2762011-11-21 19:23:44165 explicit RunnableAdapter(R(*function)(A1))
166 : function_(function) {
167 }
[email protected]93540582011-05-16 22:35:14168
[email protected]7296f2762011-11-21 19:23:44169 R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
170 return function_(a1);
171 }
[email protected]c18b1052011-03-24 02:02:17172
[email protected]7296f2762011-11-21 19:23:44173 private:
174 R (*function_)(A1);
[email protected]4346ef912011-02-19 00:52:15175};
176
177// Method: Arity 1.
[email protected]7296f2762011-11-21 19:23:44178template <typename R, typename T, typename A1>
179class RunnableAdapter<R(T::*)(A1)> {
180 public:
181 typedef R (RunType)(T*, A1);
[email protected]054ac7542011-02-27 01:25:59182 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17183
[email protected]7296f2762011-11-21 19:23:44184 explicit RunnableAdapter(R(T::*method)(A1))
185 : method_(method) {
186 }
[email protected]93540582011-05-16 22:35:14187
[email protected]7296f2762011-11-21 19:23:44188 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
189 return (object->*method_)(a1);
190 }
[email protected]c18b1052011-03-24 02:02:17191
[email protected]7296f2762011-11-21 19:23:44192 private:
193 R (T::*method_)(A1);
[email protected]4346ef912011-02-19 00:52:15194};
195
196// Const Method: Arity 1.
[email protected]7296f2762011-11-21 19:23:44197template <typename R, typename T, typename A1>
198class RunnableAdapter<R(T::*)(A1) const> {
199 public:
200 typedef R (RunType)(const T*, A1);
[email protected]054ac7542011-02-27 01:25:59201 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17202
[email protected]7296f2762011-11-21 19:23:44203 explicit RunnableAdapter(R(T::*method)(A1) const)
204 : method_(method) {
205 }
[email protected]93540582011-05-16 22:35:14206
[email protected]7296f2762011-11-21 19:23:44207 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
208 return (object->*method_)(a1);
209 }
[email protected]c18b1052011-03-24 02:02:17210
[email protected]7296f2762011-11-21 19:23:44211 private:
212 R (T::*method_)(A1) const;
[email protected]4346ef912011-02-19 00:52:15213};
214
215// Function: Arity 2.
[email protected]7296f2762011-11-21 19:23:44216template <typename R, typename A1, typename A2>
217class RunnableAdapter<R(*)(A1, A2)> {
218 public:
219 typedef R (RunType)(A1, A2);
[email protected]93540582011-05-16 22:35:14220
[email protected]7296f2762011-11-21 19:23:44221 explicit RunnableAdapter(R(*function)(A1, A2))
222 : function_(function) {
223 }
[email protected]93540582011-05-16 22:35:14224
[email protected]7296f2762011-11-21 19:23:44225 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
226 typename CallbackParamTraits<A2>::ForwardType a2) {
227 return function_(a1, a2);
228 }
[email protected]c18b1052011-03-24 02:02:17229
[email protected]7296f2762011-11-21 19:23:44230 private:
231 R (*function_)(A1, A2);
[email protected]4346ef912011-02-19 00:52:15232};
233
234// Method: Arity 2.
[email protected]7296f2762011-11-21 19:23:44235template <typename R, typename T, typename A1, typename A2>
236class RunnableAdapter<R(T::*)(A1, A2)> {
237 public:
238 typedef R (RunType)(T*, A1, A2);
[email protected]054ac7542011-02-27 01:25:59239 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17240
[email protected]7296f2762011-11-21 19:23:44241 explicit RunnableAdapter(R(T::*method)(A1, A2))
242 : method_(method) {
243 }
[email protected]93540582011-05-16 22:35:14244
[email protected]7296f2762011-11-21 19:23:44245 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
246 typename CallbackParamTraits<A2>::ForwardType a2) {
247 return (object->*method_)(a1, a2);
248 }
[email protected]c18b1052011-03-24 02:02:17249
[email protected]7296f2762011-11-21 19:23:44250 private:
251 R (T::*method_)(A1, A2);
[email protected]4346ef912011-02-19 00:52:15252};
253
254// Const Method: Arity 2.
[email protected]7296f2762011-11-21 19:23:44255template <typename R, typename T, typename A1, typename A2>
256class RunnableAdapter<R(T::*)(A1, A2) const> {
257 public:
258 typedef R (RunType)(const T*, A1, A2);
[email protected]054ac7542011-02-27 01:25:59259 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17260
[email protected]7296f2762011-11-21 19:23:44261 explicit RunnableAdapter(R(T::*method)(A1, A2) const)
262 : method_(method) {
263 }
[email protected]93540582011-05-16 22:35:14264
[email protected]7296f2762011-11-21 19:23:44265 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
266 typename CallbackParamTraits<A2>::ForwardType a2) {
267 return (object->*method_)(a1, a2);
268 }
[email protected]c18b1052011-03-24 02:02:17269
[email protected]7296f2762011-11-21 19:23:44270 private:
271 R (T::*method_)(A1, A2) const;
[email protected]4346ef912011-02-19 00:52:15272};
273
274// Function: Arity 3.
[email protected]7296f2762011-11-21 19:23:44275template <typename R, typename A1, typename A2, typename A3>
276class RunnableAdapter<R(*)(A1, A2, A3)> {
277 public:
278 typedef R (RunType)(A1, A2, A3);
[email protected]93540582011-05-16 22:35:14279
[email protected]7296f2762011-11-21 19:23:44280 explicit RunnableAdapter(R(*function)(A1, A2, A3))
281 : function_(function) {
282 }
[email protected]93540582011-05-16 22:35:14283
[email protected]7296f2762011-11-21 19:23:44284 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
285 typename CallbackParamTraits<A2>::ForwardType a2,
286 typename CallbackParamTraits<A3>::ForwardType a3) {
287 return function_(a1, a2, a3);
288 }
[email protected]c18b1052011-03-24 02:02:17289
[email protected]7296f2762011-11-21 19:23:44290 private:
291 R (*function_)(A1, A2, A3);
[email protected]4346ef912011-02-19 00:52:15292};
293
294// Method: Arity 3.
[email protected]7296f2762011-11-21 19:23:44295template <typename R, typename T, typename A1, typename A2, typename A3>
296class RunnableAdapter<R(T::*)(A1, A2, A3)> {
297 public:
298 typedef R (RunType)(T*, A1, A2, A3);
[email protected]054ac7542011-02-27 01:25:59299 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17300
[email protected]7296f2762011-11-21 19:23:44301 explicit RunnableAdapter(R(T::*method)(A1, A2, A3))
302 : method_(method) {
303 }
[email protected]93540582011-05-16 22:35:14304
[email protected]7296f2762011-11-21 19:23:44305 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
306 typename CallbackParamTraits<A2>::ForwardType a2,
307 typename CallbackParamTraits<A3>::ForwardType a3) {
308 return (object->*method_)(a1, a2, a3);
309 }
[email protected]c18b1052011-03-24 02:02:17310
[email protected]7296f2762011-11-21 19:23:44311 private:
312 R (T::*method_)(A1, A2, A3);
[email protected]4346ef912011-02-19 00:52:15313};
314
315// Const Method: Arity 3.
[email protected]7296f2762011-11-21 19:23:44316template <typename R, typename T, typename A1, typename A2, typename A3>
317class RunnableAdapter<R(T::*)(A1, A2, A3) const> {
318 public:
319 typedef R (RunType)(const T*, A1, A2, A3);
[email protected]054ac7542011-02-27 01:25:59320 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17321
[email protected]7296f2762011-11-21 19:23:44322 explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const)
323 : method_(method) {
324 }
[email protected]93540582011-05-16 22:35:14325
[email protected]7296f2762011-11-21 19:23:44326 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
327 typename CallbackParamTraits<A2>::ForwardType a2,
328 typename CallbackParamTraits<A3>::ForwardType a3) {
329 return (object->*method_)(a1, a2, a3);
330 }
[email protected]c18b1052011-03-24 02:02:17331
[email protected]7296f2762011-11-21 19:23:44332 private:
333 R (T::*method_)(A1, A2, A3) const;
[email protected]4346ef912011-02-19 00:52:15334};
335
336// Function: Arity 4.
[email protected]7296f2762011-11-21 19:23:44337template <typename R, typename A1, typename A2, typename A3, typename A4>
338class RunnableAdapter<R(*)(A1, A2, A3, A4)> {
339 public:
340 typedef R (RunType)(A1, A2, A3, A4);
[email protected]93540582011-05-16 22:35:14341
[email protected]7296f2762011-11-21 19:23:44342 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4))
343 : function_(function) {
344 }
[email protected]93540582011-05-16 22:35:14345
[email protected]7296f2762011-11-21 19:23:44346 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
347 typename CallbackParamTraits<A2>::ForwardType a2,
348 typename CallbackParamTraits<A3>::ForwardType a3,
349 typename CallbackParamTraits<A4>::ForwardType a4) {
350 return function_(a1, a2, a3, a4);
351 }
[email protected]c18b1052011-03-24 02:02:17352
[email protected]7296f2762011-11-21 19:23:44353 private:
354 R (*function_)(A1, A2, A3, A4);
[email protected]4346ef912011-02-19 00:52:15355};
356
357// Method: Arity 4.
[email protected]7296f2762011-11-21 19:23:44358template <typename R, typename T, typename A1, typename A2, typename A3,
359 typename A4>
360class RunnableAdapter<R(T::*)(A1, A2, A3, A4)> {
361 public:
362 typedef R (RunType)(T*, A1, A2, A3, A4);
[email protected]054ac7542011-02-27 01:25:59363 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17364
[email protected]7296f2762011-11-21 19:23:44365 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4))
366 : method_(method) {
367 }
[email protected]93540582011-05-16 22:35:14368
[email protected]7296f2762011-11-21 19:23:44369 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
370 typename CallbackParamTraits<A2>::ForwardType a2,
371 typename CallbackParamTraits<A3>::ForwardType a3,
372 typename CallbackParamTraits<A4>::ForwardType a4) {
373 return (object->*method_)(a1, a2, a3, a4);
374 }
[email protected]c18b1052011-03-24 02:02:17375
[email protected]7296f2762011-11-21 19:23:44376 private:
377 R (T::*method_)(A1, A2, A3, A4);
[email protected]4346ef912011-02-19 00:52:15378};
379
380// Const Method: Arity 4.
[email protected]7296f2762011-11-21 19:23:44381template <typename R, typename T, typename A1, typename A2, typename A3,
382 typename A4>
383class RunnableAdapter<R(T::*)(A1, A2, A3, A4) const> {
384 public:
385 typedef R (RunType)(const T*, A1, A2, A3, A4);
[email protected]054ac7542011-02-27 01:25:59386 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17387
[email protected]7296f2762011-11-21 19:23:44388 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const)
389 : method_(method) {
390 }
[email protected]93540582011-05-16 22:35:14391
[email protected]7296f2762011-11-21 19:23:44392 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
393 typename CallbackParamTraits<A2>::ForwardType a2,
394 typename CallbackParamTraits<A3>::ForwardType a3,
395 typename CallbackParamTraits<A4>::ForwardType a4) {
396 return (object->*method_)(a1, a2, a3, a4);
397 }
[email protected]c18b1052011-03-24 02:02:17398
[email protected]7296f2762011-11-21 19:23:44399 private:
400 R (T::*method_)(A1, A2, A3, A4) const;
[email protected]4346ef912011-02-19 00:52:15401};
402
403// Function: Arity 5.
[email protected]7296f2762011-11-21 19:23:44404template <typename R, typename A1, typename A2, typename A3, typename A4,
405 typename A5>
406class RunnableAdapter<R(*)(A1, A2, A3, A4, A5)> {
407 public:
408 typedef R (RunType)(A1, A2, A3, A4, A5);
[email protected]93540582011-05-16 22:35:14409
[email protected]7296f2762011-11-21 19:23:44410 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5))
411 : function_(function) {
412 }
[email protected]93540582011-05-16 22:35:14413
[email protected]7296f2762011-11-21 19:23:44414 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
415 typename CallbackParamTraits<A2>::ForwardType a2,
416 typename CallbackParamTraits<A3>::ForwardType a3,
417 typename CallbackParamTraits<A4>::ForwardType a4,
418 typename CallbackParamTraits<A5>::ForwardType a5) {
419 return function_(a1, a2, a3, a4, a5);
420 }
[email protected]c18b1052011-03-24 02:02:17421
[email protected]7296f2762011-11-21 19:23:44422 private:
423 R (*function_)(A1, A2, A3, A4, A5);
[email protected]4346ef912011-02-19 00:52:15424};
425
426// Method: Arity 5.
[email protected]7296f2762011-11-21 19:23:44427template <typename R, typename T, typename A1, typename A2, typename A3,
428 typename A4, typename A5>
429class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5)> {
430 public:
431 typedef R (RunType)(T*, A1, A2, A3, A4, A5);
[email protected]054ac7542011-02-27 01:25:59432 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17433
[email protected]7296f2762011-11-21 19:23:44434 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5))
435 : method_(method) {
436 }
[email protected]93540582011-05-16 22:35:14437
[email protected]7296f2762011-11-21 19:23:44438 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
439 typename CallbackParamTraits<A2>::ForwardType a2,
440 typename CallbackParamTraits<A3>::ForwardType a3,
441 typename CallbackParamTraits<A4>::ForwardType a4,
442 typename CallbackParamTraits<A5>::ForwardType a5) {
443 return (object->*method_)(a1, a2, a3, a4, a5);
444 }
[email protected]c18b1052011-03-24 02:02:17445
[email protected]7296f2762011-11-21 19:23:44446 private:
447 R (T::*method_)(A1, A2, A3, A4, A5);
[email protected]4346ef912011-02-19 00:52:15448};
449
450// Const Method: Arity 5.
[email protected]7296f2762011-11-21 19:23:44451template <typename R, typename T, typename A1, typename A2, typename A3,
452 typename A4, typename A5>
453class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5) const> {
454 public:
455 typedef R (RunType)(const T*, A1, A2, A3, A4, A5);
[email protected]054ac7542011-02-27 01:25:59456 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17457
[email protected]7296f2762011-11-21 19:23:44458 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const)
459 : method_(method) {
460 }
[email protected]93540582011-05-16 22:35:14461
[email protected]7296f2762011-11-21 19:23:44462 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
463 typename CallbackParamTraits<A2>::ForwardType a2,
464 typename CallbackParamTraits<A3>::ForwardType a3,
465 typename CallbackParamTraits<A4>::ForwardType a4,
466 typename CallbackParamTraits<A5>::ForwardType a5) {
467 return (object->*method_)(a1, a2, a3, a4, a5);
468 }
[email protected]c18b1052011-03-24 02:02:17469
[email protected]7296f2762011-11-21 19:23:44470 private:
471 R (T::*method_)(A1, A2, A3, A4, A5) const;
[email protected]4346ef912011-02-19 00:52:15472};
473
474// Function: Arity 6.
[email protected]7296f2762011-11-21 19:23:44475template <typename R, typename A1, typename A2, typename A3, typename A4,
476 typename A5, typename A6>
477class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6)> {
478 public:
479 typedef R (RunType)(A1, A2, A3, A4, A5, A6);
[email protected]93540582011-05-16 22:35:14480
[email protected]7296f2762011-11-21 19:23:44481 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6))
482 : function_(function) {
483 }
[email protected]93540582011-05-16 22:35:14484
[email protected]7296f2762011-11-21 19:23:44485 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
486 typename CallbackParamTraits<A2>::ForwardType a2,
487 typename CallbackParamTraits<A3>::ForwardType a3,
488 typename CallbackParamTraits<A4>::ForwardType a4,
489 typename CallbackParamTraits<A5>::ForwardType a5,
490 typename CallbackParamTraits<A6>::ForwardType a6) {
491 return function_(a1, a2, a3, a4, a5, a6);
492 }
[email protected]c18b1052011-03-24 02:02:17493
[email protected]7296f2762011-11-21 19:23:44494 private:
495 R (*function_)(A1, A2, A3, A4, A5, A6);
[email protected]4346ef912011-02-19 00:52:15496};
497
498// Method: Arity 6.
[email protected]7296f2762011-11-21 19:23:44499template <typename R, typename T, typename A1, typename A2, typename A3,
500 typename A4, typename A5, typename A6>
501class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6)> {
502 public:
503 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6);
[email protected]054ac7542011-02-27 01:25:59504 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17505
[email protected]7296f2762011-11-21 19:23:44506 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6))
507 : method_(method) {
508 }
[email protected]93540582011-05-16 22:35:14509
[email protected]7296f2762011-11-21 19:23:44510 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
511 typename CallbackParamTraits<A2>::ForwardType a2,
512 typename CallbackParamTraits<A3>::ForwardType a3,
513 typename CallbackParamTraits<A4>::ForwardType a4,
514 typename CallbackParamTraits<A5>::ForwardType a5,
515 typename CallbackParamTraits<A6>::ForwardType a6) {
516 return (object->*method_)(a1, a2, a3, a4, a5, a6);
517 }
[email protected]c18b1052011-03-24 02:02:17518
[email protected]7296f2762011-11-21 19:23:44519 private:
520 R (T::*method_)(A1, A2, A3, A4, A5, A6);
[email protected]4346ef912011-02-19 00:52:15521};
522
523// Const Method: Arity 6.
[email protected]7296f2762011-11-21 19:23:44524template <typename R, typename T, typename A1, typename A2, typename A3,
525 typename A4, typename A5, typename A6>
526class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6) const> {
527 public:
528 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6);
[email protected]054ac7542011-02-27 01:25:59529 typedef true_type IsMethod;
[email protected]c18b1052011-03-24 02:02:17530
[email protected]7296f2762011-11-21 19:23:44531 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const)
532 : method_(method) {
533 }
[email protected]93540582011-05-16 22:35:14534
[email protected]7296f2762011-11-21 19:23:44535 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
536 typename CallbackParamTraits<A2>::ForwardType a2,
537 typename CallbackParamTraits<A3>::ForwardType a3,
538 typename CallbackParamTraits<A4>::ForwardType a4,
539 typename CallbackParamTraits<A5>::ForwardType a5,
540 typename CallbackParamTraits<A6>::ForwardType a6) {
541 return (object->*method_)(a1, a2, a3, a4, a5, a6);
542 }
[email protected]c18b1052011-03-24 02:02:17543
[email protected]7296f2762011-11-21 19:23:44544 private:
545 R (T::*method_)(A1, A2, A3, A4, A5, A6) const;
[email protected]4346ef912011-02-19 00:52:15546};
547
[email protected]fccef1552011-11-28 22:13:54548// Function: Arity 7.
549template <typename R, typename A1, typename A2, typename A3, typename A4,
550 typename A5, typename A6, typename A7>
551class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6, A7)> {
552 public:
553 typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
554
555 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7))
556 : function_(function) {
557 }
558
559 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
560 typename CallbackParamTraits<A2>::ForwardType a2,
561 typename CallbackParamTraits<A3>::ForwardType a3,
562 typename CallbackParamTraits<A4>::ForwardType a4,
563 typename CallbackParamTraits<A5>::ForwardType a5,
564 typename CallbackParamTraits<A6>::ForwardType a6,
565 typename CallbackParamTraits<A7>::ForwardType a7) {
566 return function_(a1, a2, a3, a4, a5, a6, a7);
567 }
568
569 private:
570 R (*function_)(A1, A2, A3, A4, A5, A6, A7);
571};
572
573// Method: Arity 7.
574template <typename R, typename T, typename A1, typename A2, typename A3,
575 typename A4, typename A5, typename A6, typename A7>
576class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7)> {
577 public:
578 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7);
579 typedef true_type IsMethod;
580
581 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7))
582 : method_(method) {
583 }
584
585 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
586 typename CallbackParamTraits<A2>::ForwardType a2,
587 typename CallbackParamTraits<A3>::ForwardType a3,
588 typename CallbackParamTraits<A4>::ForwardType a4,
589 typename CallbackParamTraits<A5>::ForwardType a5,
590 typename CallbackParamTraits<A6>::ForwardType a6,
591 typename CallbackParamTraits<A7>::ForwardType a7) {
592 return (object->*method_)(a1, a2, a3, a4, a5, a6, a7);
593 }
594
595 private:
596 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7);
597};
598
599// Const Method: Arity 7.
600template <typename R, typename T, typename A1, typename A2, typename A3,
601 typename A4, typename A5, typename A6, typename A7>
602class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7) const> {
603 public:
604 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7);
605 typedef true_type IsMethod;
606
607 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const)
608 : method_(method) {
609 }
610
611 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
612 typename CallbackParamTraits<A2>::ForwardType a2,
613 typename CallbackParamTraits<A3>::ForwardType a3,
614 typename CallbackParamTraits<A4>::ForwardType a4,
615 typename CallbackParamTraits<A5>::ForwardType a5,
616 typename CallbackParamTraits<A6>::ForwardType a6,
617 typename CallbackParamTraits<A7>::ForwardType a7) {
618 return (object->*method_)(a1, a2, a3, a4, a5, a6, a7);
619 }
620
621 private:
622 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const;
623};
624
[email protected]7296f2762011-11-21 19:23:44625
626// FunctionTraits<>
[email protected]4346ef912011-02-19 00:52:15627//
[email protected]7296f2762011-11-21 19:23:44628// Breaks a function signature apart into typedefs for easier introspection.
[email protected]b38d3572011-02-15 01:27:38629template <typename Sig>
[email protected]7296f2762011-11-21 19:23:44630struct FunctionTraits;
[email protected]b38d3572011-02-15 01:27:38631
[email protected]7296f2762011-11-21 19:23:44632template <typename R>
633struct FunctionTraits<R()> {
634 typedef R ReturnType;
[email protected]b38d3572011-02-15 01:27:38635};
636
[email protected]7296f2762011-11-21 19:23:44637template <typename R, typename A1>
638struct FunctionTraits<R(A1)> {
639 typedef R ReturnType;
640 typedef A1 A1Type;
[email protected]b38d3572011-02-15 01:27:38641};
642
[email protected]7296f2762011-11-21 19:23:44643template <typename R, typename A1, typename A2>
644struct FunctionTraits<R(A1, A2)> {
645 typedef R ReturnType;
646 typedef A1 A1Type;
647 typedef A2 A2Type;
[email protected]b38d3572011-02-15 01:27:38648};
649
[email protected]7296f2762011-11-21 19:23:44650template <typename R, typename A1, typename A2, typename A3>
651struct FunctionTraits<R(A1, A2, A3)> {
652 typedef R ReturnType;
653 typedef A1 A1Type;
654 typedef A2 A2Type;
655 typedef A3 A3Type;
[email protected]b38d3572011-02-15 01:27:38656};
657
[email protected]7296f2762011-11-21 19:23:44658template <typename R, typename A1, typename A2, typename A3, typename A4>
659struct FunctionTraits<R(A1, A2, A3, A4)> {
660 typedef R ReturnType;
661 typedef A1 A1Type;
662 typedef A2 A2Type;
663 typedef A3 A3Type;
664 typedef A4 A4Type;
[email protected]b38d3572011-02-15 01:27:38665};
666
[email protected]7296f2762011-11-21 19:23:44667template <typename R, typename A1, typename A2, typename A3, typename A4,
668 typename A5>
669struct FunctionTraits<R(A1, A2, A3, A4, A5)> {
670 typedef R ReturnType;
671 typedef A1 A1Type;
672 typedef A2 A2Type;
673 typedef A3 A3Type;
674 typedef A4 A4Type;
675 typedef A5 A5Type;
676};
677
678template <typename R, typename A1, typename A2, typename A3, typename A4,
679 typename A5, typename A6>
680struct FunctionTraits<R(A1, A2, A3, A4, A5, A6)> {
681 typedef R ReturnType;
682 typedef A1 A1Type;
683 typedef A2 A2Type;
684 typedef A3 A3Type;
685 typedef A4 A4Type;
686 typedef A5 A5Type;
687 typedef A6 A6Type;
688};
689
[email protected]fccef1552011-11-28 22:13:54690template <typename R, typename A1, typename A2, typename A3, typename A4,
691 typename A5, typename A6, typename A7>
692struct FunctionTraits<R(A1, A2, A3, A4, A5, A6, A7)> {
693 typedef R ReturnType;
694 typedef A1 A1Type;
695 typedef A2 A2Type;
696 typedef A3 A3Type;
697 typedef A4 A4Type;
698 typedef A5 A5Type;
699 typedef A6 A6Type;
700 typedef A7 A7Type;
701};
702
[email protected]7296f2762011-11-21 19:23:44703
704// ForceVoidReturn<>
705//
706// Set of templates that support forcing the function return type to void.
707template <typename Sig>
708struct ForceVoidReturn;
709
710template <typename R>
711struct ForceVoidReturn<R()> {
712 typedef void(RunType)();
713};
714
715template <typename R, typename A1>
716struct ForceVoidReturn<R(A1)> {
717 typedef void(RunType)(A1);
718};
719
720template <typename R, typename A1, typename A2>
721struct ForceVoidReturn<R(A1, A2)> {
722 typedef void(RunType)(A1, A2);
723};
724
725template <typename R, typename A1, typename A2, typename A3>
726struct ForceVoidReturn<R(A1, A2, A3)> {
727 typedef void(RunType)(A1, A2, A3);
728};
729
730template <typename R, typename A1, typename A2, typename A3, typename A4>
731struct ForceVoidReturn<R(A1, A2, A3, A4)> {
732 typedef void(RunType)(A1, A2, A3, A4);
733};
734
735template <typename R, typename A1, typename A2, typename A3, typename A4,
736 typename A5>
737struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> {
738 typedef void(RunType)(A1, A2, A3, A4, A5);
739};
740
741template <typename R, typename A1, typename A2, typename A3, typename A4,
742 typename A5, typename A6>
743struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> {
744 typedef void(RunType)(A1, A2, A3, A4, A5, A6);
745};
746
[email protected]fccef1552011-11-28 22:13:54747template <typename R, typename A1, typename A2, typename A3, typename A4,
748 typename A5, typename A6, typename A7>
749struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6, A7)> {
750 typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7);
751};
752
[email protected]7296f2762011-11-21 19:23:44753
754// FunctorTraits<>
755//
756// See description at top of file.
757template <typename T>
758struct FunctorTraits {
759 typedef RunnableAdapter<T> RunnableType;
760 typedef typename RunnableType::RunType RunType;
761};
762
763template <typename T>
764struct FunctorTraits<IgnoreResultHelper<T> > {
765 typedef typename FunctorTraits<T>::RunnableType RunnableType;
766 typedef typename ForceVoidReturn<
767 typename RunnableType::RunType>::RunType RunType;
768};
769
770template <typename T>
771struct FunctorTraits<Callback<T> > {
772 typedef Callback<T> RunnableType;
773 typedef typename Callback<T>::RunType RunType;
774};
775
776
777// MakeRunnable<>
778//
779// Converts a passed in functor to a RunnableType using type inference.
780
781template <typename T>
782typename FunctorTraits<T>::RunnableType MakeRunnable(const T& t) {
783 return RunnableAdapter<T>(t);
784}
785
786template <typename T>
787typename FunctorTraits<T>::RunnableType
788MakeRunnable(const IgnoreResultHelper<T>& t) {
789 return MakeRunnable(t.functor_);
790}
791
792template <typename T>
793const typename FunctorTraits<Callback<T> >::RunnableType&
794MakeRunnable(const Callback<T>& t) {
795 return t;
796}
797
798
799// InvokeHelper<>
800//
801// There are 3 logical InvokeHelper<> specializations: normal, void-return,
802// WeakCalls.
803//
804// The normal type just calls the underlying runnable.
805//
806// We need a InvokeHelper to handle void return types in order to support
807// IgnoreResult(). Normally, if the Runnable's RunType had a void return,
808// the template system would just accept "return functor.Run()" ignoring
809// the fact that a void function is being used with return. This piece of
810// sugar breaks though when the Runnable's RunType is not void. Thus, we
811// need a partial specialization to change the syntax to drop the "return"
812// from the invocation call.
813//
814// WeakCalls similarly need special syntax that is applied to the first
815// argument to check if they should no-op themselves.
816template <bool IsWeakCall, typename ReturnType, typename Runnable,
817 typename ArgsType>
818struct InvokeHelper;
819
820template <typename ReturnType, typename Runnable>
821struct InvokeHelper<false, ReturnType, Runnable,
822 void()> {
823 static ReturnType MakeItSo(Runnable runnable) {
824 return runnable.Run();
825 }
826};
827
828template <typename Runnable>
829struct InvokeHelper<false, void, Runnable,
830 void()> {
831 static void MakeItSo(Runnable runnable) {
832 runnable.Run();
833 }
834};
835
836template <typename ReturnType, typename Runnable,typename A1>
837struct InvokeHelper<false, ReturnType, Runnable,
838 void(A1)> {
839 static ReturnType MakeItSo(Runnable runnable, A1 a1) {
840 return runnable.Run(a1);
841 }
842};
843
844template <typename Runnable,typename A1>
845struct InvokeHelper<false, void, Runnable,
846 void(A1)> {
847 static void MakeItSo(Runnable runnable, A1 a1) {
848 runnable.Run(a1);
849 }
850};
851
852template <typename Runnable, typename A1>
853struct InvokeHelper<true, void, Runnable,
854 void(A1)> {
855 static void MakeItSo(Runnable runnable, A1 a1) {
856 if (!a1.get()) {
857 return;
858 }
859
860 runnable.Run(a1);
861 }
862};
863
864template <typename ReturnType, typename Runnable,typename A1, typename A2>
865struct InvokeHelper<false, ReturnType, Runnable,
866 void(A1, A2)> {
867 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) {
868 return runnable.Run(a1, a2);
869 }
870};
871
872template <typename Runnable,typename A1, typename A2>
873struct InvokeHelper<false, void, Runnable,
874 void(A1, A2)> {
875 static void MakeItSo(Runnable runnable, A1 a1, A2 a2) {
876 runnable.Run(a1, a2);
877 }
878};
879
880template <typename Runnable, typename A1, typename A2>
881struct InvokeHelper<true, void, Runnable,
882 void(A1, A2)> {
883 static void MakeItSo(Runnable runnable, A1 a1, A2 a2) {
884 if (!a1.get()) {
885 return;
886 }
887
888 runnable.Run(a1, a2);
889 }
890};
891
892template <typename ReturnType, typename Runnable,typename A1, typename A2,
893 typename A3>
894struct InvokeHelper<false, ReturnType, Runnable,
895 void(A1, A2, A3)> {
896 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
897 return runnable.Run(a1, a2, a3);
898 }
899};
900
901template <typename Runnable,typename A1, typename A2, typename A3>
902struct InvokeHelper<false, void, Runnable,
903 void(A1, A2, A3)> {
904 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
905 runnable.Run(a1, a2, a3);
906 }
907};
908
909template <typename Runnable, typename A1, typename A2, typename A3>
910struct InvokeHelper<true, void, Runnable,
911 void(A1, A2, A3)> {
912 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
913 if (!a1.get()) {
914 return;
915 }
916
917 runnable.Run(a1, a2, a3);
918 }
919};
920
921template <typename ReturnType, typename Runnable,typename A1, typename A2,
922 typename A3, typename A4>
923struct InvokeHelper<false, ReturnType, Runnable,
924 void(A1, A2, A3, A4)> {
925 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
926 return runnable.Run(a1, a2, a3, a4);
927 }
928};
929
930template <typename Runnable,typename A1, typename A2, typename A3, typename A4>
931struct InvokeHelper<false, void, Runnable,
932 void(A1, A2, A3, A4)> {
933 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
934 runnable.Run(a1, a2, a3, a4);
935 }
936};
937
938template <typename Runnable, typename A1, typename A2, typename A3, typename A4>
939struct InvokeHelper<true, void, Runnable,
940 void(A1, A2, A3, A4)> {
941 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
942 if (!a1.get()) {
943 return;
944 }
945
946 runnable.Run(a1, a2, a3, a4);
947 }
948};
949
950template <typename ReturnType, typename Runnable,typename A1, typename A2,
951 typename A3, typename A4, typename A5>
952struct InvokeHelper<false, ReturnType, Runnable,
953 void(A1, A2, A3, A4, A5)> {
954 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
955 A5 a5) {
956 return runnable.Run(a1, a2, a3, a4, a5);
957 }
958};
959
960template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
961 typename A5>
962struct InvokeHelper<false, void, Runnable,
963 void(A1, A2, A3, A4, A5)> {
964 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
965 runnable.Run(a1, a2, a3, a4, a5);
966 }
967};
968
969template <typename Runnable, typename A1, typename A2, typename A3,
970 typename A4, typename A5>
971struct InvokeHelper<true, void, Runnable,
972 void(A1, A2, A3, A4, A5)> {
973 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
974 if (!a1.get()) {
975 return;
976 }
977
978 runnable.Run(a1, a2, a3, a4, a5);
979 }
980};
981
982template <typename ReturnType, typename Runnable,typename A1, typename A2,
983 typename A3, typename A4, typename A5, typename A6>
984struct InvokeHelper<false, ReturnType, Runnable,
985 void(A1, A2, A3, A4, A5, A6)> {
986 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
987 A5 a5, A6 a6) {
988 return runnable.Run(a1, a2, a3, a4, a5, a6);
989 }
990};
991
992template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
993 typename A5, typename A6>
994struct InvokeHelper<false, void, Runnable,
995 void(A1, A2, A3, A4, A5, A6)> {
996 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
997 A6 a6) {
998 runnable.Run(a1, a2, a3, a4, a5, a6);
999 }
1000};
1001
1002template <typename Runnable, typename A1, typename A2, typename A3,
1003 typename A4, typename A5, typename A6>
1004struct InvokeHelper<true, void, Runnable,
1005 void(A1, A2, A3, A4, A5, A6)> {
1006 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
1007 A6 a6) {
1008 if (!a1.get()) {
1009 return;
1010 }
1011
1012 runnable.Run(a1, a2, a3, a4, a5, a6);
1013 }
1014};
1015
[email protected]fccef1552011-11-28 22:13:541016template <typename ReturnType, typename Runnable,typename A1, typename A2,
1017 typename A3, typename A4, typename A5, typename A6, typename A7>
1018struct InvokeHelper<false, ReturnType, Runnable,
1019 void(A1, A2, A3, A4, A5, A6, A7)> {
1020 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
1021 A5 a5, A6 a6, A7 a7) {
1022 return runnable.Run(a1, a2, a3, a4, a5, a6, a7);
1023 }
1024};
1025
1026template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
1027 typename A5, typename A6, typename A7>
1028struct InvokeHelper<false, void, Runnable,
1029 void(A1, A2, A3, A4, A5, A6, A7)> {
1030 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
1031 A6 a6, A7 a7) {
1032 runnable.Run(a1, a2, a3, a4, a5, a6, a7);
1033 }
1034};
1035
1036template <typename Runnable, typename A1, typename A2, typename A3,
1037 typename A4, typename A5, typename A6, typename A7>
1038struct InvokeHelper<true, void, Runnable,
1039 void(A1, A2, A3, A4, A5, A6, A7)> {
1040 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
1041 A6 a6, A7 a7) {
1042 if (!a1.get()) {
1043 return;
1044 }
1045
1046 runnable.Run(a1, a2, a3, a4, a5, a6, a7);
1047 }
1048};
1049
[email protected]7296f2762011-11-21 19:23:441050#if !defined(_MSC_VER)
1051
1052template <typename ReturnType, typename Runnable, typename ArgsType>
1053struct InvokeHelper<true, ReturnType, Runnable, ArgsType> {
1054 // WeakCalls are only supported for functions with a void return type.
1055 // Otherwise, the function result would be undefined if the the WeakPtr<>
1056 // is invalidated.
1057 COMPILE_ASSERT(is_void<ReturnType>::value,
[email protected]93540582011-05-16 22:35:141058 weak_ptrs_can_only_bind_to_methods_without_return_values);
[email protected]7296f2762011-11-21 19:23:441059};
[email protected]c18b1052011-03-24 02:02:171060
[email protected]7296f2762011-11-21 19:23:441061#endif
[email protected]b38d3572011-02-15 01:27:381062
[email protected]7296f2762011-11-21 19:23:441063// Invoker<>
1064//
1065// See description at the top of the file.
1066template <int NumBound, typename Storage, typename RunType>
1067struct Invoker;
1068
1069// Arity 0 -> 0.
1070template <typename StorageType, typename R>
1071struct Invoker<0, StorageType, R()> {
1072 typedef R(RunType)(BindStateBase*);
1073
1074 typedef R(UnboundRunType)();
1075
1076 static R Run(BindStateBase* base) {
1077 StorageType* storage = static_cast<StorageType*>(base);
1078
1079 // Local references to make debugger stepping easier. If in a debugger,
1080 // you really want to warp ahead and step through the
1081 // InvokeHelper<>::MakeItSo() call below.
1082
1083 return InvokeHelper<StorageType::IsWeakCall::value, R,
1084 typename StorageType::RunnableType,
1085 void()>
1086 ::MakeItSo(storage->runnable_);
1087 }
1088};
1089
1090// Arity 1 -> 1.
1091template <typename StorageType, typename R,typename X1>
1092struct Invoker<0, StorageType, R(X1)> {
1093 typedef R(RunType)(BindStateBase*,
1094 typename CallbackParamTraits<X1>::ForwardType);
1095
1096 typedef R(UnboundRunType)(X1);
1097
1098 static R Run(BindStateBase* base,
1099 typename CallbackParamTraits<X1>::ForwardType x1) {
1100 StorageType* storage = static_cast<StorageType*>(base);
1101
1102 // Local references to make debugger stepping easier. If in a debugger,
1103 // you really want to warp ahead and step through the
1104 // InvokeHelper<>::MakeItSo() call below.
1105
1106 return InvokeHelper<StorageType::IsWeakCall::value, R,
1107 typename StorageType::RunnableType,
1108 void(typename CallbackParamTraits<X1>::ForwardType x1)>
1109 ::MakeItSo(storage->runnable_, x1);
1110 }
1111};
1112
1113// Arity 1 -> 0.
1114template <typename StorageType, typename R,typename X1>
1115struct Invoker<1, StorageType, R(X1)> {
1116 typedef R(RunType)(BindStateBase*);
1117
1118 typedef R(UnboundRunType)();
1119
1120 static R Run(BindStateBase* base) {
1121 StorageType* storage = static_cast<StorageType*>(base);
1122
1123 // Local references to make debugger stepping easier. If in a debugger,
1124 // you really want to warp ahead and step through the
1125 // InvokeHelper<>::MakeItSo() call below.
1126 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1127
1128 typename Bound1UnwrapTraits::ForwardType x1 =
1129 Bound1UnwrapTraits::Unwrap(storage->p1_);
1130 return InvokeHelper<StorageType::IsWeakCall::value, R,
1131 typename StorageType::RunnableType,
1132 void(typename Bound1UnwrapTraits::ForwardType)>
1133 ::MakeItSo(storage->runnable_, x1);
1134 }
1135};
1136
1137// Arity 2 -> 2.
1138template <typename StorageType, typename R,typename X1, typename X2>
1139struct Invoker<0, StorageType, R(X1, X2)> {
1140 typedef R(RunType)(BindStateBase*,
1141 typename CallbackParamTraits<X1>::ForwardType,
1142 typename CallbackParamTraits<X2>::ForwardType);
1143
1144 typedef R(UnboundRunType)(X1, X2);
1145
1146 static R Run(BindStateBase* base,
1147 typename CallbackParamTraits<X1>::ForwardType x1,
1148 typename CallbackParamTraits<X2>::ForwardType x2) {
1149 StorageType* storage = static_cast<StorageType*>(base);
1150
1151 // Local references to make debugger stepping easier. If in a debugger,
1152 // you really want to warp ahead and step through the
1153 // InvokeHelper<>::MakeItSo() call below.
1154
1155 return InvokeHelper<StorageType::IsWeakCall::value, R,
1156 typename StorageType::RunnableType,
1157 void(typename CallbackParamTraits<X1>::ForwardType x1,
1158 typename CallbackParamTraits<X2>::ForwardType x2)>
1159 ::MakeItSo(storage->runnable_, x1, x2);
1160 }
1161};
1162
1163// Arity 2 -> 1.
1164template <typename StorageType, typename R,typename X1, typename X2>
1165struct Invoker<1, StorageType, R(X1, X2)> {
1166 typedef R(RunType)(BindStateBase*,
1167 typename CallbackParamTraits<X2>::ForwardType);
1168
1169 typedef R(UnboundRunType)(X2);
1170
1171 static R Run(BindStateBase* base,
1172 typename CallbackParamTraits<X2>::ForwardType x2) {
1173 StorageType* storage = static_cast<StorageType*>(base);
1174
1175 // Local references to make debugger stepping easier. If in a debugger,
1176 // you really want to warp ahead and step through the
1177 // InvokeHelper<>::MakeItSo() call below.
1178 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1179
1180 typename Bound1UnwrapTraits::ForwardType x1 =
1181 Bound1UnwrapTraits::Unwrap(storage->p1_);
1182 return InvokeHelper<StorageType::IsWeakCall::value, R,
1183 typename StorageType::RunnableType,
1184 void(typename Bound1UnwrapTraits::ForwardType,
1185 typename CallbackParamTraits<X2>::ForwardType x2)>
1186 ::MakeItSo(storage->runnable_, x1, x2);
1187 }
1188};
1189
1190// Arity 2 -> 0.
1191template <typename StorageType, typename R,typename X1, typename X2>
1192struct Invoker<2, StorageType, R(X1, X2)> {
1193 typedef R(RunType)(BindStateBase*);
1194
1195 typedef R(UnboundRunType)();
1196
1197 static R Run(BindStateBase* base) {
1198 StorageType* storage = static_cast<StorageType*>(base);
1199
1200 // Local references to make debugger stepping easier. If in a debugger,
1201 // you really want to warp ahead and step through the
1202 // InvokeHelper<>::MakeItSo() call below.
1203 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1204 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1205
1206 typename Bound1UnwrapTraits::ForwardType x1 =
1207 Bound1UnwrapTraits::Unwrap(storage->p1_);
1208 typename Bound2UnwrapTraits::ForwardType x2 =
1209 Bound2UnwrapTraits::Unwrap(storage->p2_);
1210 return InvokeHelper<StorageType::IsWeakCall::value, R,
1211 typename StorageType::RunnableType,
1212 void(typename Bound1UnwrapTraits::ForwardType,
1213 typename Bound2UnwrapTraits::ForwardType)>
1214 ::MakeItSo(storage->runnable_, x1, x2);
1215 }
1216};
1217
1218// Arity 3 -> 3.
1219template <typename StorageType, typename R,typename X1, typename X2,
1220 typename X3>
1221struct Invoker<0, StorageType, R(X1, X2, X3)> {
1222 typedef R(RunType)(BindStateBase*,
1223 typename CallbackParamTraits<X1>::ForwardType,
1224 typename CallbackParamTraits<X2>::ForwardType,
1225 typename CallbackParamTraits<X3>::ForwardType);
1226
1227 typedef R(UnboundRunType)(X1, X2, X3);
1228
1229 static R Run(BindStateBase* base,
1230 typename CallbackParamTraits<X1>::ForwardType x1,
1231 typename CallbackParamTraits<X2>::ForwardType x2,
1232 typename CallbackParamTraits<X3>::ForwardType x3) {
1233 StorageType* storage = static_cast<StorageType*>(base);
1234
1235 // Local references to make debugger stepping easier. If in a debugger,
1236 // you really want to warp ahead and step through the
1237 // InvokeHelper<>::MakeItSo() call below.
1238
1239 return InvokeHelper<StorageType::IsWeakCall::value, R,
1240 typename StorageType::RunnableType,
1241 void(typename CallbackParamTraits<X1>::ForwardType x1,
1242 typename CallbackParamTraits<X2>::ForwardType x2,
1243 typename CallbackParamTraits<X3>::ForwardType x3)>
1244 ::MakeItSo(storage->runnable_, x1, x2, x3);
1245 }
1246};
1247
1248// Arity 3 -> 2.
1249template <typename StorageType, typename R,typename X1, typename X2,
1250 typename X3>
1251struct Invoker<1, StorageType, R(X1, X2, X3)> {
1252 typedef R(RunType)(BindStateBase*,
1253 typename CallbackParamTraits<X2>::ForwardType,
1254 typename CallbackParamTraits<X3>::ForwardType);
1255
1256 typedef R(UnboundRunType)(X2, X3);
1257
1258 static R Run(BindStateBase* base,
1259 typename CallbackParamTraits<X2>::ForwardType x2,
1260 typename CallbackParamTraits<X3>::ForwardType x3) {
1261 StorageType* storage = static_cast<StorageType*>(base);
1262
1263 // Local references to make debugger stepping easier. If in a debugger,
1264 // you really want to warp ahead and step through the
1265 // InvokeHelper<>::MakeItSo() call below.
1266 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1267
1268 typename Bound1UnwrapTraits::ForwardType x1 =
1269 Bound1UnwrapTraits::Unwrap(storage->p1_);
1270 return InvokeHelper<StorageType::IsWeakCall::value, R,
1271 typename StorageType::RunnableType,
1272 void(typename Bound1UnwrapTraits::ForwardType,
1273 typename CallbackParamTraits<X2>::ForwardType x2,
1274 typename CallbackParamTraits<X3>::ForwardType x3)>
1275 ::MakeItSo(storage->runnable_, x1, x2, x3);
1276 }
1277};
1278
1279// Arity 3 -> 1.
1280template <typename StorageType, typename R,typename X1, typename X2,
1281 typename X3>
1282struct Invoker<2, StorageType, R(X1, X2, X3)> {
1283 typedef R(RunType)(BindStateBase*,
1284 typename CallbackParamTraits<X3>::ForwardType);
1285
1286 typedef R(UnboundRunType)(X3);
1287
1288 static R Run(BindStateBase* base,
1289 typename CallbackParamTraits<X3>::ForwardType x3) {
1290 StorageType* storage = static_cast<StorageType*>(base);
1291
1292 // Local references to make debugger stepping easier. If in a debugger,
1293 // you really want to warp ahead and step through the
1294 // InvokeHelper<>::MakeItSo() call below.
1295 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1296 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1297
1298 typename Bound1UnwrapTraits::ForwardType x1 =
1299 Bound1UnwrapTraits::Unwrap(storage->p1_);
1300 typename Bound2UnwrapTraits::ForwardType x2 =
1301 Bound2UnwrapTraits::Unwrap(storage->p2_);
1302 return InvokeHelper<StorageType::IsWeakCall::value, R,
1303 typename StorageType::RunnableType,
1304 void(typename Bound1UnwrapTraits::ForwardType,
1305 typename Bound2UnwrapTraits::ForwardType,
1306 typename CallbackParamTraits<X3>::ForwardType x3)>
1307 ::MakeItSo(storage->runnable_, x1, x2, x3);
1308 }
1309};
1310
1311// Arity 3 -> 0.
1312template <typename StorageType, typename R,typename X1, typename X2,
1313 typename X3>
1314struct Invoker<3, StorageType, R(X1, X2, X3)> {
1315 typedef R(RunType)(BindStateBase*);
1316
1317 typedef R(UnboundRunType)();
1318
1319 static R Run(BindStateBase* base) {
1320 StorageType* storage = static_cast<StorageType*>(base);
1321
1322 // Local references to make debugger stepping easier. If in a debugger,
1323 // you really want to warp ahead and step through the
1324 // InvokeHelper<>::MakeItSo() call below.
1325 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1326 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1327 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1328
1329 typename Bound1UnwrapTraits::ForwardType x1 =
1330 Bound1UnwrapTraits::Unwrap(storage->p1_);
1331 typename Bound2UnwrapTraits::ForwardType x2 =
1332 Bound2UnwrapTraits::Unwrap(storage->p2_);
1333 typename Bound3UnwrapTraits::ForwardType x3 =
1334 Bound3UnwrapTraits::Unwrap(storage->p3_);
1335 return InvokeHelper<StorageType::IsWeakCall::value, R,
1336 typename StorageType::RunnableType,
1337 void(typename Bound1UnwrapTraits::ForwardType,
1338 typename Bound2UnwrapTraits::ForwardType,
1339 typename Bound3UnwrapTraits::ForwardType)>
1340 ::MakeItSo(storage->runnable_, x1, x2, x3);
1341 }
1342};
1343
1344// Arity 4 -> 4.
1345template <typename StorageType, typename R,typename X1, typename X2,
1346 typename X3, typename X4>
1347struct Invoker<0, StorageType, R(X1, X2, X3, X4)> {
1348 typedef R(RunType)(BindStateBase*,
1349 typename CallbackParamTraits<X1>::ForwardType,
1350 typename CallbackParamTraits<X2>::ForwardType,
1351 typename CallbackParamTraits<X3>::ForwardType,
1352 typename CallbackParamTraits<X4>::ForwardType);
1353
1354 typedef R(UnboundRunType)(X1, X2, X3, X4);
1355
1356 static R Run(BindStateBase* base,
1357 typename CallbackParamTraits<X1>::ForwardType x1,
1358 typename CallbackParamTraits<X2>::ForwardType x2,
1359 typename CallbackParamTraits<X3>::ForwardType x3,
1360 typename CallbackParamTraits<X4>::ForwardType x4) {
1361 StorageType* storage = static_cast<StorageType*>(base);
1362
1363 // Local references to make debugger stepping easier. If in a debugger,
1364 // you really want to warp ahead and step through the
1365 // InvokeHelper<>::MakeItSo() call below.
1366
1367 return InvokeHelper<StorageType::IsWeakCall::value, R,
1368 typename StorageType::RunnableType,
1369 void(typename CallbackParamTraits<X1>::ForwardType x1,
1370 typename CallbackParamTraits<X2>::ForwardType x2,
1371 typename CallbackParamTraits<X3>::ForwardType x3,
1372 typename CallbackParamTraits<X4>::ForwardType x4)>
1373 ::MakeItSo(storage->runnable_, x1, x2, x3, x4);
1374 }
1375};
1376
1377// Arity 4 -> 3.
1378template <typename StorageType, typename R,typename X1, typename X2,
1379 typename X3, typename X4>
1380struct Invoker<1, StorageType, R(X1, X2, X3, X4)> {
1381 typedef R(RunType)(BindStateBase*,
1382 typename CallbackParamTraits<X2>::ForwardType,
1383 typename CallbackParamTraits<X3>::ForwardType,
1384 typename CallbackParamTraits<X4>::ForwardType);
1385
1386 typedef R(UnboundRunType)(X2, X3, X4);
1387
1388 static R Run(BindStateBase* base,
1389 typename CallbackParamTraits<X2>::ForwardType x2,
1390 typename CallbackParamTraits<X3>::ForwardType x3,
1391 typename CallbackParamTraits<X4>::ForwardType x4) {
1392 StorageType* storage = static_cast<StorageType*>(base);
1393
1394 // Local references to make debugger stepping easier. If in a debugger,
1395 // you really want to warp ahead and step through the
1396 // InvokeHelper<>::MakeItSo() call below.
1397 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1398
1399 typename Bound1UnwrapTraits::ForwardType x1 =
1400 Bound1UnwrapTraits::Unwrap(storage->p1_);
1401 return InvokeHelper<StorageType::IsWeakCall::value, R,
1402 typename StorageType::RunnableType,
1403 void(typename Bound1UnwrapTraits::ForwardType,
1404 typename CallbackParamTraits<X2>::ForwardType x2,
1405 typename CallbackParamTraits<X3>::ForwardType x3,
1406 typename CallbackParamTraits<X4>::ForwardType x4)>
1407 ::MakeItSo(storage->runnable_, x1, x2, x3, x4);
1408 }
1409};
1410
1411// Arity 4 -> 2.
1412template <typename StorageType, typename R,typename X1, typename X2,
1413 typename X3, typename X4>
1414struct Invoker<2, StorageType, R(X1, X2, X3, X4)> {
1415 typedef R(RunType)(BindStateBase*,
1416 typename CallbackParamTraits<X3>::ForwardType,
1417 typename CallbackParamTraits<X4>::ForwardType);
1418
1419 typedef R(UnboundRunType)(X3, X4);
1420
1421 static R Run(BindStateBase* base,
1422 typename CallbackParamTraits<X3>::ForwardType x3,
1423 typename CallbackParamTraits<X4>::ForwardType x4) {
1424 StorageType* storage = static_cast<StorageType*>(base);
1425
1426 // Local references to make debugger stepping easier. If in a debugger,
1427 // you really want to warp ahead and step through the
1428 // InvokeHelper<>::MakeItSo() call below.
1429 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1430 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1431
1432 typename Bound1UnwrapTraits::ForwardType x1 =
1433 Bound1UnwrapTraits::Unwrap(storage->p1_);
1434 typename Bound2UnwrapTraits::ForwardType x2 =
1435 Bound2UnwrapTraits::Unwrap(storage->p2_);
1436 return InvokeHelper<StorageType::IsWeakCall::value, R,
1437 typename StorageType::RunnableType,
1438 void(typename Bound1UnwrapTraits::ForwardType,
1439 typename Bound2UnwrapTraits::ForwardType,
1440 typename CallbackParamTraits<X3>::ForwardType x3,
1441 typename CallbackParamTraits<X4>::ForwardType x4)>
1442 ::MakeItSo(storage->runnable_, x1, x2, x3, x4);
1443 }
1444};
1445
1446// Arity 4 -> 1.
1447template <typename StorageType, typename R,typename X1, typename X2,
1448 typename X3, typename X4>
1449struct Invoker<3, StorageType, R(X1, X2, X3, X4)> {
1450 typedef R(RunType)(BindStateBase*,
1451 typename CallbackParamTraits<X4>::ForwardType);
1452
1453 typedef R(UnboundRunType)(X4);
1454
1455 static R Run(BindStateBase* base,
1456 typename CallbackParamTraits<X4>::ForwardType x4) {
1457 StorageType* storage = static_cast<StorageType*>(base);
1458
1459 // Local references to make debugger stepping easier. If in a debugger,
1460 // you really want to warp ahead and step through the
1461 // InvokeHelper<>::MakeItSo() call below.
1462 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1463 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1464 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1465
1466 typename Bound1UnwrapTraits::ForwardType x1 =
1467 Bound1UnwrapTraits::Unwrap(storage->p1_);
1468 typename Bound2UnwrapTraits::ForwardType x2 =
1469 Bound2UnwrapTraits::Unwrap(storage->p2_);
1470 typename Bound3UnwrapTraits::ForwardType x3 =
1471 Bound3UnwrapTraits::Unwrap(storage->p3_);
1472 return InvokeHelper<StorageType::IsWeakCall::value, R,
1473 typename StorageType::RunnableType,
1474 void(typename Bound1UnwrapTraits::ForwardType,
1475 typename Bound2UnwrapTraits::ForwardType,
1476 typename Bound3UnwrapTraits::ForwardType,
1477 typename CallbackParamTraits<X4>::ForwardType x4)>
1478 ::MakeItSo(storage->runnable_, x1, x2, x3, x4);
1479 }
1480};
1481
1482// Arity 4 -> 0.
1483template <typename StorageType, typename R,typename X1, typename X2,
1484 typename X3, typename X4>
1485struct Invoker<4, StorageType, R(X1, X2, X3, X4)> {
1486 typedef R(RunType)(BindStateBase*);
1487
1488 typedef R(UnboundRunType)();
1489
1490 static R Run(BindStateBase* base) {
1491 StorageType* storage = static_cast<StorageType*>(base);
1492
1493 // Local references to make debugger stepping easier. If in a debugger,
1494 // you really want to warp ahead and step through the
1495 // InvokeHelper<>::MakeItSo() call below.
1496 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1497 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1498 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1499 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1500
1501 typename Bound1UnwrapTraits::ForwardType x1 =
1502 Bound1UnwrapTraits::Unwrap(storage->p1_);
1503 typename Bound2UnwrapTraits::ForwardType x2 =
1504 Bound2UnwrapTraits::Unwrap(storage->p2_);
1505 typename Bound3UnwrapTraits::ForwardType x3 =
1506 Bound3UnwrapTraits::Unwrap(storage->p3_);
1507 typename Bound4UnwrapTraits::ForwardType x4 =
1508 Bound4UnwrapTraits::Unwrap(storage->p4_);
1509 return InvokeHelper<StorageType::IsWeakCall::value, R,
1510 typename StorageType::RunnableType,
1511 void(typename Bound1UnwrapTraits::ForwardType,
1512 typename Bound2UnwrapTraits::ForwardType,
1513 typename Bound3UnwrapTraits::ForwardType,
1514 typename Bound4UnwrapTraits::ForwardType)>
1515 ::MakeItSo(storage->runnable_, x1, x2, x3, x4);
1516 }
1517};
1518
1519// Arity 5 -> 5.
1520template <typename StorageType, typename R,typename X1, typename X2,
1521 typename X3, typename X4, typename X5>
1522struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> {
1523 typedef R(RunType)(BindStateBase*,
1524 typename CallbackParamTraits<X1>::ForwardType,
1525 typename CallbackParamTraits<X2>::ForwardType,
1526 typename CallbackParamTraits<X3>::ForwardType,
1527 typename CallbackParamTraits<X4>::ForwardType,
1528 typename CallbackParamTraits<X5>::ForwardType);
1529
1530 typedef R(UnboundRunType)(X1, X2, X3, X4, X5);
1531
1532 static R Run(BindStateBase* base,
1533 typename CallbackParamTraits<X1>::ForwardType x1,
1534 typename CallbackParamTraits<X2>::ForwardType x2,
1535 typename CallbackParamTraits<X3>::ForwardType x3,
1536 typename CallbackParamTraits<X4>::ForwardType x4,
1537 typename CallbackParamTraits<X5>::ForwardType x5) {
1538 StorageType* storage = static_cast<StorageType*>(base);
1539
1540 // Local references to make debugger stepping easier. If in a debugger,
1541 // you really want to warp ahead and step through the
1542 // InvokeHelper<>::MakeItSo() call below.
1543
1544 return InvokeHelper<StorageType::IsWeakCall::value, R,
1545 typename StorageType::RunnableType,
1546 void(typename CallbackParamTraits<X1>::ForwardType x1,
1547 typename CallbackParamTraits<X2>::ForwardType x2,
1548 typename CallbackParamTraits<X3>::ForwardType x3,
1549 typename CallbackParamTraits<X4>::ForwardType x4,
1550 typename CallbackParamTraits<X5>::ForwardType x5)>
1551 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5);
1552 }
1553};
1554
1555// Arity 5 -> 4.
1556template <typename StorageType, typename R,typename X1, typename X2,
1557 typename X3, typename X4, typename X5>
1558struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> {
1559 typedef R(RunType)(BindStateBase*,
1560 typename CallbackParamTraits<X2>::ForwardType,
1561 typename CallbackParamTraits<X3>::ForwardType,
1562 typename CallbackParamTraits<X4>::ForwardType,
1563 typename CallbackParamTraits<X5>::ForwardType);
1564
1565 typedef R(UnboundRunType)(X2, X3, X4, X5);
1566
1567 static R Run(BindStateBase* base,
1568 typename CallbackParamTraits<X2>::ForwardType x2,
1569 typename CallbackParamTraits<X3>::ForwardType x3,
1570 typename CallbackParamTraits<X4>::ForwardType x4,
1571 typename CallbackParamTraits<X5>::ForwardType x5) {
1572 StorageType* storage = static_cast<StorageType*>(base);
1573
1574 // Local references to make debugger stepping easier. If in a debugger,
1575 // you really want to warp ahead and step through the
1576 // InvokeHelper<>::MakeItSo() call below.
1577 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1578
1579 typename Bound1UnwrapTraits::ForwardType x1 =
1580 Bound1UnwrapTraits::Unwrap(storage->p1_);
1581 return InvokeHelper<StorageType::IsWeakCall::value, R,
1582 typename StorageType::RunnableType,
1583 void(typename Bound1UnwrapTraits::ForwardType,
1584 typename CallbackParamTraits<X2>::ForwardType x2,
1585 typename CallbackParamTraits<X3>::ForwardType x3,
1586 typename CallbackParamTraits<X4>::ForwardType x4,
1587 typename CallbackParamTraits<X5>::ForwardType x5)>
1588 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5);
1589 }
1590};
1591
1592// Arity 5 -> 3.
1593template <typename StorageType, typename R,typename X1, typename X2,
1594 typename X3, typename X4, typename X5>
1595struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> {
1596 typedef R(RunType)(BindStateBase*,
1597 typename CallbackParamTraits<X3>::ForwardType,
1598 typename CallbackParamTraits<X4>::ForwardType,
1599 typename CallbackParamTraits<X5>::ForwardType);
1600
1601 typedef R(UnboundRunType)(X3, X4, X5);
1602
1603 static R Run(BindStateBase* base,
1604 typename CallbackParamTraits<X3>::ForwardType x3,
1605 typename CallbackParamTraits<X4>::ForwardType x4,
1606 typename CallbackParamTraits<X5>::ForwardType x5) {
1607 StorageType* storage = static_cast<StorageType*>(base);
1608
1609 // Local references to make debugger stepping easier. If in a debugger,
1610 // you really want to warp ahead and step through the
1611 // InvokeHelper<>::MakeItSo() call below.
1612 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1613 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1614
1615 typename Bound1UnwrapTraits::ForwardType x1 =
1616 Bound1UnwrapTraits::Unwrap(storage->p1_);
1617 typename Bound2UnwrapTraits::ForwardType x2 =
1618 Bound2UnwrapTraits::Unwrap(storage->p2_);
1619 return InvokeHelper<StorageType::IsWeakCall::value, R,
1620 typename StorageType::RunnableType,
1621 void(typename Bound1UnwrapTraits::ForwardType,
1622 typename Bound2UnwrapTraits::ForwardType,
1623 typename CallbackParamTraits<X3>::ForwardType x3,
1624 typename CallbackParamTraits<X4>::ForwardType x4,
1625 typename CallbackParamTraits<X5>::ForwardType x5)>
1626 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5);
1627 }
1628};
1629
1630// Arity 5 -> 2.
1631template <typename StorageType, typename R,typename X1, typename X2,
1632 typename X3, typename X4, typename X5>
1633struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> {
1634 typedef R(RunType)(BindStateBase*,
1635 typename CallbackParamTraits<X4>::ForwardType,
1636 typename CallbackParamTraits<X5>::ForwardType);
1637
1638 typedef R(UnboundRunType)(X4, X5);
1639
1640 static R Run(BindStateBase* base,
1641 typename CallbackParamTraits<X4>::ForwardType x4,
1642 typename CallbackParamTraits<X5>::ForwardType x5) {
1643 StorageType* storage = static_cast<StorageType*>(base);
1644
1645 // Local references to make debugger stepping easier. If in a debugger,
1646 // you really want to warp ahead and step through the
1647 // InvokeHelper<>::MakeItSo() call below.
1648 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1649 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1650 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1651
1652 typename Bound1UnwrapTraits::ForwardType x1 =
1653 Bound1UnwrapTraits::Unwrap(storage->p1_);
1654 typename Bound2UnwrapTraits::ForwardType x2 =
1655 Bound2UnwrapTraits::Unwrap(storage->p2_);
1656 typename Bound3UnwrapTraits::ForwardType x3 =
1657 Bound3UnwrapTraits::Unwrap(storage->p3_);
1658 return InvokeHelper<StorageType::IsWeakCall::value, R,
1659 typename StorageType::RunnableType,
1660 void(typename Bound1UnwrapTraits::ForwardType,
1661 typename Bound2UnwrapTraits::ForwardType,
1662 typename Bound3UnwrapTraits::ForwardType,
1663 typename CallbackParamTraits<X4>::ForwardType x4,
1664 typename CallbackParamTraits<X5>::ForwardType x5)>
1665 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5);
1666 }
1667};
1668
1669// Arity 5 -> 1.
1670template <typename StorageType, typename R,typename X1, typename X2,
1671 typename X3, typename X4, typename X5>
1672struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> {
1673 typedef R(RunType)(BindStateBase*,
1674 typename CallbackParamTraits<X5>::ForwardType);
1675
1676 typedef R(UnboundRunType)(X5);
1677
1678 static R Run(BindStateBase* base,
1679 typename CallbackParamTraits<X5>::ForwardType x5) {
1680 StorageType* storage = static_cast<StorageType*>(base);
1681
1682 // Local references to make debugger stepping easier. If in a debugger,
1683 // you really want to warp ahead and step through the
1684 // InvokeHelper<>::MakeItSo() call below.
1685 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1686 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1687 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1688 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1689
1690 typename Bound1UnwrapTraits::ForwardType x1 =
1691 Bound1UnwrapTraits::Unwrap(storage->p1_);
1692 typename Bound2UnwrapTraits::ForwardType x2 =
1693 Bound2UnwrapTraits::Unwrap(storage->p2_);
1694 typename Bound3UnwrapTraits::ForwardType x3 =
1695 Bound3UnwrapTraits::Unwrap(storage->p3_);
1696 typename Bound4UnwrapTraits::ForwardType x4 =
1697 Bound4UnwrapTraits::Unwrap(storage->p4_);
1698 return InvokeHelper<StorageType::IsWeakCall::value, R,
1699 typename StorageType::RunnableType,
1700 void(typename Bound1UnwrapTraits::ForwardType,
1701 typename Bound2UnwrapTraits::ForwardType,
1702 typename Bound3UnwrapTraits::ForwardType,
1703 typename Bound4UnwrapTraits::ForwardType,
1704 typename CallbackParamTraits<X5>::ForwardType x5)>
1705 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5);
1706 }
1707};
1708
1709// Arity 5 -> 0.
1710template <typename StorageType, typename R,typename X1, typename X2,
1711 typename X3, typename X4, typename X5>
1712struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> {
1713 typedef R(RunType)(BindStateBase*);
1714
1715 typedef R(UnboundRunType)();
1716
1717 static R Run(BindStateBase* base) {
1718 StorageType* storage = static_cast<StorageType*>(base);
1719
1720 // Local references to make debugger stepping easier. If in a debugger,
1721 // you really want to warp ahead and step through the
1722 // InvokeHelper<>::MakeItSo() call below.
1723 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1724 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1725 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1726 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1727 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
1728
1729 typename Bound1UnwrapTraits::ForwardType x1 =
1730 Bound1UnwrapTraits::Unwrap(storage->p1_);
1731 typename Bound2UnwrapTraits::ForwardType x2 =
1732 Bound2UnwrapTraits::Unwrap(storage->p2_);
1733 typename Bound3UnwrapTraits::ForwardType x3 =
1734 Bound3UnwrapTraits::Unwrap(storage->p3_);
1735 typename Bound4UnwrapTraits::ForwardType x4 =
1736 Bound4UnwrapTraits::Unwrap(storage->p4_);
1737 typename Bound5UnwrapTraits::ForwardType x5 =
1738 Bound5UnwrapTraits::Unwrap(storage->p5_);
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 Bound4UnwrapTraits::ForwardType,
1745 typename Bound5UnwrapTraits::ForwardType)>
1746 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5);
1747 }
1748};
1749
1750// Arity 6 -> 6.
1751template <typename StorageType, typename R,typename X1, typename X2,
1752 typename X3, typename X4, typename X5, typename X6>
1753struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1754 typedef R(RunType)(BindStateBase*,
1755 typename CallbackParamTraits<X1>::ForwardType,
1756 typename CallbackParamTraits<X2>::ForwardType,
1757 typename CallbackParamTraits<X3>::ForwardType,
1758 typename CallbackParamTraits<X4>::ForwardType,
1759 typename CallbackParamTraits<X5>::ForwardType,
1760 typename CallbackParamTraits<X6>::ForwardType);
1761
1762 typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6);
1763
1764 static R Run(BindStateBase* base,
1765 typename CallbackParamTraits<X1>::ForwardType x1,
1766 typename CallbackParamTraits<X2>::ForwardType x2,
1767 typename CallbackParamTraits<X3>::ForwardType x3,
1768 typename CallbackParamTraits<X4>::ForwardType x4,
1769 typename CallbackParamTraits<X5>::ForwardType x5,
1770 typename CallbackParamTraits<X6>::ForwardType x6) {
1771 StorageType* storage = static_cast<StorageType*>(base);
1772
1773 // Local references to make debugger stepping easier. If in a debugger,
1774 // you really want to warp ahead and step through the
1775 // InvokeHelper<>::MakeItSo() call below.
1776
1777 return InvokeHelper<StorageType::IsWeakCall::value, R,
1778 typename StorageType::RunnableType,
1779 void(typename CallbackParamTraits<X1>::ForwardType x1,
1780 typename CallbackParamTraits<X2>::ForwardType x2,
1781 typename CallbackParamTraits<X3>::ForwardType x3,
1782 typename CallbackParamTraits<X4>::ForwardType x4,
1783 typename CallbackParamTraits<X5>::ForwardType x5,
1784 typename CallbackParamTraits<X6>::ForwardType x6)>
1785 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
1786 }
1787};
1788
1789// Arity 6 -> 5.
1790template <typename StorageType, typename R,typename X1, typename X2,
1791 typename X3, typename X4, typename X5, typename X6>
1792struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1793 typedef R(RunType)(BindStateBase*,
1794 typename CallbackParamTraits<X2>::ForwardType,
1795 typename CallbackParamTraits<X3>::ForwardType,
1796 typename CallbackParamTraits<X4>::ForwardType,
1797 typename CallbackParamTraits<X5>::ForwardType,
1798 typename CallbackParamTraits<X6>::ForwardType);
1799
1800 typedef R(UnboundRunType)(X2, X3, X4, X5, X6);
1801
1802 static R Run(BindStateBase* base,
1803 typename CallbackParamTraits<X2>::ForwardType x2,
1804 typename CallbackParamTraits<X3>::ForwardType x3,
1805 typename CallbackParamTraits<X4>::ForwardType x4,
1806 typename CallbackParamTraits<X5>::ForwardType x5,
1807 typename CallbackParamTraits<X6>::ForwardType x6) {
1808 StorageType* storage = static_cast<StorageType*>(base);
1809
1810 // Local references to make debugger stepping easier. If in a debugger,
1811 // you really want to warp ahead and step through the
1812 // InvokeHelper<>::MakeItSo() call below.
1813 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1814
1815 typename Bound1UnwrapTraits::ForwardType x1 =
1816 Bound1UnwrapTraits::Unwrap(storage->p1_);
1817 return InvokeHelper<StorageType::IsWeakCall::value, R,
1818 typename StorageType::RunnableType,
1819 void(typename Bound1UnwrapTraits::ForwardType,
1820 typename CallbackParamTraits<X2>::ForwardType x2,
1821 typename CallbackParamTraits<X3>::ForwardType x3,
1822 typename CallbackParamTraits<X4>::ForwardType x4,
1823 typename CallbackParamTraits<X5>::ForwardType x5,
1824 typename CallbackParamTraits<X6>::ForwardType x6)>
1825 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
1826 }
1827};
1828
1829// Arity 6 -> 4.
1830template <typename StorageType, typename R,typename X1, typename X2,
1831 typename X3, typename X4, typename X5, typename X6>
1832struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1833 typedef R(RunType)(BindStateBase*,
1834 typename CallbackParamTraits<X3>::ForwardType,
1835 typename CallbackParamTraits<X4>::ForwardType,
1836 typename CallbackParamTraits<X5>::ForwardType,
1837 typename CallbackParamTraits<X6>::ForwardType);
1838
1839 typedef R(UnboundRunType)(X3, X4, X5, X6);
1840
1841 static R Run(BindStateBase* base,
1842 typename CallbackParamTraits<X3>::ForwardType x3,
1843 typename CallbackParamTraits<X4>::ForwardType x4,
1844 typename CallbackParamTraits<X5>::ForwardType x5,
1845 typename CallbackParamTraits<X6>::ForwardType x6) {
1846 StorageType* storage = static_cast<StorageType*>(base);
1847
1848 // Local references to make debugger stepping easier. If in a debugger,
1849 // you really want to warp ahead and step through the
1850 // InvokeHelper<>::MakeItSo() call below.
1851 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1852 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1853
1854 typename Bound1UnwrapTraits::ForwardType x1 =
1855 Bound1UnwrapTraits::Unwrap(storage->p1_);
1856 typename Bound2UnwrapTraits::ForwardType x2 =
1857 Bound2UnwrapTraits::Unwrap(storage->p2_);
1858 return InvokeHelper<StorageType::IsWeakCall::value, R,
1859 typename StorageType::RunnableType,
1860 void(typename Bound1UnwrapTraits::ForwardType,
1861 typename Bound2UnwrapTraits::ForwardType,
1862 typename CallbackParamTraits<X3>::ForwardType x3,
1863 typename CallbackParamTraits<X4>::ForwardType x4,
1864 typename CallbackParamTraits<X5>::ForwardType x5,
1865 typename CallbackParamTraits<X6>::ForwardType x6)>
1866 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
1867 }
1868};
1869
1870// Arity 6 -> 3.
1871template <typename StorageType, typename R,typename X1, typename X2,
1872 typename X3, typename X4, typename X5, typename X6>
1873struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1874 typedef R(RunType)(BindStateBase*,
1875 typename CallbackParamTraits<X4>::ForwardType,
1876 typename CallbackParamTraits<X5>::ForwardType,
1877 typename CallbackParamTraits<X6>::ForwardType);
1878
1879 typedef R(UnboundRunType)(X4, X5, X6);
1880
1881 static R Run(BindStateBase* base,
1882 typename CallbackParamTraits<X4>::ForwardType x4,
1883 typename CallbackParamTraits<X5>::ForwardType x5,
1884 typename CallbackParamTraits<X6>::ForwardType x6) {
1885 StorageType* storage = static_cast<StorageType*>(base);
1886
1887 // Local references to make debugger stepping easier. If in a debugger,
1888 // you really want to warp ahead and step through the
1889 // InvokeHelper<>::MakeItSo() call below.
1890 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1891 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1892 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1893
1894 typename Bound1UnwrapTraits::ForwardType x1 =
1895 Bound1UnwrapTraits::Unwrap(storage->p1_);
1896 typename Bound2UnwrapTraits::ForwardType x2 =
1897 Bound2UnwrapTraits::Unwrap(storage->p2_);
1898 typename Bound3UnwrapTraits::ForwardType x3 =
1899 Bound3UnwrapTraits::Unwrap(storage->p3_);
1900 return InvokeHelper<StorageType::IsWeakCall::value, R,
1901 typename StorageType::RunnableType,
1902 void(typename Bound1UnwrapTraits::ForwardType,
1903 typename Bound2UnwrapTraits::ForwardType,
1904 typename Bound3UnwrapTraits::ForwardType,
1905 typename CallbackParamTraits<X4>::ForwardType x4,
1906 typename CallbackParamTraits<X5>::ForwardType x5,
1907 typename CallbackParamTraits<X6>::ForwardType x6)>
1908 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
1909 }
1910};
1911
1912// Arity 6 -> 2.
1913template <typename StorageType, typename R,typename X1, typename X2,
1914 typename X3, typename X4, typename X5, typename X6>
1915struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1916 typedef R(RunType)(BindStateBase*,
1917 typename CallbackParamTraits<X5>::ForwardType,
1918 typename CallbackParamTraits<X6>::ForwardType);
1919
1920 typedef R(UnboundRunType)(X5, X6);
1921
1922 static R Run(BindStateBase* base,
1923 typename CallbackParamTraits<X5>::ForwardType x5,
1924 typename CallbackParamTraits<X6>::ForwardType x6) {
1925 StorageType* storage = static_cast<StorageType*>(base);
1926
1927 // Local references to make debugger stepping easier. If in a debugger,
1928 // you really want to warp ahead and step through the
1929 // InvokeHelper<>::MakeItSo() call below.
1930 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1931 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1932 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1933 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1934
1935 typename Bound1UnwrapTraits::ForwardType x1 =
1936 Bound1UnwrapTraits::Unwrap(storage->p1_);
1937 typename Bound2UnwrapTraits::ForwardType x2 =
1938 Bound2UnwrapTraits::Unwrap(storage->p2_);
1939 typename Bound3UnwrapTraits::ForwardType x3 =
1940 Bound3UnwrapTraits::Unwrap(storage->p3_);
1941 typename Bound4UnwrapTraits::ForwardType x4 =
1942 Bound4UnwrapTraits::Unwrap(storage->p4_);
1943 return InvokeHelper<StorageType::IsWeakCall::value, R,
1944 typename StorageType::RunnableType,
1945 void(typename Bound1UnwrapTraits::ForwardType,
1946 typename Bound2UnwrapTraits::ForwardType,
1947 typename Bound3UnwrapTraits::ForwardType,
1948 typename Bound4UnwrapTraits::ForwardType,
1949 typename CallbackParamTraits<X5>::ForwardType x5,
1950 typename CallbackParamTraits<X6>::ForwardType x6)>
1951 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
1952 }
1953};
1954
1955// Arity 6 -> 1.
1956template <typename StorageType, typename R,typename X1, typename X2,
1957 typename X3, typename X4, typename X5, typename X6>
1958struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> {
1959 typedef R(RunType)(BindStateBase*,
1960 typename CallbackParamTraits<X6>::ForwardType);
1961
1962 typedef R(UnboundRunType)(X6);
1963
1964 static R Run(BindStateBase* base,
1965 typename CallbackParamTraits<X6>::ForwardType x6) {
1966 StorageType* storage = static_cast<StorageType*>(base);
1967
1968 // Local references to make debugger stepping easier. If in a debugger,
1969 // you really want to warp ahead and step through the
1970 // InvokeHelper<>::MakeItSo() call below.
1971 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
1972 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
1973 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
1974 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
1975 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
1976
1977 typename Bound1UnwrapTraits::ForwardType x1 =
1978 Bound1UnwrapTraits::Unwrap(storage->p1_);
1979 typename Bound2UnwrapTraits::ForwardType x2 =
1980 Bound2UnwrapTraits::Unwrap(storage->p2_);
1981 typename Bound3UnwrapTraits::ForwardType x3 =
1982 Bound3UnwrapTraits::Unwrap(storage->p3_);
1983 typename Bound4UnwrapTraits::ForwardType x4 =
1984 Bound4UnwrapTraits::Unwrap(storage->p4_);
1985 typename Bound5UnwrapTraits::ForwardType x5 =
1986 Bound5UnwrapTraits::Unwrap(storage->p5_);
1987 return InvokeHelper<StorageType::IsWeakCall::value, R,
1988 typename StorageType::RunnableType,
1989 void(typename Bound1UnwrapTraits::ForwardType,
1990 typename Bound2UnwrapTraits::ForwardType,
1991 typename Bound3UnwrapTraits::ForwardType,
1992 typename Bound4UnwrapTraits::ForwardType,
1993 typename Bound5UnwrapTraits::ForwardType,
1994 typename CallbackParamTraits<X6>::ForwardType x6)>
1995 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
1996 }
1997};
1998
1999// Arity 6 -> 0.
2000template <typename StorageType, typename R,typename X1, typename X2,
2001 typename X3, typename X4, typename X5, typename X6>
2002struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> {
2003 typedef R(RunType)(BindStateBase*);
2004
2005 typedef R(UnboundRunType)();
2006
2007 static R Run(BindStateBase* base) {
2008 StorageType* storage = static_cast<StorageType*>(base);
2009
2010 // Local references to make debugger stepping easier. If in a debugger,
2011 // you really want to warp ahead and step through the
2012 // InvokeHelper<>::MakeItSo() call below.
2013 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2014 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2015 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2016 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2017 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2018 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2019
2020 typename Bound1UnwrapTraits::ForwardType x1 =
2021 Bound1UnwrapTraits::Unwrap(storage->p1_);
2022 typename Bound2UnwrapTraits::ForwardType x2 =
2023 Bound2UnwrapTraits::Unwrap(storage->p2_);
2024 typename Bound3UnwrapTraits::ForwardType x3 =
2025 Bound3UnwrapTraits::Unwrap(storage->p3_);
2026 typename Bound4UnwrapTraits::ForwardType x4 =
2027 Bound4UnwrapTraits::Unwrap(storage->p4_);
2028 typename Bound5UnwrapTraits::ForwardType x5 =
2029 Bound5UnwrapTraits::Unwrap(storage->p5_);
2030 typename Bound6UnwrapTraits::ForwardType x6 =
2031 Bound6UnwrapTraits::Unwrap(storage->p6_);
2032 return InvokeHelper<StorageType::IsWeakCall::value, R,
2033 typename StorageType::RunnableType,
2034 void(typename Bound1UnwrapTraits::ForwardType,
2035 typename Bound2UnwrapTraits::ForwardType,
2036 typename Bound3UnwrapTraits::ForwardType,
2037 typename Bound4UnwrapTraits::ForwardType,
2038 typename Bound5UnwrapTraits::ForwardType,
2039 typename Bound6UnwrapTraits::ForwardType)>
2040 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
2041 }
2042};
[email protected]c18b1052011-03-24 02:02:172043
[email protected]fccef1552011-11-28 22:13:542044// Arity 7 -> 7.
2045template <typename StorageType, typename R,typename X1, typename X2,
2046 typename X3, typename X4, typename X5, typename X6, typename X7>
2047struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2048 typedef R(RunType)(BindStateBase*,
2049 typename CallbackParamTraits<X1>::ForwardType,
2050 typename CallbackParamTraits<X2>::ForwardType,
2051 typename CallbackParamTraits<X3>::ForwardType,
2052 typename CallbackParamTraits<X4>::ForwardType,
2053 typename CallbackParamTraits<X5>::ForwardType,
2054 typename CallbackParamTraits<X6>::ForwardType,
2055 typename CallbackParamTraits<X7>::ForwardType);
2056
2057 typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7);
2058
2059 static R Run(BindStateBase* base,
2060 typename CallbackParamTraits<X1>::ForwardType x1,
2061 typename CallbackParamTraits<X2>::ForwardType x2,
2062 typename CallbackParamTraits<X3>::ForwardType x3,
2063 typename CallbackParamTraits<X4>::ForwardType x4,
2064 typename CallbackParamTraits<X5>::ForwardType x5,
2065 typename CallbackParamTraits<X6>::ForwardType x6,
2066 typename CallbackParamTraits<X7>::ForwardType x7) {
2067 StorageType* storage = static_cast<StorageType*>(base);
2068
2069 // Local references to make debugger stepping easier. If in a debugger,
2070 // you really want to warp ahead and step through the
2071 // InvokeHelper<>::MakeItSo() call below.
2072
2073 return InvokeHelper<StorageType::IsWeakCall::value, R,
2074 typename StorageType::RunnableType,
2075 void(typename CallbackParamTraits<X1>::ForwardType x1,
2076 typename CallbackParamTraits<X2>::ForwardType x2,
2077 typename CallbackParamTraits<X3>::ForwardType x3,
2078 typename CallbackParamTraits<X4>::ForwardType x4,
2079 typename CallbackParamTraits<X5>::ForwardType x5,
2080 typename CallbackParamTraits<X6>::ForwardType x6,
2081 typename CallbackParamTraits<X7>::ForwardType x7)>
2082 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2083 }
2084};
2085
2086// Arity 7 -> 6.
2087template <typename StorageType, typename R,typename X1, typename X2,
2088 typename X3, typename X4, typename X5, typename X6, typename X7>
2089struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2090 typedef R(RunType)(BindStateBase*,
2091 typename CallbackParamTraits<X2>::ForwardType,
2092 typename CallbackParamTraits<X3>::ForwardType,
2093 typename CallbackParamTraits<X4>::ForwardType,
2094 typename CallbackParamTraits<X5>::ForwardType,
2095 typename CallbackParamTraits<X6>::ForwardType,
2096 typename CallbackParamTraits<X7>::ForwardType);
2097
2098 typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7);
2099
2100 static R Run(BindStateBase* base,
2101 typename CallbackParamTraits<X2>::ForwardType x2,
2102 typename CallbackParamTraits<X3>::ForwardType x3,
2103 typename CallbackParamTraits<X4>::ForwardType x4,
2104 typename CallbackParamTraits<X5>::ForwardType x5,
2105 typename CallbackParamTraits<X6>::ForwardType x6,
2106 typename CallbackParamTraits<X7>::ForwardType x7) {
2107 StorageType* storage = static_cast<StorageType*>(base);
2108
2109 // Local references to make debugger stepping easier. If in a debugger,
2110 // you really want to warp ahead and step through the
2111 // InvokeHelper<>::MakeItSo() call below.
2112 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2113
2114 typename Bound1UnwrapTraits::ForwardType x1 =
2115 Bound1UnwrapTraits::Unwrap(storage->p1_);
2116 return InvokeHelper<StorageType::IsWeakCall::value, R,
2117 typename StorageType::RunnableType,
2118 void(typename Bound1UnwrapTraits::ForwardType,
2119 typename CallbackParamTraits<X2>::ForwardType x2,
2120 typename CallbackParamTraits<X3>::ForwardType x3,
2121 typename CallbackParamTraits<X4>::ForwardType x4,
2122 typename CallbackParamTraits<X5>::ForwardType x5,
2123 typename CallbackParamTraits<X6>::ForwardType x6,
2124 typename CallbackParamTraits<X7>::ForwardType x7)>
2125 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2126 }
2127};
2128
2129// Arity 7 -> 5.
2130template <typename StorageType, typename R,typename X1, typename X2,
2131 typename X3, typename X4, typename X5, typename X6, typename X7>
2132struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2133 typedef R(RunType)(BindStateBase*,
2134 typename CallbackParamTraits<X3>::ForwardType,
2135 typename CallbackParamTraits<X4>::ForwardType,
2136 typename CallbackParamTraits<X5>::ForwardType,
2137 typename CallbackParamTraits<X6>::ForwardType,
2138 typename CallbackParamTraits<X7>::ForwardType);
2139
2140 typedef R(UnboundRunType)(X3, X4, X5, X6, X7);
2141
2142 static R Run(BindStateBase* base,
2143 typename CallbackParamTraits<X3>::ForwardType x3,
2144 typename CallbackParamTraits<X4>::ForwardType x4,
2145 typename CallbackParamTraits<X5>::ForwardType x5,
2146 typename CallbackParamTraits<X6>::ForwardType x6,
2147 typename CallbackParamTraits<X7>::ForwardType x7) {
2148 StorageType* storage = static_cast<StorageType*>(base);
2149
2150 // Local references to make debugger stepping easier. If in a debugger,
2151 // you really want to warp ahead and step through the
2152 // InvokeHelper<>::MakeItSo() call below.
2153 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2154 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2155
2156 typename Bound1UnwrapTraits::ForwardType x1 =
2157 Bound1UnwrapTraits::Unwrap(storage->p1_);
2158 typename Bound2UnwrapTraits::ForwardType x2 =
2159 Bound2UnwrapTraits::Unwrap(storage->p2_);
2160 return InvokeHelper<StorageType::IsWeakCall::value, R,
2161 typename StorageType::RunnableType,
2162 void(typename Bound1UnwrapTraits::ForwardType,
2163 typename Bound2UnwrapTraits::ForwardType,
2164 typename CallbackParamTraits<X3>::ForwardType x3,
2165 typename CallbackParamTraits<X4>::ForwardType x4,
2166 typename CallbackParamTraits<X5>::ForwardType x5,
2167 typename CallbackParamTraits<X6>::ForwardType x6,
2168 typename CallbackParamTraits<X7>::ForwardType x7)>
2169 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2170 }
2171};
2172
2173// Arity 7 -> 4.
2174template <typename StorageType, typename R,typename X1, typename X2,
2175 typename X3, typename X4, typename X5, typename X6, typename X7>
2176struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2177 typedef R(RunType)(BindStateBase*,
2178 typename CallbackParamTraits<X4>::ForwardType,
2179 typename CallbackParamTraits<X5>::ForwardType,
2180 typename CallbackParamTraits<X6>::ForwardType,
2181 typename CallbackParamTraits<X7>::ForwardType);
2182
2183 typedef R(UnboundRunType)(X4, X5, X6, X7);
2184
2185 static R Run(BindStateBase* base,
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 StorageType* storage = static_cast<StorageType*>(base);
2191
2192 // Local references to make debugger stepping easier. If in a debugger,
2193 // you really want to warp ahead and step through the
2194 // InvokeHelper<>::MakeItSo() call below.
2195 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2196 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2197 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2198
2199 typename Bound1UnwrapTraits::ForwardType x1 =
2200 Bound1UnwrapTraits::Unwrap(storage->p1_);
2201 typename Bound2UnwrapTraits::ForwardType x2 =
2202 Bound2UnwrapTraits::Unwrap(storage->p2_);
2203 typename Bound3UnwrapTraits::ForwardType x3 =
2204 Bound3UnwrapTraits::Unwrap(storage->p3_);
2205 return InvokeHelper<StorageType::IsWeakCall::value, R,
2206 typename StorageType::RunnableType,
2207 void(typename Bound1UnwrapTraits::ForwardType,
2208 typename Bound2UnwrapTraits::ForwardType,
2209 typename Bound3UnwrapTraits::ForwardType,
2210 typename CallbackParamTraits<X4>::ForwardType x4,
2211 typename CallbackParamTraits<X5>::ForwardType x5,
2212 typename CallbackParamTraits<X6>::ForwardType x6,
2213 typename CallbackParamTraits<X7>::ForwardType x7)>
2214 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2215 }
2216};
2217
2218// Arity 7 -> 3.
2219template <typename StorageType, typename R,typename X1, typename X2,
2220 typename X3, typename X4, typename X5, typename X6, typename X7>
2221struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2222 typedef R(RunType)(BindStateBase*,
2223 typename CallbackParamTraits<X5>::ForwardType,
2224 typename CallbackParamTraits<X6>::ForwardType,
2225 typename CallbackParamTraits<X7>::ForwardType);
2226
2227 typedef R(UnboundRunType)(X5, X6, X7);
2228
2229 static R Run(BindStateBase* base,
2230 typename CallbackParamTraits<X5>::ForwardType x5,
2231 typename CallbackParamTraits<X6>::ForwardType x6,
2232 typename CallbackParamTraits<X7>::ForwardType x7) {
2233 StorageType* storage = static_cast<StorageType*>(base);
2234
2235 // Local references to make debugger stepping easier. If in a debugger,
2236 // you really want to warp ahead and step through the
2237 // InvokeHelper<>::MakeItSo() call below.
2238 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2239 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2240 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2241 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2242
2243 typename Bound1UnwrapTraits::ForwardType x1 =
2244 Bound1UnwrapTraits::Unwrap(storage->p1_);
2245 typename Bound2UnwrapTraits::ForwardType x2 =
2246 Bound2UnwrapTraits::Unwrap(storage->p2_);
2247 typename Bound3UnwrapTraits::ForwardType x3 =
2248 Bound3UnwrapTraits::Unwrap(storage->p3_);
2249 typename Bound4UnwrapTraits::ForwardType x4 =
2250 Bound4UnwrapTraits::Unwrap(storage->p4_);
2251 return InvokeHelper<StorageType::IsWeakCall::value, R,
2252 typename StorageType::RunnableType,
2253 void(typename Bound1UnwrapTraits::ForwardType,
2254 typename Bound2UnwrapTraits::ForwardType,
2255 typename Bound3UnwrapTraits::ForwardType,
2256 typename Bound4UnwrapTraits::ForwardType,
2257 typename CallbackParamTraits<X5>::ForwardType x5,
2258 typename CallbackParamTraits<X6>::ForwardType x6,
2259 typename CallbackParamTraits<X7>::ForwardType x7)>
2260 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2261 }
2262};
2263
2264// Arity 7 -> 2.
2265template <typename StorageType, typename R,typename X1, typename X2,
2266 typename X3, typename X4, typename X5, typename X6, typename X7>
2267struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2268 typedef R(RunType)(BindStateBase*,
2269 typename CallbackParamTraits<X6>::ForwardType,
2270 typename CallbackParamTraits<X7>::ForwardType);
2271
2272 typedef R(UnboundRunType)(X6, X7);
2273
2274 static R Run(BindStateBase* base,
2275 typename CallbackParamTraits<X6>::ForwardType x6,
2276 typename CallbackParamTraits<X7>::ForwardType x7) {
2277 StorageType* storage = static_cast<StorageType*>(base);
2278
2279 // Local references to make debugger stepping easier. If in a debugger,
2280 // you really want to warp ahead and step through the
2281 // InvokeHelper<>::MakeItSo() call below.
2282 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2283 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2284 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2285 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2286 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2287
2288 typename Bound1UnwrapTraits::ForwardType x1 =
2289 Bound1UnwrapTraits::Unwrap(storage->p1_);
2290 typename Bound2UnwrapTraits::ForwardType x2 =
2291 Bound2UnwrapTraits::Unwrap(storage->p2_);
2292 typename Bound3UnwrapTraits::ForwardType x3 =
2293 Bound3UnwrapTraits::Unwrap(storage->p3_);
2294 typename Bound4UnwrapTraits::ForwardType x4 =
2295 Bound4UnwrapTraits::Unwrap(storage->p4_);
2296 typename Bound5UnwrapTraits::ForwardType x5 =
2297 Bound5UnwrapTraits::Unwrap(storage->p5_);
2298 return InvokeHelper<StorageType::IsWeakCall::value, R,
2299 typename StorageType::RunnableType,
2300 void(typename Bound1UnwrapTraits::ForwardType,
2301 typename Bound2UnwrapTraits::ForwardType,
2302 typename Bound3UnwrapTraits::ForwardType,
2303 typename Bound4UnwrapTraits::ForwardType,
2304 typename Bound5UnwrapTraits::ForwardType,
2305 typename CallbackParamTraits<X6>::ForwardType x6,
2306 typename CallbackParamTraits<X7>::ForwardType x7)>
2307 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2308 }
2309};
2310
2311// Arity 7 -> 1.
2312template <typename StorageType, typename R,typename X1, typename X2,
2313 typename X3, typename X4, typename X5, typename X6, typename X7>
2314struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2315 typedef R(RunType)(BindStateBase*,
2316 typename CallbackParamTraits<X7>::ForwardType);
2317
2318 typedef R(UnboundRunType)(X7);
2319
2320 static R Run(BindStateBase* base,
2321 typename CallbackParamTraits<X7>::ForwardType x7) {
2322 StorageType* storage = static_cast<StorageType*>(base);
2323
2324 // Local references to make debugger stepping easier. If in a debugger,
2325 // you really want to warp ahead and step through the
2326 // InvokeHelper<>::MakeItSo() call below.
2327 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2328 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2329 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2330 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2331 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2332 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2333
2334 typename Bound1UnwrapTraits::ForwardType x1 =
2335 Bound1UnwrapTraits::Unwrap(storage->p1_);
2336 typename Bound2UnwrapTraits::ForwardType x2 =
2337 Bound2UnwrapTraits::Unwrap(storage->p2_);
2338 typename Bound3UnwrapTraits::ForwardType x3 =
2339 Bound3UnwrapTraits::Unwrap(storage->p3_);
2340 typename Bound4UnwrapTraits::ForwardType x4 =
2341 Bound4UnwrapTraits::Unwrap(storage->p4_);
2342 typename Bound5UnwrapTraits::ForwardType x5 =
2343 Bound5UnwrapTraits::Unwrap(storage->p5_);
2344 typename Bound6UnwrapTraits::ForwardType x6 =
2345 Bound6UnwrapTraits::Unwrap(storage->p6_);
2346 return InvokeHelper<StorageType::IsWeakCall::value, R,
2347 typename StorageType::RunnableType,
2348 void(typename Bound1UnwrapTraits::ForwardType,
2349 typename Bound2UnwrapTraits::ForwardType,
2350 typename Bound3UnwrapTraits::ForwardType,
2351 typename Bound4UnwrapTraits::ForwardType,
2352 typename Bound5UnwrapTraits::ForwardType,
2353 typename Bound6UnwrapTraits::ForwardType,
2354 typename CallbackParamTraits<X7>::ForwardType x7)>
2355 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2356 }
2357};
2358
2359// Arity 7 -> 0.
2360template <typename StorageType, typename R,typename X1, typename X2,
2361 typename X3, typename X4, typename X5, typename X6, typename X7>
2362struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2363 typedef R(RunType)(BindStateBase*);
2364
2365 typedef R(UnboundRunType)();
2366
2367 static R Run(BindStateBase* base) {
2368 StorageType* storage = static_cast<StorageType*>(base);
2369
2370 // Local references to make debugger stepping easier. If in a debugger,
2371 // you really want to warp ahead and step through the
2372 // InvokeHelper<>::MakeItSo() call below.
2373 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2374 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2375 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2376 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2377 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2378 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2379 typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits;
2380
2381 typename Bound1UnwrapTraits::ForwardType x1 =
2382 Bound1UnwrapTraits::Unwrap(storage->p1_);
2383 typename Bound2UnwrapTraits::ForwardType x2 =
2384 Bound2UnwrapTraits::Unwrap(storage->p2_);
2385 typename Bound3UnwrapTraits::ForwardType x3 =
2386 Bound3UnwrapTraits::Unwrap(storage->p3_);
2387 typename Bound4UnwrapTraits::ForwardType x4 =
2388 Bound4UnwrapTraits::Unwrap(storage->p4_);
2389 typename Bound5UnwrapTraits::ForwardType x5 =
2390 Bound5UnwrapTraits::Unwrap(storage->p5_);
2391 typename Bound6UnwrapTraits::ForwardType x6 =
2392 Bound6UnwrapTraits::Unwrap(storage->p6_);
2393 typename Bound7UnwrapTraits::ForwardType x7 =
2394 Bound7UnwrapTraits::Unwrap(storage->p7_);
2395 return InvokeHelper<StorageType::IsWeakCall::value, R,
2396 typename StorageType::RunnableType,
2397 void(typename Bound1UnwrapTraits::ForwardType,
2398 typename Bound2UnwrapTraits::ForwardType,
2399 typename Bound3UnwrapTraits::ForwardType,
2400 typename Bound4UnwrapTraits::ForwardType,
2401 typename Bound5UnwrapTraits::ForwardType,
2402 typename Bound6UnwrapTraits::ForwardType,
2403 typename Bound7UnwrapTraits::ForwardType)>
2404 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2405 }
2406};
2407
[email protected]b38d3572011-02-15 01:27:382408
[email protected]7296f2762011-11-21 19:23:442409// BindState<>
2410//
2411// This stores all the state passed into Bind() and is also where most
2412// of the template resolution magic occurs.
2413//
2414// Runnable is the functor we are binding arguments to.
2415// RunType is type of the Run() function that the Invoker<> should use.
2416// Normally, this is the same as the RunType of the Runnable, but it can
2417// be different if an adapter like IgnoreResult() has been used.
2418//
2419// BoundArgsType contains the storage type for all the bound arguments by
2420// (ab)using a function type.
2421template <typename Runnable, typename RunType, typename BoundArgsType>
2422struct BindState;
2423
2424template <typename Runnable, typename RunType>
2425struct BindState<Runnable, RunType, void()> : public BindStateBase {
2426 typedef Runnable RunnableType;
2427 typedef false_type IsWeakCall;
2428 typedef Invoker<0, BindState, RunType> InvokerType;
2429 typedef typename InvokerType::UnboundRunType UnboundRunType;
2430 explicit BindState(const Runnable& runnable)
2431 : runnable_(runnable) {
2432 }
2433
2434 virtual ~BindState() { }
2435
2436 RunnableType runnable_;
2437};
2438
2439template <typename Runnable, typename RunType, typename P1>
2440struct BindState<Runnable, RunType, void(P1)> : public BindStateBase {
2441 typedef Runnable RunnableType;
2442 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2443 typedef Invoker<1, BindState, RunType> InvokerType;
2444 typedef typename InvokerType::UnboundRunType UnboundRunType;
2445
2446 // Convenience typedefs for bound argument types.
2447 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2448
2449 BindState(const Runnable& runnable, const P1& p1)
2450 : runnable_(runnable),
2451 p1_(p1) {
2452 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2453 }
2454
2455 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2456 P1>::Release(p1_); }
2457
2458 RunnableType runnable_;
2459 P1 p1_;
2460};
2461
2462template <typename Runnable, typename RunType, typename P1, typename P2>
2463struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {
2464 typedef Runnable RunnableType;
2465 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2466 typedef Invoker<2, BindState, RunType> InvokerType;
2467 typedef typename InvokerType::UnboundRunType UnboundRunType;
2468
2469 // Convenience typedefs for bound argument types.
2470 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2471 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2472
2473 BindState(const Runnable& runnable, const P1& p1, const P2& p2)
2474 : runnable_(runnable),
2475 p1_(p1),
2476 p2_(p2) {
2477 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2478 }
2479
2480 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2481 P1>::Release(p1_); }
2482
2483 RunnableType runnable_;
2484 P1 p1_;
2485 P2 p2_;
2486};
2487
2488template <typename Runnable, typename RunType, typename P1, typename P2,
2489 typename P3>
2490struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {
2491 typedef Runnable RunnableType;
2492 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2493 typedef Invoker<3, BindState, RunType> InvokerType;
2494 typedef typename InvokerType::UnboundRunType UnboundRunType;
2495
2496 // Convenience typedefs for bound argument types.
2497 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2498 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2499 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2500
2501 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3)
2502 : runnable_(runnable),
2503 p1_(p1),
2504 p2_(p2),
2505 p3_(p3) {
2506 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2507 }
2508
2509 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2510 P1>::Release(p1_); }
2511
2512 RunnableType runnable_;
2513 P1 p1_;
2514 P2 p2_;
2515 P3 p3_;
2516};
2517
2518template <typename Runnable, typename RunType, typename P1, typename P2,
2519 typename P3, typename P4>
2520struct BindState<Runnable, RunType, void(P1, P2, P3,
2521 P4)> : public BindStateBase {
2522 typedef Runnable RunnableType;
2523 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2524 typedef Invoker<4, BindState, RunType> InvokerType;
2525 typedef typename InvokerType::UnboundRunType UnboundRunType;
2526
2527 // Convenience typedefs for bound argument types.
2528 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2529 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2530 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2531 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2532
2533 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2534 const P4& p4)
2535 : runnable_(runnable),
2536 p1_(p1),
2537 p2_(p2),
2538 p3_(p3),
2539 p4_(p4) {
2540 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2541 }
2542
2543 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2544 P1>::Release(p1_); }
2545
2546 RunnableType runnable_;
2547 P1 p1_;
2548 P2 p2_;
2549 P3 p3_;
2550 P4 p4_;
2551};
2552
2553template <typename Runnable, typename RunType, typename P1, typename P2,
2554 typename P3, typename P4, typename P5>
2555struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
2556 P5)> : public BindStateBase {
2557 typedef Runnable RunnableType;
2558 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2559 typedef Invoker<5, BindState, RunType> InvokerType;
2560 typedef typename InvokerType::UnboundRunType UnboundRunType;
2561
2562 // Convenience typedefs for bound argument types.
2563 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2564 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2565 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2566 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2567 typedef UnwrapTraits<P5> Bound5UnwrapTraits;
2568
2569 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
[email protected]b38d3572011-02-15 01:27:382570 const P4& p4, const P5& p5)
[email protected]7296f2762011-11-21 19:23:442571 : runnable_(runnable),
2572 p1_(p1),
2573 p2_(p2),
2574 p3_(p3),
2575 p4_(p4),
2576 p5_(p5) {
2577 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
[email protected]b38d3572011-02-15 01:27:382578 }
2579
[email protected]7296f2762011-11-21 19:23:442580 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2581 P1>::Release(p1_); }
[email protected]b38d3572011-02-15 01:27:382582
[email protected]7296f2762011-11-21 19:23:442583 RunnableType runnable_;
2584 P1 p1_;
2585 P2 p2_;
2586 P3 p3_;
2587 P4 p4_;
2588 P5 p5_;
[email protected]b38d3572011-02-15 01:27:382589};
2590
[email protected]7296f2762011-11-21 19:23:442591template <typename Runnable, typename RunType, typename P1, typename P2,
2592 typename P3, typename P4, typename P5, typename P6>
2593struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
2594 P6)> : public BindStateBase {
2595 typedef Runnable RunnableType;
2596 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2597 typedef Invoker<6, BindState, RunType> InvokerType;
2598 typedef typename InvokerType::UnboundRunType UnboundRunType;
[email protected]c18b1052011-03-24 02:02:172599
[email protected]7296f2762011-11-21 19:23:442600 // Convenience typedefs for bound argument types.
2601 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2602 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2603 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2604 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2605 typedef UnwrapTraits<P5> Bound5UnwrapTraits;
2606 typedef UnwrapTraits<P6> Bound6UnwrapTraits;
[email protected]b38d3572011-02-15 01:27:382607
[email protected]7296f2762011-11-21 19:23:442608 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
[email protected]b38d3572011-02-15 01:27:382609 const P4& p4, const P5& p5, const P6& p6)
[email protected]7296f2762011-11-21 19:23:442610 : runnable_(runnable),
2611 p1_(p1),
2612 p2_(p2),
2613 p3_(p3),
2614 p4_(p4),
2615 p5_(p5),
2616 p6_(p6) {
2617 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
[email protected]b38d3572011-02-15 01:27:382618 }
2619
[email protected]7296f2762011-11-21 19:23:442620 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2621 P1>::Release(p1_); }
[email protected]b38d3572011-02-15 01:27:382622
[email protected]7296f2762011-11-21 19:23:442623 RunnableType runnable_;
2624 P1 p1_;
2625 P2 p2_;
2626 P3 p3_;
2627 P4 p4_;
2628 P5 p5_;
2629 P6 p6_;
[email protected]b38d3572011-02-15 01:27:382630};
2631
[email protected]fccef1552011-11-28 22:13:542632template <typename Runnable, typename RunType, typename P1, typename P2,
2633 typename P3, typename P4, typename P5, typename P6, typename P7>
2634struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
2635 P7)> : public BindStateBase {
2636 typedef Runnable RunnableType;
2637 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2638 typedef Invoker<7, BindState, RunType> InvokerType;
2639 typedef typename InvokerType::UnboundRunType UnboundRunType;
2640
2641 // Convenience typedefs for bound argument types.
2642 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2643 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2644 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2645 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2646 typedef UnwrapTraits<P5> Bound5UnwrapTraits;
2647 typedef UnwrapTraits<P6> Bound6UnwrapTraits;
2648 typedef UnwrapTraits<P7> Bound7UnwrapTraits;
2649
2650 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2651 const P4& p4, const P5& p5, const P6& p6, const P7& p7)
2652 : runnable_(runnable),
2653 p1_(p1),
2654 p2_(p2),
2655 p3_(p3),
2656 p4_(p4),
2657 p5_(p5),
2658 p6_(p6),
2659 p7_(p7) {
2660 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2661 }
2662
2663 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2664 P1>::Release(p1_); }
2665
2666 RunnableType runnable_;
2667 P1 p1_;
2668 P2 p2_;
2669 P3 p3_;
2670 P4 p4_;
2671 P5 p5_;
2672 P6 p6_;
2673 P7 p7_;
2674};
2675
[email protected]b38d3572011-02-15 01:27:382676} // namespace internal
2677} // namespace base
2678
2679#endif // BASE_BIND_INTERNAL_H_