security/sandbox/chromium/base/bind_internal.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial