michael@0: // This file was GENERATED by command: michael@0: // pump.py bind_internal.h.pump michael@0: // DO NOT EDIT BY HAND!!! michael@0: michael@0: michael@0: // Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_BIND_INTERNAL_H_ michael@0: #define BASE_BIND_INTERNAL_H_ michael@0: michael@0: #include "base/bind_helpers.h" michael@0: #include "base/callback_internal.h" michael@0: #include "base/memory/raw_scoped_refptr_mismatch_checker.h" michael@0: #include "base/memory/weak_ptr.h" michael@0: #include "base/template_util.h" michael@0: #include "build/build_config.h" michael@0: michael@0: #if defined(OS_WIN) michael@0: #include "base/bind_internal_win.h" michael@0: #endif michael@0: michael@0: namespace base { michael@0: namespace internal { michael@0: michael@0: // See base/callback.h for user documentation. michael@0: // michael@0: // michael@0: // CONCEPTS: michael@0: // Runnable -- A type (really a type class) that has a single Run() method michael@0: // and a RunType typedef that corresponds to the type of Run(). michael@0: // A Runnable can declare that it should treated like a method michael@0: // call by including a typedef named IsMethod. The value of michael@0: // this typedef is NOT inspected, only the existence. When a michael@0: // Runnable declares itself a method, Bind() will enforce special michael@0: // refcounting + WeakPtr handling semantics for the first michael@0: // parameter which is expected to be an object. michael@0: // Functor -- A copyable type representing something that should be called. michael@0: // All function pointers, Callback<>, and Runnables are functors michael@0: // even if the invocation syntax differs. michael@0: // RunType -- A function type (as opposed to function _pointer_ type) for michael@0: // a Run() function. Usually just a convenience typedef. michael@0: // (Bound)ArgsType -- A function type that is being (ab)used to store the michael@0: // types of set of arguments. The "return" type is always michael@0: // void here. We use this hack so that we do not need michael@0: // a new type name for each arity of type. (eg., michael@0: // BindState1, BindState2). This makes forward michael@0: // declarations and friending much much easier. michael@0: // michael@0: // Types: michael@0: // RunnableAdapter<> -- Wraps the various "function" pointer types into an michael@0: // object that adheres to the Runnable interface. michael@0: // There are |3*ARITY| RunnableAdapter types. michael@0: // FunctionTraits<> -- Type traits that unwrap a function signature into a michael@0: // a set of easier to use typedefs. Used mainly for michael@0: // compile time asserts. michael@0: // There are |ARITY| FunctionTraits types. michael@0: // ForceVoidReturn<> -- Helper class for translating function signatures to michael@0: // equivalent forms with a "void" return type. michael@0: // There are |ARITY| ForceVoidReturn types. michael@0: // FunctorTraits<> -- Type traits used determine the correct RunType and michael@0: // RunnableType for a Functor. This is where function michael@0: // signature adapters are applied. michael@0: // There are |ARITY| ForceVoidReturn types. michael@0: // MakeRunnable<> -- Takes a Functor and returns an object in the Runnable michael@0: // type class that represents the underlying Functor. michael@0: // There are |O(1)| MakeRunnable types. michael@0: // InvokeHelper<> -- Take a Runnable + arguments and actully invokes it. michael@0: // Handle the differing syntaxes needed for WeakPtr<> support, michael@0: // and for ignoring return values. This is separate from michael@0: // Invoker to avoid creating multiple version of Invoker<> michael@0: // which grows at O(n^2) with the arity. michael@0: // There are |k*ARITY| InvokeHelper types. michael@0: // Invoker<> -- Unwraps the curried parameters and executes the Runnable. michael@0: // There are |(ARITY^2 + ARITY)/2| Invoketypes. michael@0: // BindState<> -- Stores the curried parameters, and is the main entry point michael@0: // into the Bind() system, doing most of the type resolution. michael@0: // There are ARITY BindState types. michael@0: michael@0: // RunnableAdapter<> michael@0: // michael@0: // The RunnableAdapter<> templates provide a uniform interface for invoking michael@0: // a function pointer, method pointer, or const method pointer. The adapter michael@0: // exposes a Run() method with an appropriate signature. Using this wrapper michael@0: // allows for writing code that supports all three pointer types without michael@0: // undue repetition. Without it, a lot of code would need to be repeated 3 michael@0: // times. michael@0: // michael@0: // For method pointers and const method pointers the first argument to Run() michael@0: // is considered to be the received of the method. This is similar to STL's michael@0: // mem_fun(). michael@0: // michael@0: // This class also exposes a RunType typedef that is the function type of the michael@0: // Run() function. michael@0: // michael@0: // If and only if the wrapper contains a method or const method pointer, an michael@0: // IsMethod typedef is exposed. The existence of this typedef (NOT the value) michael@0: // marks that the wrapper should be considered a method wrapper. michael@0: michael@0: template michael@0: class RunnableAdapter; michael@0: michael@0: // Function: Arity 0. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(); michael@0: michael@0: explicit RunnableAdapter(R(*function)()) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run() { michael@0: return function_(); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(); michael@0: }; michael@0: michael@0: // Method: Arity 0. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)()) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object) { michael@0: return (object->*method_)(); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(); michael@0: }; michael@0: michael@0: // Const Method: Arity 0. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)() const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object) { michael@0: return (object->*method_)(); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)() const; michael@0: }; michael@0: michael@0: // Function: Arity 1. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(A1); michael@0: michael@0: explicit RunnableAdapter(R(*function)(A1)) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run(typename CallbackParamTraits::ForwardType a1) { michael@0: return function_(CallbackForward(a1)); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(A1); michael@0: }; michael@0: michael@0: // Method: Arity 1. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*, A1); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1)) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object, typename CallbackParamTraits::ForwardType a1) { michael@0: return (object->*method_)(CallbackForward(a1)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1); michael@0: }; michael@0: michael@0: // Const Method: Arity 1. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*, A1); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1) const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object, typename CallbackParamTraits::ForwardType a1) { michael@0: return (object->*method_)(CallbackForward(a1)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1) const; michael@0: }; michael@0: michael@0: // Function: Arity 2. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(A1, A2); michael@0: michael@0: explicit RunnableAdapter(R(*function)(A1, A2)) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run(typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2) { michael@0: return function_(CallbackForward(a1), CallbackForward(a2)); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(A1, A2); michael@0: }; michael@0: michael@0: // Method: Arity 2. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*, A1, A2); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2)) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2); michael@0: }; michael@0: michael@0: // Const Method: Arity 2. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*, A1, A2); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2) const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2) const; michael@0: }; michael@0: michael@0: // Function: Arity 3. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(A1, A2, A3); michael@0: michael@0: explicit RunnableAdapter(R(*function)(A1, A2, A3)) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run(typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3) { michael@0: return function_(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3)); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(A1, A2, A3); michael@0: }; michael@0: michael@0: // Method: Arity 3. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*, A1, A2, A3); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3)) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3); michael@0: }; michael@0: michael@0: // Const Method: Arity 3. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*, A1, A2, A3); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3) const; michael@0: }; michael@0: michael@0: // Function: Arity 4. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(A1, A2, A3, A4); michael@0: michael@0: explicit RunnableAdapter(R(*function)(A1, A2, A3, A4)) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run(typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4) { michael@0: return function_(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4)); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(A1, A2, A3, A4); michael@0: }; michael@0: michael@0: // Method: Arity 4. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*, A1, A2, A3, A4); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4)) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4); michael@0: }; michael@0: michael@0: // Const Method: Arity 4. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*, A1, A2, A3, A4); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4) const; michael@0: }; michael@0: michael@0: // Function: Arity 5. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(A1, A2, A3, A4, A5); michael@0: michael@0: explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5)) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run(typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5) { michael@0: return function_(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(A1, A2, A3, A4, A5); michael@0: }; michael@0: michael@0: // Method: Arity 5. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*, A1, A2, A3, A4, A5); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5)) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4, A5); michael@0: }; michael@0: michael@0: // Const Method: Arity 5. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*, A1, A2, A3, A4, A5); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4, A5) const; michael@0: }; michael@0: michael@0: // Function: Arity 6. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(A1, A2, A3, A4, A5, A6); michael@0: michael@0: explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6)) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run(typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5, michael@0: typename CallbackParamTraits::ForwardType a6) { michael@0: return function_(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6)); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(A1, A2, A3, A4, A5, A6); michael@0: }; michael@0: michael@0: // Method: Arity 6. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6)) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5, michael@0: typename CallbackParamTraits::ForwardType a6) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4, A5, A6); michael@0: }; michael@0: michael@0: // Const Method: Arity 6. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5, michael@0: typename CallbackParamTraits::ForwardType a6) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4, A5, A6) const; michael@0: }; michael@0: michael@0: // Function: Arity 7. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7); michael@0: michael@0: explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7)) michael@0: : function_(function) { michael@0: } michael@0: michael@0: R Run(typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5, michael@0: typename CallbackParamTraits::ForwardType a6, michael@0: typename CallbackParamTraits::ForwardType a7) { michael@0: return function_(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6), CallbackForward(a7)); michael@0: } michael@0: michael@0: private: michael@0: R (*function_)(A1, A2, A3, A4, A5, A6, A7); michael@0: }; michael@0: michael@0: // Method: Arity 7. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7)) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5, michael@0: typename CallbackParamTraits::ForwardType a6, michael@0: typename CallbackParamTraits::ForwardType a7) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6), CallbackForward(a7)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4, A5, A6, A7); michael@0: }; michael@0: michael@0: // Const Method: Arity 7. michael@0: template michael@0: class RunnableAdapter { michael@0: public: michael@0: typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7); michael@0: typedef true_type IsMethod; michael@0: michael@0: explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const) michael@0: : method_(method) { michael@0: } michael@0: michael@0: R Run(const T* object, typename CallbackParamTraits::ForwardType a1, michael@0: typename CallbackParamTraits::ForwardType a2, michael@0: typename CallbackParamTraits::ForwardType a3, michael@0: typename CallbackParamTraits::ForwardType a4, michael@0: typename CallbackParamTraits::ForwardType a5, michael@0: typename CallbackParamTraits::ForwardType a6, michael@0: typename CallbackParamTraits::ForwardType a7) { michael@0: return (object->*method_)(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6), CallbackForward(a7)); michael@0: } michael@0: michael@0: private: michael@0: R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const; michael@0: }; michael@0: michael@0: michael@0: // FunctionTraits<> michael@0: // michael@0: // Breaks a function signature apart into typedefs for easier introspection. michael@0: template michael@0: struct FunctionTraits; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: }; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: typedef A1 A1Type; michael@0: }; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: typedef A1 A1Type; michael@0: typedef A2 A2Type; michael@0: }; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: typedef A1 A1Type; michael@0: typedef A2 A2Type; michael@0: typedef A3 A3Type; michael@0: }; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: typedef A1 A1Type; michael@0: typedef A2 A2Type; michael@0: typedef A3 A3Type; michael@0: typedef A4 A4Type; michael@0: }; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: typedef A1 A1Type; michael@0: typedef A2 A2Type; michael@0: typedef A3 A3Type; michael@0: typedef A4 A4Type; michael@0: typedef A5 A5Type; michael@0: }; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: typedef A1 A1Type; michael@0: typedef A2 A2Type; michael@0: typedef A3 A3Type; michael@0: typedef A4 A4Type; michael@0: typedef A5 A5Type; michael@0: typedef A6 A6Type; michael@0: }; michael@0: michael@0: template michael@0: struct FunctionTraits { michael@0: typedef R ReturnType; michael@0: typedef A1 A1Type; michael@0: typedef A2 A2Type; michael@0: typedef A3 A3Type; michael@0: typedef A4 A4Type; michael@0: typedef A5 A5Type; michael@0: typedef A6 A6Type; michael@0: typedef A7 A7Type; michael@0: }; michael@0: michael@0: michael@0: // ForceVoidReturn<> michael@0: // michael@0: // Set of templates that support forcing the function return type to void. michael@0: template michael@0: struct ForceVoidReturn; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(); michael@0: }; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(A1); michael@0: }; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(A1, A2); michael@0: }; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(A1, A2, A3); michael@0: }; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(A1, A2, A3, A4); michael@0: }; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(A1, A2, A3, A4, A5); michael@0: }; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(A1, A2, A3, A4, A5, A6); michael@0: }; michael@0: michael@0: template michael@0: struct ForceVoidReturn { michael@0: typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7); michael@0: }; michael@0: michael@0: michael@0: // FunctorTraits<> michael@0: // michael@0: // See description at top of file. michael@0: template michael@0: struct FunctorTraits { michael@0: typedef RunnableAdapter RunnableType; michael@0: typedef typename RunnableType::RunType RunType; michael@0: }; michael@0: michael@0: template michael@0: struct FunctorTraits > { michael@0: typedef typename FunctorTraits::RunnableType RunnableType; michael@0: typedef typename ForceVoidReturn< michael@0: typename RunnableType::RunType>::RunType RunType; michael@0: }; michael@0: michael@0: template michael@0: struct FunctorTraits > { michael@0: typedef Callback RunnableType; michael@0: typedef typename Callback::RunType RunType; michael@0: }; michael@0: michael@0: michael@0: // MakeRunnable<> michael@0: // michael@0: // Converts a passed in functor to a RunnableType using type inference. michael@0: michael@0: template michael@0: typename FunctorTraits::RunnableType MakeRunnable(const T& t) { michael@0: return RunnableAdapter(t); michael@0: } michael@0: michael@0: template michael@0: typename FunctorTraits::RunnableType michael@0: MakeRunnable(const IgnoreResultHelper& t) { michael@0: return MakeRunnable(t.functor_); michael@0: } michael@0: michael@0: template michael@0: const typename FunctorTraits >::RunnableType& michael@0: MakeRunnable(const Callback& t) { michael@0: DCHECK(!t.is_null()); michael@0: return t; michael@0: } michael@0: michael@0: michael@0: // InvokeHelper<> michael@0: // michael@0: // There are 3 logical InvokeHelper<> specializations: normal, void-return, michael@0: // WeakCalls. michael@0: // michael@0: // The normal type just calls the underlying runnable. michael@0: // michael@0: // We need a InvokeHelper to handle void return types in order to support michael@0: // IgnoreResult(). Normally, if the Runnable's RunType had a void return, michael@0: // the template system would just accept "return functor.Run()" ignoring michael@0: // the fact that a void function is being used with return. This piece of michael@0: // sugar breaks though when the Runnable's RunType is not void. Thus, we michael@0: // need a partial specialization to change the syntax to drop the "return" michael@0: // from the invocation call. michael@0: // michael@0: // WeakCalls similarly need special syntax that is applied to the first michael@0: // argument to check if they should no-op themselves. michael@0: template michael@0: struct InvokeHelper; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable) { michael@0: return runnable.Run(); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable) { michael@0: runnable.Run(); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable, A1 a1) { michael@0: return runnable.Run(CallbackForward(a1)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, A1 a1) { michael@0: runnable.Run(CallbackForward(a1)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr) { michael@0: if (!weak_ptr.get()) { michael@0: return; michael@0: } michael@0: runnable.Run(weak_ptr.get()); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) { michael@0: return runnable.Run(CallbackForward(a1), CallbackForward(a2)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, A1 a1, A2 a2) { michael@0: runnable.Run(CallbackForward(a1), CallbackForward(a2)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2) { michael@0: if (!weak_ptr.get()) { michael@0: return; michael@0: } michael@0: runnable.Run(weak_ptr.get(), CallbackForward(a2)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { michael@0: return runnable.Run(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { michael@0: runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3) { michael@0: if (!weak_ptr.get()) { michael@0: return; michael@0: } michael@0: runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { michael@0: return runnable.Run(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { michael@0: runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, michael@0: A4 a4) { michael@0: if (!weak_ptr.get()) { michael@0: return; michael@0: } michael@0: runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, michael@0: A5 a5) { michael@0: return runnable.Run(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { michael@0: runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4), CallbackForward(a5)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, michael@0: A4 a4, A5 a5) { michael@0: if (!weak_ptr.get()) { michael@0: return; michael@0: } michael@0: runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4), CallbackForward(a5)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, michael@0: A5 a5, A6 a6) { michael@0: return runnable.Run(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, michael@0: A6 a6) { michael@0: runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, michael@0: A4 a4, A5 a5, A6 a6) { michael@0: if (!weak_ptr.get()) { michael@0: return; michael@0: } michael@0: runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, michael@0: A5 a5, A6 a6, A7 a7) { michael@0: return runnable.Run(CallbackForward(a1), CallbackForward(a2), michael@0: CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), michael@0: CallbackForward(a6), CallbackForward(a7)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, michael@0: A6 a6, A7 a7) { michael@0: runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), michael@0: CallbackForward(a7)); michael@0: } michael@0: }; michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, michael@0: A4 a4, A5 a5, A6 a6, A7 a7) { michael@0: if (!weak_ptr.get()) { michael@0: return; michael@0: } michael@0: runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), michael@0: CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), michael@0: CallbackForward(a7)); michael@0: } michael@0: }; michael@0: michael@0: #if !defined(_MSC_VER) michael@0: michael@0: template michael@0: struct InvokeHelper { michael@0: // WeakCalls are only supported for functions with a void return type. michael@0: // Otherwise, the function result would be undefined if the the WeakPtr<> michael@0: // is invalidated. michael@0: COMPILE_ASSERT(is_void::value, michael@0: weak_ptrs_can_only_bind_to_methods_without_return_values); michael@0: }; michael@0: michael@0: #endif michael@0: michael@0: // Invoker<> michael@0: // michael@0: // See description at the top of the file. michael@0: template michael@0: struct Invoker; michael@0: michael@0: // Arity 0 -> 0. michael@0: template michael@0: struct Invoker<0, StorageType, R()> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_); michael@0: } michael@0: }; michael@0: michael@0: // Arity 1 -> 1. michael@0: template michael@0: struct Invoker<0, StorageType, R(X1)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X1); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x1) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper::ForwardType x1)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 1 -> 0. michael@0: template michael@0: struct Invoker<1, StorageType, R(X1)> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 2 -> 2. michael@0: template michael@0: struct Invoker<0, StorageType, R(X1, X2)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X1, X2); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 2 -> 1. michael@0: template michael@0: struct Invoker<1, StorageType, R(X1, X2)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X2); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x2) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: return InvokeHelper::ForwardType x2)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 2 -> 0. michael@0: template michael@0: struct Invoker<2, StorageType, R(X1, X2)> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 3 -> 3. michael@0: template michael@0: struct Invoker<0, StorageType, R(X1, X2, X3)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X1, X2, X3); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 3 -> 2. michael@0: template michael@0: struct Invoker<1, StorageType, R(X1, X2, X3)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X2, X3); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: return InvokeHelper::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 3 -> 1. michael@0: template michael@0: struct Invoker<2, StorageType, R(X1, X2, X3)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X3); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x3) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: return InvokeHelper::ForwardType x3)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 3 -> 0. michael@0: template michael@0: struct Invoker<3, StorageType, R(X1, X2, X3)> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 4 -> 4. michael@0: template michael@0: struct Invoker<0, StorageType, R(X1, X2, X3, X4)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X1, X2, X3, X4); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 4 -> 3. michael@0: template michael@0: struct Invoker<1, StorageType, R(X1, X2, X3, X4)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X2, X3, X4); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: return InvokeHelper::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 4 -> 2. michael@0: template michael@0: struct Invoker<2, StorageType, R(X1, X2, X3, X4)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X3, X4); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: return InvokeHelper::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 4 -> 1. michael@0: template michael@0: struct Invoker<3, StorageType, R(X1, X2, X3, X4)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X4); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x4) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: return InvokeHelper::ForwardType x4)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 4 -> 0. michael@0: template michael@0: struct Invoker<4, StorageType, R(X1, X2, X3, X4)> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 5 -> 5. michael@0: template michael@0: struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X1, X2, X3, X4, X5); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 5 -> 4. michael@0: template michael@0: struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X2, X3, X4, X5); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: return InvokeHelper::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 5 -> 3. michael@0: template michael@0: struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X3, X4, X5); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: return InvokeHelper::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 5 -> 2. michael@0: template michael@0: struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X4, X5); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: return InvokeHelper::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 5 -> 1. michael@0: template michael@0: struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X5); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x5) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: return InvokeHelper::ForwardType x5)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 5 -> 0. michael@0: template michael@0: struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: typename Bound5UnwrapTraits::ForwardType x5 = michael@0: Bound5UnwrapTraits::Unwrap(storage->p5_); michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 6 -> 6. michael@0: template michael@0: struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 6 -> 5. michael@0: template michael@0: struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X2, X3, X4, X5, X6); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: return InvokeHelper::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 6 -> 4. michael@0: template michael@0: struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X3, X4, X5, X6); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: return InvokeHelper::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 6 -> 3. michael@0: template michael@0: struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X4, X5, X6); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: return InvokeHelper::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 6 -> 2. michael@0: template michael@0: struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X5, X6); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: return InvokeHelper::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 6 -> 1. michael@0: template michael@0: struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X6); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x6) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: typename Bound5UnwrapTraits::ForwardType x5 = michael@0: Bound5UnwrapTraits::Unwrap(storage->p5_); michael@0: return InvokeHelper::ForwardType x6)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 6 -> 0. michael@0: template michael@0: struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; michael@0: typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: typename Bound5UnwrapTraits::ForwardType x5 = michael@0: Bound5UnwrapTraits::Unwrap(storage->p5_); michael@0: typename Bound6UnwrapTraits::ForwardType x6 = michael@0: Bound6UnwrapTraits::Unwrap(storage->p6_); michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 7. michael@0: template michael@0: struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: michael@0: return InvokeHelper::ForwardType x1, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 6. michael@0: template michael@0: struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: return InvokeHelper::ForwardType x2, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 5. michael@0: template michael@0: struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X3, X4, X5, X6, X7); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: return InvokeHelper::ForwardType x3, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 4. michael@0: template michael@0: struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X4, X5, X6, X7); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: return InvokeHelper::ForwardType x4, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 3. michael@0: template michael@0: struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X5, X6, X7); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: return InvokeHelper::ForwardType x5, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 2. michael@0: template michael@0: struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X6, X7); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: typename Bound5UnwrapTraits::ForwardType x5 = michael@0: Bound5UnwrapTraits::Unwrap(storage->p5_); michael@0: return InvokeHelper::ForwardType x6, michael@0: typename CallbackParamTraits::ForwardType x7)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 1. michael@0: template michael@0: struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*, michael@0: typename CallbackParamTraits::ForwardType); michael@0: michael@0: typedef R(UnboundRunType)(X7); michael@0: michael@0: static R Run(BindStateBase* base, michael@0: typename CallbackParamTraits::ForwardType x7) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; michael@0: typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: typename Bound5UnwrapTraits::ForwardType x5 = michael@0: Bound5UnwrapTraits::Unwrap(storage->p5_); michael@0: typename Bound6UnwrapTraits::ForwardType x6 = michael@0: Bound6UnwrapTraits::Unwrap(storage->p6_); michael@0: return InvokeHelper::ForwardType x7)> michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: // Arity 7 -> 0. michael@0: template michael@0: struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { michael@0: typedef R(RunType)(BindStateBase*); michael@0: michael@0: typedef R(UnboundRunType)(); michael@0: michael@0: static R Run(BindStateBase* base) { michael@0: StorageType* storage = static_cast(base); michael@0: michael@0: // Local references to make debugger stepping easier. If in a debugger, michael@0: // you really want to warp ahead and step through the michael@0: // InvokeHelper<>::MakeItSo() call below. michael@0: typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; michael@0: typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; michael@0: typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; michael@0: typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; michael@0: typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; michael@0: typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; michael@0: typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits; michael@0: michael@0: typename Bound1UnwrapTraits::ForwardType x1 = michael@0: Bound1UnwrapTraits::Unwrap(storage->p1_); michael@0: typename Bound2UnwrapTraits::ForwardType x2 = michael@0: Bound2UnwrapTraits::Unwrap(storage->p2_); michael@0: typename Bound3UnwrapTraits::ForwardType x3 = michael@0: Bound3UnwrapTraits::Unwrap(storage->p3_); michael@0: typename Bound4UnwrapTraits::ForwardType x4 = michael@0: Bound4UnwrapTraits::Unwrap(storage->p4_); michael@0: typename Bound5UnwrapTraits::ForwardType x5 = michael@0: Bound5UnwrapTraits::Unwrap(storage->p5_); michael@0: typename Bound6UnwrapTraits::ForwardType x6 = michael@0: Bound6UnwrapTraits::Unwrap(storage->p6_); michael@0: typename Bound7UnwrapTraits::ForwardType x7 = michael@0: Bound7UnwrapTraits::Unwrap(storage->p7_); michael@0: return InvokeHelper michael@0: ::MakeItSo(storage->runnable_, CallbackForward(x1), michael@0: CallbackForward(x2), CallbackForward(x3), michael@0: CallbackForward(x4), CallbackForward(x5), michael@0: CallbackForward(x6), CallbackForward(x7)); michael@0: } michael@0: }; michael@0: michael@0: michael@0: // BindState<> michael@0: // michael@0: // This stores all the state passed into Bind() and is also where most michael@0: // of the template resolution magic occurs. michael@0: // michael@0: // Runnable is the functor we are binding arguments to. michael@0: // RunType is type of the Run() function that the Invoker<> should use. michael@0: // Normally, this is the same as the RunType of the Runnable, but it can michael@0: // be different if an adapter like IgnoreResult() has been used. michael@0: // michael@0: // BoundArgsType contains the storage type for all the bound arguments by michael@0: // (ab)using a function type. michael@0: template michael@0: struct BindState; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef false_type IsWeakCall; michael@0: typedef Invoker<0, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: explicit BindState(const Runnable& runnable) michael@0: : runnable_(runnable) { michael@0: } michael@0: michael@0: virtual ~BindState() { } michael@0: michael@0: RunnableType runnable_; michael@0: }; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef IsWeakMethod::value, P1> IsWeakCall; michael@0: typedef Invoker<1, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: michael@0: // Convenience typedefs for bound argument types. michael@0: typedef UnwrapTraits Bound1UnwrapTraits; michael@0: michael@0: BindState(const Runnable& runnable, const P1& p1) michael@0: : runnable_(runnable), michael@0: p1_(p1) { michael@0: MaybeRefcount::value, P1>::AddRef(p1_); michael@0: } michael@0: michael@0: virtual ~BindState() { MaybeRefcount::value, michael@0: P1>::Release(p1_); } michael@0: michael@0: RunnableType runnable_; michael@0: P1 p1_; michael@0: }; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef IsWeakMethod::value, P1> IsWeakCall; michael@0: typedef Invoker<2, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: michael@0: // Convenience typedefs for bound argument types. michael@0: typedef UnwrapTraits Bound1UnwrapTraits; michael@0: typedef UnwrapTraits Bound2UnwrapTraits; michael@0: michael@0: BindState(const Runnable& runnable, const P1& p1, const P2& p2) michael@0: : runnable_(runnable), michael@0: p1_(p1), michael@0: p2_(p2) { michael@0: MaybeRefcount::value, P1>::AddRef(p1_); michael@0: } michael@0: michael@0: virtual ~BindState() { MaybeRefcount::value, michael@0: P1>::Release(p1_); } michael@0: michael@0: RunnableType runnable_; michael@0: P1 p1_; michael@0: P2 p2_; michael@0: }; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef IsWeakMethod::value, P1> IsWeakCall; michael@0: typedef Invoker<3, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: michael@0: // Convenience typedefs for bound argument types. michael@0: typedef UnwrapTraits Bound1UnwrapTraits; michael@0: typedef UnwrapTraits Bound2UnwrapTraits; michael@0: typedef UnwrapTraits Bound3UnwrapTraits; michael@0: michael@0: BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3) michael@0: : runnable_(runnable), michael@0: p1_(p1), michael@0: p2_(p2), michael@0: p3_(p3) { michael@0: MaybeRefcount::value, P1>::AddRef(p1_); michael@0: } michael@0: michael@0: virtual ~BindState() { MaybeRefcount::value, michael@0: P1>::Release(p1_); } michael@0: michael@0: RunnableType runnable_; michael@0: P1 p1_; michael@0: P2 p2_; michael@0: P3 p3_; michael@0: }; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef IsWeakMethod::value, P1> IsWeakCall; michael@0: typedef Invoker<4, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: michael@0: // Convenience typedefs for bound argument types. michael@0: typedef UnwrapTraits Bound1UnwrapTraits; michael@0: typedef UnwrapTraits Bound2UnwrapTraits; michael@0: typedef UnwrapTraits Bound3UnwrapTraits; michael@0: typedef UnwrapTraits Bound4UnwrapTraits; michael@0: michael@0: BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, michael@0: const P4& p4) michael@0: : runnable_(runnable), michael@0: p1_(p1), michael@0: p2_(p2), michael@0: p3_(p3), michael@0: p4_(p4) { michael@0: MaybeRefcount::value, P1>::AddRef(p1_); michael@0: } michael@0: michael@0: virtual ~BindState() { MaybeRefcount::value, michael@0: P1>::Release(p1_); } michael@0: michael@0: RunnableType runnable_; michael@0: P1 p1_; michael@0: P2 p2_; michael@0: P3 p3_; michael@0: P4 p4_; michael@0: }; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef IsWeakMethod::value, P1> IsWeakCall; michael@0: typedef Invoker<5, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: michael@0: // Convenience typedefs for bound argument types. michael@0: typedef UnwrapTraits Bound1UnwrapTraits; michael@0: typedef UnwrapTraits Bound2UnwrapTraits; michael@0: typedef UnwrapTraits Bound3UnwrapTraits; michael@0: typedef UnwrapTraits Bound4UnwrapTraits; michael@0: typedef UnwrapTraits Bound5UnwrapTraits; michael@0: michael@0: BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, michael@0: const P4& p4, const P5& p5) michael@0: : runnable_(runnable), michael@0: p1_(p1), michael@0: p2_(p2), michael@0: p3_(p3), michael@0: p4_(p4), michael@0: p5_(p5) { michael@0: MaybeRefcount::value, P1>::AddRef(p1_); michael@0: } michael@0: michael@0: virtual ~BindState() { MaybeRefcount::value, michael@0: P1>::Release(p1_); } michael@0: michael@0: RunnableType runnable_; michael@0: P1 p1_; michael@0: P2 p2_; michael@0: P3 p3_; michael@0: P4 p4_; michael@0: P5 p5_; michael@0: }; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef IsWeakMethod::value, P1> IsWeakCall; michael@0: typedef Invoker<6, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: michael@0: // Convenience typedefs for bound argument types. michael@0: typedef UnwrapTraits Bound1UnwrapTraits; michael@0: typedef UnwrapTraits Bound2UnwrapTraits; michael@0: typedef UnwrapTraits Bound3UnwrapTraits; michael@0: typedef UnwrapTraits Bound4UnwrapTraits; michael@0: typedef UnwrapTraits Bound5UnwrapTraits; michael@0: typedef UnwrapTraits Bound6UnwrapTraits; michael@0: michael@0: BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, michael@0: const P4& p4, const P5& p5, const P6& p6) michael@0: : runnable_(runnable), michael@0: p1_(p1), michael@0: p2_(p2), michael@0: p3_(p3), michael@0: p4_(p4), michael@0: p5_(p5), michael@0: p6_(p6) { michael@0: MaybeRefcount::value, P1>::AddRef(p1_); michael@0: } michael@0: michael@0: virtual ~BindState() { MaybeRefcount::value, michael@0: P1>::Release(p1_); } michael@0: michael@0: RunnableType runnable_; michael@0: P1 p1_; michael@0: P2 p2_; michael@0: P3 p3_; michael@0: P4 p4_; michael@0: P5 p5_; michael@0: P6 p6_; michael@0: }; michael@0: michael@0: template michael@0: struct BindState : public BindStateBase { michael@0: typedef Runnable RunnableType; michael@0: typedef IsWeakMethod::value, P1> IsWeakCall; michael@0: typedef Invoker<7, BindState, RunType> InvokerType; michael@0: typedef typename InvokerType::UnboundRunType UnboundRunType; michael@0: michael@0: // Convenience typedefs for bound argument types. michael@0: typedef UnwrapTraits Bound1UnwrapTraits; michael@0: typedef UnwrapTraits Bound2UnwrapTraits; michael@0: typedef UnwrapTraits Bound3UnwrapTraits; michael@0: typedef UnwrapTraits Bound4UnwrapTraits; michael@0: typedef UnwrapTraits Bound5UnwrapTraits; michael@0: typedef UnwrapTraits Bound6UnwrapTraits; michael@0: typedef UnwrapTraits Bound7UnwrapTraits; michael@0: michael@0: BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, michael@0: const P4& p4, const P5& p5, const P6& p6, const P7& p7) michael@0: : runnable_(runnable), michael@0: p1_(p1), michael@0: p2_(p2), michael@0: p3_(p3), michael@0: p4_(p4), michael@0: p5_(p5), michael@0: p6_(p6), michael@0: p7_(p7) { michael@0: MaybeRefcount::value, P1>::AddRef(p1_); michael@0: } michael@0: michael@0: virtual ~BindState() { MaybeRefcount::value, michael@0: P1>::Release(p1_); } michael@0: michael@0: RunnableType runnable_; michael@0: P1 p1_; michael@0: P2 p2_; michael@0: P3 p3_; michael@0: P4 p4_; michael@0: P5 p5_; michael@0: P6 p6_; michael@0: P7 p7_; michael@0: }; michael@0: michael@0: } // namespace internal michael@0: } // namespace base michael@0: michael@0: #endif // BASE_BIND_INTERNAL_H_