diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-19 00:52:15 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-19 00:52:15 +0000 |
commit | 4346ef91c5d16fd98da3dad5356b0f994f225ce6 (patch) | |
tree | 2f0d0bcdb836a1f0d052ae901b9bfc69a44ed6b1 /base/callback.h | |
parent | c034941e26f9e62e7f5c9b58cd7a3f52bac1b1db (diff) | |
download | chromium_src-4346ef91c5d16fd98da3dad5356b0f994f225ce6.zip chromium_src-4346ef91c5d16fd98da3dad5356b0f994f225ce6.tar.gz chromium_src-4346ef91c5d16fd98da3dad5356b0f994f225ce6.tar.bz2 |
Callbacks: Replumb the type-inference.
In preparation for attempting to support __stdcall, __fastcall, etc., break
apart the templates so that instead of having one set of InvokerNs per type
of function pointer, only have one per syntactic method of invocation.
This lets the number of template specializations scale better. Previously,
for each type of function pointer, we needed sum(1...arity) InvokerN
specializations. There were 3 types (function, method, const method).
The Windows calling conventions would have added another 2.
in this method, we have 2 sets of InvokerN templates, and 1 set of
FunctionTraits templates for each type. We only need (arity) number of
FunctionTraits templates, so this is a net win. For our 6-arity system,
it should go from
5 types * (1+2+3+4+5+6) InvokerNs = 105 specializations
to
5 types * 6 FunctionTraits + 2 calling_syntaxes * (1+2+3+4+5+6) InvokerNs = 72 specializations
This puts a bit more work on the compiler, but...hey, better it than the reader of the code.
BUG=35223
TEST=none
Review URL: http://codereview.chromium.org/6538045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/callback.h')
-rw-r--r-- | base/callback.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/base/callback.h b/base/callback.h index 9c76aa5..bcc3dfd 100644 --- a/base/callback.h +++ b/base/callback.h @@ -221,6 +221,7 @@ namespace base { // only has one type: the function signature. template <typename Sig> class Callback; + template <typename R> class Callback<R(void)> : public internal::CallbackBase { public: @@ -238,7 +239,7 @@ class Callback<R(void)> : public internal::CallbackBase { template <typename T> Callback(const internal::InvokerStorageHolder<T>& invoker_holder) : CallbackBase( - reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), + reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), &invoker_holder.invoker_storage_) { } @@ -267,7 +268,7 @@ class Callback<R(A1)> : public internal::CallbackBase { template <typename T> Callback(const internal::InvokerStorageHolder<T>& invoker_holder) : CallbackBase( - reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), + reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), &invoker_holder.invoker_storage_) { } @@ -297,7 +298,7 @@ class Callback<R(A1, A2)> : public internal::CallbackBase { template <typename T> Callback(const internal::InvokerStorageHolder<T>& invoker_holder) : CallbackBase( - reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), + reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), &invoker_holder.invoker_storage_) { } @@ -330,7 +331,7 @@ class Callback<R(A1, A2, A3)> : public internal::CallbackBase { template <typename T> Callback(const internal::InvokerStorageHolder<T>& invoker_holder) : CallbackBase( - reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), + reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), &invoker_holder.invoker_storage_) { } @@ -366,7 +367,7 @@ class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase { template <typename T> Callback(const internal::InvokerStorageHolder<T>& invoker_holder) : CallbackBase( - reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), + reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), &invoker_holder.invoker_storage_) { } @@ -406,7 +407,7 @@ class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase { template <typename T> Callback(const internal::InvokerStorageHolder<T>& invoker_holder) : CallbackBase( - reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), + reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), &invoker_holder.invoker_storage_) { } @@ -449,7 +450,7 @@ class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase { template <typename T> Callback(const internal::InvokerStorageHolder<T>& invoker_holder) : CallbackBase( - reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), + reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), &invoker_holder.invoker_storage_) { } |