diff options
author | xiaomings@google.com <xiaomings@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 23:11:50 +0000 |
---|---|---|
committer | xiaomings@google.com <xiaomings@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 23:11:50 +0000 |
commit | 3c69b0d4558d9d92b49ac7be0e1d022487a64ec9 (patch) | |
tree | 914c7bdc58ccbdc3f028c23459b6c16952606267 | |
parent | 512101fadead33886af06d8c2e0419319084a73e (diff) | |
download | chromium_src-3c69b0d4558d9d92b49ac7be0e1d022487a64ec9.zip chromium_src-3c69b0d4558d9d92b49ac7be0e1d022487a64ec9.tar.gz chromium_src-3c69b0d4558d9d92b49ac7be0e1d022487a64ec9.tar.bz2 |
Rename template parameter in callback from RunType to BindRunType.
The original code is correct. The fix is a work around for mips gcc 4.3.2.
The constructor of Callback is a template. In the context of the constructor, there are two type named RunType. One is its second template parameter, the other is a typedef inside Callback. The correct compiler will pick the "local" one, i.e. the template parameter. However, gcc 4.3.2 on mips incorrectly uses the typedef. The solution is to rename the template parameter.
After discussing with ajwong, we decide to push the work around up stream as it is cleaner not to shadow names anyways.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10836215
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151383 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/callback.h | 58 | ||||
-rw-r--r-- | base/callback.h.pump | 9 |
2 files changed, 38 insertions, 29 deletions
diff --git a/base/callback.h b/base/callback.h index eada958..c613890 100644 --- a/base/callback.h +++ b/base/callback.h @@ -123,7 +123,7 @@ // the rest when you execute the callback. // // void MyFunc(int i, const std::string& str) {} -// base::Callback<void(const std::string)> cb = base::Bind(&MyFunc, 23); +// base::Callback<void(const std::string&)> cb = base::Bind(&MyFunc, 23); // cb.Run("hello world"); // // When calling a function bound parameters are first, followed by unbound @@ -364,15 +364,16 @@ class Callback<R(void)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } @@ -403,15 +404,16 @@ class Callback<R(A1)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } @@ -443,15 +445,16 @@ class Callback<R(A1, A2)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } @@ -486,15 +489,16 @@ class Callback<R(A1, A2, A3)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } @@ -532,15 +536,16 @@ class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } @@ -582,15 +587,16 @@ class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } @@ -635,15 +641,16 @@ class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } @@ -691,15 +698,16 @@ class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } diff --git a/base/callback.h.pump b/base/callback.h.pump index 37ee56d..e236254 100644 --- a/base/callback.h.pump +++ b/base/callback.h.pump @@ -128,7 +128,7 @@ $var MAX_ARITY = 7 // the rest when you execute the callback. // // void MyFunc(int i, const std::string& str) {} -// base::Callback<void(int)> cb = base::Bind(&MyFunc, 23); +// base::Callback<void(const std::string&)> cb = base::Bind(&MyFunc, 23); // cb.Run("hello world"); // // When calling a function bound parameters are first, followed by unbound @@ -380,15 +380,16 @@ class Callback<R($for ARG , [[A$(ARG)]])> : public internal::CallbackBase { // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. - template <typename Runnable, typename RunType, typename BoundArgsType> - Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) + template <typename Runnable, typename BindRunType, typename BoundArgsType> + Callback(internal::BindState<Runnable, BindRunType, + BoundArgsType>* bind_state) : CallbackBase(bind_state) { // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &internal::BindState<Runnable, RunType, BoundArgsType> + &internal::BindState<Runnable, BindRunType, BoundArgsType> ::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); } |