Index: base/callback_registry.h.pump |
diff --git a/base/callback_registry.h b/base/callback_registry.h.pump |
similarity index 79% |
copy from base/callback_registry.h |
copy to base/callback_registry.h.pump |
index fcacbf549f2a79412130e0b1d902715a9663cca0..79e423865b59f1d8fc6dd4e623bc8c61efeb5aec 100644 |
--- a/base/callback_registry.h |
+++ b/base/callback_registry.h.pump |
@@ -1,3 +1,13 @@ |
+$$ This is a pump file for generating file templates. Pump is a python |
+$$ script that is part of the Google Test suite of utilities. Description |
+$$ can be found here: |
+$$ |
+$$ http://code.google.com/p/googletest/wiki/PumpManual |
+$$ |
+ |
+$$ See comment for MAX_ARITY in base/bind.h.pump. |
+$var MAX_ARITY = 7 |
+ |
// Copyright 2013 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. |
@@ -173,44 +183,52 @@ class CallbackRegistryBase { |
} // namespace internal |
-template <typename Details> |
-class CallbackRegistry |
- : public internal::CallbackRegistryBase<Callback<void(const Details&)> > { |
- public: |
- CallbackRegistry() {} |
+template <typename Sig> class CallbackRegistry; |
- // Execute all active callbacks with |details| parameter. |
- void Notify(const Details& details) { |
- typename internal::CallbackRegistryBase< |
- Callback<void(const Details&)> >::Iterator it = this->GetIterator(); |
- Callback<void(const Details&)>* cb; |
- while((cb = it.GetNext()) != NULL) { |
- cb->Run(details); |
- } |
- } |
+$range ARITY 0..MAX_ARITY |
+$for ARITY [[ |
+$range ARG 1..ARITY |
-private: |
- DISALLOW_COPY_AND_ASSIGN(CallbackRegistry); |
-}; |
+$if ARITY == 0 [[ |
+template <> |
+class CallbackRegistry<void(void)> |
+ : public internal::CallbackRegistryBase<Callback<void(void)> > { |
+]] $else [[ |
+template <$for ARG , [[typename A$(ARG)]]> |
+class CallbackRegistry<void($for ARG , [[const A$(ARG)&]])> |
+ : public internal::CallbackRegistryBase< |
+ Callback<void($for ARG , [[const A$(ARG)&]])> > { |
+]] |
-template <> class CallbackRegistry<void> |
- : public internal::CallbackRegistryBase<Closure> { |
public: |
+$if ARITY == 0 [[ |
+ |
+ typedef Callback<void(void)> CallbackType; |
+]] $else [[ |
+ |
+ typedef Callback<void($for ARG , [[const A$(ARG)&]])> CallbackType; |
+]] |
+ |
+ |
CallbackRegistry() {} |
- // Execute all active callbacks. |
- void Notify() { |
- Iterator it = this->GetIterator(); |
- Closure* cb; |
+ void Notify($for ARG , [[const A$(ARG)& a$(ARG)]]) { |
+ typename internal::CallbackRegistryBase<CallbackType>::Iterator it = |
+ this->GetIterator(); |
+ CallbackType* cb; |
while((cb = it.GetNext()) != NULL) { |
- cb->Run(); |
+ cb->Run($for ARG , [[a$(ARG)]]); |
} |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(CallbackRegistry); |
+ |
+ |
}; |
+ |
+]] $$ for ARITY |
} // namespace base |
-#endif // BASE_CALLBACK_REGISTRY_H_ |
+#endif // BASE_CALLBACK_REGISTRY_H |