| OLD | NEW |
| 1 // This file was GENERATED by command: | 1 // This file was GENERATED by command: |
| 2 // pump.py bind_internal.h.pump | 2 // pump.py bind_internal.h.pump |
| 3 // DO NOT EDIT BY HAND!!! | 3 // DO NOT EDIT BY HAND!!! |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 // TODO(ajwong): If you create an fully unbound method, is there a way to |
| 8 // enforce the first argument must be refcounted? Or do we just say |
| 9 // "oh well"? |
| 10 // |
| 11 // Do we want to allow creating a fully unbound method?? |
| 12 |
| 7 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 13 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 8 // Use of this source code is governed by a BSD-style license that can be | 14 // Use of this source code is governed by a BSD-style license that can be |
| 9 // found in the LICENSE file. | 15 // found in the LICENSE file. |
| 10 | 16 |
| 11 #ifndef BASE_BIND_INTERNAL_H_ | 17 #ifndef BASE_BIND_INTERNAL_H_ |
| 12 #define BASE_BIND_INTERNAL_H_ | 18 #define BASE_BIND_INTERNAL_H_ |
| 13 #pragma once | 19 #pragma once |
| 14 | 20 |
| 15 #include "base/bind_helpers.h" | 21 #include "base/bind_helpers.h" |
| 16 #include "base/callback_internal.h" | 22 #include "base/callback_internal.h" |
| 17 #include "base/memory/raw_scoped_refptr_mismatch_checker.h" | 23 #include "base/memory/raw_scoped_refptr_mismatch_checker.h" |
| 18 #include "base/memory/weak_ptr.h" | 24 #include "base/memory/weak_ptr.h" |
| 19 #include "base/template_util.h" | 25 #include "base/template_util.h" |
| 20 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 21 | 27 |
| 22 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 23 #include "base/bind_internal_win.h" | 29 #include "base/bind_internal_win.h" |
| 24 #endif | 30 #endif |
| 25 | 31 |
| 26 namespace base { | 32 namespace base { |
| 27 namespace internal { | 33 namespace internal { |
| 28 | 34 |
| 29 // The method by which a function is invoked is determined by 3 different | 35 // CONCEPTS: |
| 30 // dimensions: | 36 // Runnable -- A type (really a type class) that has a single Run() method |
| 37 // and a RunType typedef that corresponds to the type of Run(). |
| 38 // A Runnable can declare that it should treated like a method |
| 39 // call by including a typedef named IsMethod. The value of |
| 40 // this typedef is NOT inspected, only the existence. When a |
| 41 // Runnable declares itself a method, Bind() will enforce special |
| 42 // refcounting + WeakPtr handling semantics for the first |
| 43 // parameter which is expected to be an object. |
| 44 // Functor -- A copyable type representing something that should be called. |
| 45 // All function pointers, Callback<>, and Runnables are functors |
| 46 // even if the invocation syntax differs. |
| 47 // RunType -- A function type (as opposed to function _pointer_ type) for |
| 48 // a Run() function. Usually just a convenience typedef. |
| 49 // (Bound)ArgsType -- A function type that is being (ab)used to store the |
| 50 // types of set of arguments. The "return" type is always |
| 51 // void here. We use this hack so that we do not need |
| 52 // a new type name for each arity of type. (eg., |
| 53 // BindState1, BindState2). This makes forward |
| 54 // declarations and friending much much easier. |
| 31 // | 55 // |
| 32 // 1) The type of function (normal or method). | 56 // Types: |
| 33 // 2) The arity of the function. | 57 // RunnableAdapter<> -- Wraps the various "function" pointer types into an |
| 34 // 3) The number of bound parameters. | 58 // object that adheres to the Runnable interface. |
| 59 // There are |3*ARITY| RunnableAdapter types. |
| 60 // FunctionTraits<> -- Type traits that unwrap a function signature into a |
| 61 // a set of easier to use typedefs. Used mainly for |
| 62 // compile time asserts. |
| 63 // There are |ARITY| FunctionTraits types. |
| 64 // ForceVoidReturn<> -- Helper class for translating function signatures to |
| 65 // equivalent forms with a "void" return type. |
| 66 // There are |ARITY| ForceVoidReturn types. |
| 67 // FunctorTraits<> -- Type traits used determine the correct RunType and |
| 68 // RunnableType for a Functor. This is where function |
| 69 // signature adapters are applied. |
| 70 // There are |ARITY| ForceVoidReturn types. |
| 71 // MakeRunnable<> -- Takes a Functor and returns an object in the Runnable |
| 72 // type class that represents the underlying Functor. |
| 73 // There are |O(1)| MakeRunnable types. |
| 74 // InvokeHelper<> -- Take a Runnable + arguments and actully invokes it. |
| 75 // Handle the differing syntaxes needed for WeakPtr<> support, |
| 76 // and for ignoring return values. This is separate from |
| 77 // Invoker to avoid creating multiple version of Invoker<> |
| 78 // which grows at O(n^2) with the arity. |
| 79 // There are |k*ARITY| InvokeHelper types. |
| 80 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. |
| 81 // There are |(ARITY^2 + ARITY)/2| Invoketypes. |
| 82 // BindState<> -- Stores the curried parameters, and is the main entry point |
| 83 // into the Bind() system, doing most of the type resolution. |
| 84 // There are ARITY BindState types. |
| 85 |
| 86 |
| 87 // RunnableAdapter<> |
| 35 // | 88 // |
| 36 // The templates below handle the determination of each of these dimensions. | 89 // The RunnableAdapter<> templates provide a uniform interface for invoking |
| 37 // In brief: | 90 // a function pointer, method pointer, or const method pointer. The adapter |
| 91 // exposes a Run() method with an appropriate signature. Using this wrapper |
| 92 // allows for writing code that supports all three pointer types without |
| 93 // undue repetition. Without it, a lot of code would need to be repeated 3 |
| 94 // times. |
| 38 // | 95 // |
| 39 // FunctionTraits<> -- Provides a normalied signature, and other traits. | 96 // For method pointers and const method pointers the first argument to Run() |
| 40 // InvokerN<> -- Provides a DoInvoke() function that actually executes | 97 // is considered to be the received of the method. This is similar to STL's |
| 41 // a calback. | 98 // mem_fun(). |
| 42 // InvokerStorageN<> -- Provides storage for the bound parameters, and | |
| 43 // typedefs to the above. | |
| 44 // IsWeakMethod<> -- Determines if we are binding a method to a WeakPtr<>. | |
| 45 // | 99 // |
| 46 // More details about the design of each class is included in a comment closer | 100 // This class also exposes a RunType typedef that is the function type of the |
| 47 // to their defition. | 101 // Run() function. |
| 48 | 102 // |
| 49 | 103 // If and only if the wrapper contains a method or const method pointer, an |
| 50 // IsWeakMethod determines if we are binding a method to a WeakPtr<> for an | 104 // IsMethod typedef is exposed. The existence of this typedef (NOT the value) |
| 51 // object. It is used to select an InvokerN that will no-op itself in the | 105 // marks that the wrapper should be considered a method wrapper. |
| 52 // event the WeakPtr<> for the target object is invalidated. | 106 |
| 53 template <bool IsMethod, typename T> | 107 template <typename Functor> |
| 54 struct IsWeakMethod : public false_type {}; | 108 class RunnableAdapter; |
| 55 | 109 |
| 56 template <typename T> | 110 // Function: Arity 0. |
| 57 struct IsWeakMethod<true, WeakPtr<T> > : public true_type {}; | 111 template <typename R> |
| 112 class RunnableAdapter<R(*)()> { |
| 113 public: |
| 114 typedef R (RunType)(); |
| 115 |
| 116 explicit RunnableAdapter(R(*function)()) |
| 117 : function_(function) { |
| 118 } |
| 119 |
| 120 R Run() { |
| 121 return function_(); |
| 122 } |
| 123 |
| 124 private: |
| 125 R (*function_)(); |
| 126 }; |
| 127 |
| 128 // Method: Arity 0. |
| 129 template <typename R, typename T> |
| 130 class RunnableAdapter<R(T::*)()> { |
| 131 public: |
| 132 typedef R (RunType)(T*); |
| 133 typedef true_type IsMethod; |
| 134 |
| 135 explicit RunnableAdapter(R(T::*method)()) |
| 136 : method_(method) { |
| 137 } |
| 138 |
| 139 R Run(T* object) { |
| 140 return (object->*method_)(); |
| 141 } |
| 142 |
| 143 private: |
| 144 R (T::*method_)(); |
| 145 }; |
| 146 |
| 147 // Const Method: Arity 0. |
| 148 template <typename R, typename T> |
| 149 class RunnableAdapter<R(T::*)() const> { |
| 150 public: |
| 151 typedef R (RunType)(const T*); |
| 152 typedef true_type IsMethod; |
| 153 |
| 154 explicit RunnableAdapter(R(T::*method)() const) |
| 155 : method_(method) { |
| 156 } |
| 157 |
| 158 R Run(const T* object) { |
| 159 return (object->*method_)(); |
| 160 } |
| 161 |
| 162 private: |
| 163 R (T::*method_)() const; |
| 164 }; |
| 165 |
| 166 // Function: Arity 1. |
| 167 template <typename R, typename A1> |
| 168 class RunnableAdapter<R(*)(A1)> { |
| 169 public: |
| 170 typedef R (RunType)(A1); |
| 171 |
| 172 explicit RunnableAdapter(R(*function)(A1)) |
| 173 : function_(function) { |
| 174 } |
| 175 |
| 176 R Run(typename CallbackParamTraits<A1>::ForwardType a1) { |
| 177 return function_(a1); |
| 178 } |
| 179 |
| 180 private: |
| 181 R (*function_)(A1); |
| 182 }; |
| 183 |
| 184 // Method: Arity 1. |
| 185 template <typename R, typename T, typename A1> |
| 186 class RunnableAdapter<R(T::*)(A1)> { |
| 187 public: |
| 188 typedef R (RunType)(T*, A1); |
| 189 typedef true_type IsMethod; |
| 190 |
| 191 explicit RunnableAdapter(R(T::*method)(A1)) |
| 192 : method_(method) { |
| 193 } |
| 194 |
| 195 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1) { |
| 196 return (object->*method_)(a1); |
| 197 } |
| 198 |
| 199 private: |
| 200 R (T::*method_)(A1); |
| 201 }; |
| 202 |
| 203 // Const Method: Arity 1. |
| 204 template <typename R, typename T, typename A1> |
| 205 class RunnableAdapter<R(T::*)(A1) const> { |
| 206 public: |
| 207 typedef R (RunType)(const T*, A1); |
| 208 typedef true_type IsMethod; |
| 209 |
| 210 explicit RunnableAdapter(R(T::*method)(A1) const) |
| 211 : method_(method) { |
| 212 } |
| 213 |
| 214 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1) { |
| 215 return (object->*method_)(a1); |
| 216 } |
| 217 |
| 218 private: |
| 219 R (T::*method_)(A1) const; |
| 220 }; |
| 221 |
| 222 // Function: Arity 2. |
| 223 template <typename R, typename A1, typename A2> |
| 224 class RunnableAdapter<R(*)(A1, A2)> { |
| 225 public: |
| 226 typedef R (RunType)(A1, A2); |
| 227 |
| 228 explicit RunnableAdapter(R(*function)(A1, A2)) |
| 229 : function_(function) { |
| 230 } |
| 231 |
| 232 R Run(typename CallbackParamTraits<A1>::ForwardType a1, |
| 233 typename CallbackParamTraits<A2>::ForwardType a2) { |
| 234 return function_(a1, a2); |
| 235 } |
| 236 |
| 237 private: |
| 238 R (*function_)(A1, A2); |
| 239 }; |
| 240 |
| 241 // Method: Arity 2. |
| 242 template <typename R, typename T, typename A1, typename A2> |
| 243 class RunnableAdapter<R(T::*)(A1, A2)> { |
| 244 public: |
| 245 typedef R (RunType)(T*, A1, A2); |
| 246 typedef true_type IsMethod; |
| 247 |
| 248 explicit RunnableAdapter(R(T::*method)(A1, A2)) |
| 249 : method_(method) { |
| 250 } |
| 251 |
| 252 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 253 typename CallbackParamTraits<A2>::ForwardType a2) { |
| 254 return (object->*method_)(a1, a2); |
| 255 } |
| 256 |
| 257 private: |
| 258 R (T::*method_)(A1, A2); |
| 259 }; |
| 260 |
| 261 // Const Method: Arity 2. |
| 262 template <typename R, typename T, typename A1, typename A2> |
| 263 class RunnableAdapter<R(T::*)(A1, A2) const> { |
| 264 public: |
| 265 typedef R (RunType)(const T*, A1, A2); |
| 266 typedef true_type IsMethod; |
| 267 |
| 268 explicit RunnableAdapter(R(T::*method)(A1, A2) const) |
| 269 : method_(method) { |
| 270 } |
| 271 |
| 272 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 273 typename CallbackParamTraits<A2>::ForwardType a2) { |
| 274 return (object->*method_)(a1, a2); |
| 275 } |
| 276 |
| 277 private: |
| 278 R (T::*method_)(A1, A2) const; |
| 279 }; |
| 280 |
| 281 // Function: Arity 3. |
| 282 template <typename R, typename A1, typename A2, typename A3> |
| 283 class RunnableAdapter<R(*)(A1, A2, A3)> { |
| 284 public: |
| 285 typedef R (RunType)(A1, A2, A3); |
| 286 |
| 287 explicit RunnableAdapter(R(*function)(A1, A2, A3)) |
| 288 : function_(function) { |
| 289 } |
| 290 |
| 291 R Run(typename CallbackParamTraits<A1>::ForwardType a1, |
| 292 typename CallbackParamTraits<A2>::ForwardType a2, |
| 293 typename CallbackParamTraits<A3>::ForwardType a3) { |
| 294 return function_(a1, a2, a3); |
| 295 } |
| 296 |
| 297 private: |
| 298 R (*function_)(A1, A2, A3); |
| 299 }; |
| 300 |
| 301 // Method: Arity 3. |
| 302 template <typename R, typename T, typename A1, typename A2, typename A3> |
| 303 class RunnableAdapter<R(T::*)(A1, A2, A3)> { |
| 304 public: |
| 305 typedef R (RunType)(T*, A1, A2, A3); |
| 306 typedef true_type IsMethod; |
| 307 |
| 308 explicit RunnableAdapter(R(T::*method)(A1, A2, A3)) |
| 309 : method_(method) { |
| 310 } |
| 311 |
| 312 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 313 typename CallbackParamTraits<A2>::ForwardType a2, |
| 314 typename CallbackParamTraits<A3>::ForwardType a3) { |
| 315 return (object->*method_)(a1, a2, a3); |
| 316 } |
| 317 |
| 318 private: |
| 319 R (T::*method_)(A1, A2, A3); |
| 320 }; |
| 321 |
| 322 // Const Method: Arity 3. |
| 323 template <typename R, typename T, typename A1, typename A2, typename A3> |
| 324 class RunnableAdapter<R(T::*)(A1, A2, A3) const> { |
| 325 public: |
| 326 typedef R (RunType)(const T*, A1, A2, A3); |
| 327 typedef true_type IsMethod; |
| 328 |
| 329 explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const) |
| 330 : method_(method) { |
| 331 } |
| 332 |
| 333 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 334 typename CallbackParamTraits<A2>::ForwardType a2, |
| 335 typename CallbackParamTraits<A3>::ForwardType a3) { |
| 336 return (object->*method_)(a1, a2, a3); |
| 337 } |
| 338 |
| 339 private: |
| 340 R (T::*method_)(A1, A2, A3) const; |
| 341 }; |
| 342 |
| 343 // Function: Arity 4. |
| 344 template <typename R, typename A1, typename A2, typename A3, typename A4> |
| 345 class RunnableAdapter<R(*)(A1, A2, A3, A4)> { |
| 346 public: |
| 347 typedef R (RunType)(A1, A2, A3, A4); |
| 348 |
| 349 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4)) |
| 350 : function_(function) { |
| 351 } |
| 352 |
| 353 R Run(typename CallbackParamTraits<A1>::ForwardType a1, |
| 354 typename CallbackParamTraits<A2>::ForwardType a2, |
| 355 typename CallbackParamTraits<A3>::ForwardType a3, |
| 356 typename CallbackParamTraits<A4>::ForwardType a4) { |
| 357 return function_(a1, a2, a3, a4); |
| 358 } |
| 359 |
| 360 private: |
| 361 R (*function_)(A1, A2, A3, A4); |
| 362 }; |
| 363 |
| 364 // Method: Arity 4. |
| 365 template <typename R, typename T, typename A1, typename A2, typename A3, |
| 366 typename A4> |
| 367 class RunnableAdapter<R(T::*)(A1, A2, A3, A4)> { |
| 368 public: |
| 369 typedef R (RunType)(T*, A1, A2, A3, A4); |
| 370 typedef true_type IsMethod; |
| 371 |
| 372 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4)) |
| 373 : method_(method) { |
| 374 } |
| 375 |
| 376 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 377 typename CallbackParamTraits<A2>::ForwardType a2, |
| 378 typename CallbackParamTraits<A3>::ForwardType a3, |
| 379 typename CallbackParamTraits<A4>::ForwardType a4) { |
| 380 return (object->*method_)(a1, a2, a3, a4); |
| 381 } |
| 382 |
| 383 private: |
| 384 R (T::*method_)(A1, A2, A3, A4); |
| 385 }; |
| 386 |
| 387 // Const Method: Arity 4. |
| 388 template <typename R, typename T, typename A1, typename A2, typename A3, |
| 389 typename A4> |
| 390 class RunnableAdapter<R(T::*)(A1, A2, A3, A4) const> { |
| 391 public: |
| 392 typedef R (RunType)(const T*, A1, A2, A3, A4); |
| 393 typedef true_type IsMethod; |
| 394 |
| 395 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const) |
| 396 : method_(method) { |
| 397 } |
| 398 |
| 399 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 400 typename CallbackParamTraits<A2>::ForwardType a2, |
| 401 typename CallbackParamTraits<A3>::ForwardType a3, |
| 402 typename CallbackParamTraits<A4>::ForwardType a4) { |
| 403 return (object->*method_)(a1, a2, a3, a4); |
| 404 } |
| 405 |
| 406 private: |
| 407 R (T::*method_)(A1, A2, A3, A4) const; |
| 408 }; |
| 409 |
| 410 // Function: Arity 5. |
| 411 template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 412 typename A5> |
| 413 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5)> { |
| 414 public: |
| 415 typedef R (RunType)(A1, A2, A3, A4, A5); |
| 416 |
| 417 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5)) |
| 418 : function_(function) { |
| 419 } |
| 420 |
| 421 R Run(typename CallbackParamTraits<A1>::ForwardType a1, |
| 422 typename CallbackParamTraits<A2>::ForwardType a2, |
| 423 typename CallbackParamTraits<A3>::ForwardType a3, |
| 424 typename CallbackParamTraits<A4>::ForwardType a4, |
| 425 typename CallbackParamTraits<A5>::ForwardType a5) { |
| 426 return function_(a1, a2, a3, a4, a5); |
| 427 } |
| 428 |
| 429 private: |
| 430 R (*function_)(A1, A2, A3, A4, A5); |
| 431 }; |
| 432 |
| 433 // Method: Arity 5. |
| 434 template <typename R, typename T, typename A1, typename A2, typename A3, |
| 435 typename A4, typename A5> |
| 436 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5)> { |
| 437 public: |
| 438 typedef R (RunType)(T*, A1, A2, A3, A4, A5); |
| 439 typedef true_type IsMethod; |
| 440 |
| 441 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5)) |
| 442 : method_(method) { |
| 443 } |
| 444 |
| 445 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 446 typename CallbackParamTraits<A2>::ForwardType a2, |
| 447 typename CallbackParamTraits<A3>::ForwardType a3, |
| 448 typename CallbackParamTraits<A4>::ForwardType a4, |
| 449 typename CallbackParamTraits<A5>::ForwardType a5) { |
| 450 return (object->*method_)(a1, a2, a3, a4, a5); |
| 451 } |
| 452 |
| 453 private: |
| 454 R (T::*method_)(A1, A2, A3, A4, A5); |
| 455 }; |
| 456 |
| 457 // Const Method: Arity 5. |
| 458 template <typename R, typename T, typename A1, typename A2, typename A3, |
| 459 typename A4, typename A5> |
| 460 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5) const> { |
| 461 public: |
| 462 typedef R (RunType)(const T*, A1, A2, A3, A4, A5); |
| 463 typedef true_type IsMethod; |
| 464 |
| 465 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const) |
| 466 : method_(method) { |
| 467 } |
| 468 |
| 469 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 470 typename CallbackParamTraits<A2>::ForwardType a2, |
| 471 typename CallbackParamTraits<A3>::ForwardType a3, |
| 472 typename CallbackParamTraits<A4>::ForwardType a4, |
| 473 typename CallbackParamTraits<A5>::ForwardType a5) { |
| 474 return (object->*method_)(a1, a2, a3, a4, a5); |
| 475 } |
| 476 |
| 477 private: |
| 478 R (T::*method_)(A1, A2, A3, A4, A5) const; |
| 479 }; |
| 480 |
| 481 // Function: Arity 6. |
| 482 template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 483 typename A5, typename A6> |
| 484 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6)> { |
| 485 public: |
| 486 typedef R (RunType)(A1, A2, A3, A4, A5, A6); |
| 487 |
| 488 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6)) |
| 489 : function_(function) { |
| 490 } |
| 491 |
| 492 R Run(typename CallbackParamTraits<A1>::ForwardType a1, |
| 493 typename CallbackParamTraits<A2>::ForwardType a2, |
| 494 typename CallbackParamTraits<A3>::ForwardType a3, |
| 495 typename CallbackParamTraits<A4>::ForwardType a4, |
| 496 typename CallbackParamTraits<A5>::ForwardType a5, |
| 497 typename CallbackParamTraits<A6>::ForwardType a6) { |
| 498 return function_(a1, a2, a3, a4, a5, a6); |
| 499 } |
| 500 |
| 501 private: |
| 502 R (*function_)(A1, A2, A3, A4, A5, A6); |
| 503 }; |
| 504 |
| 505 // Method: Arity 6. |
| 506 template <typename R, typename T, typename A1, typename A2, typename A3, |
| 507 typename A4, typename A5, typename A6> |
| 508 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6)> { |
| 509 public: |
| 510 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6); |
| 511 typedef true_type IsMethod; |
| 512 |
| 513 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6)) |
| 514 : method_(method) { |
| 515 } |
| 516 |
| 517 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 518 typename CallbackParamTraits<A2>::ForwardType a2, |
| 519 typename CallbackParamTraits<A3>::ForwardType a3, |
| 520 typename CallbackParamTraits<A4>::ForwardType a4, |
| 521 typename CallbackParamTraits<A5>::ForwardType a5, |
| 522 typename CallbackParamTraits<A6>::ForwardType a6) { |
| 523 return (object->*method_)(a1, a2, a3, a4, a5, a6); |
| 524 } |
| 525 |
| 526 private: |
| 527 R (T::*method_)(A1, A2, A3, A4, A5, A6); |
| 528 }; |
| 529 |
| 530 // Const Method: Arity 6. |
| 531 template <typename R, typename T, typename A1, typename A2, typename A3, |
| 532 typename A4, typename A5, typename A6> |
| 533 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6) const> { |
| 534 public: |
| 535 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6); |
| 536 typedef true_type IsMethod; |
| 537 |
| 538 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const) |
| 539 : method_(method) { |
| 540 } |
| 541 |
| 542 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, |
| 543 typename CallbackParamTraits<A2>::ForwardType a2, |
| 544 typename CallbackParamTraits<A3>::ForwardType a3, |
| 545 typename CallbackParamTraits<A4>::ForwardType a4, |
| 546 typename CallbackParamTraits<A5>::ForwardType a5, |
| 547 typename CallbackParamTraits<A6>::ForwardType a6) { |
| 548 return (object->*method_)(a1, a2, a3, a4, a5, a6); |
| 549 } |
| 550 |
| 551 private: |
| 552 R (T::*method_)(A1, A2, A3, A4, A5, A6) const; |
| 553 }; |
| 554 |
| 58 | 555 |
| 59 // FunctionTraits<> | 556 // FunctionTraits<> |
| 60 // | 557 // |
| 61 // The FunctionTraits<> template determines the type of function, and also | 558 // Breaks a function signature apart into typedefs for easier introspection. |
| 62 // creates a NormalizedType used to select the InvokerN classes. It turns out | |
| 63 // that syntactically, you only really have 2 variations when invoking a | |
| 64 // funciton pointer: normal, and method. One is invoked func_ptr(arg1). The | |
| 65 // other is invoked (*obj_->method_ptr(arg1)). | |
| 66 // | |
| 67 // However, in the type system, there are many more distinctions. In standard | |
| 68 // C++, there's all variations of const, and volatile on the function pointer. | |
| 69 // In Windows, there are additional calling conventions (eg., __stdcall, | |
| 70 // __fastcall, etc.). FunctionTraits<> handles categorizing each of these into | |
| 71 // a normalized signature. | |
| 72 // | |
| 73 // Having a NormalizedSignature signature, reduces the combinatoric | |
| 74 // complexity of defintions for the InvokerN<> later. Even though there are | |
| 75 // only 2 syntactic variations on invoking a function, without normalizing the | |
| 76 // signature, there would need to be one specialization of InvokerN for each | |
| 77 // unique (function_type, bound_arg, unbound_args) tuple in order to match all | |
| 78 // function signatures. | |
| 79 // | |
| 80 // By normalizing the function signature, we reduce function_type to exactly 2. | |
| 81 | |
| 82 template <typename Sig> | 559 template <typename Sig> |
| 83 struct FunctionTraits; | 560 struct FunctionTraits; |
| 84 | 561 |
| 85 // Function: Arity 0. | |
| 86 template <typename R> | 562 template <typename R> |
| 87 struct FunctionTraits<R(*)()> { | 563 struct FunctionTraits<R()> { |
| 88 typedef R (*NormalizedSig)(); | 564 typedef R ReturnType; |
| 89 typedef false_type IsMethod; | 565 }; |
| 90 | 566 |
| 91 typedef R Return; | 567 template <typename R, typename A1> |
| 92 | 568 struct FunctionTraits<R(A1)> { |
| 93 }; | 569 typedef R ReturnType; |
| 94 | 570 typedef A1 A1Type; |
| 95 // Method: Arity 0. | 571 }; |
| 96 template <typename R, typename T> | 572 |
| 97 struct FunctionTraits<R(T::*)()> { | 573 template <typename R, typename A1, typename A2> |
| 98 typedef R (T::*NormalizedSig)(); | 574 struct FunctionTraits<R(A1, A2)> { |
| 99 typedef true_type IsMethod; | 575 typedef R ReturnType; |
| 100 | 576 typedef A1 A1Type; |
| 101 typedef R Return; | 577 typedef A2 A2Type; |
| 102 | 578 }; |
| 103 // Target type for each bound parameter. | 579 |
| 104 typedef T B1; | 580 template <typename R, typename A1, typename A2, typename A3> |
| 105 | 581 struct FunctionTraits<R(A1, A2, A3)> { |
| 106 }; | 582 typedef R ReturnType; |
| 107 | 583 typedef A1 A1Type; |
| 108 // Const Method: Arity 0. | 584 typedef A2 A2Type; |
| 109 template <typename R, typename T> | 585 typedef A3 A3Type; |
| 110 struct FunctionTraits<R(T::*)() const> { | 586 }; |
| 111 typedef R (T::*NormalizedSig)(); | 587 |
| 112 typedef true_type IsMethod; | 588 template <typename R, typename A1, typename A2, typename A3, typename A4> |
| 113 | 589 struct FunctionTraits<R(A1, A2, A3, A4)> { |
| 114 typedef R Return; | 590 typedef R ReturnType; |
| 115 | 591 typedef A1 A1Type; |
| 116 // Target type for each bound parameter. | 592 typedef A2 A2Type; |
| 117 typedef T B1; | 593 typedef A3 A3Type; |
| 118 | 594 typedef A4 A4Type; |
| 119 }; | 595 }; |
| 120 | 596 |
| 121 // Function: Arity 1. | 597 template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 122 template <typename R, typename X1> | 598 typename A5> |
| 123 struct FunctionTraits<R(*)(X1)> { | 599 struct FunctionTraits<R(A1, A2, A3, A4, A5)> { |
| 124 typedef R (*NormalizedSig)(X1); | 600 typedef R ReturnType; |
| 125 typedef false_type IsMethod; | 601 typedef A1 A1Type; |
| 126 | 602 typedef A2 A2Type; |
| 127 typedef R Return; | 603 typedef A3 A3Type; |
| 128 | 604 typedef A4 A4Type; |
| 129 // Target type for each bound parameter. | 605 typedef A5 A5Type; |
| 130 typedef X1 B1; | 606 }; |
| 131 | 607 |
| 132 }; | 608 template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 133 | 609 typename A5, typename A6> |
| 134 // Method: Arity 1. | 610 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6)> { |
| 135 template <typename R, typename T, typename X1> | 611 typedef R ReturnType; |
| 136 struct FunctionTraits<R(T::*)(X1)> { | 612 typedef A1 A1Type; |
| 137 typedef R (T::*NormalizedSig)(X1); | 613 typedef A2 A2Type; |
| 138 typedef true_type IsMethod; | 614 typedef A3 A3Type; |
| 139 | 615 typedef A4 A4Type; |
| 140 typedef R Return; | 616 typedef A5 A5Type; |
| 141 | 617 typedef A6 A6Type; |
| 142 // Target type for each bound parameter. | 618 }; |
| 143 typedef T B1; | 619 |
| 144 typedef X1 B2; | 620 |
| 145 | 621 // ForceVoidReturn<> |
| 146 }; | |
| 147 | |
| 148 // Const Method: Arity 1. | |
| 149 template <typename R, typename T, typename X1> | |
| 150 struct FunctionTraits<R(T::*)(X1) const> { | |
| 151 typedef R (T::*NormalizedSig)(X1); | |
| 152 typedef true_type IsMethod; | |
| 153 | |
| 154 typedef R Return; | |
| 155 | |
| 156 // Target type for each bound parameter. | |
| 157 typedef T B1; | |
| 158 typedef X1 B2; | |
| 159 | |
| 160 }; | |
| 161 | |
| 162 // Function: Arity 2. | |
| 163 template <typename R, typename X1, typename X2> | |
| 164 struct FunctionTraits<R(*)(X1, X2)> { | |
| 165 typedef R (*NormalizedSig)(X1, X2); | |
| 166 typedef false_type IsMethod; | |
| 167 | |
| 168 typedef R Return; | |
| 169 | |
| 170 // Target type for each bound parameter. | |
| 171 typedef X1 B1; | |
| 172 typedef X2 B2; | |
| 173 | |
| 174 }; | |
| 175 | |
| 176 // Method: Arity 2. | |
| 177 template <typename R, typename T, typename X1, typename X2> | |
| 178 struct FunctionTraits<R(T::*)(X1, X2)> { | |
| 179 typedef R (T::*NormalizedSig)(X1, X2); | |
| 180 typedef true_type IsMethod; | |
| 181 | |
| 182 typedef R Return; | |
| 183 | |
| 184 // Target type for each bound parameter. | |
| 185 typedef T B1; | |
| 186 typedef X1 B2; | |
| 187 typedef X2 B3; | |
| 188 | |
| 189 }; | |
| 190 | |
| 191 // Const Method: Arity 2. | |
| 192 template <typename R, typename T, typename X1, typename X2> | |
| 193 struct FunctionTraits<R(T::*)(X1, X2) const> { | |
| 194 typedef R (T::*NormalizedSig)(X1, X2); | |
| 195 typedef true_type IsMethod; | |
| 196 | |
| 197 typedef R Return; | |
| 198 | |
| 199 // Target type for each bound parameter. | |
| 200 typedef T B1; | |
| 201 typedef X1 B2; | |
| 202 typedef X2 B3; | |
| 203 | |
| 204 }; | |
| 205 | |
| 206 // Function: Arity 3. | |
| 207 template <typename R, typename X1, typename X2, typename X3> | |
| 208 struct FunctionTraits<R(*)(X1, X2, X3)> { | |
| 209 typedef R (*NormalizedSig)(X1, X2, X3); | |
| 210 typedef false_type IsMethod; | |
| 211 | |
| 212 typedef R Return; | |
| 213 | |
| 214 // Target type for each bound parameter. | |
| 215 typedef X1 B1; | |
| 216 typedef X2 B2; | |
| 217 typedef X3 B3; | |
| 218 | |
| 219 }; | |
| 220 | |
| 221 // Method: Arity 3. | |
| 222 template <typename R, typename T, typename X1, typename X2, typename X3> | |
| 223 struct FunctionTraits<R(T::*)(X1, X2, X3)> { | |
| 224 typedef R (T::*NormalizedSig)(X1, X2, X3); | |
| 225 typedef true_type IsMethod; | |
| 226 | |
| 227 typedef R Return; | |
| 228 | |
| 229 // Target type for each bound parameter. | |
| 230 typedef T B1; | |
| 231 typedef X1 B2; | |
| 232 typedef X2 B3; | |
| 233 typedef X3 B4; | |
| 234 | |
| 235 }; | |
| 236 | |
| 237 // Const Method: Arity 3. | |
| 238 template <typename R, typename T, typename X1, typename X2, typename X3> | |
| 239 struct FunctionTraits<R(T::*)(X1, X2, X3) const> { | |
| 240 typedef R (T::*NormalizedSig)(X1, X2, X3); | |
| 241 typedef true_type IsMethod; | |
| 242 | |
| 243 typedef R Return; | |
| 244 | |
| 245 // Target type for each bound parameter. | |
| 246 typedef T B1; | |
| 247 typedef X1 B2; | |
| 248 typedef X2 B3; | |
| 249 typedef X3 B4; | |
| 250 | |
| 251 }; | |
| 252 | |
| 253 // Function: Arity 4. | |
| 254 template <typename R, typename X1, typename X2, typename X3, typename X4> | |
| 255 struct FunctionTraits<R(*)(X1, X2, X3, X4)> { | |
| 256 typedef R (*NormalizedSig)(X1, X2, X3, X4); | |
| 257 typedef false_type IsMethod; | |
| 258 | |
| 259 typedef R Return; | |
| 260 | |
| 261 // Target type for each bound parameter. | |
| 262 typedef X1 B1; | |
| 263 typedef X2 B2; | |
| 264 typedef X3 B3; | |
| 265 typedef X4 B4; | |
| 266 | |
| 267 }; | |
| 268 | |
| 269 // Method: Arity 4. | |
| 270 template <typename R, typename T, typename X1, typename X2, typename X3, | |
| 271 typename X4> | |
| 272 struct FunctionTraits<R(T::*)(X1, X2, X3, X4)> { | |
| 273 typedef R (T::*NormalizedSig)(X1, X2, X3, X4); | |
| 274 typedef true_type IsMethod; | |
| 275 | |
| 276 typedef R Return; | |
| 277 | |
| 278 // Target type for each bound parameter. | |
| 279 typedef T B1; | |
| 280 typedef X1 B2; | |
| 281 typedef X2 B3; | |
| 282 typedef X3 B4; | |
| 283 typedef X4 B5; | |
| 284 | |
| 285 }; | |
| 286 | |
| 287 // Const Method: Arity 4. | |
| 288 template <typename R, typename T, typename X1, typename X2, typename X3, | |
| 289 typename X4> | |
| 290 struct FunctionTraits<R(T::*)(X1, X2, X3, X4) const> { | |
| 291 typedef R (T::*NormalizedSig)(X1, X2, X3, X4); | |
| 292 typedef true_type IsMethod; | |
| 293 | |
| 294 typedef R Return; | |
| 295 | |
| 296 // Target type for each bound parameter. | |
| 297 typedef T B1; | |
| 298 typedef X1 B2; | |
| 299 typedef X2 B3; | |
| 300 typedef X3 B4; | |
| 301 typedef X4 B5; | |
| 302 | |
| 303 }; | |
| 304 | |
| 305 // Function: Arity 5. | |
| 306 template <typename R, typename X1, typename X2, typename X3, typename X4, | |
| 307 typename X5> | |
| 308 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5)> { | |
| 309 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5); | |
| 310 typedef false_type IsMethod; | |
| 311 | |
| 312 typedef R Return; | |
| 313 | |
| 314 // Target type for each bound parameter. | |
| 315 typedef X1 B1; | |
| 316 typedef X2 B2; | |
| 317 typedef X3 B3; | |
| 318 typedef X4 B4; | |
| 319 typedef X5 B5; | |
| 320 | |
| 321 }; | |
| 322 | |
| 323 // Method: Arity 5. | |
| 324 template <typename R, typename T, typename X1, typename X2, typename X3, | |
| 325 typename X4, typename X5> | |
| 326 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5)> { | |
| 327 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); | |
| 328 typedef true_type IsMethod; | |
| 329 | |
| 330 typedef R Return; | |
| 331 | |
| 332 // Target type for each bound parameter. | |
| 333 typedef T B1; | |
| 334 typedef X1 B2; | |
| 335 typedef X2 B3; | |
| 336 typedef X3 B4; | |
| 337 typedef X4 B5; | |
| 338 typedef X5 B6; | |
| 339 | |
| 340 }; | |
| 341 | |
| 342 // Const Method: Arity 5. | |
| 343 template <typename R, typename T, typename X1, typename X2, typename X3, | |
| 344 typename X4, typename X5> | |
| 345 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5) const> { | |
| 346 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); | |
| 347 typedef true_type IsMethod; | |
| 348 | |
| 349 typedef R Return; | |
| 350 | |
| 351 // Target type for each bound parameter. | |
| 352 typedef T B1; | |
| 353 typedef X1 B2; | |
| 354 typedef X2 B3; | |
| 355 typedef X3 B4; | |
| 356 typedef X4 B5; | |
| 357 typedef X5 B6; | |
| 358 | |
| 359 }; | |
| 360 | |
| 361 // Function: Arity 6. | |
| 362 template <typename R, typename X1, typename X2, typename X3, typename X4, | |
| 363 typename X5, typename X6> | |
| 364 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5, X6)> { | |
| 365 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5, X6); | |
| 366 typedef false_type IsMethod; | |
| 367 | |
| 368 typedef R Return; | |
| 369 | |
| 370 // Target type for each bound parameter. | |
| 371 typedef X1 B1; | |
| 372 typedef X2 B2; | |
| 373 typedef X3 B3; | |
| 374 typedef X4 B4; | |
| 375 typedef X5 B5; | |
| 376 typedef X6 B6; | |
| 377 | |
| 378 }; | |
| 379 | |
| 380 // Method: Arity 6. | |
| 381 template <typename R, typename T, typename X1, typename X2, typename X3, | |
| 382 typename X4, typename X5, typename X6> | |
| 383 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6)> { | |
| 384 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); | |
| 385 typedef true_type IsMethod; | |
| 386 | |
| 387 typedef R Return; | |
| 388 | |
| 389 // Target type for each bound parameter. | |
| 390 typedef T B1; | |
| 391 typedef X1 B2; | |
| 392 typedef X2 B3; | |
| 393 typedef X3 B4; | |
| 394 typedef X4 B5; | |
| 395 typedef X5 B6; | |
| 396 typedef X6 B7; | |
| 397 | |
| 398 }; | |
| 399 | |
| 400 // Const Method: Arity 6. | |
| 401 template <typename R, typename T, typename X1, typename X2, typename X3, | |
| 402 typename X4, typename X5, typename X6> | |
| 403 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6) const> { | |
| 404 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); | |
| 405 typedef true_type IsMethod; | |
| 406 | |
| 407 typedef R Return; | |
| 408 | |
| 409 // Target type for each bound parameter. | |
| 410 typedef T B1; | |
| 411 typedef X1 B2; | |
| 412 typedef X2 B3; | |
| 413 typedef X3 B4; | |
| 414 typedef X4 B5; | |
| 415 typedef X5 B6; | |
| 416 typedef X6 B7; | |
| 417 | |
| 418 }; | |
| 419 | |
| 420 // InvokerN<> | |
| 421 // | 622 // |
| 422 // The InvokerN templates contain a static DoInvoke() function that is the key | 623 // Set of templates that support forcing the function return type to void. |
| 423 // to implementing type erasure in the Callback() classes. | 624 template <typename Sig> |
| 625 struct ForceVoidReturn; |
| 626 |
| 627 template <typename R> |
| 628 struct ForceVoidReturn<R()> { |
| 629 typedef void(RunType)(); |
| 630 }; |
| 631 |
| 632 template <typename R, typename A1> |
| 633 struct ForceVoidReturn<R(A1)> { |
| 634 typedef void(RunType)(A1); |
| 635 }; |
| 636 |
| 637 template <typename R, typename A1, typename A2> |
| 638 struct ForceVoidReturn<R(A1, A2)> { |
| 639 typedef void(RunType)(A1, A2); |
| 640 }; |
| 641 |
| 642 template <typename R, typename A1, typename A2, typename A3> |
| 643 struct ForceVoidReturn<R(A1, A2, A3)> { |
| 644 typedef void(RunType)(A1, A2, A3); |
| 645 }; |
| 646 |
| 647 template <typename R, typename A1, typename A2, typename A3, typename A4> |
| 648 struct ForceVoidReturn<R(A1, A2, A3, A4)> { |
| 649 typedef void(RunType)(A1, A2, A3, A4); |
| 650 }; |
| 651 |
| 652 template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 653 typename A5> |
| 654 struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> { |
| 655 typedef void(RunType)(A1, A2, A3, A4, A5); |
| 656 }; |
| 657 |
| 658 template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 659 typename A5, typename A6> |
| 660 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> { |
| 661 typedef void(RunType)(A1, A2, A3, A4, A5, A6); |
| 662 }; |
| 663 |
| 664 |
| 665 // FunctorTraits<> |
| 424 // | 666 // |
| 425 // DoInvoke() is a static function with a fixed signature that is independent | 667 // See description at top of file. |
| 426 // of StorageType; its first argument is a pointer to the non-templated common | 668 template <typename T> |
| 427 // baseclass of StorageType. This lets us store pointer to DoInvoke() in a | 669 struct FunctorTraits { |
| 428 // function pointer that has knowledge of the specific StorageType, and thus | 670 typedef RunnableAdapter<T> RunnableType; |
| 429 // no knowledge of the bound function and bound parameter types. | 671 typedef typename RunnableType::RunType RunType; |
| 672 }; |
| 673 |
| 674 template <typename T> |
| 675 struct FunctorTraits<IgnoreResultHelper<T> > { |
| 676 typedef typename FunctorTraits<T>::RunnableType RunnableType; |
| 677 typedef typename ForceVoidReturn< |
| 678 typename RunnableType::RunType>::RunType RunType; |
| 679 }; |
| 680 |
| 681 template <typename T> |
| 682 struct FunctorTraits<Callback<T> > { |
| 683 typedef Callback<T> RunnableType; |
| 684 typedef typename Callback<T>::RunType RunType; |
| 685 }; |
| 686 |
| 687 |
| 688 // MakeRunnable<> |
| 430 // | 689 // |
| 431 // As long as we ensure that DoInvoke() is only used with pointers there were | 690 // Converts a passed in functor to a RunnableType using type inference. |
| 432 // upcasted from the correct StorageType, we can be sure that execution is | 691 |
| 433 // safe. | 692 template <typename T> |
| 693 typename FunctorTraits<T>::RunnableType MakeRunnable(const T& t) { |
| 694 return RunnableAdapter<T>(t); |
| 695 } |
| 696 |
| 697 template <typename T> |
| 698 typename FunctorTraits<T>::RunnableType |
| 699 MakeRunnable(const IgnoreResultHelper<T>& t) { |
| 700 return MakeRunnable(t.functor_); |
| 701 } |
| 702 |
| 703 template <typename T> |
| 704 const typename FunctorTraits<Callback<T> >::RunnableType& |
| 705 MakeRunnable(const Callback<T>& t) { |
| 706 return t; |
| 707 } |
| 708 |
| 709 |
| 710 // InvokeHelper<> |
| 434 // | 711 // |
| 435 // The InvokerN templates are the only point that knows the number of bound | 712 // There are 3 logical InvokeHelper<> specializations: normal, void-return, |
| 436 // and unbound arguments. This is intentional because it allows the other | 713 // WeakCalls. |
| 437 // templates classes in the system to only have as many specializations as | 714 // |
| 438 // the max arity of function we wish to support. | 715 // The normal type just calls the underlying runnable. |
| 439 | 716 // |
| 440 template <bool IsWeak, typename StorageType, typename NormalizedSig> | 717 // We need a InvokeHelper to handle void return types in order to support |
| 441 struct Invoker0; | 718 // IgnoreResult(). Normally, if the Runnable's RunType had a void return, |
| 442 | 719 // the template system would just accept "return functor.Run()" ignoring |
| 443 // Function: Arity 0 -> 0. | 720 // the fact that a void function is being used with return. This piece of |
| 721 // sugar breaks though when the Runnable's RunType is not void. Thus, we |
| 722 // need a partial specialization to change the syntax to drop the "return" |
| 723 // from the invocation call. |
| 724 // |
| 725 // WeakCalls similarly need special syntax that is applied to the first |
| 726 // argument to check if they should no-op themselves. |
| 727 template <bool IsWeakCall, typename ReturnType, typename Runnable, |
| 728 typename ArgsType> |
| 729 struct InvokeHelper; |
| 730 |
| 731 template <typename ReturnType, typename Runnable> |
| 732 struct InvokeHelper<false, ReturnType, Runnable, |
| 733 void()> { |
| 734 static ReturnType MakeItSo(Runnable runnable) { |
| 735 return runnable.Run(); |
| 736 } |
| 737 }; |
| 738 |
| 739 template <typename Runnable> |
| 740 struct InvokeHelper<false, void, Runnable, |
| 741 void()> { |
| 742 static void MakeItSo(Runnable runnable) { |
| 743 runnable.Run(); |
| 744 } |
| 745 }; |
| 746 |
| 747 template <typename ReturnType, typename Runnable,typename A1> |
| 748 struct InvokeHelper<false, ReturnType, Runnable, |
| 749 void(A1)> { |
| 750 static ReturnType MakeItSo(Runnable runnable, A1 a1) { |
| 751 return runnable.Run(a1); |
| 752 } |
| 753 }; |
| 754 |
| 755 template <typename Runnable,typename A1> |
| 756 struct InvokeHelper<false, void, Runnable, |
| 757 void(A1)> { |
| 758 static void MakeItSo(Runnable runnable, A1 a1) { |
| 759 runnable.Run(a1); |
| 760 } |
| 761 }; |
| 762 |
| 763 template <typename Runnable, typename A1> |
| 764 struct InvokeHelper<true, void, Runnable, |
| 765 void(A1)> { |
| 766 static void MakeItSo(Runnable runnable, A1 a1) { |
| 767 if (!a1.get()) { |
| 768 return; |
| 769 } |
| 770 |
| 771 runnable.Run(a1); |
| 772 } |
| 773 }; |
| 774 |
| 775 template <typename ReturnType, typename Runnable,typename A1, typename A2> |
| 776 struct InvokeHelper<false, ReturnType, Runnable, |
| 777 void(A1, A2)> { |
| 778 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) { |
| 779 return runnable.Run(a1, a2); |
| 780 } |
| 781 }; |
| 782 |
| 783 template <typename Runnable,typename A1, typename A2> |
| 784 struct InvokeHelper<false, void, Runnable, |
| 785 void(A1, A2)> { |
| 786 static void MakeItSo(Runnable runnable, A1 a1, A2 a2) { |
| 787 runnable.Run(a1, a2); |
| 788 } |
| 789 }; |
| 790 |
| 791 template <typename Runnable, typename A1, typename A2> |
| 792 struct InvokeHelper<true, void, Runnable, |
| 793 void(A1, A2)> { |
| 794 static void MakeItSo(Runnable runnable, A1 a1, A2 a2) { |
| 795 if (!a1.get()) { |
| 796 return; |
| 797 } |
| 798 |
| 799 runnable.Run(a1, a2); |
| 800 } |
| 801 }; |
| 802 |
| 803 template <typename ReturnType, typename Runnable,typename A1, typename A2, |
| 804 typename A3> |
| 805 struct InvokeHelper<false, ReturnType, Runnable, |
| 806 void(A1, A2, A3)> { |
| 807 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { |
| 808 return runnable.Run(a1, a2, a3); |
| 809 } |
| 810 }; |
| 811 |
| 812 template <typename Runnable,typename A1, typename A2, typename A3> |
| 813 struct InvokeHelper<false, void, Runnable, |
| 814 void(A1, A2, A3)> { |
| 815 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { |
| 816 runnable.Run(a1, a2, a3); |
| 817 } |
| 818 }; |
| 819 |
| 820 template <typename Runnable, typename A1, typename A2, typename A3> |
| 821 struct InvokeHelper<true, void, Runnable, |
| 822 void(A1, A2, A3)> { |
| 823 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { |
| 824 if (!a1.get()) { |
| 825 return; |
| 826 } |
| 827 |
| 828 runnable.Run(a1, a2, a3); |
| 829 } |
| 830 }; |
| 831 |
| 832 template <typename ReturnType, typename Runnable,typename A1, typename A2, |
| 833 typename A3, typename A4> |
| 834 struct InvokeHelper<false, ReturnType, Runnable, |
| 835 void(A1, A2, A3, A4)> { |
| 836 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { |
| 837 return runnable.Run(a1, a2, a3, a4); |
| 838 } |
| 839 }; |
| 840 |
| 841 template <typename Runnable,typename A1, typename A2, typename A3, typename A4> |
| 842 struct InvokeHelper<false, void, Runnable, |
| 843 void(A1, A2, A3, A4)> { |
| 844 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { |
| 845 runnable.Run(a1, a2, a3, a4); |
| 846 } |
| 847 }; |
| 848 |
| 849 template <typename Runnable, typename A1, typename A2, typename A3, typename A4> |
| 850 struct InvokeHelper<true, void, Runnable, |
| 851 void(A1, A2, A3, A4)> { |
| 852 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { |
| 853 if (!a1.get()) { |
| 854 return; |
| 855 } |
| 856 |
| 857 runnable.Run(a1, a2, a3, a4); |
| 858 } |
| 859 }; |
| 860 |
| 861 template <typename ReturnType, typename Runnable,typename A1, typename A2, |
| 862 typename A3, typename A4, typename A5> |
| 863 struct InvokeHelper<false, ReturnType, Runnable, |
| 864 void(A1, A2, A3, A4, A5)> { |
| 865 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, |
| 866 A5 a5) { |
| 867 return runnable.Run(a1, a2, a3, a4, a5); |
| 868 } |
| 869 }; |
| 870 |
| 871 template <typename Runnable,typename A1, typename A2, typename A3, typename A4, |
| 872 typename A5> |
| 873 struct InvokeHelper<false, void, Runnable, |
| 874 void(A1, A2, A3, A4, A5)> { |
| 875 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { |
| 876 runnable.Run(a1, a2, a3, a4, a5); |
| 877 } |
| 878 }; |
| 879 |
| 880 template <typename Runnable, typename A1, typename A2, typename A3, |
| 881 typename A4, typename A5> |
| 882 struct InvokeHelper<true, void, Runnable, |
| 883 void(A1, A2, A3, A4, A5)> { |
| 884 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { |
| 885 if (!a1.get()) { |
| 886 return; |
| 887 } |
| 888 |
| 889 runnable.Run(a1, a2, a3, a4, a5); |
| 890 } |
| 891 }; |
| 892 |
| 893 template <typename ReturnType, typename Runnable,typename A1, typename A2, |
| 894 typename A3, typename A4, typename A5, typename A6> |
| 895 struct InvokeHelper<false, ReturnType, Runnable, |
| 896 void(A1, A2, A3, A4, A5, A6)> { |
| 897 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, |
| 898 A5 a5, A6 a6) { |
| 899 return runnable.Run(a1, a2, a3, a4, a5, a6); |
| 900 } |
| 901 }; |
| 902 |
| 903 template <typename Runnable,typename A1, typename A2, typename A3, typename A4, |
| 904 typename A5, typename A6> |
| 905 struct InvokeHelper<false, void, Runnable, |
| 906 void(A1, A2, A3, A4, A5, A6)> { |
| 907 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, |
| 908 A6 a6) { |
| 909 runnable.Run(a1, a2, a3, a4, a5, a6); |
| 910 } |
| 911 }; |
| 912 |
| 913 template <typename Runnable, typename A1, typename A2, typename A3, |
| 914 typename A4, typename A5, typename A6> |
| 915 struct InvokeHelper<true, void, Runnable, |
| 916 void(A1, A2, A3, A4, A5, A6)> { |
| 917 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, |
| 918 A6 a6) { |
| 919 if (!a1.get()) { |
| 920 return; |
| 921 } |
| 922 |
| 923 runnable.Run(a1, a2, a3, a4, a5, a6); |
| 924 } |
| 925 }; |
| 926 |
| 927 #if !defined(_MSC_VER) |
| 928 |
| 929 template <typename ReturnType, typename Runnable, typename ArgsType> |
| 930 struct InvokeHelper<true, ReturnType, Runnable, ArgsType> { |
| 931 // WeakCalls are only supported for functions with a void return type. |
| 932 // Otherwise, the function result would be undefined if the the WeakPtr<> |
| 933 // is invalidated. |
| 934 COMPILE_ASSERT(is_void<ReturnType>::value, |
| 935 weak_ptrs_can_only_bind_to_methods_without_return_values); |
| 936 }; |
| 937 |
| 938 #endif |
| 939 |
| 940 // Invoker<> |
| 941 // |
| 942 // See description at the top of the file. |
| 943 template <int NumBound, typename Storage, typename RunType> |
| 944 struct Invoker; |
| 945 |
| 946 // Arity 0 -> 0. |
| 444 template <typename StorageType, typename R> | 947 template <typename StorageType, typename R> |
| 445 struct Invoker0<false, StorageType, R(*)()> { | 948 struct Invoker<0, StorageType, R()> { |
| 446 typedef R(*DoInvokeType)( | 949 typedef R(RunType)(BindStateBase*); |
| 447 internal::InvokerStorageBase*); | 950 |
| 448 | 951 typedef R(UnboundRunType)(); |
| 449 static R DoInvoke(InvokerStorageBase* base) { | 952 |
| 450 StorageType* invoker = static_cast<StorageType*>(base); | 953 static R Run(BindStateBase* base) { |
| 451 return invoker->f_(); | 954 StorageType* storage = static_cast<StorageType*>(base); |
| 452 } | 955 |
| 453 }; | 956 // Local references to make debugger stepping easier. If in a debugger, |
| 454 | 957 // you really want to warp ahead and step through the |
| 455 // Function: Arity 1 -> 1. | 958 // InvokeHelper<>::MakeItSo() call below. |
| 959 |
| 960 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 961 typename StorageType::RunnableType, |
| 962 void()> |
| 963 ::MakeItSo(storage->runnable_); |
| 964 } |
| 965 }; |
| 966 |
| 967 // Arity 1 -> 1. |
| 456 template <typename StorageType, typename R,typename X1> | 968 template <typename StorageType, typename R,typename X1> |
| 457 struct Invoker0<false, StorageType, R(*)(X1)> { | 969 struct Invoker<0, StorageType, R(X1)> { |
| 458 typedef R(*DoInvokeType)( | 970 typedef R(RunType)(BindStateBase*, |
| 459 internal::InvokerStorageBase*, | 971 typename CallbackParamTraits<X1>::ForwardType); |
| 460 typename internal::ParamTraits<X1>::ForwardType); | 972 |
| 461 | 973 typedef R(UnboundRunType)(X1); |
| 462 static R DoInvoke(InvokerStorageBase* base, | 974 |
| 463 typename internal::ParamTraits<X1>::ForwardType x1) { | 975 static R Run(BindStateBase* base, |
| 464 StorageType* invoker = static_cast<StorageType*>(base); | 976 typename CallbackParamTraits<X1>::ForwardType x1) { |
| 465 return invoker->f_(x1); | 977 StorageType* storage = static_cast<StorageType*>(base); |
| 466 } | 978 |
| 467 }; | 979 // Local references to make debugger stepping easier. If in a debugger, |
| 468 | 980 // you really want to warp ahead and step through the |
| 469 // Function: Arity 2 -> 2. | 981 // InvokeHelper<>::MakeItSo() call below. |
| 982 |
| 983 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 984 typename StorageType::RunnableType, |
| 985 void(typename CallbackParamTraits<X1>::ForwardType x1)> |
| 986 ::MakeItSo(storage->runnable_, x1); |
| 987 } |
| 988 }; |
| 989 |
| 990 // Arity 1 -> 0. |
| 991 template <typename StorageType, typename R,typename X1> |
| 992 struct Invoker<1, StorageType, R(X1)> { |
| 993 typedef R(RunType)(BindStateBase*); |
| 994 |
| 995 typedef R(UnboundRunType)(); |
| 996 |
| 997 static R Run(BindStateBase* base) { |
| 998 StorageType* storage = static_cast<StorageType*>(base); |
| 999 |
| 1000 // Local references to make debugger stepping easier. If in a debugger, |
| 1001 // you really want to warp ahead and step through the |
| 1002 // InvokeHelper<>::MakeItSo() call below. |
| 1003 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1004 |
| 1005 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1006 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1007 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1008 typename StorageType::RunnableType, |
| 1009 void(typename Bound1UnwrapTraits::ForwardType)> |
| 1010 ::MakeItSo(storage->runnable_, x1); |
| 1011 } |
| 1012 }; |
| 1013 |
| 1014 // Arity 2 -> 2. |
| 470 template <typename StorageType, typename R,typename X1, typename X2> | 1015 template <typename StorageType, typename R,typename X1, typename X2> |
| 471 struct Invoker0<false, StorageType, R(*)(X1, X2)> { | 1016 struct Invoker<0, StorageType, R(X1, X2)> { |
| 472 typedef R(*DoInvokeType)( | 1017 typedef R(RunType)(BindStateBase*, |
| 473 internal::InvokerStorageBase*, | 1018 typename CallbackParamTraits<X1>::ForwardType, |
| 474 typename internal::ParamTraits<X1>::ForwardType, | 1019 typename CallbackParamTraits<X2>::ForwardType); |
| 475 typename internal::ParamTraits<X2>::ForwardType); | 1020 |
| 476 | 1021 typedef R(UnboundRunType)(X1, X2); |
| 477 static R DoInvoke(InvokerStorageBase* base, | 1022 |
| 478 typename internal::ParamTraits<X1>::ForwardType x1, | 1023 static R Run(BindStateBase* base, |
| 479 typename internal::ParamTraits<X2>::ForwardType x2) { | 1024 typename CallbackParamTraits<X1>::ForwardType x1, |
| 480 StorageType* invoker = static_cast<StorageType*>(base); | 1025 typename CallbackParamTraits<X2>::ForwardType x2) { |
| 481 return invoker->f_(x1, x2); | 1026 StorageType* storage = static_cast<StorageType*>(base); |
| 482 } | 1027 |
| 483 }; | 1028 // Local references to make debugger stepping easier. If in a debugger, |
| 484 | 1029 // you really want to warp ahead and step through the |
| 485 // Function: Arity 3 -> 3. | 1030 // InvokeHelper<>::MakeItSo() call below. |
| 1031 |
| 1032 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1033 typename StorageType::RunnableType, |
| 1034 void(typename CallbackParamTraits<X1>::ForwardType x1, |
| 1035 typename CallbackParamTraits<X2>::ForwardType x2)> |
| 1036 ::MakeItSo(storage->runnable_, x1, x2); |
| 1037 } |
| 1038 }; |
| 1039 |
| 1040 // Arity 2 -> 1. |
| 1041 template <typename StorageType, typename R,typename X1, typename X2> |
| 1042 struct Invoker<1, StorageType, R(X1, X2)> { |
| 1043 typedef R(RunType)(BindStateBase*, |
| 1044 typename CallbackParamTraits<X2>::ForwardType); |
| 1045 |
| 1046 typedef R(UnboundRunType)(X2); |
| 1047 |
| 1048 static R Run(BindStateBase* base, |
| 1049 typename CallbackParamTraits<X2>::ForwardType x2) { |
| 1050 StorageType* storage = static_cast<StorageType*>(base); |
| 1051 |
| 1052 // Local references to make debugger stepping easier. If in a debugger, |
| 1053 // you really want to warp ahead and step through the |
| 1054 // InvokeHelper<>::MakeItSo() call below. |
| 1055 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1056 |
| 1057 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1058 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1059 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1060 typename StorageType::RunnableType, |
| 1061 void(typename Bound1UnwrapTraits::ForwardType, |
| 1062 typename CallbackParamTraits<X2>::ForwardType x2)> |
| 1063 ::MakeItSo(storage->runnable_, x1, x2); |
| 1064 } |
| 1065 }; |
| 1066 |
| 1067 // Arity 2 -> 0. |
| 1068 template <typename StorageType, typename R,typename X1, typename X2> |
| 1069 struct Invoker<2, StorageType, R(X1, X2)> { |
| 1070 typedef R(RunType)(BindStateBase*); |
| 1071 |
| 1072 typedef R(UnboundRunType)(); |
| 1073 |
| 1074 static R Run(BindStateBase* base) { |
| 1075 StorageType* storage = static_cast<StorageType*>(base); |
| 1076 |
| 1077 // Local references to make debugger stepping easier. If in a debugger, |
| 1078 // you really want to warp ahead and step through the |
| 1079 // InvokeHelper<>::MakeItSo() call below. |
| 1080 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1081 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1082 |
| 1083 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1084 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1085 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1086 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1087 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1088 typename StorageType::RunnableType, |
| 1089 void(typename Bound1UnwrapTraits::ForwardType, |
| 1090 typename Bound2UnwrapTraits::ForwardType)> |
| 1091 ::MakeItSo(storage->runnable_, x1, x2); |
| 1092 } |
| 1093 }; |
| 1094 |
| 1095 // Arity 3 -> 3. |
| 486 template <typename StorageType, typename R,typename X1, typename X2, | 1096 template <typename StorageType, typename R,typename X1, typename X2, |
| 487 typename X3> | 1097 typename X3> |
| 488 struct Invoker0<false, StorageType, R(*)(X1, X2, X3)> { | 1098 struct Invoker<0, StorageType, R(X1, X2, X3)> { |
| 489 typedef R(*DoInvokeType)( | 1099 typedef R(RunType)(BindStateBase*, |
| 490 internal::InvokerStorageBase*, | 1100 typename CallbackParamTraits<X1>::ForwardType, |
| 491 typename internal::ParamTraits<X1>::ForwardType, | 1101 typename CallbackParamTraits<X2>::ForwardType, |
| 492 typename internal::ParamTraits<X2>::ForwardType, | 1102 typename CallbackParamTraits<X3>::ForwardType); |
| 493 typename internal::ParamTraits<X3>::ForwardType); | 1103 |
| 494 | 1104 typedef R(UnboundRunType)(X1, X2, X3); |
| 495 static R DoInvoke(InvokerStorageBase* base, | 1105 |
| 496 typename internal::ParamTraits<X1>::ForwardType x1, | 1106 static R Run(BindStateBase* base, |
| 497 typename internal::ParamTraits<X2>::ForwardType x2, | 1107 typename CallbackParamTraits<X1>::ForwardType x1, |
| 498 typename internal::ParamTraits<X3>::ForwardType x3) { | 1108 typename CallbackParamTraits<X2>::ForwardType x2, |
| 499 StorageType* invoker = static_cast<StorageType*>(base); | 1109 typename CallbackParamTraits<X3>::ForwardType x3) { |
| 500 return invoker->f_(x1, x2, x3); | 1110 StorageType* storage = static_cast<StorageType*>(base); |
| 501 } | 1111 |
| 502 }; | 1112 // Local references to make debugger stepping easier. If in a debugger, |
| 503 | 1113 // you really want to warp ahead and step through the |
| 504 // Function: Arity 4 -> 4. | 1114 // InvokeHelper<>::MakeItSo() call below. |
| 1115 |
| 1116 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1117 typename StorageType::RunnableType, |
| 1118 void(typename CallbackParamTraits<X1>::ForwardType x1, |
| 1119 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1120 typename CallbackParamTraits<X3>::ForwardType x3)> |
| 1121 ::MakeItSo(storage->runnable_, x1, x2, x3); |
| 1122 } |
| 1123 }; |
| 1124 |
| 1125 // Arity 3 -> 2. |
| 1126 template <typename StorageType, typename R,typename X1, typename X2, |
| 1127 typename X3> |
| 1128 struct Invoker<1, StorageType, R(X1, X2, X3)> { |
| 1129 typedef R(RunType)(BindStateBase*, |
| 1130 typename CallbackParamTraits<X2>::ForwardType, |
| 1131 typename CallbackParamTraits<X3>::ForwardType); |
| 1132 |
| 1133 typedef R(UnboundRunType)(X2, X3); |
| 1134 |
| 1135 static R Run(BindStateBase* base, |
| 1136 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1137 typename CallbackParamTraits<X3>::ForwardType x3) { |
| 1138 StorageType* storage = static_cast<StorageType*>(base); |
| 1139 |
| 1140 // Local references to make debugger stepping easier. If in a debugger, |
| 1141 // you really want to warp ahead and step through the |
| 1142 // InvokeHelper<>::MakeItSo() call below. |
| 1143 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1144 |
| 1145 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1146 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1147 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1148 typename StorageType::RunnableType, |
| 1149 void(typename Bound1UnwrapTraits::ForwardType, |
| 1150 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1151 typename CallbackParamTraits<X3>::ForwardType x3)> |
| 1152 ::MakeItSo(storage->runnable_, x1, x2, x3); |
| 1153 } |
| 1154 }; |
| 1155 |
| 1156 // Arity 3 -> 1. |
| 1157 template <typename StorageType, typename R,typename X1, typename X2, |
| 1158 typename X3> |
| 1159 struct Invoker<2, StorageType, R(X1, X2, X3)> { |
| 1160 typedef R(RunType)(BindStateBase*, |
| 1161 typename CallbackParamTraits<X3>::ForwardType); |
| 1162 |
| 1163 typedef R(UnboundRunType)(X3); |
| 1164 |
| 1165 static R Run(BindStateBase* base, |
| 1166 typename CallbackParamTraits<X3>::ForwardType x3) { |
| 1167 StorageType* storage = static_cast<StorageType*>(base); |
| 1168 |
| 1169 // Local references to make debugger stepping easier. If in a debugger, |
| 1170 // you really want to warp ahead and step through the |
| 1171 // InvokeHelper<>::MakeItSo() call below. |
| 1172 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1173 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1174 |
| 1175 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1176 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1177 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1178 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1179 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1180 typename StorageType::RunnableType, |
| 1181 void(typename Bound1UnwrapTraits::ForwardType, |
| 1182 typename Bound2UnwrapTraits::ForwardType, |
| 1183 typename CallbackParamTraits<X3>::ForwardType x3)> |
| 1184 ::MakeItSo(storage->runnable_, x1, x2, x3); |
| 1185 } |
| 1186 }; |
| 1187 |
| 1188 // Arity 3 -> 0. |
| 1189 template <typename StorageType, typename R,typename X1, typename X2, |
| 1190 typename X3> |
| 1191 struct Invoker<3, StorageType, R(X1, X2, X3)> { |
| 1192 typedef R(RunType)(BindStateBase*); |
| 1193 |
| 1194 typedef R(UnboundRunType)(); |
| 1195 |
| 1196 static R Run(BindStateBase* base) { |
| 1197 StorageType* storage = static_cast<StorageType*>(base); |
| 1198 |
| 1199 // Local references to make debugger stepping easier. If in a debugger, |
| 1200 // you really want to warp ahead and step through the |
| 1201 // InvokeHelper<>::MakeItSo() call below. |
| 1202 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1203 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1204 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1205 |
| 1206 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1207 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1208 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1209 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1210 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1211 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1212 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1213 typename StorageType::RunnableType, |
| 1214 void(typename Bound1UnwrapTraits::ForwardType, |
| 1215 typename Bound2UnwrapTraits::ForwardType, |
| 1216 typename Bound3UnwrapTraits::ForwardType)> |
| 1217 ::MakeItSo(storage->runnable_, x1, x2, x3); |
| 1218 } |
| 1219 }; |
| 1220 |
| 1221 // Arity 4 -> 4. |
| 505 template <typename StorageType, typename R,typename X1, typename X2, | 1222 template <typename StorageType, typename R,typename X1, typename X2, |
| 506 typename X3, typename X4> | 1223 typename X3, typename X4> |
| 507 struct Invoker0<false, StorageType, R(*)(X1, X2, X3, X4)> { | 1224 struct Invoker<0, StorageType, R(X1, X2, X3, X4)> { |
| 508 typedef R(*DoInvokeType)( | 1225 typedef R(RunType)(BindStateBase*, |
| 509 internal::InvokerStorageBase*, | 1226 typename CallbackParamTraits<X1>::ForwardType, |
| 510 typename internal::ParamTraits<X1>::ForwardType, | 1227 typename CallbackParamTraits<X2>::ForwardType, |
| 511 typename internal::ParamTraits<X2>::ForwardType, | 1228 typename CallbackParamTraits<X3>::ForwardType, |
| 512 typename internal::ParamTraits<X3>::ForwardType, | 1229 typename CallbackParamTraits<X4>::ForwardType); |
| 513 typename internal::ParamTraits<X4>::ForwardType); | 1230 |
| 514 | 1231 typedef R(UnboundRunType)(X1, X2, X3, X4); |
| 515 static R DoInvoke(InvokerStorageBase* base, | 1232 |
| 516 typename internal::ParamTraits<X1>::ForwardType x1, | 1233 static R Run(BindStateBase* base, |
| 517 typename internal::ParamTraits<X2>::ForwardType x2, | 1234 typename CallbackParamTraits<X1>::ForwardType x1, |
| 518 typename internal::ParamTraits<X3>::ForwardType x3, | 1235 typename CallbackParamTraits<X2>::ForwardType x2, |
| 519 typename internal::ParamTraits<X4>::ForwardType x4) { | 1236 typename CallbackParamTraits<X3>::ForwardType x3, |
| 520 StorageType* invoker = static_cast<StorageType*>(base); | 1237 typename CallbackParamTraits<X4>::ForwardType x4) { |
| 521 return invoker->f_(x1, x2, x3, x4); | 1238 StorageType* storage = static_cast<StorageType*>(base); |
| 522 } | 1239 |
| 523 }; | 1240 // Local references to make debugger stepping easier. If in a debugger, |
| 524 | 1241 // you really want to warp ahead and step through the |
| 525 // Function: Arity 5 -> 5. | 1242 // InvokeHelper<>::MakeItSo() call below. |
| 1243 |
| 1244 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1245 typename StorageType::RunnableType, |
| 1246 void(typename CallbackParamTraits<X1>::ForwardType x1, |
| 1247 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1248 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1249 typename CallbackParamTraits<X4>::ForwardType x4)> |
| 1250 ::MakeItSo(storage->runnable_, x1, x2, x3, x4); |
| 1251 } |
| 1252 }; |
| 1253 |
| 1254 // Arity 4 -> 3. |
| 1255 template <typename StorageType, typename R,typename X1, typename X2, |
| 1256 typename X3, typename X4> |
| 1257 struct Invoker<1, StorageType, R(X1, X2, X3, X4)> { |
| 1258 typedef R(RunType)(BindStateBase*, |
| 1259 typename CallbackParamTraits<X2>::ForwardType, |
| 1260 typename CallbackParamTraits<X3>::ForwardType, |
| 1261 typename CallbackParamTraits<X4>::ForwardType); |
| 1262 |
| 1263 typedef R(UnboundRunType)(X2, X3, X4); |
| 1264 |
| 1265 static R Run(BindStateBase* base, |
| 1266 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1267 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1268 typename CallbackParamTraits<X4>::ForwardType x4) { |
| 1269 StorageType* storage = static_cast<StorageType*>(base); |
| 1270 |
| 1271 // Local references to make debugger stepping easier. If in a debugger, |
| 1272 // you really want to warp ahead and step through the |
| 1273 // InvokeHelper<>::MakeItSo() call below. |
| 1274 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1275 |
| 1276 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1277 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1278 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1279 typename StorageType::RunnableType, |
| 1280 void(typename Bound1UnwrapTraits::ForwardType, |
| 1281 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1282 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1283 typename CallbackParamTraits<X4>::ForwardType x4)> |
| 1284 ::MakeItSo(storage->runnable_, x1, x2, x3, x4); |
| 1285 } |
| 1286 }; |
| 1287 |
| 1288 // Arity 4 -> 2. |
| 1289 template <typename StorageType, typename R,typename X1, typename X2, |
| 1290 typename X3, typename X4> |
| 1291 struct Invoker<2, StorageType, R(X1, X2, X3, X4)> { |
| 1292 typedef R(RunType)(BindStateBase*, |
| 1293 typename CallbackParamTraits<X3>::ForwardType, |
| 1294 typename CallbackParamTraits<X4>::ForwardType); |
| 1295 |
| 1296 typedef R(UnboundRunType)(X3, X4); |
| 1297 |
| 1298 static R Run(BindStateBase* base, |
| 1299 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1300 typename CallbackParamTraits<X4>::ForwardType x4) { |
| 1301 StorageType* storage = static_cast<StorageType*>(base); |
| 1302 |
| 1303 // Local references to make debugger stepping easier. If in a debugger, |
| 1304 // you really want to warp ahead and step through the |
| 1305 // InvokeHelper<>::MakeItSo() call below. |
| 1306 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1307 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1308 |
| 1309 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1310 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1311 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1312 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1313 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1314 typename StorageType::RunnableType, |
| 1315 void(typename Bound1UnwrapTraits::ForwardType, |
| 1316 typename Bound2UnwrapTraits::ForwardType, |
| 1317 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1318 typename CallbackParamTraits<X4>::ForwardType x4)> |
| 1319 ::MakeItSo(storage->runnable_, x1, x2, x3, x4); |
| 1320 } |
| 1321 }; |
| 1322 |
| 1323 // Arity 4 -> 1. |
| 1324 template <typename StorageType, typename R,typename X1, typename X2, |
| 1325 typename X3, typename X4> |
| 1326 struct Invoker<3, StorageType, R(X1, X2, X3, X4)> { |
| 1327 typedef R(RunType)(BindStateBase*, |
| 1328 typename CallbackParamTraits<X4>::ForwardType); |
| 1329 |
| 1330 typedef R(UnboundRunType)(X4); |
| 1331 |
| 1332 static R Run(BindStateBase* base, |
| 1333 typename CallbackParamTraits<X4>::ForwardType x4) { |
| 1334 StorageType* storage = static_cast<StorageType*>(base); |
| 1335 |
| 1336 // Local references to make debugger stepping easier. If in a debugger, |
| 1337 // you really want to warp ahead and step through the |
| 1338 // InvokeHelper<>::MakeItSo() call below. |
| 1339 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1340 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1341 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1342 |
| 1343 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1344 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1345 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1346 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1347 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1348 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1349 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1350 typename StorageType::RunnableType, |
| 1351 void(typename Bound1UnwrapTraits::ForwardType, |
| 1352 typename Bound2UnwrapTraits::ForwardType, |
| 1353 typename Bound3UnwrapTraits::ForwardType, |
| 1354 typename CallbackParamTraits<X4>::ForwardType x4)> |
| 1355 ::MakeItSo(storage->runnable_, x1, x2, x3, x4); |
| 1356 } |
| 1357 }; |
| 1358 |
| 1359 // Arity 4 -> 0. |
| 1360 template <typename StorageType, typename R,typename X1, typename X2, |
| 1361 typename X3, typename X4> |
| 1362 struct Invoker<4, StorageType, R(X1, X2, X3, X4)> { |
| 1363 typedef R(RunType)(BindStateBase*); |
| 1364 |
| 1365 typedef R(UnboundRunType)(); |
| 1366 |
| 1367 static R Run(BindStateBase* base) { |
| 1368 StorageType* storage = static_cast<StorageType*>(base); |
| 1369 |
| 1370 // Local references to make debugger stepping easier. If in a debugger, |
| 1371 // you really want to warp ahead and step through the |
| 1372 // InvokeHelper<>::MakeItSo() call below. |
| 1373 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1374 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1375 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1376 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; |
| 1377 |
| 1378 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1379 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1380 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1381 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1382 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1383 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1384 typename Bound4UnwrapTraits::ForwardType x4 = |
| 1385 Bound4UnwrapTraits::Unwrap(storage->p4_); |
| 1386 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1387 typename StorageType::RunnableType, |
| 1388 void(typename Bound1UnwrapTraits::ForwardType, |
| 1389 typename Bound2UnwrapTraits::ForwardType, |
| 1390 typename Bound3UnwrapTraits::ForwardType, |
| 1391 typename Bound4UnwrapTraits::ForwardType)> |
| 1392 ::MakeItSo(storage->runnable_, x1, x2, x3, x4); |
| 1393 } |
| 1394 }; |
| 1395 |
| 1396 // Arity 5 -> 5. |
| 526 template <typename StorageType, typename R,typename X1, typename X2, | 1397 template <typename StorageType, typename R,typename X1, typename X2, |
| 527 typename X3, typename X4, typename X5> | 1398 typename X3, typename X4, typename X5> |
| 528 struct Invoker0<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { | 1399 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> { |
| 529 typedef R(*DoInvokeType)( | 1400 typedef R(RunType)(BindStateBase*, |
| 530 internal::InvokerStorageBase*, | 1401 typename CallbackParamTraits<X1>::ForwardType, |
| 531 typename internal::ParamTraits<X1>::ForwardType, | 1402 typename CallbackParamTraits<X2>::ForwardType, |
| 532 typename internal::ParamTraits<X2>::ForwardType, | 1403 typename CallbackParamTraits<X3>::ForwardType, |
| 533 typename internal::ParamTraits<X3>::ForwardType, | 1404 typename CallbackParamTraits<X4>::ForwardType, |
| 534 typename internal::ParamTraits<X4>::ForwardType, | 1405 typename CallbackParamTraits<X5>::ForwardType); |
| 535 typename internal::ParamTraits<X5>::ForwardType); | 1406 |
| 536 | 1407 typedef R(UnboundRunType)(X1, X2, X3, X4, X5); |
| 537 static R DoInvoke(InvokerStorageBase* base, | 1408 |
| 538 typename internal::ParamTraits<X1>::ForwardType x1, | 1409 static R Run(BindStateBase* base, |
| 539 typename internal::ParamTraits<X2>::ForwardType x2, | 1410 typename CallbackParamTraits<X1>::ForwardType x1, |
| 540 typename internal::ParamTraits<X3>::ForwardType x3, | 1411 typename CallbackParamTraits<X2>::ForwardType x2, |
| 541 typename internal::ParamTraits<X4>::ForwardType x4, | 1412 typename CallbackParamTraits<X3>::ForwardType x3, |
| 542 typename internal::ParamTraits<X5>::ForwardType x5) { | 1413 typename CallbackParamTraits<X4>::ForwardType x4, |
| 543 StorageType* invoker = static_cast<StorageType*>(base); | 1414 typename CallbackParamTraits<X5>::ForwardType x5) { |
| 544 return invoker->f_(x1, x2, x3, x4, x5); | 1415 StorageType* storage = static_cast<StorageType*>(base); |
| 545 } | 1416 |
| 546 }; | 1417 // Local references to make debugger stepping easier. If in a debugger, |
| 547 | 1418 // you really want to warp ahead and step through the |
| 548 // Function: Arity 6 -> 6. | 1419 // InvokeHelper<>::MakeItSo() call below. |
| 1420 |
| 1421 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1422 typename StorageType::RunnableType, |
| 1423 void(typename CallbackParamTraits<X1>::ForwardType x1, |
| 1424 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1425 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1426 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1427 typename CallbackParamTraits<X5>::ForwardType x5)> |
| 1428 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5); |
| 1429 } |
| 1430 }; |
| 1431 |
| 1432 // Arity 5 -> 4. |
| 1433 template <typename StorageType, typename R,typename X1, typename X2, |
| 1434 typename X3, typename X4, typename X5> |
| 1435 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> { |
| 1436 typedef R(RunType)(BindStateBase*, |
| 1437 typename CallbackParamTraits<X2>::ForwardType, |
| 1438 typename CallbackParamTraits<X3>::ForwardType, |
| 1439 typename CallbackParamTraits<X4>::ForwardType, |
| 1440 typename CallbackParamTraits<X5>::ForwardType); |
| 1441 |
| 1442 typedef R(UnboundRunType)(X2, X3, X4, X5); |
| 1443 |
| 1444 static R Run(BindStateBase* base, |
| 1445 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1446 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1447 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1448 typename CallbackParamTraits<X5>::ForwardType x5) { |
| 1449 StorageType* storage = static_cast<StorageType*>(base); |
| 1450 |
| 1451 // Local references to make debugger stepping easier. If in a debugger, |
| 1452 // you really want to warp ahead and step through the |
| 1453 // InvokeHelper<>::MakeItSo() call below. |
| 1454 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1455 |
| 1456 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1457 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1458 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1459 typename StorageType::RunnableType, |
| 1460 void(typename Bound1UnwrapTraits::ForwardType, |
| 1461 typename CallbackParamTraits<X2>::ForwardType x2, |
| 1462 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1463 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1464 typename CallbackParamTraits<X5>::ForwardType x5)> |
| 1465 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5); |
| 1466 } |
| 1467 }; |
| 1468 |
| 1469 // Arity 5 -> 3. |
| 1470 template <typename StorageType, typename R,typename X1, typename X2, |
| 1471 typename X3, typename X4, typename X5> |
| 1472 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> { |
| 1473 typedef R(RunType)(BindStateBase*, |
| 1474 typename CallbackParamTraits<X3>::ForwardType, |
| 1475 typename CallbackParamTraits<X4>::ForwardType, |
| 1476 typename CallbackParamTraits<X5>::ForwardType); |
| 1477 |
| 1478 typedef R(UnboundRunType)(X3, X4, X5); |
| 1479 |
| 1480 static R Run(BindStateBase* base, |
| 1481 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1482 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1483 typename CallbackParamTraits<X5>::ForwardType x5) { |
| 1484 StorageType* storage = static_cast<StorageType*>(base); |
| 1485 |
| 1486 // Local references to make debugger stepping easier. If in a debugger, |
| 1487 // you really want to warp ahead and step through the |
| 1488 // InvokeHelper<>::MakeItSo() call below. |
| 1489 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1490 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1491 |
| 1492 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1493 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1494 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1495 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1496 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1497 typename StorageType::RunnableType, |
| 1498 void(typename Bound1UnwrapTraits::ForwardType, |
| 1499 typename Bound2UnwrapTraits::ForwardType, |
| 1500 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1501 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1502 typename CallbackParamTraits<X5>::ForwardType x5)> |
| 1503 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5); |
| 1504 } |
| 1505 }; |
| 1506 |
| 1507 // Arity 5 -> 2. |
| 1508 template <typename StorageType, typename R,typename X1, typename X2, |
| 1509 typename X3, typename X4, typename X5> |
| 1510 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> { |
| 1511 typedef R(RunType)(BindStateBase*, |
| 1512 typename CallbackParamTraits<X4>::ForwardType, |
| 1513 typename CallbackParamTraits<X5>::ForwardType); |
| 1514 |
| 1515 typedef R(UnboundRunType)(X4, X5); |
| 1516 |
| 1517 static R Run(BindStateBase* base, |
| 1518 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1519 typename CallbackParamTraits<X5>::ForwardType x5) { |
| 1520 StorageType* storage = static_cast<StorageType*>(base); |
| 1521 |
| 1522 // Local references to make debugger stepping easier. If in a debugger, |
| 1523 // you really want to warp ahead and step through the |
| 1524 // InvokeHelper<>::MakeItSo() call below. |
| 1525 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1526 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1527 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1528 |
| 1529 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1530 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1531 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1532 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1533 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1534 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1535 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1536 typename StorageType::RunnableType, |
| 1537 void(typename Bound1UnwrapTraits::ForwardType, |
| 1538 typename Bound2UnwrapTraits::ForwardType, |
| 1539 typename Bound3UnwrapTraits::ForwardType, |
| 1540 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1541 typename CallbackParamTraits<X5>::ForwardType x5)> |
| 1542 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5); |
| 1543 } |
| 1544 }; |
| 1545 |
| 1546 // Arity 5 -> 1. |
| 1547 template <typename StorageType, typename R,typename X1, typename X2, |
| 1548 typename X3, typename X4, typename X5> |
| 1549 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> { |
| 1550 typedef R(RunType)(BindStateBase*, |
| 1551 typename CallbackParamTraits<X5>::ForwardType); |
| 1552 |
| 1553 typedef R(UnboundRunType)(X5); |
| 1554 |
| 1555 static R Run(BindStateBase* base, |
| 1556 typename CallbackParamTraits<X5>::ForwardType x5) { |
| 1557 StorageType* storage = static_cast<StorageType*>(base); |
| 1558 |
| 1559 // Local references to make debugger stepping easier. If in a debugger, |
| 1560 // you really want to warp ahead and step through the |
| 1561 // InvokeHelper<>::MakeItSo() call below. |
| 1562 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1563 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1564 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1565 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; |
| 1566 |
| 1567 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1568 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1569 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1570 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1571 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1572 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1573 typename Bound4UnwrapTraits::ForwardType x4 = |
| 1574 Bound4UnwrapTraits::Unwrap(storage->p4_); |
| 1575 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1576 typename StorageType::RunnableType, |
| 1577 void(typename Bound1UnwrapTraits::ForwardType, |
| 1578 typename Bound2UnwrapTraits::ForwardType, |
| 1579 typename Bound3UnwrapTraits::ForwardType, |
| 1580 typename Bound4UnwrapTraits::ForwardType, |
| 1581 typename CallbackParamTraits<X5>::ForwardType x5)> |
| 1582 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5); |
| 1583 } |
| 1584 }; |
| 1585 |
| 1586 // Arity 5 -> 0. |
| 1587 template <typename StorageType, typename R,typename X1, typename X2, |
| 1588 typename X3, typename X4, typename X5> |
| 1589 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> { |
| 1590 typedef R(RunType)(BindStateBase*); |
| 1591 |
| 1592 typedef R(UnboundRunType)(); |
| 1593 |
| 1594 static R Run(BindStateBase* base) { |
| 1595 StorageType* storage = static_cast<StorageType*>(base); |
| 1596 |
| 1597 // Local references to make debugger stepping easier. If in a debugger, |
| 1598 // you really want to warp ahead and step through the |
| 1599 // InvokeHelper<>::MakeItSo() call below. |
| 1600 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1601 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1602 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1603 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; |
| 1604 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; |
| 1605 |
| 1606 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1607 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1608 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1609 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1610 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1611 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1612 typename Bound4UnwrapTraits::ForwardType x4 = |
| 1613 Bound4UnwrapTraits::Unwrap(storage->p4_); |
| 1614 typename Bound5UnwrapTraits::ForwardType x5 = |
| 1615 Bound5UnwrapTraits::Unwrap(storage->p5_); |
| 1616 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1617 typename StorageType::RunnableType, |
| 1618 void(typename Bound1UnwrapTraits::ForwardType, |
| 1619 typename Bound2UnwrapTraits::ForwardType, |
| 1620 typename Bound3UnwrapTraits::ForwardType, |
| 1621 typename Bound4UnwrapTraits::ForwardType, |
| 1622 typename Bound5UnwrapTraits::ForwardType)> |
| 1623 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5); |
| 1624 } |
| 1625 }; |
| 1626 |
| 1627 // Arity 6 -> 6. |
| 549 template <typename StorageType, typename R,typename X1, typename X2, | 1628 template <typename StorageType, typename R,typename X1, typename X2, |
| 550 typename X3, typename X4, typename X5, typename X6> | 1629 typename X3, typename X4, typename X5, typename X6> |
| 551 struct Invoker0<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1630 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> { |
| 552 typedef R(*DoInvokeType)( | 1631 typedef R(RunType)(BindStateBase*, |
| 553 internal::InvokerStorageBase*, | 1632 typename CallbackParamTraits<X1>::ForwardType, |
| 554 typename internal::ParamTraits<X1>::ForwardType, | 1633 typename CallbackParamTraits<X2>::ForwardType, |
| 555 typename internal::ParamTraits<X2>::ForwardType, | 1634 typename CallbackParamTraits<X3>::ForwardType, |
| 556 typename internal::ParamTraits<X3>::ForwardType, | 1635 typename CallbackParamTraits<X4>::ForwardType, |
| 557 typename internal::ParamTraits<X4>::ForwardType, | 1636 typename CallbackParamTraits<X5>::ForwardType, |
| 558 typename internal::ParamTraits<X5>::ForwardType, | 1637 typename CallbackParamTraits<X6>::ForwardType); |
| 559 typename internal::ParamTraits<X6>::ForwardType); | 1638 |
| 560 | 1639 typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6); |
| 561 static R DoInvoke(InvokerStorageBase* base, | 1640 |
| 562 typename internal::ParamTraits<X1>::ForwardType x1, | 1641 static R Run(BindStateBase* base, |
| 563 typename internal::ParamTraits<X2>::ForwardType x2, | 1642 typename CallbackParamTraits<X1>::ForwardType x1, |
| 564 typename internal::ParamTraits<X3>::ForwardType x3, | 1643 typename CallbackParamTraits<X2>::ForwardType x2, |
| 565 typename internal::ParamTraits<X4>::ForwardType x4, | 1644 typename CallbackParamTraits<X3>::ForwardType x3, |
| 566 typename internal::ParamTraits<X5>::ForwardType x5, | 1645 typename CallbackParamTraits<X4>::ForwardType x4, |
| 567 typename internal::ParamTraits<X6>::ForwardType x6) { | 1646 typename CallbackParamTraits<X5>::ForwardType x5, |
| 568 StorageType* invoker = static_cast<StorageType*>(base); | 1647 typename CallbackParamTraits<X6>::ForwardType x6) { |
| 569 return invoker->f_(x1, x2, x3, x4, x5, x6); | 1648 StorageType* storage = static_cast<StorageType*>(base); |
| 570 } | 1649 |
| 571 }; | 1650 // Local references to make debugger stepping easier. If in a debugger, |
| 572 | 1651 // you really want to warp ahead and step through the |
| 573 template <bool IsWeak, typename StorageType, typename NormalizedSig> | 1652 // InvokeHelper<>::MakeItSo() call below. |
| 574 struct Invoker1; | 1653 |
| 575 | 1654 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 576 // Function: Arity 1 -> 0. | 1655 typename StorageType::RunnableType, |
| 577 template <typename StorageType, typename R,typename X1> | 1656 void(typename CallbackParamTraits<X1>::ForwardType x1, |
| 578 struct Invoker1<false, StorageType, R(*)(X1)> { | 1657 typename CallbackParamTraits<X2>::ForwardType x2, |
| 579 typedef R(*DoInvokeType)( | 1658 typename CallbackParamTraits<X3>::ForwardType x3, |
| 580 internal::InvokerStorageBase*); | 1659 typename CallbackParamTraits<X4>::ForwardType x4, |
| 581 | 1660 typename CallbackParamTraits<X5>::ForwardType x5, |
| 582 static R DoInvoke(InvokerStorageBase* base) { | 1661 typename CallbackParamTraits<X6>::ForwardType x6)> |
| 583 StorageType* invoker = static_cast<StorageType*>(base); | 1662 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); |
| 584 return invoker->f_(Unwrap(invoker->p1_)); | 1663 } |
| 585 } | 1664 }; |
| 586 }; | 1665 |
| 587 | 1666 // Arity 6 -> 5. |
| 588 // Method: Arity 0 -> 0. | |
| 589 template <typename StorageType, typename R, typename T> | |
| 590 struct Invoker1<false, StorageType, R(T::*)()> { | |
| 591 typedef R(*DoInvokeType)( | |
| 592 internal::InvokerStorageBase*); | |
| 593 | |
| 594 static R DoInvoke(InvokerStorageBase* base) { | |
| 595 StorageType* invoker = static_cast<StorageType*>(base); | |
| 596 return (Unwrap(invoker->p1_)->*invoker->f_)(); | |
| 597 } | |
| 598 }; | |
| 599 | |
| 600 // WeakPtr Method: Arity 0 -> 0. | |
| 601 template <typename StorageType, typename T> | |
| 602 struct Invoker1<true, StorageType, void(T::*)()> { | |
| 603 typedef void(*DoInvokeType)( | |
| 604 internal::InvokerStorageBase*); | |
| 605 | |
| 606 static void DoInvoke(InvokerStorageBase* base) { | |
| 607 StorageType* invoker = static_cast<StorageType*>(base); | |
| 608 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 609 if (!weak_ptr.get()) { | |
| 610 return; | |
| 611 } | |
| 612 (weak_ptr->*invoker->f_)(); | |
| 613 } | |
| 614 }; | |
| 615 | |
| 616 // Function: Arity 2 -> 1. | |
| 617 template <typename StorageType, typename R,typename X1, typename X2> | |
| 618 struct Invoker1<false, StorageType, R(*)(X1, X2)> { | |
| 619 typedef R(*DoInvokeType)( | |
| 620 internal::InvokerStorageBase*, | |
| 621 typename internal::ParamTraits<X2>::ForwardType); | |
| 622 | |
| 623 static R DoInvoke(InvokerStorageBase* base, | |
| 624 typename internal::ParamTraits<X2>::ForwardType x2) { | |
| 625 StorageType* invoker = static_cast<StorageType*>(base); | |
| 626 return invoker->f_(Unwrap(invoker->p1_), x2); | |
| 627 } | |
| 628 }; | |
| 629 | |
| 630 // Method: Arity 1 -> 1. | |
| 631 template <typename StorageType, typename R, typename T, typename X1> | |
| 632 struct Invoker1<false, StorageType, R(T::*)(X1)> { | |
| 633 typedef R(*DoInvokeType)( | |
| 634 internal::InvokerStorageBase*, | |
| 635 typename internal::ParamTraits<X1>::ForwardType); | |
| 636 | |
| 637 static R DoInvoke(InvokerStorageBase* base, | |
| 638 typename internal::ParamTraits<X1>::ForwardType x1) { | |
| 639 StorageType* invoker = static_cast<StorageType*>(base); | |
| 640 return (Unwrap(invoker->p1_)->*invoker->f_)(x1); | |
| 641 } | |
| 642 }; | |
| 643 | |
| 644 // WeakPtr Method: Arity 1 -> 1. | |
| 645 template <typename StorageType, typename T, typename X1> | |
| 646 struct Invoker1<true, StorageType, void(T::*)(X1)> { | |
| 647 typedef void(*DoInvokeType)( | |
| 648 internal::InvokerStorageBase*, | |
| 649 typename internal::ParamTraits<X1>::ForwardType); | |
| 650 | |
| 651 static void DoInvoke(InvokerStorageBase* base, | |
| 652 typename internal::ParamTraits<X1>::ForwardType x1) { | |
| 653 StorageType* invoker = static_cast<StorageType*>(base); | |
| 654 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 655 if (!weak_ptr.get()) { | |
| 656 return; | |
| 657 } | |
| 658 (weak_ptr->*invoker->f_)(x1); | |
| 659 } | |
| 660 }; | |
| 661 | |
| 662 // Function: Arity 3 -> 2. | |
| 663 template <typename StorageType, typename R,typename X1, typename X2, | |
| 664 typename X3> | |
| 665 struct Invoker1<false, StorageType, R(*)(X1, X2, X3)> { | |
| 666 typedef R(*DoInvokeType)( | |
| 667 internal::InvokerStorageBase*, | |
| 668 typename internal::ParamTraits<X2>::ForwardType, | |
| 669 typename internal::ParamTraits<X3>::ForwardType); | |
| 670 | |
| 671 static R DoInvoke(InvokerStorageBase* base, | |
| 672 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 673 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 674 StorageType* invoker = static_cast<StorageType*>(base); | |
| 675 return invoker->f_(Unwrap(invoker->p1_), x2, x3); | |
| 676 } | |
| 677 }; | |
| 678 | |
| 679 // Method: Arity 2 -> 2. | |
| 680 template <typename StorageType, typename R, typename T, typename X1, | |
| 681 typename X2> | |
| 682 struct Invoker1<false, StorageType, R(T::*)(X1, X2)> { | |
| 683 typedef R(*DoInvokeType)( | |
| 684 internal::InvokerStorageBase*, | |
| 685 typename internal::ParamTraits<X1>::ForwardType, | |
| 686 typename internal::ParamTraits<X2>::ForwardType); | |
| 687 | |
| 688 static R DoInvoke(InvokerStorageBase* base, | |
| 689 typename internal::ParamTraits<X1>::ForwardType x1, | |
| 690 typename internal::ParamTraits<X2>::ForwardType x2) { | |
| 691 StorageType* invoker = static_cast<StorageType*>(base); | |
| 692 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); | |
| 693 } | |
| 694 }; | |
| 695 | |
| 696 // WeakPtr Method: Arity 2 -> 2. | |
| 697 template <typename StorageType, typename T, typename X1, typename X2> | |
| 698 struct Invoker1<true, StorageType, void(T::*)(X1, X2)> { | |
| 699 typedef void(*DoInvokeType)( | |
| 700 internal::InvokerStorageBase*, | |
| 701 typename internal::ParamTraits<X1>::ForwardType, | |
| 702 typename internal::ParamTraits<X2>::ForwardType); | |
| 703 | |
| 704 static void DoInvoke(InvokerStorageBase* base, | |
| 705 typename internal::ParamTraits<X1>::ForwardType x1, | |
| 706 typename internal::ParamTraits<X2>::ForwardType x2) { | |
| 707 StorageType* invoker = static_cast<StorageType*>(base); | |
| 708 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 709 if (!weak_ptr.get()) { | |
| 710 return; | |
| 711 } | |
| 712 (weak_ptr->*invoker->f_)(x1, x2); | |
| 713 } | |
| 714 }; | |
| 715 | |
| 716 // Function: Arity 4 -> 3. | |
| 717 template <typename StorageType, typename R,typename X1, typename X2, | |
| 718 typename X3, typename X4> | |
| 719 struct Invoker1<false, StorageType, R(*)(X1, X2, X3, X4)> { | |
| 720 typedef R(*DoInvokeType)( | |
| 721 internal::InvokerStorageBase*, | |
| 722 typename internal::ParamTraits<X2>::ForwardType, | |
| 723 typename internal::ParamTraits<X3>::ForwardType, | |
| 724 typename internal::ParamTraits<X4>::ForwardType); | |
| 725 | |
| 726 static R DoInvoke(InvokerStorageBase* base, | |
| 727 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 728 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 729 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 730 StorageType* invoker = static_cast<StorageType*>(base); | |
| 731 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4); | |
| 732 } | |
| 733 }; | |
| 734 | |
| 735 // Method: Arity 3 -> 3. | |
| 736 template <typename StorageType, typename R, typename T, typename X1, | |
| 737 typename X2, typename X3> | |
| 738 struct Invoker1<false, StorageType, R(T::*)(X1, X2, X3)> { | |
| 739 typedef R(*DoInvokeType)( | |
| 740 internal::InvokerStorageBase*, | |
| 741 typename internal::ParamTraits<X1>::ForwardType, | |
| 742 typename internal::ParamTraits<X2>::ForwardType, | |
| 743 typename internal::ParamTraits<X3>::ForwardType); | |
| 744 | |
| 745 static R DoInvoke(InvokerStorageBase* base, | |
| 746 typename internal::ParamTraits<X1>::ForwardType x1, | |
| 747 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 748 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 749 StorageType* invoker = static_cast<StorageType*>(base); | |
| 750 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); | |
| 751 } | |
| 752 }; | |
| 753 | |
| 754 // WeakPtr Method: Arity 3 -> 3. | |
| 755 template <typename StorageType, typename T, typename X1, typename X2, | |
| 756 typename X3> | |
| 757 struct Invoker1<true, StorageType, void(T::*)(X1, X2, X3)> { | |
| 758 typedef void(*DoInvokeType)( | |
| 759 internal::InvokerStorageBase*, | |
| 760 typename internal::ParamTraits<X1>::ForwardType, | |
| 761 typename internal::ParamTraits<X2>::ForwardType, | |
| 762 typename internal::ParamTraits<X3>::ForwardType); | |
| 763 | |
| 764 static void DoInvoke(InvokerStorageBase* base, | |
| 765 typename internal::ParamTraits<X1>::ForwardType x1, | |
| 766 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 767 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 768 StorageType* invoker = static_cast<StorageType*>(base); | |
| 769 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 770 if (!weak_ptr.get()) { | |
| 771 return; | |
| 772 } | |
| 773 (weak_ptr->*invoker->f_)(x1, x2, x3); | |
| 774 } | |
| 775 }; | |
| 776 | |
| 777 // Function: Arity 5 -> 4. | |
| 778 template <typename StorageType, typename R,typename X1, typename X2, | |
| 779 typename X3, typename X4, typename X5> | |
| 780 struct Invoker1<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
| 781 typedef R(*DoInvokeType)( | |
| 782 internal::InvokerStorageBase*, | |
| 783 typename internal::ParamTraits<X2>::ForwardType, | |
| 784 typename internal::ParamTraits<X3>::ForwardType, | |
| 785 typename internal::ParamTraits<X4>::ForwardType, | |
| 786 typename internal::ParamTraits<X5>::ForwardType); | |
| 787 | |
| 788 static R DoInvoke(InvokerStorageBase* base, | |
| 789 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 790 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 791 typename internal::ParamTraits<X4>::ForwardType x4, | |
| 792 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 793 StorageType* invoker = static_cast<StorageType*>(base); | |
| 794 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5); | |
| 795 } | |
| 796 }; | |
| 797 | |
| 798 // Method: Arity 4 -> 4. | |
| 799 template <typename StorageType, typename R, typename T, typename X1, | |
| 800 typename X2, typename X3, typename X4> | |
| 801 struct Invoker1<false, StorageType, R(T::*)(X1, X2, X3, X4)> { | |
| 802 typedef R(*DoInvokeType)( | |
| 803 internal::InvokerStorageBase*, | |
| 804 typename internal::ParamTraits<X1>::ForwardType, | |
| 805 typename internal::ParamTraits<X2>::ForwardType, | |
| 806 typename internal::ParamTraits<X3>::ForwardType, | |
| 807 typename internal::ParamTraits<X4>::ForwardType); | |
| 808 | |
| 809 static R DoInvoke(InvokerStorageBase* base, | |
| 810 typename internal::ParamTraits<X1>::ForwardType x1, | |
| 811 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 812 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 813 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 814 StorageType* invoker = static_cast<StorageType*>(base); | |
| 815 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); | |
| 816 } | |
| 817 }; | |
| 818 | |
| 819 // WeakPtr Method: Arity 4 -> 4. | |
| 820 template <typename StorageType, typename T, typename X1, typename X2, | |
| 821 typename X3, typename X4> | |
| 822 struct Invoker1<true, StorageType, void(T::*)(X1, X2, X3, X4)> { | |
| 823 typedef void(*DoInvokeType)( | |
| 824 internal::InvokerStorageBase*, | |
| 825 typename internal::ParamTraits<X1>::ForwardType, | |
| 826 typename internal::ParamTraits<X2>::ForwardType, | |
| 827 typename internal::ParamTraits<X3>::ForwardType, | |
| 828 typename internal::ParamTraits<X4>::ForwardType); | |
| 829 | |
| 830 static void DoInvoke(InvokerStorageBase* base, | |
| 831 typename internal::ParamTraits<X1>::ForwardType x1, | |
| 832 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 833 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 834 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 835 StorageType* invoker = static_cast<StorageType*>(base); | |
| 836 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 837 if (!weak_ptr.get()) { | |
| 838 return; | |
| 839 } | |
| 840 (weak_ptr->*invoker->f_)(x1, x2, x3, x4); | |
| 841 } | |
| 842 }; | |
| 843 | |
| 844 // Function: Arity 6 -> 5. | |
| 845 template <typename StorageType, typename R,typename X1, typename X2, | 1667 template <typename StorageType, typename R,typename X1, typename X2, |
| 846 typename X3, typename X4, typename X5, typename X6> | 1668 typename X3, typename X4, typename X5, typename X6> |
| 847 struct Invoker1<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1669 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> { |
| 848 typedef R(*DoInvokeType)( | 1670 typedef R(RunType)(BindStateBase*, |
| 849 internal::InvokerStorageBase*, | 1671 typename CallbackParamTraits<X2>::ForwardType, |
| 850 typename internal::ParamTraits<X2>::ForwardType, | 1672 typename CallbackParamTraits<X3>::ForwardType, |
| 851 typename internal::ParamTraits<X3>::ForwardType, | 1673 typename CallbackParamTraits<X4>::ForwardType, |
| 852 typename internal::ParamTraits<X4>::ForwardType, | 1674 typename CallbackParamTraits<X5>::ForwardType, |
| 853 typename internal::ParamTraits<X5>::ForwardType, | 1675 typename CallbackParamTraits<X6>::ForwardType); |
| 854 typename internal::ParamTraits<X6>::ForwardType); | 1676 |
| 855 | 1677 typedef R(UnboundRunType)(X2, X3, X4, X5, X6); |
| 856 static R DoInvoke(InvokerStorageBase* base, | 1678 |
| 857 typename internal::ParamTraits<X2>::ForwardType x2, | 1679 static R Run(BindStateBase* base, |
| 858 typename internal::ParamTraits<X3>::ForwardType x3, | 1680 typename CallbackParamTraits<X2>::ForwardType x2, |
| 859 typename internal::ParamTraits<X4>::ForwardType x4, | 1681 typename CallbackParamTraits<X3>::ForwardType x3, |
| 860 typename internal::ParamTraits<X5>::ForwardType x5, | 1682 typename CallbackParamTraits<X4>::ForwardType x4, |
| 861 typename internal::ParamTraits<X6>::ForwardType x6) { | 1683 typename CallbackParamTraits<X5>::ForwardType x5, |
| 862 StorageType* invoker = static_cast<StorageType*>(base); | 1684 typename CallbackParamTraits<X6>::ForwardType x6) { |
| 863 return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6); | 1685 StorageType* storage = static_cast<StorageType*>(base); |
| 864 } | 1686 |
| 865 }; | 1687 // Local references to make debugger stepping easier. If in a debugger, |
| 866 | 1688 // you really want to warp ahead and step through the |
| 867 // Method: Arity 5 -> 5. | 1689 // InvokeHelper<>::MakeItSo() call below. |
| 868 template <typename StorageType, typename R, typename T, typename X1, | 1690 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 869 typename X2, typename X3, typename X4, typename X5> | 1691 |
| 870 struct Invoker1<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1692 typename Bound1UnwrapTraits::ForwardType x1 = |
| 871 typedef R(*DoInvokeType)( | 1693 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 872 internal::InvokerStorageBase*, | 1694 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 873 typename internal::ParamTraits<X1>::ForwardType, | 1695 typename StorageType::RunnableType, |
| 874 typename internal::ParamTraits<X2>::ForwardType, | 1696 void(typename Bound1UnwrapTraits::ForwardType, |
| 875 typename internal::ParamTraits<X3>::ForwardType, | 1697 typename CallbackParamTraits<X2>::ForwardType x2, |
| 876 typename internal::ParamTraits<X4>::ForwardType, | 1698 typename CallbackParamTraits<X3>::ForwardType x3, |
| 877 typename internal::ParamTraits<X5>::ForwardType); | 1699 typename CallbackParamTraits<X4>::ForwardType x4, |
| 878 | 1700 typename CallbackParamTraits<X5>::ForwardType x5, |
| 879 static R DoInvoke(InvokerStorageBase* base, | 1701 typename CallbackParamTraits<X6>::ForwardType x6)> |
| 880 typename internal::ParamTraits<X1>::ForwardType x1, | 1702 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); |
| 881 typename internal::ParamTraits<X2>::ForwardType x2, | 1703 } |
| 882 typename internal::ParamTraits<X3>::ForwardType x3, | 1704 }; |
| 883 typename internal::ParamTraits<X4>::ForwardType x4, | 1705 |
| 884 typename internal::ParamTraits<X5>::ForwardType x5) { | 1706 // Arity 6 -> 4. |
| 885 StorageType* invoker = static_cast<StorageType*>(base); | |
| 886 return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); | |
| 887 } | |
| 888 }; | |
| 889 | |
| 890 // WeakPtr Method: Arity 5 -> 5. | |
| 891 template <typename StorageType, typename T, typename X1, typename X2, | |
| 892 typename X3, typename X4, typename X5> | |
| 893 struct Invoker1<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { | |
| 894 typedef void(*DoInvokeType)( | |
| 895 internal::InvokerStorageBase*, | |
| 896 typename internal::ParamTraits<X1>::ForwardType, | |
| 897 typename internal::ParamTraits<X2>::ForwardType, | |
| 898 typename internal::ParamTraits<X3>::ForwardType, | |
| 899 typename internal::ParamTraits<X4>::ForwardType, | |
| 900 typename internal::ParamTraits<X5>::ForwardType); | |
| 901 | |
| 902 static void DoInvoke(InvokerStorageBase* base, | |
| 903 typename internal::ParamTraits<X1>::ForwardType x1, | |
| 904 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 905 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 906 typename internal::ParamTraits<X4>::ForwardType x4, | |
| 907 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 908 StorageType* invoker = static_cast<StorageType*>(base); | |
| 909 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 910 if (!weak_ptr.get()) { | |
| 911 return; | |
| 912 } | |
| 913 (weak_ptr->*invoker->f_)(x1, x2, x3, x4, x5); | |
| 914 } | |
| 915 }; | |
| 916 | |
| 917 template <bool IsWeak, typename StorageType, typename NormalizedSig> | |
| 918 struct Invoker2; | |
| 919 | |
| 920 // Function: Arity 2 -> 0. | |
| 921 template <typename StorageType, typename R,typename X1, typename X2> | |
| 922 struct Invoker2<false, StorageType, R(*)(X1, X2)> { | |
| 923 typedef R(*DoInvokeType)( | |
| 924 internal::InvokerStorageBase*); | |
| 925 | |
| 926 static R DoInvoke(InvokerStorageBase* base) { | |
| 927 StorageType* invoker = static_cast<StorageType*>(base); | |
| 928 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_)); | |
| 929 } | |
| 930 }; | |
| 931 | |
| 932 // Method: Arity 1 -> 0. | |
| 933 template <typename StorageType, typename R, typename T, typename X1> | |
| 934 struct Invoker2<false, StorageType, R(T::*)(X1)> { | |
| 935 typedef R(*DoInvokeType)( | |
| 936 internal::InvokerStorageBase*); | |
| 937 | |
| 938 static R DoInvoke(InvokerStorageBase* base) { | |
| 939 StorageType* invoker = static_cast<StorageType*>(base); | |
| 940 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); | |
| 941 } | |
| 942 }; | |
| 943 | |
| 944 // WeakPtr Method: Arity 1 -> 0. | |
| 945 template <typename StorageType, typename T, typename X1> | |
| 946 struct Invoker2<true, StorageType, void(T::*)(X1)> { | |
| 947 typedef void(*DoInvokeType)( | |
| 948 internal::InvokerStorageBase*); | |
| 949 | |
| 950 static void DoInvoke(InvokerStorageBase* base) { | |
| 951 StorageType* invoker = static_cast<StorageType*>(base); | |
| 952 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 953 if (!weak_ptr.get()) { | |
| 954 return; | |
| 955 } | |
| 956 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_)); | |
| 957 } | |
| 958 }; | |
| 959 | |
| 960 // Function: Arity 3 -> 1. | |
| 961 template <typename StorageType, typename R,typename X1, typename X2, | |
| 962 typename X3> | |
| 963 struct Invoker2<false, StorageType, R(*)(X1, X2, X3)> { | |
| 964 typedef R(*DoInvokeType)( | |
| 965 internal::InvokerStorageBase*, | |
| 966 typename internal::ParamTraits<X3>::ForwardType); | |
| 967 | |
| 968 static R DoInvoke(InvokerStorageBase* base, | |
| 969 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 970 StorageType* invoker = static_cast<StorageType*>(base); | |
| 971 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3); | |
| 972 } | |
| 973 }; | |
| 974 | |
| 975 // Method: Arity 2 -> 1. | |
| 976 template <typename StorageType, typename R, typename T, typename X1, | |
| 977 typename X2> | |
| 978 struct Invoker2<false, StorageType, R(T::*)(X1, X2)> { | |
| 979 typedef R(*DoInvokeType)( | |
| 980 internal::InvokerStorageBase*, | |
| 981 typename internal::ParamTraits<X2>::ForwardType); | |
| 982 | |
| 983 static R DoInvoke(InvokerStorageBase* base, | |
| 984 typename internal::ParamTraits<X2>::ForwardType x2) { | |
| 985 StorageType* invoker = static_cast<StorageType*>(base); | |
| 986 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); | |
| 987 } | |
| 988 }; | |
| 989 | |
| 990 // WeakPtr Method: Arity 2 -> 1. | |
| 991 template <typename StorageType, typename T, typename X1, typename X2> | |
| 992 struct Invoker2<true, StorageType, void(T::*)(X1, X2)> { | |
| 993 typedef void(*DoInvokeType)( | |
| 994 internal::InvokerStorageBase*, | |
| 995 typename internal::ParamTraits<X2>::ForwardType); | |
| 996 | |
| 997 static void DoInvoke(InvokerStorageBase* base, | |
| 998 typename internal::ParamTraits<X2>::ForwardType x2) { | |
| 999 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1000 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1001 if (!weak_ptr.get()) { | |
| 1002 return; | |
| 1003 } | |
| 1004 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2); | |
| 1005 } | |
| 1006 }; | |
| 1007 | |
| 1008 // Function: Arity 4 -> 2. | |
| 1009 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1010 typename X3, typename X4> | |
| 1011 struct Invoker2<false, StorageType, R(*)(X1, X2, X3, X4)> { | |
| 1012 typedef R(*DoInvokeType)( | |
| 1013 internal::InvokerStorageBase*, | |
| 1014 typename internal::ParamTraits<X3>::ForwardType, | |
| 1015 typename internal::ParamTraits<X4>::ForwardType); | |
| 1016 | |
| 1017 static R DoInvoke(InvokerStorageBase* base, | |
| 1018 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1019 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1020 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1021 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4); | |
| 1022 } | |
| 1023 }; | |
| 1024 | |
| 1025 // Method: Arity 3 -> 2. | |
| 1026 template <typename StorageType, typename R, typename T, typename X1, | |
| 1027 typename X2, typename X3> | |
| 1028 struct Invoker2<false, StorageType, R(T::*)(X1, X2, X3)> { | |
| 1029 typedef R(*DoInvokeType)( | |
| 1030 internal::InvokerStorageBase*, | |
| 1031 typename internal::ParamTraits<X2>::ForwardType, | |
| 1032 typename internal::ParamTraits<X3>::ForwardType); | |
| 1033 | |
| 1034 static R DoInvoke(InvokerStorageBase* base, | |
| 1035 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 1036 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 1037 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1038 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); | |
| 1039 } | |
| 1040 }; | |
| 1041 | |
| 1042 // WeakPtr Method: Arity 3 -> 2. | |
| 1043 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1044 typename X3> | |
| 1045 struct Invoker2<true, StorageType, void(T::*)(X1, X2, X3)> { | |
| 1046 typedef void(*DoInvokeType)( | |
| 1047 internal::InvokerStorageBase*, | |
| 1048 typename internal::ParamTraits<X2>::ForwardType, | |
| 1049 typename internal::ParamTraits<X3>::ForwardType); | |
| 1050 | |
| 1051 static void DoInvoke(InvokerStorageBase* base, | |
| 1052 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 1053 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 1054 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1055 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1056 if (!weak_ptr.get()) { | |
| 1057 return; | |
| 1058 } | |
| 1059 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); | |
| 1060 } | |
| 1061 }; | |
| 1062 | |
| 1063 // Function: Arity 5 -> 3. | |
| 1064 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1065 typename X3, typename X4, typename X5> | |
| 1066 struct Invoker2<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
| 1067 typedef R(*DoInvokeType)( | |
| 1068 internal::InvokerStorageBase*, | |
| 1069 typename internal::ParamTraits<X3>::ForwardType, | |
| 1070 typename internal::ParamTraits<X4>::ForwardType, | |
| 1071 typename internal::ParamTraits<X5>::ForwardType); | |
| 1072 | |
| 1073 static R DoInvoke(InvokerStorageBase* base, | |
| 1074 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1075 typename internal::ParamTraits<X4>::ForwardType x4, | |
| 1076 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 1077 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1078 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5); | |
| 1079 } | |
| 1080 }; | |
| 1081 | |
| 1082 // Method: Arity 4 -> 3. | |
| 1083 template <typename StorageType, typename R, typename T, typename X1, | |
| 1084 typename X2, typename X3, typename X4> | |
| 1085 struct Invoker2<false, StorageType, R(T::*)(X1, X2, X3, X4)> { | |
| 1086 typedef R(*DoInvokeType)( | |
| 1087 internal::InvokerStorageBase*, | |
| 1088 typename internal::ParamTraits<X2>::ForwardType, | |
| 1089 typename internal::ParamTraits<X3>::ForwardType, | |
| 1090 typename internal::ParamTraits<X4>::ForwardType); | |
| 1091 | |
| 1092 static R DoInvoke(InvokerStorageBase* base, | |
| 1093 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 1094 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1095 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1096 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1097 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | |
| 1098 x4); | |
| 1099 } | |
| 1100 }; | |
| 1101 | |
| 1102 // WeakPtr Method: Arity 4 -> 3. | |
| 1103 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1104 typename X3, typename X4> | |
| 1105 struct Invoker2<true, StorageType, void(T::*)(X1, X2, X3, X4)> { | |
| 1106 typedef void(*DoInvokeType)( | |
| 1107 internal::InvokerStorageBase*, | |
| 1108 typename internal::ParamTraits<X2>::ForwardType, | |
| 1109 typename internal::ParamTraits<X3>::ForwardType, | |
| 1110 typename internal::ParamTraits<X4>::ForwardType); | |
| 1111 | |
| 1112 static void DoInvoke(InvokerStorageBase* base, | |
| 1113 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 1114 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1115 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1116 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1117 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1118 if (!weak_ptr.get()) { | |
| 1119 return; | |
| 1120 } | |
| 1121 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, x4); | |
| 1122 } | |
| 1123 }; | |
| 1124 | |
| 1125 // Function: Arity 6 -> 4. | |
| 1126 template <typename StorageType, typename R,typename X1, typename X2, | 1707 template <typename StorageType, typename R,typename X1, typename X2, |
| 1127 typename X3, typename X4, typename X5, typename X6> | 1708 typename X3, typename X4, typename X5, typename X6> |
| 1128 struct Invoker2<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1709 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> { |
| 1129 typedef R(*DoInvokeType)( | 1710 typedef R(RunType)(BindStateBase*, |
| 1130 internal::InvokerStorageBase*, | 1711 typename CallbackParamTraits<X3>::ForwardType, |
| 1131 typename internal::ParamTraits<X3>::ForwardType, | 1712 typename CallbackParamTraits<X4>::ForwardType, |
| 1132 typename internal::ParamTraits<X4>::ForwardType, | 1713 typename CallbackParamTraits<X5>::ForwardType, |
| 1133 typename internal::ParamTraits<X5>::ForwardType, | 1714 typename CallbackParamTraits<X6>::ForwardType); |
| 1134 typename internal::ParamTraits<X6>::ForwardType); | 1715 |
| 1135 | 1716 typedef R(UnboundRunType)(X3, X4, X5, X6); |
| 1136 static R DoInvoke(InvokerStorageBase* base, | 1717 |
| 1137 typename internal::ParamTraits<X3>::ForwardType x3, | 1718 static R Run(BindStateBase* base, |
| 1138 typename internal::ParamTraits<X4>::ForwardType x4, | 1719 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1139 typename internal::ParamTraits<X5>::ForwardType x5, | 1720 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1140 typename internal::ParamTraits<X6>::ForwardType x6) { | 1721 typename CallbackParamTraits<X5>::ForwardType x5, |
| 1141 StorageType* invoker = static_cast<StorageType*>(base); | 1722 typename CallbackParamTraits<X6>::ForwardType x6) { |
| 1142 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5, | 1723 StorageType* storage = static_cast<StorageType*>(base); |
| 1143 x6); | 1724 |
| 1144 } | 1725 // Local references to make debugger stepping easier. If in a debugger, |
| 1145 }; | 1726 // you really want to warp ahead and step through the |
| 1146 | 1727 // InvokeHelper<>::MakeItSo() call below. |
| 1147 // Method: Arity 5 -> 4. | 1728 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1148 template <typename StorageType, typename R, typename T, typename X1, | 1729 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1149 typename X2, typename X3, typename X4, typename X5> | 1730 |
| 1150 struct Invoker2<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1731 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1151 typedef R(*DoInvokeType)( | 1732 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1152 internal::InvokerStorageBase*, | 1733 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1153 typename internal::ParamTraits<X2>::ForwardType, | 1734 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1154 typename internal::ParamTraits<X3>::ForwardType, | 1735 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1155 typename internal::ParamTraits<X4>::ForwardType, | 1736 typename StorageType::RunnableType, |
| 1156 typename internal::ParamTraits<X5>::ForwardType); | 1737 void(typename Bound1UnwrapTraits::ForwardType, |
| 1157 | 1738 typename Bound2UnwrapTraits::ForwardType, |
| 1158 static R DoInvoke(InvokerStorageBase* base, | 1739 typename CallbackParamTraits<X3>::ForwardType x3, |
| 1159 typename internal::ParamTraits<X2>::ForwardType x2, | 1740 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1160 typename internal::ParamTraits<X3>::ForwardType x3, | 1741 typename CallbackParamTraits<X5>::ForwardType x5, |
| 1161 typename internal::ParamTraits<X4>::ForwardType x4, | 1742 typename CallbackParamTraits<X6>::ForwardType x6)> |
| 1162 typename internal::ParamTraits<X5>::ForwardType x5) { | 1743 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); |
| 1163 StorageType* invoker = static_cast<StorageType*>(base); | 1744 } |
| 1164 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, | 1745 }; |
| 1165 x4, x5); | 1746 |
| 1166 } | 1747 // Arity 6 -> 3. |
| 1167 }; | |
| 1168 | |
| 1169 // WeakPtr Method: Arity 5 -> 4. | |
| 1170 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1171 typename X3, typename X4, typename X5> | |
| 1172 struct Invoker2<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { | |
| 1173 typedef void(*DoInvokeType)( | |
| 1174 internal::InvokerStorageBase*, | |
| 1175 typename internal::ParamTraits<X2>::ForwardType, | |
| 1176 typename internal::ParamTraits<X3>::ForwardType, | |
| 1177 typename internal::ParamTraits<X4>::ForwardType, | |
| 1178 typename internal::ParamTraits<X5>::ForwardType); | |
| 1179 | |
| 1180 static void DoInvoke(InvokerStorageBase* base, | |
| 1181 typename internal::ParamTraits<X2>::ForwardType x2, | |
| 1182 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1183 typename internal::ParamTraits<X4>::ForwardType x4, | |
| 1184 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 1185 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1186 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1187 if (!weak_ptr.get()) { | |
| 1188 return; | |
| 1189 } | |
| 1190 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, x4, x5); | |
| 1191 } | |
| 1192 }; | |
| 1193 | |
| 1194 template <bool IsWeak, typename StorageType, typename NormalizedSig> | |
| 1195 struct Invoker3; | |
| 1196 | |
| 1197 // Function: Arity 3 -> 0. | |
| 1198 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1199 typename X3> | |
| 1200 struct Invoker3<false, StorageType, R(*)(X1, X2, X3)> { | |
| 1201 typedef R(*DoInvokeType)( | |
| 1202 internal::InvokerStorageBase*); | |
| 1203 | |
| 1204 static R DoInvoke(InvokerStorageBase* base) { | |
| 1205 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1206 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
| 1207 Unwrap(invoker->p3_)); | |
| 1208 } | |
| 1209 }; | |
| 1210 | |
| 1211 // Method: Arity 2 -> 0. | |
| 1212 template <typename StorageType, typename R, typename T, typename X1, | |
| 1213 typename X2> | |
| 1214 struct Invoker3<false, StorageType, R(T::*)(X1, X2)> { | |
| 1215 typedef R(*DoInvokeType)( | |
| 1216 internal::InvokerStorageBase*); | |
| 1217 | |
| 1218 static R DoInvoke(InvokerStorageBase* base) { | |
| 1219 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1220 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
| 1221 Unwrap(invoker->p3_)); | |
| 1222 } | |
| 1223 }; | |
| 1224 | |
| 1225 // WeakPtr Method: Arity 2 -> 0. | |
| 1226 template <typename StorageType, typename T, typename X1, typename X2> | |
| 1227 struct Invoker3<true, StorageType, void(T::*)(X1, X2)> { | |
| 1228 typedef void(*DoInvokeType)( | |
| 1229 internal::InvokerStorageBase*); | |
| 1230 | |
| 1231 static void DoInvoke(InvokerStorageBase* base) { | |
| 1232 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1233 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1234 if (!weak_ptr.get()) { | |
| 1235 return; | |
| 1236 } | |
| 1237 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_)); | |
| 1238 } | |
| 1239 }; | |
| 1240 | |
| 1241 // Function: Arity 4 -> 1. | |
| 1242 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1243 typename X3, typename X4> | |
| 1244 struct Invoker3<false, StorageType, R(*)(X1, X2, X3, X4)> { | |
| 1245 typedef R(*DoInvokeType)( | |
| 1246 internal::InvokerStorageBase*, | |
| 1247 typename internal::ParamTraits<X4>::ForwardType); | |
| 1248 | |
| 1249 static R DoInvoke(InvokerStorageBase* base, | |
| 1250 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1251 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1252 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
| 1253 Unwrap(invoker->p3_), x4); | |
| 1254 } | |
| 1255 }; | |
| 1256 | |
| 1257 // Method: Arity 3 -> 1. | |
| 1258 template <typename StorageType, typename R, typename T, typename X1, | |
| 1259 typename X2, typename X3> | |
| 1260 struct Invoker3<false, StorageType, R(T::*)(X1, X2, X3)> { | |
| 1261 typedef R(*DoInvokeType)( | |
| 1262 internal::InvokerStorageBase*, | |
| 1263 typename internal::ParamTraits<X3>::ForwardType); | |
| 1264 | |
| 1265 static R DoInvoke(InvokerStorageBase* base, | |
| 1266 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 1267 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1268 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
| 1269 Unwrap(invoker->p3_), x3); | |
| 1270 } | |
| 1271 }; | |
| 1272 | |
| 1273 // WeakPtr Method: Arity 3 -> 1. | |
| 1274 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1275 typename X3> | |
| 1276 struct Invoker3<true, StorageType, void(T::*)(X1, X2, X3)> { | |
| 1277 typedef void(*DoInvokeType)( | |
| 1278 internal::InvokerStorageBase*, | |
| 1279 typename internal::ParamTraits<X3>::ForwardType); | |
| 1280 | |
| 1281 static void DoInvoke(InvokerStorageBase* base, | |
| 1282 typename internal::ParamTraits<X3>::ForwardType x3) { | |
| 1283 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1284 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1285 if (!weak_ptr.get()) { | |
| 1286 return; | |
| 1287 } | |
| 1288 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3); | |
| 1289 } | |
| 1290 }; | |
| 1291 | |
| 1292 // Function: Arity 5 -> 2. | |
| 1293 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1294 typename X3, typename X4, typename X5> | |
| 1295 struct Invoker3<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
| 1296 typedef R(*DoInvokeType)( | |
| 1297 internal::InvokerStorageBase*, | |
| 1298 typename internal::ParamTraits<X4>::ForwardType, | |
| 1299 typename internal::ParamTraits<X5>::ForwardType); | |
| 1300 | |
| 1301 static R DoInvoke(InvokerStorageBase* base, | |
| 1302 typename internal::ParamTraits<X4>::ForwardType x4, | |
| 1303 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 1304 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1305 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
| 1306 Unwrap(invoker->p3_), x4, x5); | |
| 1307 } | |
| 1308 }; | |
| 1309 | |
| 1310 // Method: Arity 4 -> 2. | |
| 1311 template <typename StorageType, typename R, typename T, typename X1, | |
| 1312 typename X2, typename X3, typename X4> | |
| 1313 struct Invoker3<false, StorageType, R(T::*)(X1, X2, X3, X4)> { | |
| 1314 typedef R(*DoInvokeType)( | |
| 1315 internal::InvokerStorageBase*, | |
| 1316 typename internal::ParamTraits<X3>::ForwardType, | |
| 1317 typename internal::ParamTraits<X4>::ForwardType); | |
| 1318 | |
| 1319 static R DoInvoke(InvokerStorageBase* base, | |
| 1320 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1321 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1322 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1323 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
| 1324 Unwrap(invoker->p3_), x3, x4); | |
| 1325 } | |
| 1326 }; | |
| 1327 | |
| 1328 // WeakPtr Method: Arity 4 -> 2. | |
| 1329 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1330 typename X3, typename X4> | |
| 1331 struct Invoker3<true, StorageType, void(T::*)(X1, X2, X3, X4)> { | |
| 1332 typedef void(*DoInvokeType)( | |
| 1333 internal::InvokerStorageBase*, | |
| 1334 typename internal::ParamTraits<X3>::ForwardType, | |
| 1335 typename internal::ParamTraits<X4>::ForwardType); | |
| 1336 | |
| 1337 static void DoInvoke(InvokerStorageBase* base, | |
| 1338 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1339 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1340 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1341 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1342 if (!weak_ptr.get()) { | |
| 1343 return; | |
| 1344 } | |
| 1345 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3, | |
| 1346 x4); | |
| 1347 } | |
| 1348 }; | |
| 1349 | |
| 1350 // Function: Arity 6 -> 3. | |
| 1351 template <typename StorageType, typename R,typename X1, typename X2, | 1748 template <typename StorageType, typename R,typename X1, typename X2, |
| 1352 typename X3, typename X4, typename X5, typename X6> | 1749 typename X3, typename X4, typename X5, typename X6> |
| 1353 struct Invoker3<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1750 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> { |
| 1354 typedef R(*DoInvokeType)( | 1751 typedef R(RunType)(BindStateBase*, |
| 1355 internal::InvokerStorageBase*, | 1752 typename CallbackParamTraits<X4>::ForwardType, |
| 1356 typename internal::ParamTraits<X4>::ForwardType, | 1753 typename CallbackParamTraits<X5>::ForwardType, |
| 1357 typename internal::ParamTraits<X5>::ForwardType, | 1754 typename CallbackParamTraits<X6>::ForwardType); |
| 1358 typename internal::ParamTraits<X6>::ForwardType); | 1755 |
| 1359 | 1756 typedef R(UnboundRunType)(X4, X5, X6); |
| 1360 static R DoInvoke(InvokerStorageBase* base, | 1757 |
| 1361 typename internal::ParamTraits<X4>::ForwardType x4, | 1758 static R Run(BindStateBase* base, |
| 1362 typename internal::ParamTraits<X5>::ForwardType x5, | 1759 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1363 typename internal::ParamTraits<X6>::ForwardType x6) { | 1760 typename CallbackParamTraits<X5>::ForwardType x5, |
| 1364 StorageType* invoker = static_cast<StorageType*>(base); | 1761 typename CallbackParamTraits<X6>::ForwardType x6) { |
| 1365 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 1762 StorageType* storage = static_cast<StorageType*>(base); |
| 1366 Unwrap(invoker->p3_), x4, x5, x6); | 1763 |
| 1367 } | 1764 // Local references to make debugger stepping easier. If in a debugger, |
| 1368 }; | 1765 // you really want to warp ahead and step through the |
| 1369 | 1766 // InvokeHelper<>::MakeItSo() call below. |
| 1370 // Method: Arity 5 -> 3. | 1767 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1371 template <typename StorageType, typename R, typename T, typename X1, | 1768 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1372 typename X2, typename X3, typename X4, typename X5> | 1769 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1373 struct Invoker3<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1770 |
| 1374 typedef R(*DoInvokeType)( | 1771 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1375 internal::InvokerStorageBase*, | 1772 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1376 typename internal::ParamTraits<X3>::ForwardType, | 1773 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1377 typename internal::ParamTraits<X4>::ForwardType, | 1774 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1378 typename internal::ParamTraits<X5>::ForwardType); | 1775 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1379 | 1776 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1380 static R DoInvoke(InvokerStorageBase* base, | 1777 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1381 typename internal::ParamTraits<X3>::ForwardType x3, | 1778 typename StorageType::RunnableType, |
| 1382 typename internal::ParamTraits<X4>::ForwardType x4, | 1779 void(typename Bound1UnwrapTraits::ForwardType, |
| 1383 typename internal::ParamTraits<X5>::ForwardType x5) { | 1780 typename Bound2UnwrapTraits::ForwardType, |
| 1384 StorageType* invoker = static_cast<StorageType*>(base); | 1781 typename Bound3UnwrapTraits::ForwardType, |
| 1385 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 1782 typename CallbackParamTraits<X4>::ForwardType x4, |
| 1386 Unwrap(invoker->p3_), x3, x4, x5); | 1783 typename CallbackParamTraits<X5>::ForwardType x5, |
| 1387 } | 1784 typename CallbackParamTraits<X6>::ForwardType x6)> |
| 1388 }; | 1785 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); |
| 1389 | 1786 } |
| 1390 // WeakPtr Method: Arity 5 -> 3. | 1787 }; |
| 1391 template <typename StorageType, typename T, typename X1, typename X2, | 1788 |
| 1392 typename X3, typename X4, typename X5> | 1789 // Arity 6 -> 2. |
| 1393 struct Invoker3<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { | |
| 1394 typedef void(*DoInvokeType)( | |
| 1395 internal::InvokerStorageBase*, | |
| 1396 typename internal::ParamTraits<X3>::ForwardType, | |
| 1397 typename internal::ParamTraits<X4>::ForwardType, | |
| 1398 typename internal::ParamTraits<X5>::ForwardType); | |
| 1399 | |
| 1400 static void DoInvoke(InvokerStorageBase* base, | |
| 1401 typename internal::ParamTraits<X3>::ForwardType x3, | |
| 1402 typename internal::ParamTraits<X4>::ForwardType x4, | |
| 1403 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 1404 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1405 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1406 if (!weak_ptr.get()) { | |
| 1407 return; | |
| 1408 } | |
| 1409 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3, | |
| 1410 x4, x5); | |
| 1411 } | |
| 1412 }; | |
| 1413 | |
| 1414 template <bool IsWeak, typename StorageType, typename NormalizedSig> | |
| 1415 struct Invoker4; | |
| 1416 | |
| 1417 // Function: Arity 4 -> 0. | |
| 1418 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1419 typename X3, typename X4> | |
| 1420 struct Invoker4<false, StorageType, R(*)(X1, X2, X3, X4)> { | |
| 1421 typedef R(*DoInvokeType)( | |
| 1422 internal::InvokerStorageBase*); | |
| 1423 | |
| 1424 static R DoInvoke(InvokerStorageBase* base) { | |
| 1425 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1426 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
| 1427 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | |
| 1428 } | |
| 1429 }; | |
| 1430 | |
| 1431 // Method: Arity 3 -> 0. | |
| 1432 template <typename StorageType, typename R, typename T, typename X1, | |
| 1433 typename X2, typename X3> | |
| 1434 struct Invoker4<false, StorageType, R(T::*)(X1, X2, X3)> { | |
| 1435 typedef R(*DoInvokeType)( | |
| 1436 internal::InvokerStorageBase*); | |
| 1437 | |
| 1438 static R DoInvoke(InvokerStorageBase* base) { | |
| 1439 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1440 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
| 1441 Unwrap(invoker->p3_), Unwrap(invoker->p4_)); | |
| 1442 } | |
| 1443 }; | |
| 1444 | |
| 1445 // WeakPtr Method: Arity 3 -> 0. | |
| 1446 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1447 typename X3> | |
| 1448 struct Invoker4<true, StorageType, void(T::*)(X1, X2, X3)> { | |
| 1449 typedef void(*DoInvokeType)( | |
| 1450 internal::InvokerStorageBase*); | |
| 1451 | |
| 1452 static void DoInvoke(InvokerStorageBase* base) { | |
| 1453 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1454 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1455 if (!weak_ptr.get()) { | |
| 1456 return; | |
| 1457 } | |
| 1458 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), | |
| 1459 Unwrap(invoker->p4_)); | |
| 1460 } | |
| 1461 }; | |
| 1462 | |
| 1463 // Function: Arity 5 -> 1. | |
| 1464 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1465 typename X3, typename X4, typename X5> | |
| 1466 struct Invoker4<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
| 1467 typedef R(*DoInvokeType)( | |
| 1468 internal::InvokerStorageBase*, | |
| 1469 typename internal::ParamTraits<X5>::ForwardType); | |
| 1470 | |
| 1471 static R DoInvoke(InvokerStorageBase* base, | |
| 1472 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 1473 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1474 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
| 1475 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5); | |
| 1476 } | |
| 1477 }; | |
| 1478 | |
| 1479 // Method: Arity 4 -> 1. | |
| 1480 template <typename StorageType, typename R, typename T, typename X1, | |
| 1481 typename X2, typename X3, typename X4> | |
| 1482 struct Invoker4<false, StorageType, R(T::*)(X1, X2, X3, X4)> { | |
| 1483 typedef R(*DoInvokeType)( | |
| 1484 internal::InvokerStorageBase*, | |
| 1485 typename internal::ParamTraits<X4>::ForwardType); | |
| 1486 | |
| 1487 static R DoInvoke(InvokerStorageBase* base, | |
| 1488 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1489 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1490 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
| 1491 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); | |
| 1492 } | |
| 1493 }; | |
| 1494 | |
| 1495 // WeakPtr Method: Arity 4 -> 1. | |
| 1496 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1497 typename X3, typename X4> | |
| 1498 struct Invoker4<true, StorageType, void(T::*)(X1, X2, X3, X4)> { | |
| 1499 typedef void(*DoInvokeType)( | |
| 1500 internal::InvokerStorageBase*, | |
| 1501 typename internal::ParamTraits<X4>::ForwardType); | |
| 1502 | |
| 1503 static void DoInvoke(InvokerStorageBase* base, | |
| 1504 typename internal::ParamTraits<X4>::ForwardType x4) { | |
| 1505 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1506 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1507 if (!weak_ptr.get()) { | |
| 1508 return; | |
| 1509 } | |
| 1510 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), | |
| 1511 Unwrap(invoker->p4_), x4); | |
| 1512 } | |
| 1513 }; | |
| 1514 | |
| 1515 // Function: Arity 6 -> 2. | |
| 1516 template <typename StorageType, typename R,typename X1, typename X2, | 1790 template <typename StorageType, typename R,typename X1, typename X2, |
| 1517 typename X3, typename X4, typename X5, typename X6> | 1791 typename X3, typename X4, typename X5, typename X6> |
| 1518 struct Invoker4<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1792 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> { |
| 1519 typedef R(*DoInvokeType)( | 1793 typedef R(RunType)(BindStateBase*, |
| 1520 internal::InvokerStorageBase*, | 1794 typename CallbackParamTraits<X5>::ForwardType, |
| 1521 typename internal::ParamTraits<X5>::ForwardType, | 1795 typename CallbackParamTraits<X6>::ForwardType); |
| 1522 typename internal::ParamTraits<X6>::ForwardType); | 1796 |
| 1523 | 1797 typedef R(UnboundRunType)(X5, X6); |
| 1524 static R DoInvoke(InvokerStorageBase* base, | 1798 |
| 1525 typename internal::ParamTraits<X5>::ForwardType x5, | 1799 static R Run(BindStateBase* base, |
| 1526 typename internal::ParamTraits<X6>::ForwardType x6) { | 1800 typename CallbackParamTraits<X5>::ForwardType x5, |
| 1527 StorageType* invoker = static_cast<StorageType*>(base); | 1801 typename CallbackParamTraits<X6>::ForwardType x6) { |
| 1528 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 1802 StorageType* storage = static_cast<StorageType*>(base); |
| 1529 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5, x6); | 1803 |
| 1530 } | 1804 // Local references to make debugger stepping easier. If in a debugger, |
| 1531 }; | 1805 // you really want to warp ahead and step through the |
| 1532 | 1806 // InvokeHelper<>::MakeItSo() call below. |
| 1533 // Method: Arity 5 -> 2. | 1807 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1534 template <typename StorageType, typename R, typename T, typename X1, | 1808 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1535 typename X2, typename X3, typename X4, typename X5> | 1809 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1536 struct Invoker4<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1810 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; |
| 1537 typedef R(*DoInvokeType)( | 1811 |
| 1538 internal::InvokerStorageBase*, | 1812 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1539 typename internal::ParamTraits<X4>::ForwardType, | 1813 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1540 typename internal::ParamTraits<X5>::ForwardType); | 1814 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1541 | 1815 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1542 static R DoInvoke(InvokerStorageBase* base, | 1816 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1543 typename internal::ParamTraits<X4>::ForwardType x4, | 1817 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1544 typename internal::ParamTraits<X5>::ForwardType x5) { | 1818 typename Bound4UnwrapTraits::ForwardType x4 = |
| 1545 StorageType* invoker = static_cast<StorageType*>(base); | 1819 Bound4UnwrapTraits::Unwrap(storage->p4_); |
| 1546 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 1820 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1547 Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); | 1821 typename StorageType::RunnableType, |
| 1548 } | 1822 void(typename Bound1UnwrapTraits::ForwardType, |
| 1549 }; | 1823 typename Bound2UnwrapTraits::ForwardType, |
| 1550 | 1824 typename Bound3UnwrapTraits::ForwardType, |
| 1551 // WeakPtr Method: Arity 5 -> 2. | 1825 typename Bound4UnwrapTraits::ForwardType, |
| 1552 template <typename StorageType, typename T, typename X1, typename X2, | 1826 typename CallbackParamTraits<X5>::ForwardType x5, |
| 1553 typename X3, typename X4, typename X5> | 1827 typename CallbackParamTraits<X6>::ForwardType x6)> |
| 1554 struct Invoker4<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { | 1828 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); |
| 1555 typedef void(*DoInvokeType)( | 1829 } |
| 1556 internal::InvokerStorageBase*, | 1830 }; |
| 1557 typename internal::ParamTraits<X4>::ForwardType, | 1831 |
| 1558 typename internal::ParamTraits<X5>::ForwardType); | 1832 // Arity 6 -> 1. |
| 1559 | |
| 1560 static void DoInvoke(InvokerStorageBase* base, | |
| 1561 typename internal::ParamTraits<X4>::ForwardType x4, | |
| 1562 typename internal::ParamTraits<X5>::ForwardType x5) { | |
| 1563 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1564 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1565 if (!weak_ptr.get()) { | |
| 1566 return; | |
| 1567 } | |
| 1568 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), | |
| 1569 Unwrap(invoker->p4_), x4, x5); | |
| 1570 } | |
| 1571 }; | |
| 1572 | |
| 1573 template <bool IsWeak, typename StorageType, typename NormalizedSig> | |
| 1574 struct Invoker5; | |
| 1575 | |
| 1576 // Function: Arity 5 -> 0. | |
| 1577 template <typename StorageType, typename R,typename X1, typename X2, | |
| 1578 typename X3, typename X4, typename X5> | |
| 1579 struct Invoker5<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { | |
| 1580 typedef R(*DoInvokeType)( | |
| 1581 internal::InvokerStorageBase*); | |
| 1582 | |
| 1583 static R DoInvoke(InvokerStorageBase* base) { | |
| 1584 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1585 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | |
| 1586 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | |
| 1587 } | |
| 1588 }; | |
| 1589 | |
| 1590 // Method: Arity 4 -> 0. | |
| 1591 template <typename StorageType, typename R, typename T, typename X1, | |
| 1592 typename X2, typename X3, typename X4> | |
| 1593 struct Invoker5<false, StorageType, R(T::*)(X1, X2, X3, X4)> { | |
| 1594 typedef R(*DoInvokeType)( | |
| 1595 internal::InvokerStorageBase*); | |
| 1596 | |
| 1597 static R DoInvoke(InvokerStorageBase* base) { | |
| 1598 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1599 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | |
| 1600 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | |
| 1601 } | |
| 1602 }; | |
| 1603 | |
| 1604 // WeakPtr Method: Arity 4 -> 0. | |
| 1605 template <typename StorageType, typename T, typename X1, typename X2, | |
| 1606 typename X3, typename X4> | |
| 1607 struct Invoker5<true, StorageType, void(T::*)(X1, X2, X3, X4)> { | |
| 1608 typedef void(*DoInvokeType)( | |
| 1609 internal::InvokerStorageBase*); | |
| 1610 | |
| 1611 static void DoInvoke(InvokerStorageBase* base) { | |
| 1612 StorageType* invoker = static_cast<StorageType*>(base); | |
| 1613 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | |
| 1614 if (!weak_ptr.get()) { | |
| 1615 return; | |
| 1616 } | |
| 1617 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), | |
| 1618 Unwrap(invoker->p4_), Unwrap(invoker->p5_)); | |
| 1619 } | |
| 1620 }; | |
| 1621 | |
| 1622 // Function: Arity 6 -> 1. | |
| 1623 template <typename StorageType, typename R,typename X1, typename X2, | 1833 template <typename StorageType, typename R,typename X1, typename X2, |
| 1624 typename X3, typename X4, typename X5, typename X6> | 1834 typename X3, typename X4, typename X5, typename X6> |
| 1625 struct Invoker5<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1835 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> { |
| 1626 typedef R(*DoInvokeType)( | 1836 typedef R(RunType)(BindStateBase*, |
| 1627 internal::InvokerStorageBase*, | 1837 typename CallbackParamTraits<X6>::ForwardType); |
| 1628 typename internal::ParamTraits<X6>::ForwardType); | 1838 |
| 1629 | 1839 typedef R(UnboundRunType)(X6); |
| 1630 static R DoInvoke(InvokerStorageBase* base, | 1840 |
| 1631 typename internal::ParamTraits<X6>::ForwardType x6) { | 1841 static R Run(BindStateBase* base, |
| 1632 StorageType* invoker = static_cast<StorageType*>(base); | 1842 typename CallbackParamTraits<X6>::ForwardType x6) { |
| 1633 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 1843 StorageType* storage = static_cast<StorageType*>(base); |
| 1634 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x6); | 1844 |
| 1635 } | 1845 // Local references to make debugger stepping easier. If in a debugger, |
| 1636 }; | 1846 // you really want to warp ahead and step through the |
| 1637 | 1847 // InvokeHelper<>::MakeItSo() call below. |
| 1638 // Method: Arity 5 -> 1. | 1848 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1639 template <typename StorageType, typename R, typename T, typename X1, | 1849 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1640 typename X2, typename X3, typename X4, typename X5> | 1850 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1641 struct Invoker5<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1851 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; |
| 1642 typedef R(*DoInvokeType)( | 1852 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; |
| 1643 internal::InvokerStorageBase*, | 1853 |
| 1644 typename internal::ParamTraits<X5>::ForwardType); | 1854 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1645 | 1855 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1646 static R DoInvoke(InvokerStorageBase* base, | 1856 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1647 typename internal::ParamTraits<X5>::ForwardType x5) { | 1857 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1648 StorageType* invoker = static_cast<StorageType*>(base); | 1858 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1649 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 1859 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1650 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); | 1860 typename Bound4UnwrapTraits::ForwardType x4 = |
| 1651 } | 1861 Bound4UnwrapTraits::Unwrap(storage->p4_); |
| 1652 }; | 1862 typename Bound5UnwrapTraits::ForwardType x5 = |
| 1653 | 1863 Bound5UnwrapTraits::Unwrap(storage->p5_); |
| 1654 // WeakPtr Method: Arity 5 -> 1. | 1864 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1655 template <typename StorageType, typename T, typename X1, typename X2, | 1865 typename StorageType::RunnableType, |
| 1656 typename X3, typename X4, typename X5> | 1866 void(typename Bound1UnwrapTraits::ForwardType, |
| 1657 struct Invoker5<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { | 1867 typename Bound2UnwrapTraits::ForwardType, |
| 1658 typedef void(*DoInvokeType)( | 1868 typename Bound3UnwrapTraits::ForwardType, |
| 1659 internal::InvokerStorageBase*, | 1869 typename Bound4UnwrapTraits::ForwardType, |
| 1660 typename internal::ParamTraits<X5>::ForwardType); | 1870 typename Bound5UnwrapTraits::ForwardType, |
| 1661 | 1871 typename CallbackParamTraits<X6>::ForwardType x6)> |
| 1662 static void DoInvoke(InvokerStorageBase* base, | 1872 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); |
| 1663 typename internal::ParamTraits<X5>::ForwardType x5) { | 1873 } |
| 1664 StorageType* invoker = static_cast<StorageType*>(base); | 1874 }; |
| 1665 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | 1875 |
| 1666 if (!weak_ptr.get()) { | 1876 // Arity 6 -> 0. |
| 1667 return; | |
| 1668 } | |
| 1669 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), | |
| 1670 Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); | |
| 1671 } | |
| 1672 }; | |
| 1673 | |
| 1674 template <bool IsWeak, typename StorageType, typename NormalizedSig> | |
| 1675 struct Invoker6; | |
| 1676 | |
| 1677 // Function: Arity 6 -> 0. | |
| 1678 template <typename StorageType, typename R,typename X1, typename X2, | 1877 template <typename StorageType, typename R,typename X1, typename X2, |
| 1679 typename X3, typename X4, typename X5, typename X6> | 1878 typename X3, typename X4, typename X5, typename X6> |
| 1680 struct Invoker6<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { | 1879 struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> { |
| 1681 typedef R(*DoInvokeType)( | 1880 typedef R(RunType)(BindStateBase*); |
| 1682 internal::InvokerStorageBase*); | 1881 |
| 1683 | 1882 typedef R(UnboundRunType)(); |
| 1684 static R DoInvoke(InvokerStorageBase* base) { | 1883 |
| 1685 StorageType* invoker = static_cast<StorageType*>(base); | 1884 static R Run(BindStateBase* base) { |
| 1686 return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), | 1885 StorageType* storage = static_cast<StorageType*>(base); |
| 1687 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | 1886 |
| 1688 Unwrap(invoker->p6_)); | 1887 // Local references to make debugger stepping easier. If in a debugger, |
| 1689 } | 1888 // you really want to warp ahead and step through the |
| 1690 }; | 1889 // InvokeHelper<>::MakeItSo() call below. |
| 1691 | 1890 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; |
| 1692 // Method: Arity 5 -> 0. | 1891 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; |
| 1693 template <typename StorageType, typename R, typename T, typename X1, | 1892 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; |
| 1694 typename X2, typename X3, typename X4, typename X5> | 1893 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; |
| 1695 struct Invoker6<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { | 1894 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; |
| 1696 typedef R(*DoInvokeType)( | 1895 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; |
| 1697 internal::InvokerStorageBase*); | 1896 |
| 1698 | 1897 typename Bound1UnwrapTraits::ForwardType x1 = |
| 1699 static R DoInvoke(InvokerStorageBase* base) { | 1898 Bound1UnwrapTraits::Unwrap(storage->p1_); |
| 1700 StorageType* invoker = static_cast<StorageType*>(base); | 1899 typename Bound2UnwrapTraits::ForwardType x2 = |
| 1701 return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), | 1900 Bound2UnwrapTraits::Unwrap(storage->p2_); |
| 1702 Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), | 1901 typename Bound3UnwrapTraits::ForwardType x3 = |
| 1703 Unwrap(invoker->p6_)); | 1902 Bound3UnwrapTraits::Unwrap(storage->p3_); |
| 1704 } | 1903 typename Bound4UnwrapTraits::ForwardType x4 = |
| 1705 }; | 1904 Bound4UnwrapTraits::Unwrap(storage->p4_); |
| 1706 | 1905 typename Bound5UnwrapTraits::ForwardType x5 = |
| 1707 // WeakPtr Method: Arity 5 -> 0. | 1906 Bound5UnwrapTraits::Unwrap(storage->p5_); |
| 1708 template <typename StorageType, typename T, typename X1, typename X2, | 1907 typename Bound6UnwrapTraits::ForwardType x6 = |
| 1709 typename X3, typename X4, typename X5> | 1908 Bound6UnwrapTraits::Unwrap(storage->p6_); |
| 1710 struct Invoker6<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { | 1909 return InvokeHelper<StorageType::IsWeakCall::value, R, |
| 1711 typedef void(*DoInvokeType)( | 1910 typename StorageType::RunnableType, |
| 1712 internal::InvokerStorageBase*); | 1911 void(typename Bound1UnwrapTraits::ForwardType, |
| 1713 | 1912 typename Bound2UnwrapTraits::ForwardType, |
| 1714 static void DoInvoke(InvokerStorageBase* base) { | 1913 typename Bound3UnwrapTraits::ForwardType, |
| 1715 StorageType* invoker = static_cast<StorageType*>(base); | 1914 typename Bound4UnwrapTraits::ForwardType, |
| 1716 typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; | 1915 typename Bound5UnwrapTraits::ForwardType, |
| 1717 if (!weak_ptr.get()) { | 1916 typename Bound6UnwrapTraits::ForwardType)> |
| 1718 return; | 1917 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); |
| 1719 } | 1918 } |
| 1720 (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), | 1919 }; |
| 1721 Unwrap(invoker->p4_), Unwrap(invoker->p5_), Unwrap(invoker->p6_)); | 1920 |
| 1722 } | 1921 |
| 1723 }; | 1922 // BindState<> |
| 1724 | |
| 1725 // BindMoreFuncN<> | |
| 1726 // | 1923 // |
| 1727 // This set of functions help in fully binding the free parameters in a | 1924 // This stores all the state passed into Bind() and is also where most |
| 1728 // Callback<>. | 1925 // of the template resolution magic occurs. |
| 1729 template <typename Sig, typename P1> | |
| 1730 void BindMoreFunc1(const base::Callback<Sig>& callback, const P1& p1) { | |
| 1731 callback.Run(p1); | |
| 1732 } | |
| 1733 | |
| 1734 template <typename Sig, typename P1, typename P2> | |
| 1735 void BindMoreFunc2(const base::Callback<Sig>& callback, const P1& p1, | |
| 1736 const P2& p2) { | |
| 1737 callback.Run(p1, p2); | |
| 1738 } | |
| 1739 | |
| 1740 template <typename Sig, typename P1, typename P2, typename P3> | |
| 1741 void BindMoreFunc3(const base::Callback<Sig>& callback, const P1& p1, | |
| 1742 const P2& p2, const P3& p3) { | |
| 1743 callback.Run(p1, p2, p3); | |
| 1744 } | |
| 1745 | |
| 1746 template <typename Sig, typename P1, typename P2, typename P3, typename P4> | |
| 1747 void BindMoreFunc4(const base::Callback<Sig>& callback, const P1& p1, | |
| 1748 const P2& p2, const P3& p3, const P4& p4) { | |
| 1749 callback.Run(p1, p2, p3, p4); | |
| 1750 } | |
| 1751 | |
| 1752 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | |
| 1753 typename P5> | |
| 1754 void BindMoreFunc5(const base::Callback<Sig>& callback, const P1& p1, | |
| 1755 const P2& p2, const P3& p3, const P4& p4, const P5& p5) { | |
| 1756 callback.Run(p1, p2, p3, p4, p5); | |
| 1757 } | |
| 1758 | |
| 1759 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | |
| 1760 typename P5, typename P6> | |
| 1761 void BindMoreFunc6(const base::Callback<Sig>& callback, const P1& p1, | |
| 1762 const P2& p2, const P3& p3, const P4& p4, const P5& p5, const P6& p6) { | |
| 1763 callback.Run(p1, p2, p3, p4, p5, p6); | |
| 1764 } | |
| 1765 | |
| 1766 // InvokerStorageN<> | |
| 1767 // | 1926 // |
| 1768 // These are the actual storage classes for the Invokers. | 1927 // Runnable is the functor we are binding arguments to. |
| 1928 // RunType is type of the Run() function that the Invoker<> should use. |
| 1929 // Normally, this is the same as the RunType of the Runnable, but it can |
| 1930 // be different if an adapter like IgnoreResult() has been used. |
| 1769 // | 1931 // |
| 1770 // Though these types are "classes", they are being used as structs with | 1932 // BoundArgsType contains the storage type for all the bound arguments by |
| 1771 // all member variable public. We cannot make it a struct because it inherits | 1933 // (ab)using a function type. |
| 1772 // from a class which causes a compiler warning. We cannot add a "Run()" method | 1934 template <typename Runnable, typename RunType, typename BoundArgsType> |
| 1773 // that forwards the unbound arguments because that would require we unwrap the | 1935 struct BindState; |
| 1774 // Sig type like in InvokerN above to know the return type, and the arity | 1936 |
| 1775 // of Run(). | 1937 template <typename Runnable, typename RunType> |
| 1776 // | 1938 struct BindState<Runnable, RunType, void()> : public BindStateBase { |
| 1777 // An alternate solution would be to merge InvokerN and InvokerStorageN, | 1939 typedef Runnable RunnableType; |
| 1778 // but the generated code seemed harder to read. | 1940 typedef false_type IsWeakCall; |
| 1779 | 1941 typedef Invoker<0, BindState, RunType> InvokerType; |
| 1780 template <typename Sig> | 1942 typedef typename InvokerType::UnboundRunType UnboundRunType; |
| 1781 class InvokerStorage0 : public InvokerStorageBase { | 1943 explicit BindState(const Runnable& runnable) |
| 1782 public: | 1944 : runnable_(runnable) { |
| 1783 typedef InvokerStorage0 StorageType; | 1945 } |
| 1784 typedef FunctionTraits<Sig> TargetTraits; | 1946 |
| 1785 typedef typename TargetTraits::IsMethod IsMethod; | 1947 virtual ~BindState() { } |
| 1786 typedef Sig Signature; | 1948 |
| 1787 typedef Invoker0<false, StorageType, | 1949 RunnableType runnable_; |
| 1788 typename TargetTraits::NormalizedSig> Invoker; | 1950 }; |
| 1789 | 1951 |
| 1790 | 1952 template <typename Runnable, typename RunType, typename P1> |
| 1791 | 1953 struct BindState<Runnable, RunType, void(P1)> : public BindStateBase { |
| 1792 InvokerStorage0(Sig f) | 1954 typedef Runnable RunnableType; |
| 1793 : f_(f) { | 1955 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall; |
| 1794 } | 1956 typedef Invoker<1, BindState, RunType> InvokerType; |
| 1795 | 1957 typedef typename InvokerType::UnboundRunType UnboundRunType; |
| 1796 virtual ~InvokerStorage0() { } | 1958 |
| 1797 | 1959 // Convenience typedefs for bound argument types. |
| 1798 Sig f_; | 1960 typedef UnwrapTraits<P1> Bound1UnwrapTraits; |
| 1799 }; | 1961 |
| 1800 | 1962 BindState(const Runnable& runnable, const P1& p1) |
| 1801 template <typename Sig, typename P1> | 1963 : runnable_(runnable), |
| 1802 class InvokerStorage1 : public InvokerStorageBase { | 1964 p1_(p1) { |
| 1803 public: | 1965 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); |
| 1804 typedef InvokerStorage1 StorageType; | 1966 } |
| 1805 typedef FunctionTraits<Sig> TargetTraits; | 1967 |
| 1806 typedef typename TargetTraits::IsMethod IsMethod; | 1968 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, |
| 1807 typedef Sig Signature; | 1969 P1>::Release(p1_); } |
| 1808 typedef ParamTraits<P1> P1Traits; | 1970 |
| 1809 typedef Invoker1<IsWeakMethod<IsMethod::value, P1>::value, StorageType, | 1971 RunnableType runnable_; |
| 1810 typename TargetTraits::NormalizedSig> Invoker; | 1972 P1 p1_; |
| 1811 COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || | 1973 }; |
| 1812 is_void<typename TargetTraits::Return>::value, | 1974 |
| 1813 weak_ptrs_can_only_bind_to_methods_without_return_values); | 1975 template <typename Runnable, typename RunType, typename P1, typename P2> |
| 1814 | 1976 struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase { |
| 1815 // For methods, we need to be careful for parameter 1. We skip the | 1977 typedef Runnable RunnableType; |
| 1816 // scoped_refptr check because the binder itself takes care of this. We also | 1978 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall; |
| 1817 // disallow binding of an array as the method's target object. | 1979 typedef Invoker<2, BindState, RunType> InvokerType; |
| 1818 COMPILE_ASSERT(IsMethod::value || | 1980 typedef typename InvokerType::UnboundRunType UnboundRunType; |
| 1819 internal::NeedsScopedRefptrButGetsRawPtr< | 1981 |
| 1820 typename ParamTraits<P1>::StorageType>::value == 0, | 1982 // Convenience typedefs for bound argument types. |
| 1821 p1_is_refcounted_type_and_needs_scoped_refptr); | 1983 typedef UnwrapTraits<P1> Bound1UnwrapTraits; |
| 1822 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 1984 typedef UnwrapTraits<P2> Bound2UnwrapTraits; |
| 1823 first_bound_argument_to_method_cannot_be_array); | 1985 |
| 1824 | 1986 BindState(const Runnable& runnable, const P1& p1, const P2& p2) |
| 1825 // Do not allow binding a non-const reference parameter. Non-const reference | 1987 : runnable_(runnable), |
| 1826 // parameters are disallowed by the Google style guide. Also, binding a | 1988 p1_(p1), |
| 1827 // non-const reference parameter can make for subtle bugs because the | 1989 p2_(p2) { |
| 1828 // invoked function will receive a reference to the stored copy of the | 1990 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); |
| 1829 // argument and not the original. | 1991 } |
| 1830 COMPILE_ASSERT( | 1992 |
| 1831 !( is_non_const_reference<typename TargetTraits::B1>::value ), | 1993 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, |
| 1832 do_not_bind_functions_with_nonconst_ref); | 1994 P1>::Release(p1_); } |
| 1833 | 1995 |
| 1834 | 1996 RunnableType runnable_; |
| 1835 InvokerStorage1(Sig f, const P1& p1) | 1997 P1 p1_; |
| 1836 : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)) { | 1998 P2 p2_; |
| 1837 MaybeRefcount<IsMethod, P1>::AddRef(p1_); | 1999 }; |
| 1838 } | 2000 |
| 1839 | 2001 template <typename Runnable, typename RunType, typename P1, typename P2, |
| 1840 virtual ~InvokerStorage1() { | 2002 typename P3> |
| 1841 MaybeRefcount<IsMethod, P1>::Release(p1_); | 2003 struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase { |
| 1842 } | 2004 typedef Runnable RunnableType; |
| 1843 | 2005 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall; |
| 1844 Sig f_; | 2006 typedef Invoker<3, BindState, RunType> InvokerType; |
| 1845 typename ParamTraits<P1>::StorageType p1_; | 2007 typedef typename InvokerType::UnboundRunType UnboundRunType; |
| 1846 }; | 2008 |
| 1847 | 2009 // Convenience typedefs for bound argument types. |
| 1848 template <typename Sig, typename P1, typename P2> | 2010 typedef UnwrapTraits<P1> Bound1UnwrapTraits; |
| 1849 class InvokerStorage2 : public InvokerStorageBase { | 2011 typedef UnwrapTraits<P2> Bound2UnwrapTraits; |
| 1850 public: | 2012 typedef UnwrapTraits<P3> Bound3UnwrapTraits; |
| 1851 typedef InvokerStorage2 StorageType; | 2013 |
| 1852 typedef FunctionTraits<Sig> TargetTraits; | 2014 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3) |
| 1853 typedef typename TargetTraits::IsMethod IsMethod; | 2015 : runnable_(runnable), |
| 1854 typedef Sig Signature; | 2016 p1_(p1), |
| 1855 typedef ParamTraits<P1> P1Traits; | 2017 p2_(p2), |
| 1856 typedef ParamTraits<P2> P2Traits; | 2018 p3_(p3) { |
| 1857 typedef Invoker2<IsWeakMethod<IsMethod::value, P1>::value, StorageType, | 2019 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); |
| 1858 typename TargetTraits::NormalizedSig> Invoker; | 2020 } |
| 1859 COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || | 2021 |
| 1860 is_void<typename TargetTraits::Return>::value, | 2022 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, |
| 1861 weak_ptrs_can_only_bind_to_methods_without_return_values); | 2023 P1>::Release(p1_); } |
| 1862 | 2024 |
| 1863 // For methods, we need to be careful for parameter 1. We skip the | 2025 RunnableType runnable_; |
| 1864 // scoped_refptr check because the binder itself takes care of this. We also | 2026 P1 p1_; |
| 1865 // disallow binding of an array as the method's target object. | 2027 P2 p2_; |
| 1866 COMPILE_ASSERT(IsMethod::value || | 2028 P3 p3_; |
| 1867 internal::NeedsScopedRefptrButGetsRawPtr< | 2029 }; |
| 1868 typename ParamTraits<P1>::StorageType>::value == 0, | 2030 |
| 1869 p1_is_refcounted_type_and_needs_scoped_refptr); | 2031 template <typename Runnable, typename RunType, typename P1, typename P2, |
| 1870 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | 2032 typename P3, typename P4> |
| 1871 first_bound_argument_to_method_cannot_be_array); | 2033 struct BindState<Runnable, RunType, void(P1, P2, P3, |
| 1872 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | 2034 P4)> : public BindStateBase { |
| 1873 typename ParamTraits<P2>::StorageType>::value == 0, | 2035 typedef Runnable RunnableType; |
| 1874 p2_is_refcounted_type_and_needs_scoped_refptr); | 2036 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall; |
| 1875 | 2037 typedef Invoker<4, BindState, RunType> InvokerType; |
| 1876 // Do not allow binding a non-const reference parameter. Non-const reference | 2038 typedef typename InvokerType::UnboundRunType UnboundRunType; |
| 1877 // parameters are disallowed by the Google style guide. Also, binding a | 2039 |
| 1878 // non-const reference parameter can make for subtle bugs because the | 2040 // Convenience typedefs for bound argument types. |
| 1879 // invoked function will receive a reference to the stored copy of the | 2041 typedef UnwrapTraits<P1> Bound1UnwrapTraits; |
| 1880 // argument and not the original. | 2042 typedef UnwrapTraits<P2> Bound2UnwrapTraits; |
| 1881 COMPILE_ASSERT( | 2043 typedef UnwrapTraits<P3> Bound3UnwrapTraits; |
| 1882 !( is_non_const_reference<typename TargetTraits::B1>::value || | 2044 typedef UnwrapTraits<P4> Bound4UnwrapTraits; |
| 1883 is_non_const_reference<typename TargetTraits::B2>::value ), | 2045 |
| 1884 do_not_bind_functions_with_nonconst_ref); | 2046 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, |
| 1885 | 2047 const P4& p4) |
| 1886 | 2048 : runnable_(runnable), |
| 1887 InvokerStorage2(Sig f, const P1& p1, const P2& p2) | 2049 p1_(p1), |
| 1888 : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), | 2050 p2_(p2), |
| 1889 p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)) { | 2051 p3_(p3), |
| 1890 MaybeRefcount<IsMethod, P1>::AddRef(p1_); | 2052 p4_(p4) { |
| 1891 } | 2053 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); |
| 1892 | 2054 } |
| 1893 virtual ~InvokerStorage2() { | 2055 |
| 1894 MaybeRefcount<IsMethod, P1>::Release(p1_); | 2056 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, |
| 1895 } | 2057 P1>::Release(p1_); } |
| 1896 | 2058 |
| 1897 Sig f_; | 2059 RunnableType runnable_; |
| 1898 typename ParamTraits<P1>::StorageType p1_; | 2060 P1 p1_; |
| 1899 typename ParamTraits<P2>::StorageType p2_; | 2061 P2 p2_; |
| 1900 }; | 2062 P3 p3_; |
| 1901 | 2063 P4 p4_; |
| 1902 template <typename Sig, typename P1, typename P2, typename P3> | 2064 }; |
| 1903 class InvokerStorage3 : public InvokerStorageBase { | 2065 |
| 1904 public: | 2066 template <typename Runnable, typename RunType, typename P1, typename P2, |
| 1905 typedef InvokerStorage3 StorageType; | 2067 typename P3, typename P4, typename P5> |
| 1906 typedef FunctionTraits<Sig> TargetTraits; | 2068 struct BindState<Runnable, RunType, void(P1, P2, P3, P4, |
| 1907 typedef typename TargetTraits::IsMethod IsMethod; | 2069 P5)> : public BindStateBase { |
| 1908 typedef Sig Signature; | 2070 typedef Runnable RunnableType; |
| 1909 typedef ParamTraits<P1> P1Traits; | 2071 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall; |
| 1910 typedef ParamTraits<P2> P2Traits; | 2072 typedef Invoker<5, BindState, RunType> InvokerType; |
| 1911 typedef ParamTraits<P3> P3Traits; | 2073 typedef typename InvokerType::UnboundRunType UnboundRunType; |
| 1912 typedef Invoker3<IsWeakMethod<IsMethod::value, P1>::value, StorageType, | 2074 |
| 1913 typename TargetTraits::NormalizedSig> Invoker; | 2075 // Convenience typedefs for bound argument types. |
| 1914 COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || | 2076 typedef UnwrapTraits<P1> Bound1UnwrapTraits; |
| 1915 is_void<typename TargetTraits::Return>::value, | 2077 typedef UnwrapTraits<P2> Bound2UnwrapTraits; |
| 1916 weak_ptrs_can_only_bind_to_methods_without_return_values); | 2078 typedef UnwrapTraits<P3> Bound3UnwrapTraits; |
| 1917 | 2079 typedef UnwrapTraits<P4> Bound4UnwrapTraits; |
| 1918 // For methods, we need to be careful for parameter 1. We skip the | 2080 typedef UnwrapTraits<P5> Bound5UnwrapTraits; |
| 1919 // scoped_refptr check because the binder itself takes care of this. We also | 2081 |
| 1920 // disallow binding of an array as the method's target object. | 2082 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, |
| 1921 COMPILE_ASSERT(IsMethod::value || | |
| 1922 internal::NeedsScopedRefptrButGetsRawPtr< | |
| 1923 typename ParamTraits<P1>::StorageType>::value == 0, | |
| 1924 p1_is_refcounted_type_and_needs_scoped_refptr); | |
| 1925 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | |
| 1926 first_bound_argument_to_method_cannot_be_array); | |
| 1927 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 1928 typename ParamTraits<P2>::StorageType>::value == 0, | |
| 1929 p2_is_refcounted_type_and_needs_scoped_refptr); | |
| 1930 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 1931 typename ParamTraits<P3>::StorageType>::value == 0, | |
| 1932 p3_is_refcounted_type_and_needs_scoped_refptr); | |
| 1933 | |
| 1934 // Do not allow binding a non-const reference parameter. Non-const reference | |
| 1935 // parameters are disallowed by the Google style guide. Also, binding a | |
| 1936 // non-const reference parameter can make for subtle bugs because the | |
| 1937 // invoked function will receive a reference to the stored copy of the | |
| 1938 // argument and not the original. | |
| 1939 COMPILE_ASSERT( | |
| 1940 !( is_non_const_reference<typename TargetTraits::B1>::value || | |
| 1941 is_non_const_reference<typename TargetTraits::B2>::value || | |
| 1942 is_non_const_reference<typename TargetTraits::B3>::value ), | |
| 1943 do_not_bind_functions_with_nonconst_ref); | |
| 1944 | |
| 1945 | |
| 1946 InvokerStorage3(Sig f, const P1& p1, const P2& p2, const P3& p3) | |
| 1947 : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), | |
| 1948 p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), | |
| 1949 p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)) { | |
| 1950 MaybeRefcount<IsMethod, P1>::AddRef(p1_); | |
| 1951 } | |
| 1952 | |
| 1953 virtual ~InvokerStorage3() { | |
| 1954 MaybeRefcount<IsMethod, P1>::Release(p1_); | |
| 1955 } | |
| 1956 | |
| 1957 Sig f_; | |
| 1958 typename ParamTraits<P1>::StorageType p1_; | |
| 1959 typename ParamTraits<P2>::StorageType p2_; | |
| 1960 typename ParamTraits<P3>::StorageType p3_; | |
| 1961 }; | |
| 1962 | |
| 1963 template <typename Sig, typename P1, typename P2, typename P3, typename P4> | |
| 1964 class InvokerStorage4 : public InvokerStorageBase { | |
| 1965 public: | |
| 1966 typedef InvokerStorage4 StorageType; | |
| 1967 typedef FunctionTraits<Sig> TargetTraits; | |
| 1968 typedef typename TargetTraits::IsMethod IsMethod; | |
| 1969 typedef Sig Signature; | |
| 1970 typedef ParamTraits<P1> P1Traits; | |
| 1971 typedef ParamTraits<P2> P2Traits; | |
| 1972 typedef ParamTraits<P3> P3Traits; | |
| 1973 typedef ParamTraits<P4> P4Traits; | |
| 1974 typedef Invoker4<IsWeakMethod<IsMethod::value, P1>::value, StorageType, | |
| 1975 typename TargetTraits::NormalizedSig> Invoker; | |
| 1976 COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || | |
| 1977 is_void<typename TargetTraits::Return>::value, | |
| 1978 weak_ptrs_can_only_bind_to_methods_without_return_values); | |
| 1979 | |
| 1980 // For methods, we need to be careful for parameter 1. We skip the | |
| 1981 // scoped_refptr check because the binder itself takes care of this. We also | |
| 1982 // disallow binding of an array as the method's target object. | |
| 1983 COMPILE_ASSERT(IsMethod::value || | |
| 1984 internal::NeedsScopedRefptrButGetsRawPtr< | |
| 1985 typename ParamTraits<P1>::StorageType>::value == 0, | |
| 1986 p1_is_refcounted_type_and_needs_scoped_refptr); | |
| 1987 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | |
| 1988 first_bound_argument_to_method_cannot_be_array); | |
| 1989 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 1990 typename ParamTraits<P2>::StorageType>::value == 0, | |
| 1991 p2_is_refcounted_type_and_needs_scoped_refptr); | |
| 1992 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 1993 typename ParamTraits<P3>::StorageType>::value == 0, | |
| 1994 p3_is_refcounted_type_and_needs_scoped_refptr); | |
| 1995 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 1996 typename ParamTraits<P4>::StorageType>::value == 0, | |
| 1997 p4_is_refcounted_type_and_needs_scoped_refptr); | |
| 1998 | |
| 1999 // Do not allow binding a non-const reference parameter. Non-const reference | |
| 2000 // parameters are disallowed by the Google style guide. Also, binding a | |
| 2001 // non-const reference parameter can make for subtle bugs because the | |
| 2002 // invoked function will receive a reference to the stored copy of the | |
| 2003 // argument and not the original. | |
| 2004 COMPILE_ASSERT( | |
| 2005 !( is_non_const_reference<typename TargetTraits::B1>::value || | |
| 2006 is_non_const_reference<typename TargetTraits::B2>::value || | |
| 2007 is_non_const_reference<typename TargetTraits::B3>::value || | |
| 2008 is_non_const_reference<typename TargetTraits::B4>::value ), | |
| 2009 do_not_bind_functions_with_nonconst_ref); | |
| 2010 | |
| 2011 | |
| 2012 InvokerStorage4(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4) | |
| 2013 : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), | |
| 2014 p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), | |
| 2015 p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)), | |
| 2016 p4_(static_cast<typename ParamTraits<P4>::StorageType>(p4)) { | |
| 2017 MaybeRefcount<IsMethod, P1>::AddRef(p1_); | |
| 2018 } | |
| 2019 | |
| 2020 virtual ~InvokerStorage4() { | |
| 2021 MaybeRefcount<IsMethod, P1>::Release(p1_); | |
| 2022 } | |
| 2023 | |
| 2024 Sig f_; | |
| 2025 typename ParamTraits<P1>::StorageType p1_; | |
| 2026 typename ParamTraits<P2>::StorageType p2_; | |
| 2027 typename ParamTraits<P3>::StorageType p3_; | |
| 2028 typename ParamTraits<P4>::StorageType p4_; | |
| 2029 }; | |
| 2030 | |
| 2031 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | |
| 2032 typename P5> | |
| 2033 class InvokerStorage5 : public InvokerStorageBase { | |
| 2034 public: | |
| 2035 typedef InvokerStorage5 StorageType; | |
| 2036 typedef FunctionTraits<Sig> TargetTraits; | |
| 2037 typedef typename TargetTraits::IsMethod IsMethod; | |
| 2038 typedef Sig Signature; | |
| 2039 typedef ParamTraits<P1> P1Traits; | |
| 2040 typedef ParamTraits<P2> P2Traits; | |
| 2041 typedef ParamTraits<P3> P3Traits; | |
| 2042 typedef ParamTraits<P4> P4Traits; | |
| 2043 typedef ParamTraits<P5> P5Traits; | |
| 2044 typedef Invoker5<IsWeakMethod<IsMethod::value, P1>::value, StorageType, | |
| 2045 typename TargetTraits::NormalizedSig> Invoker; | |
| 2046 COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || | |
| 2047 is_void<typename TargetTraits::Return>::value, | |
| 2048 weak_ptrs_can_only_bind_to_methods_without_return_values); | |
| 2049 | |
| 2050 // For methods, we need to be careful for parameter 1. We skip the | |
| 2051 // scoped_refptr check because the binder itself takes care of this. We also | |
| 2052 // disallow binding of an array as the method's target object. | |
| 2053 COMPILE_ASSERT(IsMethod::value || | |
| 2054 internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2055 typename ParamTraits<P1>::StorageType>::value == 0, | |
| 2056 p1_is_refcounted_type_and_needs_scoped_refptr); | |
| 2057 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | |
| 2058 first_bound_argument_to_method_cannot_be_array); | |
| 2059 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2060 typename ParamTraits<P2>::StorageType>::value == 0, | |
| 2061 p2_is_refcounted_type_and_needs_scoped_refptr); | |
| 2062 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2063 typename ParamTraits<P3>::StorageType>::value == 0, | |
| 2064 p3_is_refcounted_type_and_needs_scoped_refptr); | |
| 2065 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2066 typename ParamTraits<P4>::StorageType>::value == 0, | |
| 2067 p4_is_refcounted_type_and_needs_scoped_refptr); | |
| 2068 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2069 typename ParamTraits<P5>::StorageType>::value == 0, | |
| 2070 p5_is_refcounted_type_and_needs_scoped_refptr); | |
| 2071 | |
| 2072 // Do not allow binding a non-const reference parameter. Non-const reference | |
| 2073 // parameters are disallowed by the Google style guide. Also, binding a | |
| 2074 // non-const reference parameter can make for subtle bugs because the | |
| 2075 // invoked function will receive a reference to the stored copy of the | |
| 2076 // argument and not the original. | |
| 2077 COMPILE_ASSERT( | |
| 2078 !( is_non_const_reference<typename TargetTraits::B1>::value || | |
| 2079 is_non_const_reference<typename TargetTraits::B2>::value || | |
| 2080 is_non_const_reference<typename TargetTraits::B3>::value || | |
| 2081 is_non_const_reference<typename TargetTraits::B4>::value || | |
| 2082 is_non_const_reference<typename TargetTraits::B5>::value ), | |
| 2083 do_not_bind_functions_with_nonconst_ref); | |
| 2084 | |
| 2085 | |
| 2086 InvokerStorage5(Sig f, const P1& p1, const P2& p2, const P3& p3, | |
| 2087 const P4& p4, const P5& p5) | 2083 const P4& p4, const P5& p5) |
| 2088 : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), | 2084 : runnable_(runnable), |
| 2089 p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), | 2085 p1_(p1), |
| 2090 p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)), | 2086 p2_(p2), |
| 2091 p4_(static_cast<typename ParamTraits<P4>::StorageType>(p4)), | 2087 p3_(p3), |
| 2092 p5_(static_cast<typename ParamTraits<P5>::StorageType>(p5)) { | 2088 p4_(p4), |
| 2093 MaybeRefcount<IsMethod, P1>::AddRef(p1_); | 2089 p5_(p5) { |
| 2094 } | 2090 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); |
| 2095 | 2091 } |
| 2096 virtual ~InvokerStorage5() { | 2092 |
| 2097 MaybeRefcount<IsMethod, P1>::Release(p1_); | 2093 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, |
| 2098 } | 2094 P1>::Release(p1_); } |
| 2099 | 2095 |
| 2100 Sig f_; | 2096 RunnableType runnable_; |
| 2101 typename ParamTraits<P1>::StorageType p1_; | 2097 P1 p1_; |
| 2102 typename ParamTraits<P2>::StorageType p2_; | 2098 P2 p2_; |
| 2103 typename ParamTraits<P3>::StorageType p3_; | 2099 P3 p3_; |
| 2104 typename ParamTraits<P4>::StorageType p4_; | 2100 P4 p4_; |
| 2105 typename ParamTraits<P5>::StorageType p5_; | 2101 P5 p5_; |
| 2106 }; | 2102 }; |
| 2107 | 2103 |
| 2108 template <typename Sig, typename P1, typename P2, typename P3, typename P4, | 2104 template <typename Runnable, typename RunType, typename P1, typename P2, |
| 2109 typename P5, typename P6> | 2105 typename P3, typename P4, typename P5, typename P6> |
| 2110 class InvokerStorage6 : public InvokerStorageBase { | 2106 struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, |
| 2111 public: | 2107 P6)> : public BindStateBase { |
| 2112 typedef InvokerStorage6 StorageType; | 2108 typedef Runnable RunnableType; |
| 2113 typedef FunctionTraits<Sig> TargetTraits; | 2109 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall; |
| 2114 typedef typename TargetTraits::IsMethod IsMethod; | 2110 typedef Invoker<6, BindState, RunType> InvokerType; |
| 2115 typedef Sig Signature; | 2111 typedef typename InvokerType::UnboundRunType UnboundRunType; |
| 2116 typedef ParamTraits<P1> P1Traits; | 2112 |
| 2117 typedef ParamTraits<P2> P2Traits; | 2113 // Convenience typedefs for bound argument types. |
| 2118 typedef ParamTraits<P3> P3Traits; | 2114 typedef UnwrapTraits<P1> Bound1UnwrapTraits; |
| 2119 typedef ParamTraits<P4> P4Traits; | 2115 typedef UnwrapTraits<P2> Bound2UnwrapTraits; |
| 2120 typedef ParamTraits<P5> P5Traits; | 2116 typedef UnwrapTraits<P3> Bound3UnwrapTraits; |
| 2121 typedef ParamTraits<P6> P6Traits; | 2117 typedef UnwrapTraits<P4> Bound4UnwrapTraits; |
| 2122 typedef Invoker6<IsWeakMethod<IsMethod::value, P1>::value, StorageType, | 2118 typedef UnwrapTraits<P5> Bound5UnwrapTraits; |
| 2123 typename TargetTraits::NormalizedSig> Invoker; | 2119 typedef UnwrapTraits<P6> Bound6UnwrapTraits; |
| 2124 COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || | 2120 |
| 2125 is_void<typename TargetTraits::Return>::value, | 2121 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, |
| 2126 weak_ptrs_can_only_bind_to_methods_without_return_values); | |
| 2127 | |
| 2128 // For methods, we need to be careful for parameter 1. We skip the | |
| 2129 // scoped_refptr check because the binder itself takes care of this. We also | |
| 2130 // disallow binding of an array as the method's target object. | |
| 2131 COMPILE_ASSERT(IsMethod::value || | |
| 2132 internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2133 typename ParamTraits<P1>::StorageType>::value == 0, | |
| 2134 p1_is_refcounted_type_and_needs_scoped_refptr); | |
| 2135 COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, | |
| 2136 first_bound_argument_to_method_cannot_be_array); | |
| 2137 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2138 typename ParamTraits<P2>::StorageType>::value == 0, | |
| 2139 p2_is_refcounted_type_and_needs_scoped_refptr); | |
| 2140 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2141 typename ParamTraits<P3>::StorageType>::value == 0, | |
| 2142 p3_is_refcounted_type_and_needs_scoped_refptr); | |
| 2143 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2144 typename ParamTraits<P4>::StorageType>::value == 0, | |
| 2145 p4_is_refcounted_type_and_needs_scoped_refptr); | |
| 2146 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2147 typename ParamTraits<P5>::StorageType>::value == 0, | |
| 2148 p5_is_refcounted_type_and_needs_scoped_refptr); | |
| 2149 COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< | |
| 2150 typename ParamTraits<P6>::StorageType>::value == 0, | |
| 2151 p6_is_refcounted_type_and_needs_scoped_refptr); | |
| 2152 | |
| 2153 // Do not allow binding a non-const reference parameter. Non-const reference | |
| 2154 // parameters are disallowed by the Google style guide. Also, binding a | |
| 2155 // non-const reference parameter can make for subtle bugs because the | |
| 2156 // invoked function will receive a reference to the stored copy of the | |
| 2157 // argument and not the original. | |
| 2158 COMPILE_ASSERT( | |
| 2159 !( is_non_const_reference<typename TargetTraits::B1>::value || | |
| 2160 is_non_const_reference<typename TargetTraits::B2>::value || | |
| 2161 is_non_const_reference<typename TargetTraits::B3>::value || | |
| 2162 is_non_const_reference<typename TargetTraits::B4>::value || | |
| 2163 is_non_const_reference<typename TargetTraits::B5>::value || | |
| 2164 is_non_const_reference<typename TargetTraits::B6>::value ), | |
| 2165 do_not_bind_functions_with_nonconst_ref); | |
| 2166 | |
| 2167 | |
| 2168 InvokerStorage6(Sig f, const P1& p1, const P2& p2, const P3& p3, | |
| 2169 const P4& p4, const P5& p5, const P6& p6) | 2122 const P4& p4, const P5& p5, const P6& p6) |
| 2170 : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), | 2123 : runnable_(runnable), |
| 2171 p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), | 2124 p1_(p1), |
| 2172 p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)), | 2125 p2_(p2), |
| 2173 p4_(static_cast<typename ParamTraits<P4>::StorageType>(p4)), | 2126 p3_(p3), |
| 2174 p5_(static_cast<typename ParamTraits<P5>::StorageType>(p5)), | 2127 p4_(p4), |
| 2175 p6_(static_cast<typename ParamTraits<P6>::StorageType>(p6)) { | 2128 p5_(p5), |
| 2176 MaybeRefcount<IsMethod, P1>::AddRef(p1_); | 2129 p6_(p6) { |
| 2177 } | 2130 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_); |
| 2178 | 2131 } |
| 2179 virtual ~InvokerStorage6() { | 2132 |
| 2180 MaybeRefcount<IsMethod, P1>::Release(p1_); | 2133 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value, |
| 2181 } | 2134 P1>::Release(p1_); } |
| 2182 | 2135 |
| 2183 Sig f_; | 2136 RunnableType runnable_; |
| 2184 typename ParamTraits<P1>::StorageType p1_; | 2137 P1 p1_; |
| 2185 typename ParamTraits<P2>::StorageType p2_; | 2138 P2 p2_; |
| 2186 typename ParamTraits<P3>::StorageType p3_; | 2139 P3 p3_; |
| 2187 typename ParamTraits<P4>::StorageType p4_; | 2140 P4 p4_; |
| 2188 typename ParamTraits<P5>::StorageType p5_; | 2141 P5 p5_; |
| 2189 typename ParamTraits<P6>::StorageType p6_; | 2142 P6 p6_; |
| 2190 }; | 2143 }; |
| 2191 | 2144 |
| 2192 } // namespace internal | 2145 } // namespace internal |
| 2193 } // namespace base | 2146 } // namespace base |
| 2194 | 2147 |
| 2195 #endif // BASE_BIND_INTERNAL_H_ | 2148 #endif // BASE_BIND_INTERNAL_H_ |
| OLD | NEW |