Chromium Code Reviews| Index: base/prebind.h |
| diff --git a/base/prebind.h b/base/prebind.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cae7a9ba7cc1330b85ce4cb2b754a9b1b8178524 |
| --- /dev/null |
| +++ b/base/prebind.h |
| @@ -0,0 +1,1374 @@ |
| +// This file was GENERATED by command: |
| +// pump.py prebind.h.pump |
| +// DO NOT EDIT BY HAND!!! |
| + |
| + |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_PREBIND_H_ |
| +#define BASE_PREBIND_H_ |
| +#pragma once |
| + |
| +#include "base/prebind_helpers.h" |
| +#include "base/template_util.h" |
| +#include "base/uber_callback.h" |
| + |
| +namespace base { |
| +namespace internal { |
| + |
| +// The method by which a function is invoked is determined by 3 different |
| +// dimensions: |
| +// |
| +// 1) The type of function (normal, method, const-method) |
| +// 2) The arity of the function |
| +// 3) The number of bound parameters. |
| +// |
| +// The FunctionTraitsN classes unwrap the function signature type to |
| +// specialize based on the first two dimensions. The N in FunctionTraitsN |
| +// specifies the 3rd dimension. We could have specified the unbound parameters |
| +// via template parameters, but this method looked cleaner. |
| +// |
| +// The FunctionTraitsN contains a static DoInvoke() function that is the key to |
| +// implementing type erasure in the Callback() classes. DoInvoke() is a static |
| +// function with a fixed signature that is indepenent of StorageType; its first |
|
willchan no longer on Chromium
2011/02/07 20:51:48
independent
awong
2011/02/08 18:52:26
Done.
|
| +// argument is a pointer to the non-templated common baseclass of StorageType. |
| +// This lets us store pointer to DoInvoke() in a function pointer that has |
| +// knowledge of the specific StorageType, and thus no knowledge of the bound |
| +// function and bound parameter types. |
| +// |
| +// As long as we ensure that DoInvoke() is only used with pointers there were |
| +// upcasted from the correct StorageType, we can be sure that execution is |
| +// safe. |
| + |
| +template <typename StorageType, typename Sig> |
| +struct FunctionTraits0; |
| + |
| +// Function: Arity 0 -> 0. |
| +template <typename StorageType, typename R> |
| +struct FunctionTraits0<StorageType, R(*)()> { |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(); |
| + } |
| +}; |
| + |
| +// Function: Arity 1 -> 1. |
| +template <typename StorageType, typename R,typename X1> |
| +struct FunctionTraits0<StorageType, R(*)(X1)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(x1); |
| + } |
| +}; |
| + |
| +// Function: Arity 2 -> 2. |
| +template <typename StorageType, typename R,typename X1, typename X2> |
| +struct FunctionTraits0<StorageType, R(*)(X1, X2)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(x1, x2); |
| + } |
| +}; |
| + |
| +// Function: Arity 3 -> 3. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3> |
| +struct FunctionTraits0<StorageType, R(*)(X1, X2, X3)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(x1, x2, x3); |
| + } |
| +}; |
| + |
| +// Function: Arity 4 -> 4. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4> |
| +struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(x1, x2, x3, x4); |
| + } |
| +}; |
| + |
| +// Function: Arity 5 -> 5. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5> |
| +struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3, const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(x1, x2, x3, x4, x5); |
| + } |
| +}; |
| + |
| +// Function: Arity 6 -> 6. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5, typename X6> |
| +struct FunctionTraits0<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value || |
| + is_non_const_reference<X6>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3, const X4& x4, const X5& x5, const X6& x6) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(x1, x2, x3, x4, x5, x6); |
| + } |
| +}; |
| + |
| +template <typename StorageType, typename Sig> |
| +struct FunctionTraits1; |
| + |
| +// Function: Arity 1 -> 0. |
| +template <typename StorageType, typename R,typename X1> |
| +struct FunctionTraits1<StorageType, R(*)(X1)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_)); |
| + } |
| +}; |
| + |
| +// Method: Arity 0 -> 0. |
| +template <typename StorageType, typename R, typename T> |
| +struct FunctionTraits1<StorageType, R(T::*)()> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 0 -> 0. |
| +template <typename StorageType, typename R, typename T> |
| +struct FunctionTraits1<StorageType, R(T::*)() const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base ) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(); |
| + } |
| +}; |
| + |
| +// Function: Arity 2 -> 1. |
| +template <typename StorageType, typename R,typename X1, typename X2> |
| +struct FunctionTraits1<StorageType, R(*)(X1, X2)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), x2); |
| + } |
| +}; |
| + |
| +// Method: Arity 1 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 1 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1); |
| + } |
| +}; |
| + |
| +// Function: Arity 3 -> 2. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3> |
| +struct FunctionTraits1<StorageType, R(*)(X1, X2, X3)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), x2, x3); |
| + } |
| +}; |
| + |
| +// Method: Arity 2 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 2 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); |
| + } |
| +}; |
| + |
| +// Function: Arity 4 -> 3. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4> |
| +struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4); |
| + } |
| +}; |
| + |
| +// Method: Arity 3 -> 3. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 3 -> 3. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); |
| + } |
| +}; |
| + |
| +// Function: Arity 5 -> 4. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5> |
| +struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3, const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5); |
| + } |
| +}; |
| + |
| +// Method: Arity 4 -> 4. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 4 -> 4. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); |
| + } |
| +}; |
| + |
| +// Function: Arity 6 -> 5. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5, typename X6> |
| +struct FunctionTraits1<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value || |
| + is_non_const_reference<X6>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3, const X4& x4, const X5& x5, const X6& x6) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6); |
| + } |
| +}; |
| + |
| +// Method: Arity 5 -> 5. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3, const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 5 -> 5. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits1<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X1& x1, |
| + const X2& x2, const X3& x3, const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); |
| + } |
| +}; |
| + |
| +template <typename StorageType, typename Sig> |
| +struct FunctionTraits2; |
| + |
| +// Function: Arity 2 -> 0. |
| +template <typename StorageType, typename R,typename X1, typename X2> |
| +struct FunctionTraits2<StorageType, R(*)(X1, X2)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_)); |
| + } |
| +}; |
| + |
| +// Method: Arity 1 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 1 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base ) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); |
| + } |
| +}; |
| + |
| +// Function: Arity 3 -> 1. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3> |
| +struct FunctionTraits2<StorageType, R(*)(X1, X2, X3)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3); |
| + } |
| +}; |
| + |
| +// Method: Arity 2 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 2 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); |
| + } |
| +}; |
| + |
| +// Function: Arity 4 -> 2. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4> |
| +struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, |
| + const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4); |
| + } |
| +}; |
| + |
| +// Method: Arity 3 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 3 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); |
| + } |
| +}; |
| + |
| +// Function: Arity 5 -> 3. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5> |
| +struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, |
| + const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5); |
| + } |
| +}; |
| + |
| +// Method: Arity 4 -> 3. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
| + x4); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 4 -> 3. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
| + x4); |
| + } |
| +}; |
| + |
| +// Function: Arity 6 -> 4. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5, typename X6> |
| +struct FunctionTraits2<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value || |
| + is_non_const_reference<X6>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, |
| + const X4& x4, const X5& x5, const X6& x6) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5, |
| + x6); |
| + } |
| +}; |
| + |
| +// Method: Arity 5 -> 4. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3, const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
| + x4, x5); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 5 -> 4. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits2<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X2& x2, |
| + const X3& x3, const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
| + x4, x5); |
| + } |
| +}; |
| + |
| +template <typename StorageType, typename Sig> |
| +struct FunctionTraits3; |
| + |
| +// Function: Arity 3 -> 0. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3> |
| +struct FunctionTraits3<StorageType, R(*)(X1, X2, X3)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_)); |
| + } |
| +}; |
| + |
| +// Method: Arity 2 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_)); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 2 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base ) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_)); |
| + } |
| +}; |
| + |
| +// Function: Arity 4 -> 1. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4> |
| +struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x4); |
| + } |
| +}; |
| + |
| +// Method: Arity 3 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x3); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 3 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x3); |
| + } |
| +}; |
| + |
| +// Function: Arity 5 -> 2. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5> |
| +struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, |
| + const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x4, x5); |
| + } |
| +}; |
| + |
| +// Method: Arity 4 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, |
| + const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x3, x4); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 4 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, |
| + const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x3, x4); |
| + } |
| +}; |
| + |
| +// Function: Arity 6 -> 3. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5, typename X6> |
| +struct FunctionTraits3<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value || |
| + is_non_const_reference<X6>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, |
| + const X5& x5, const X6& x6) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x4, x5, x6); |
| + } |
| +}; |
| + |
| +// Method: Arity 5 -> 3. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, |
| + const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x3, x4, x5); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 5 -> 3. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits3<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X3& x3, |
| + const X4& x4, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), x3, x4, x5); |
| + } |
| +}; |
| + |
| +template <typename StorageType, typename Sig> |
| +struct FunctionTraits4; |
| + |
| +// Function: Arity 4 -> 0. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4> |
| +struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_)); |
| + } |
| +}; |
| + |
| +// Method: Arity 3 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_)); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 3 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3> |
| +struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base ) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_)); |
| + } |
| +}; |
| + |
| +// Function: Arity 5 -> 1. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5> |
| +struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5); |
| + } |
| +}; |
| + |
| +// Method: Arity 4 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 4 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); |
| + } |
| +}; |
| + |
| +// Function: Arity 6 -> 2. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5, typename X6> |
| +struct FunctionTraits4<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value || |
| + is_non_const_reference<X6>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5, |
| + const X6& x6) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5, x6); |
| + } |
| +}; |
| + |
| +// Method: Arity 5 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, |
| + const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 5 -> 2. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits4<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X4& x4, |
| + const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); |
| + } |
| +}; |
| + |
| +template <typename StorageType, typename Sig> |
| +struct FunctionTraits5; |
| + |
| +// Function: Arity 5 -> 0. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5> |
| +struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
| + } |
| +}; |
| + |
| +// Method: Arity 4 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 4 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4> |
| +struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base ) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
| + } |
| +}; |
| + |
| +// Function: Arity 6 -> 1. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5, typename X6> |
| +struct FunctionTraits5<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value || |
| + is_non_const_reference<X6>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X6& x6) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x6); |
| + } |
| +}; |
| + |
| +// Method: Arity 5 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 5 -> 1. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits5<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base, const X5& x5) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); |
| + } |
| +}; |
| + |
| +template <typename StorageType, typename Sig> |
| +struct FunctionTraits6; |
| + |
| +// Function: Arity 6 -> 0. |
| +template <typename StorageType, typename R,typename X1, typename X2, |
| + typename X3, typename X4, typename X5, typename X6> |
| +struct FunctionTraits6<StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
| + COMPILE_ASSERT( |
| + !( is_non_const_reference<X1>::value || |
| + is_non_const_reference<X2>::value || |
| + is_non_const_reference<X3>::value || |
| + is_non_const_reference<X4>::value || |
| + is_non_const_reference<X5>::value || |
| + is_non_const_reference<X6>::value ), |
| + do_not_prebind_functions_with_nonconst_ref); |
| + |
| + typedef base::false_type ShouldRef; |
| + |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), |
| + Unwrap(invoker->p6_)); |
| + } |
| +}; |
| + |
| +// Method: Arity 5 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits6<StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), |
| + Unwrap(invoker->p6_)); |
| + } |
| +}; |
| + |
| +// Const Method: Arity 5 -> 0. |
| +template <typename StorageType, typename R, typename T, typename X1, |
| + typename X2, typename X3, typename X4, typename X5> |
| +struct FunctionTraits6<StorageType, R(T::*)(X1, X2, X3, X4, X5) const> { |
| + typedef base::true_type ShouldRef; |
| + static R DoInvoke(internal::InvokerStorageBase* base ) { |
| + StorageType* invoker = static_cast<StorageType*>(base); |
| + return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| + Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), |
| + Unwrap(invoker->p6_)); |
| + } |
| +}; |
| + |
| + |
| +// These are the actual storage classes for the invokers. |
| + |
| +template <typename Sig> |
| +class InvokerStorage0 : public internal::InvokerStorageBase { |
| + public: |
| + typedef InvokerStorage0 StorageType; |
| + typedef FunctionTraits0<StorageType, Sig> FunctionTraits; |
| + typedef typename FunctionTraits::ShouldRef ShouldRef; |
| + |
| + InvokerStorage0(Sig f) |
| + : f_(f) { |
| + } |
| + |
| + virtual ~InvokerStorage0() { } |
| + |
| + Sig f_; |
| +}; |
| + |
| +template <typename Sig, typename P1> |
| +class InvokerStorage1 : public internal::InvokerStorageBase { |
| + public: |
| + typedef InvokerStorage1 StorageType; |
| + typedef FunctionTraits1<StorageType, Sig> FunctionTraits; |
| + typedef typename FunctionTraits::ShouldRef ShouldRef; |
| + |
| + COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, |
| + first_bound_argument_to_method_cannot_be_array); |
| + |
| + InvokerStorage1(Sig f, const P1& p1) |
| + : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)) { |
| + MaybeRefcount<ShouldRef, P1>::AddRef(p1_); |
| + } |
| + |
| + virtual ~InvokerStorage1() { |
| + MaybeRefcount<ShouldRef, P1>::Release(p1_); |
| + } |
| + |
|
willchan no longer on Chromium
2011/02/07 20:51:48
These should be private. Perhaps you need to add a
awong
2011/02/08 18:52:26
:-/
Really, if I had my way, I'd make InvokerStor
|
| + Sig f_; |
| + typename PrebindType<P1>::StorageType p1_; |
| +}; |
| + |
| +template <typename Sig, typename P1, typename P2> |
| +class InvokerStorage2 : public internal::InvokerStorageBase { |
| + public: |
| + typedef InvokerStorage2 StorageType; |
| + typedef FunctionTraits2<StorageType, Sig> FunctionTraits; |
| + typedef typename FunctionTraits::ShouldRef ShouldRef; |
| + |
| + COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, |
| + first_bound_argument_to_method_cannot_be_array); |
| + |
| + InvokerStorage2(Sig f, const P1& p1, const P2& p2) |
| + : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), |
| + p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)) { |
| + MaybeRefcount<ShouldRef, P1>::AddRef(p1_); |
| + } |
| + |
| + virtual ~InvokerStorage2() { |
| + MaybeRefcount<ShouldRef, P1>::Release(p1_); |
| + } |
| + |
| + Sig f_; |
| + typename PrebindType<P1>::StorageType p1_; |
| + typename PrebindType<P2>::StorageType p2_; |
| +}; |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3> |
| +class InvokerStorage3 : public internal::InvokerStorageBase { |
| + public: |
| + typedef InvokerStorage3 StorageType; |
| + typedef FunctionTraits3<StorageType, Sig> FunctionTraits; |
| + typedef typename FunctionTraits::ShouldRef ShouldRef; |
| + |
| + COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, |
| + first_bound_argument_to_method_cannot_be_array); |
| + |
| + InvokerStorage3(Sig f, const P1& p1, const P2& p2, const P3& p3) |
| + : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), |
| + p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), |
| + p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)) { |
| + MaybeRefcount<ShouldRef, P1>::AddRef(p1_); |
| + } |
| + |
| + virtual ~InvokerStorage3() { |
| + MaybeRefcount<ShouldRef, P1>::Release(p1_); |
| + } |
| + |
| + Sig f_; |
| + typename PrebindType<P1>::StorageType p1_; |
| + typename PrebindType<P2>::StorageType p2_; |
| + typename PrebindType<P3>::StorageType p3_; |
| +}; |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3, typename P4> |
| +class InvokerStorage4 : public internal::InvokerStorageBase { |
| + public: |
| + typedef InvokerStorage4 StorageType; |
| + typedef FunctionTraits4<StorageType, Sig> FunctionTraits; |
| + typedef typename FunctionTraits::ShouldRef ShouldRef; |
| + |
| + COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, |
| + first_bound_argument_to_method_cannot_be_array); |
| + |
| + InvokerStorage4(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4) |
| + : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), |
| + p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), |
| + p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)), |
| + p4_(static_cast<typename PrebindType<P4>::StorageType>(p4)) { |
| + MaybeRefcount<ShouldRef, P1>::AddRef(p1_); |
| + } |
| + |
| + virtual ~InvokerStorage4() { |
| + MaybeRefcount<ShouldRef, P1>::Release(p1_); |
| + } |
| + |
| + Sig f_; |
| + typename PrebindType<P1>::StorageType p1_; |
| + typename PrebindType<P2>::StorageType p2_; |
| + typename PrebindType<P3>::StorageType p3_; |
| + typename PrebindType<P4>::StorageType p4_; |
| +}; |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| + typename P5> |
| +class InvokerStorage5 : public internal::InvokerStorageBase { |
| + public: |
| + typedef InvokerStorage5 StorageType; |
| + typedef FunctionTraits5<StorageType, Sig> FunctionTraits; |
| + typedef typename FunctionTraits::ShouldRef ShouldRef; |
| + |
| + COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, |
| + first_bound_argument_to_method_cannot_be_array); |
| + |
| + InvokerStorage5(Sig f, const P1& p1, const P2& p2, const P3& p3, |
| + const P4& p4, const P5& p5) |
| + : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), |
| + p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), |
| + p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)), |
| + p4_(static_cast<typename PrebindType<P4>::StorageType>(p4)), |
| + p5_(static_cast<typename PrebindType<P5>::StorageType>(p5)) { |
| + MaybeRefcount<ShouldRef, P1>::AddRef(p1_); |
| + } |
| + |
| + virtual ~InvokerStorage5() { |
| + MaybeRefcount<ShouldRef, P1>::Release(p1_); |
| + } |
| + |
| + Sig f_; |
| + typename PrebindType<P1>::StorageType p1_; |
| + typename PrebindType<P2>::StorageType p2_; |
| + typename PrebindType<P3>::StorageType p3_; |
| + typename PrebindType<P4>::StorageType p4_; |
| + typename PrebindType<P5>::StorageType p5_; |
| +}; |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| + typename P5, typename P6> |
| +class InvokerStorage6 : public internal::InvokerStorageBase { |
|
willchan no longer on Chromium
2011/02/07 23:25:15
You shouldn't need internal:: since you're already
awong
2011/02/08 18:52:26
Done.
|
| + public: |
| + typedef InvokerStorage6 StorageType; |
| + typedef FunctionTraits6<StorageType, Sig> FunctionTraits; |
| + typedef typename FunctionTraits::ShouldRef ShouldRef; |
| + |
| + COMPILE_ASSERT(!ShouldRef::value || !is_array<P1>::value, |
| + first_bound_argument_to_method_cannot_be_array); |
| + |
| + InvokerStorage6(Sig f, const P1& p1, const P2& p2, const P3& p3, |
| + const P4& p4, const P5& p5, const P6& p6) |
| + : f_(f), p1_(static_cast<typename PrebindType<P1>::StorageType>(p1)), |
| + p2_(static_cast<typename PrebindType<P2>::StorageType>(p2)), |
| + p3_(static_cast<typename PrebindType<P3>::StorageType>(p3)), |
| + p4_(static_cast<typename PrebindType<P4>::StorageType>(p4)), |
| + p5_(static_cast<typename PrebindType<P5>::StorageType>(p5)), |
| + p6_(static_cast<typename PrebindType<P6>::StorageType>(p6)) { |
| + MaybeRefcount<ShouldRef, P1>::AddRef(p1_); |
| + } |
| + |
| + virtual ~InvokerStorage6() { |
| + MaybeRefcount<ShouldRef, P1>::Release(p1_); |
| + } |
| + |
| + Sig f_; |
| + typename PrebindType<P1>::StorageType p1_; |
| + typename PrebindType<P2>::StorageType p2_; |
| + typename PrebindType<P3>::StorageType p3_; |
| + typename PrebindType<P4>::StorageType p4_; |
| + typename PrebindType<P5>::StorageType p5_; |
| + typename PrebindType<P6>::StorageType p6_; |
| +}; |
| + |
| +} // namespace internal |
| + |
| +template <typename Sig> |
| +internal::InvokerStorageHolder<internal::InvokerStorage0<Sig> > |
| +Prebind(Sig f) { |
| + return internal::MakeInvokerStorageHolder( |
| + new internal::InvokerStorage0<Sig>(f)); |
| +} |
| + |
| +template <typename Sig, typename P1> |
| +internal::InvokerStorageHolder<internal::InvokerStorage1<Sig,P1> > |
| +Prebind(Sig f, const P1& p1) { |
| + return internal::MakeInvokerStorageHolder( |
| + new internal::InvokerStorage1<Sig, P1>( |
| + f, p1)); |
| +} |
| + |
| +template <typename Sig, typename P1, typename P2> |
| +internal::InvokerStorageHolder<internal::InvokerStorage2<Sig,P1, P2> > |
| +Prebind(Sig f, const P1& p1, const P2& p2) { |
| + return internal::MakeInvokerStorageHolder( |
| + new internal::InvokerStorage2<Sig, P1, P2>( |
| + f, p1, p2)); |
| +} |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3> |
| +internal::InvokerStorageHolder<internal::InvokerStorage3<Sig,P1, P2, P3> > |
| +Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3) { |
| + return internal::MakeInvokerStorageHolder( |
| + new internal::InvokerStorage3<Sig, P1, P2, P3>( |
| + f, p1, p2, p3)); |
| +} |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3, typename P4> |
| +internal::InvokerStorageHolder<internal::InvokerStorage4<Sig,P1, P2, P3, P4> > |
| +Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { |
| + return internal::MakeInvokerStorageHolder( |
| + new internal::InvokerStorage4<Sig, P1, P2, P3, P4>( |
| + f, p1, p2, p3, p4)); |
| +} |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| + typename P5> |
| +internal::InvokerStorageHolder<internal::InvokerStorage5<Sig,P1, P2, P3, P4, |
| + P5> > |
| +Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4, |
| + const P5& p5) { |
| + return internal::MakeInvokerStorageHolder( |
| + new internal::InvokerStorage5<Sig, P1, P2, P3, P4, P5>( |
| + f, p1, p2, p3, p4, p5)); |
| +} |
| + |
| +template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| + typename P5, typename P6> |
| +internal::InvokerStorageHolder<internal::InvokerStorage6<Sig,P1, P2, P3, P4, |
| + P5, P6> > |
| +Prebind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4, |
| + const P5& p5, const P6& p6) { |
| + return internal::MakeInvokerStorageHolder( |
| + new internal::InvokerStorage6<Sig, P1, P2, P3, P4, P5, P6>( |
| + f, p1, p2, p3, p4, p5, p6)); |
| +} |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_PREBIND_H_ |