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 base::Callback< | 74 internal::BindStateHolder< |
75 typename internal::BindState< | 75 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> | |
80 Bind(Functor functor | 79 Bind(Functor functor |
81 $if ARITY > 0 [[, ]] $for ARG , [[const P$(ARG)& p$(ARG)]]) { | 80 $if ARITY > 0 [[, ]] $for ARG , [[const P$(ARG)& p$(ARG)]]) { |
82 // Typedefs for how to store and run the functor. | 81 // Typedefs for how to store and run the functor. |
83 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; | 82 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; |
84 typedef typename internal::FunctorTraits<Functor>::RunType RunType; | 83 typedef typename internal::FunctorTraits<Functor>::RunType RunType; |
85 | 84 |
86 // Use RunnableType::RunType instead of RunType above because our | 85 // Use RunnableType::RunType instead of RunType above because our |
87 // checks should below for bound references need to know what the actual | 86 // checks should below for bound references need to know what the actual |
88 // functor is going to interpret the argument as. | 87 // functor is going to interpret the argument as. |
89 typedef internal::FunctionTraits<typename RunnableType::RunType> | 88 typedef internal::FunctionTraits<typename RunnableType::RunType> |
(...skipping 29 matching lines...) Expand all Loading... |
119 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || | 118 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || |
120 !is_array<P$(ARG)>::value, | 119 !is_array<P$(ARG)>::value, |
121 first_bound_argument_to_method_cannot_be_array); | 120 first_bound_argument_to_method_cannot_be_array); |
122 ]] $else [[ | 121 ]] $else [[ |
123 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P$(ARG)>::value, | 122 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P$(ARG)>::value, |
124 p$(ARG)_is_refcounted_type_and_needs_scoped_refptr); | 123 p$(ARG)_is_refcounted_type_and_needs_scoped_refptr); |
125 ]] $$ $if ARG | 124 ]] $$ $if ARG |
126 | 125 |
127 ]] $$ $for ARG | 126 ]] $$ $for ARG |
128 | 127 |
129 typedef internal::BindState<RunnableType, RunType, [[]] | |
130 void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::StorageType]]
)> [[]] | |
131 BindState; | |
132 | 128 |
133 | 129 return internal::MakeBindStateHolder( |
134 return Callback<typename BindState::UnboundRunType>( | 130 new internal::BindState<RunnableType, RunType, [[]] |
135 new BindState(internal::MakeRunnable(functor)[[]] | 131 void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::StorageType]]
)>( |
| 132 internal::MakeRunnable(functor)[[]] |
136 $if ARITY > 0 [[, ]] $for ARG , [[p$(ARG)]])); | 133 $if ARITY > 0 [[, ]] $for ARG , [[p$(ARG)]])); |
137 } | 134 } |
138 | 135 |
139 ]] $$ for ARITY | 136 ]] $$ for ARITY |
140 | 137 |
141 } // namespace base | 138 } // namespace base |
142 | 139 |
143 #endif // BASE_BIND_H_ | 140 #endif // BASE_BIND_H_ |
OLD | NEW |