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 $range ARITY 0..MAX_ARITY | 10 $range ARITY 0..MAX_ARITY |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // from the invocation call. | 279 // from the invocation call. |
280 // | 280 // |
281 // WeakCalls similarly need special syntax that is applied to the first | 281 // WeakCalls similarly need special syntax that is applied to the first |
282 // argument to check if they should no-op themselves. | 282 // argument to check if they should no-op themselves. |
283 template <bool IsWeakCall, typename ReturnType, typename Runnable, | 283 template <bool IsWeakCall, typename ReturnType, typename Runnable, |
284 typename ArgsType> | 284 typename ArgsType> |
285 struct InvokeHelper; | 285 struct InvokeHelper; |
286 | 286 |
287 $for ARITY [[ | 287 $for ARITY [[ |
288 $range ARG 1..ARITY | 288 $range ARG 1..ARITY |
| 289 $range WEAKCALL_ARG 2..ARITY |
289 | 290 |
290 template <typename ReturnType, typename Runnable[[]] | 291 template <typename ReturnType, typename Runnable[[]] |
291 $if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]> | 292 $if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]> |
292 struct InvokeHelper<false, ReturnType, Runnable, | 293 struct InvokeHelper<false, ReturnType, Runnable, |
293 void($for ARG , [[A$(ARG)]])> { | 294 void($for ARG , [[A$(ARG)]])> { |
294 static ReturnType MakeItSo(Runnable runnable[[]] | 295 static ReturnType MakeItSo(Runnable runnable[[]] |
295 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) { | 296 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) { |
296 return runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]); | 297 return runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]); |
297 } | 298 } |
298 }; | 299 }; |
299 | 300 |
300 template <typename Runnable[[]] | 301 template <typename Runnable[[]] |
301 $if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]> | 302 $if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]> |
302 struct InvokeHelper<false, void, Runnable, | 303 struct InvokeHelper<false, void, Runnable, |
303 void($for ARG , [[A$(ARG)]])> { | 304 void($for ARG , [[A$(ARG)]])> { |
304 static void MakeItSo(Runnable runnable[[]] | 305 static void MakeItSo(Runnable runnable[[]] |
305 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) { | 306 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) { |
306 runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]); | 307 runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]); |
307 } | 308 } |
308 }; | 309 }; |
309 | 310 |
310 $if ARITY > 0 [[ | 311 $if ARITY > 0 [[ |
311 | 312 |
312 template <typename Runnable[[]], $for ARG , [[typename A$(ARG)]]> | 313 template <typename Runnable[[]], typename BoundWeakPtr |
| 314 $if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[typename A$(WEAKCALL_ARG)]]> |
313 struct InvokeHelper<true, void, Runnable, | 315 struct InvokeHelper<true, void, Runnable, |
314 void($for ARG , [[A$(ARG)]])> { | 316 void(BoundWeakPtr |
315 static void MakeItSo(Runnable runnable[[]] | 317 $if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[A$(WEAKCALL_ARG)]])> { |
316 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) { | 318 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr |
317 if (!a1.get()) { | 319 $if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[A$(WEAKCALL_ARG) a$(WEAKCALL_ARG)]]) { |
| 320 if (!weak_ptr.get()) { |
318 return; | 321 return; |
319 } | 322 } |
320 | 323 runnable.Run(weak_ptr.get() |
321 runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]); | 324 $if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[CallbackForward(a$(WEAKCALL_ARG))]]); |
322 } | 325 } |
323 }; | 326 }; |
324 | 327 |
325 ]] | 328 ]] |
326 | 329 |
327 ]] $$ for ARITY | 330 ]] $$ for ARITY |
328 | 331 |
329 #if !defined(_MSC_VER) | 332 #if !defined(_MSC_VER) |
330 | 333 |
331 template <typename ReturnType, typename Runnable, typename ArgsType> | 334 template <typename ReturnType, typename Runnable, typename ArgsType> |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 491 |
489 ]] | 492 ]] |
490 }; | 493 }; |
491 | 494 |
492 ]] $$ for ARITY | 495 ]] $$ for ARITY |
493 | 496 |
494 } // namespace internal | 497 } // namespace internal |
495 } // namespace base | 498 } // namespace base |
496 | 499 |
497 #endif // BASE_BIND_INTERNAL_H_ | 500 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |