OLD | NEW |
1 $$ This is a pump file for generating file templates. Pump is a python | 1 $$ This is a pump file for generating file templates. Pump is a python |
2 $$ script that is part of the Google Test suite of utilities. Description | 2 $$ script that is part of the Google Test suite of utilities. Description |
3 $$ can be found here: | 3 $$ can be found here: |
4 $$ | 4 $$ |
5 $$ http://code.google.com/p/googletest/wiki/PumpManual | 5 $$ http://code.google.com/p/googletest/wiki/PumpManual |
6 $$ | 6 $$ |
7 | 7 |
8 $$ See comment for MAX_ARITY in base/bind.h.pump. | 8 $$ See comment for MAX_ARITY in base/bind.h.pump. |
9 $var MAX_ARITY = 7 | 9 $var MAX_ARITY = 7 |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // pointer. | 121 // pointer. |
122 // | 122 // |
123 // base::Closure cb = base::Bind(&MyClass::MyFunc, this, 23, "hello world"); | 123 // base::Closure cb = base::Bind(&MyClass::MyFunc, this, 23, "hello world"); |
124 // | 124 // |
125 // PARTIAL BINDING OF PARAMETERS | 125 // PARTIAL BINDING OF PARAMETERS |
126 // | 126 // |
127 // You can specify some parameters when you create the callback, and specify | 127 // You can specify some parameters when you create the callback, and specify |
128 // the rest when you execute the callback. | 128 // the rest when you execute the callback. |
129 // | 129 // |
130 // void MyFunc(int i, const std::string& str) {} | 130 // void MyFunc(int i, const std::string& str) {} |
131 // base::Callback<void(int)> cb = base::Bind(&MyFunc, 23); | 131 // base::Callback<void(const std::string&)> cb = base::Bind(&MyFunc, 23); |
132 // cb.Run("hello world"); | 132 // cb.Run("hello world"); |
133 // | 133 // |
134 // When calling a function bound parameters are first, followed by unbound | 134 // When calling a function bound parameters are first, followed by unbound |
135 // parameters. | 135 // parameters. |
136 // | 136 // |
137 // | 137 // |
138 // ----------------------------------------------------------------------------- | 138 // ----------------------------------------------------------------------------- |
139 // Quick reference for advanced binding | 139 // Quick reference for advanced binding |
140 // ----------------------------------------------------------------------------- | 140 // ----------------------------------------------------------------------------- |
141 // | 141 // |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 class Callback<R($for ARG , [[A$(ARG)]])> : public internal::CallbackBase { | 373 class Callback<R($for ARG , [[A$(ARG)]])> : public internal::CallbackBase { |
374 ]] | 374 ]] |
375 | 375 |
376 public: | 376 public: |
377 typedef R(RunType)($for ARG , [[A$(ARG)]]); | 377 typedef R(RunType)($for ARG , [[A$(ARG)]]); |
378 | 378 |
379 Callback() : CallbackBase(NULL) { } | 379 Callback() : CallbackBase(NULL) { } |
380 | 380 |
381 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 381 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
382 // return the exact Callback<> type. See base/bind.h for details. | 382 // return the exact Callback<> type. See base/bind.h for details. |
383 template <typename Runnable, typename RunType, typename BoundArgsType> | 383 template <typename Runnable, typename BindRunType, typename BoundArgsType> |
384 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state) | 384 Callback(internal::BindState<Runnable, BindRunType, |
| 385 BoundArgsType>* bind_state) |
385 : CallbackBase(bind_state) { | 386 : CallbackBase(bind_state) { |
386 | 387 |
387 // Force the assignment to a local variable of PolymorphicInvoke | 388 // Force the assignment to a local variable of PolymorphicInvoke |
388 // so the compiler will typecheck that the passed in Run() method has | 389 // so the compiler will typecheck that the passed in Run() method has |
389 // the correct type. | 390 // the correct type. |
390 PolymorphicInvoke invoke_func = | 391 PolymorphicInvoke invoke_func = |
391 &internal::BindState<Runnable, RunType, BoundArgsType> | 392 &internal::BindState<Runnable, BindRunType, BoundArgsType> |
392 ::InvokerType::Run; | 393 ::InvokerType::Run; |
393 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | 394 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); |
394 } | 395 } |
395 | 396 |
396 bool Equals(const Callback& other) const { | 397 bool Equals(const Callback& other) const { |
397 return CallbackBase::Equals(other); | 398 return CallbackBase::Equals(other); |
398 } | 399 } |
399 | 400 |
400 R Run($for ARG , | 401 R Run($for ARG , |
401 [[typename internal::CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]
) const { | 402 [[typename internal::CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]
) const { |
(...skipping 17 matching lines...) Expand all Loading... |
419 | 420 |
420 ]] $$ for ARITY | 421 ]] $$ for ARITY |
421 | 422 |
422 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it | 423 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it |
423 // will be used in a lot of APIs with delayed execution. | 424 // will be used in a lot of APIs with delayed execution. |
424 typedef Callback<void(void)> Closure; | 425 typedef Callback<void(void)> Closure; |
425 | 426 |
426 } // namespace base | 427 } // namespace base |
427 | 428 |
428 #endif // BASE_CALLBACK_H | 429 #endif // BASE_CALLBACK_H |
OLD | NEW |