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 $$ | 8 $$ |
9 $$ MAX_ARITY controls the number of arguments that Bind() supports. | 9 $$ MAX_ARITY controls the number of arguments that Bind() supports. |
10 $$ The amount of code, and more importantly, the number of template types | 10 $$ The amount of code, and more importantly, the number of template types |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // harder to read. | 64 // harder to read. |
65 | 65 |
66 namespace base { | 66 namespace base { |
67 | 67 |
68 $range ARITY 0..MAX_ARITY | 68 $range ARITY 0..MAX_ARITY |
69 $for ARITY [[ | 69 $for ARITY [[ |
70 $range ARG 1..ARITY | 70 $range ARG 1..ARITY |
71 | 71 |
72 template <typename Functor[[]] | 72 template <typename Functor[[]] |
73 $if ARITY > 0 [[, ]] $for ARG , [[typename P$(ARG)]]> | 73 $if ARITY > 0 [[, ]] $for ARG , [[typename P$(ARG)]]> |
74 internal::BindStateHolder< | 74 base::Callback< |
75 internal::BindState< | 75 typename internal::BindState< |
76 typename internal::FunctorTraits<Functor>::RunnableType, | 76 typename internal::FunctorTraits<Functor>::RunnableType, |
77 typename internal::FunctorTraits<Functor>::RunType, | 77 typename internal::FunctorTraits<Functor>::RunType, |
78 void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::Stora
geType]])> > | 78 void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::Stora
geType]])> |
| 79 ::UnboundRunType> |
79 Bind(Functor functor | 80 Bind(Functor functor |
80 $if ARITY > 0 [[, ]] $for ARG , [[const P$(ARG)& p$(ARG)]]) { | 81 $if ARITY > 0 [[, ]] $for ARG , [[const P$(ARG)& p$(ARG)]]) { |
81 // Typedefs for how to store and run the functor. | 82 // Typedefs for how to store and run the functor. |
82 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; | 83 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; |
83 typedef typename internal::FunctorTraits<Functor>::RunType RunType; | 84 typedef typename internal::FunctorTraits<Functor>::RunType RunType; |
84 | 85 |
85 // Use RunnableType::RunType instead of RunType above because our | 86 // Use RunnableType::RunType instead of RunType above because our |
86 // checks should below for bound references need to know what the actual | 87 // checks should below for bound references need to know what the actual |
87 // functor is going to interpret the argument as. | 88 // functor is going to interpret the argument as. |
88 typedef internal::FunctionTraits<typename RunnableType::RunType> | 89 typedef internal::FunctionTraits<typename RunnableType::RunType> |
(...skipping 29 matching lines...) Expand all Loading... |
118 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || | 119 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || |
119 !is_array<P$(ARG)>::value, | 120 !is_array<P$(ARG)>::value, |
120 first_bound_argument_to_method_cannot_be_array); | 121 first_bound_argument_to_method_cannot_be_array); |
121 ]] $else [[ | 122 ]] $else [[ |
122 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P$(ARG)>::value, | 123 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P$(ARG)>::value, |
123 p$(ARG)_is_refcounted_type_and_needs_scoped_refptr); | 124 p$(ARG)_is_refcounted_type_and_needs_scoped_refptr); |
124 ]] $$ $if ARG | 125 ]] $$ $if ARG |
125 | 126 |
126 ]] $$ $for ARG | 127 ]] $$ $for ARG |
127 | 128 |
| 129 typedef internal::BindState<RunnableType, RunType, [[]] |
| 130 void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::StorageType]]
)> [[]] |
| 131 BindState; |
128 | 132 |
129 return internal::MakeBindStateHolder( | 133 |
130 new internal::BindState<RunnableType, RunType, [[]] | 134 return Callback<typename BindState::UnboundRunType>( |
131 void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::StorageType]]
)>( | 135 new BindState(internal::MakeRunnable(functor)[[]] |
132 internal::MakeRunnable(functor)[[]] | |
133 $if ARITY > 0 [[, ]] $for ARG , [[p$(ARG)]])); | 136 $if ARITY > 0 [[, ]] $for ARG , [[p$(ARG)]])); |
134 } | 137 } |
135 | 138 |
136 ]] $$ for ARITY | 139 ]] $$ for ARITY |
137 | 140 |
138 } // namespace base | 141 } // namespace base |
139 | 142 |
140 #endif // BASE_BIND_H_ | 143 #endif // BASE_BIND_H_ |
OLD | NEW |