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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // and for ignoring return values. This is separate from | 75 // and for ignoring return values. This is separate from |
76 // Invoker to avoid creating multiple version of Invoker<> | 76 // Invoker to avoid creating multiple version of Invoker<> |
77 // which grows at O(n^2) with the arity. | 77 // which grows at O(n^2) with the arity. |
78 // There are |k*ARITY| InvokeHelper types. | 78 // There are |k*ARITY| InvokeHelper types. |
79 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. | 79 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. |
80 // There are |(ARITY^2 + ARITY)/2| Invoketypes. | 80 // There are |(ARITY^2 + ARITY)/2| Invoketypes. |
81 // BindState<> -- Stores the curried parameters, and is the main entry point | 81 // BindState<> -- Stores the curried parameters, and is the main entry point |
82 // into the Bind() system, doing most of the type resolution. | 82 // into the Bind() system, doing most of the type resolution. |
83 // There are ARITY BindState types. | 83 // There are ARITY BindState types. |
84 | 84 |
85 | |
86 // RunnableAdapter<> | 85 // RunnableAdapter<> |
87 // | 86 // |
88 // The RunnableAdapter<> templates provide a uniform interface for invoking | 87 // The RunnableAdapter<> templates provide a uniform interface for invoking |
89 // a function pointer, method pointer, or const method pointer. The adapter | 88 // a function pointer, method pointer, or const method pointer. The adapter |
90 // exposes a Run() method with an appropriate signature. Using this wrapper | 89 // exposes a Run() method with an appropriate signature. Using this wrapper |
91 // allows for writing code that supports all three pointer types without | 90 // allows for writing code that supports all three pointer types without |
92 // undue repetition. Without it, a lot of code would need to be repeated 3 | 91 // undue repetition. Without it, a lot of code would need to be repeated 3 |
93 // times. | 92 // times. |
94 // | 93 // |
95 // For method pointers and const method pointers the first argument to Run() | 94 // For method pointers and const method pointers the first argument to Run() |
(...skipping 18 matching lines...) Expand all Loading... |
114 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> | 113 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> |
115 class RunnableAdapter<R(*)($for ARG , [[A$(ARG)]])> { | 114 class RunnableAdapter<R(*)($for ARG , [[A$(ARG)]])> { |
116 public: | 115 public: |
117 typedef R (RunType)($for ARG , [[A$(ARG)]]); | 116 typedef R (RunType)($for ARG , [[A$(ARG)]]); |
118 | 117 |
119 explicit RunnableAdapter(R(*function)($for ARG , [[A$(ARG)]])) | 118 explicit RunnableAdapter(R(*function)($for ARG , [[A$(ARG)]])) |
120 : function_(function) { | 119 : function_(function) { |
121 } | 120 } |
122 | 121 |
123 R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]
]) { | 122 R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]
]) { |
124 return function_($for ARG , [[a$(ARG)]]); | 123 return function_($for ARG , [[BindMoveSupport(a$(ARG))]]); |
125 } | 124 } |
126 | 125 |
127 private: | 126 private: |
128 R (*function_)($for ARG , [[A$(ARG)]]); | 127 R (*function_)($for ARG , [[A$(ARG)]]); |
129 }; | 128 }; |
130 | 129 |
131 // Method: Arity $(ARITY). | 130 // Method: Arity $(ARITY). |
132 template <typename R, typename T[[]] | 131 template <typename R, typename T[[]] |
133 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> | 132 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> |
134 class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]])> { | 133 class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]])> { |
135 public: | 134 public: |
136 typedef R (RunType)(T*[[]] | 135 typedef R (RunType)(T*[[]] |
137 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]); | 136 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]); |
138 typedef true_type IsMethod; | 137 typedef true_type IsMethod; |
139 | 138 |
140 explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]])) | 139 explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]])) |
141 : method_(method) { | 140 : method_(method) { |
142 } | 141 } |
143 | 142 |
144 R Run(T* object[[]] | 143 R Run(T* object[[]] |
145 $if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardT
ype a$(ARG)]]) { | 144 $if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardT
ype a$(ARG)]]) { |
146 return (object->*method_)($for ARG , [[a$(ARG)]]); | 145 return (object->*method_)($for ARG , [[BindMoveSupport(a$(ARG))]]); |
147 } | 146 } |
148 | 147 |
149 private: | 148 private: |
150 R (T::*method_)($for ARG , [[A$(ARG)]]); | 149 R (T::*method_)($for ARG , [[A$(ARG)]]); |
151 }; | 150 }; |
152 | 151 |
153 // Const Method: Arity $(ARITY). | 152 // Const Method: Arity $(ARITY). |
154 template <typename R, typename T[[]] | 153 template <typename R, typename T[[]] |
155 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> | 154 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> |
156 class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]]) const> { | 155 class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]]) const> { |
157 public: | 156 public: |
158 typedef R (RunType)(const T*[[]] | 157 typedef R (RunType)(const T*[[]] |
159 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]); | 158 $if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]); |
160 typedef true_type IsMethod; | 159 typedef true_type IsMethod; |
161 | 160 |
162 explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]]) const) | 161 explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]]) const) |
163 : method_(method) { | 162 : method_(method) { |
164 } | 163 } |
165 | 164 |
166 R Run(const T* object[[]] | 165 R Run(const T* object[[]] |
167 $if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardT
ype a$(ARG)]]) { | 166 $if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardT
ype a$(ARG)]]) { |
168 return (object->*method_)($for ARG , [[a$(ARG)]]); | 167 return (object->*method_)($for ARG , [[BindMoveSupport(a$(ARG))]]); |
169 } | 168 } |
170 | 169 |
171 private: | 170 private: |
172 R (T::*method_)($for ARG , [[A$(ARG)]]) const; | 171 R (T::*method_)($for ARG , [[A$(ARG)]]) const; |
173 }; | 172 }; |
174 | 173 |
175 ]] $$ for ARITY | 174 ]] $$ for ARITY |
176 | 175 |
177 | 176 |
178 // FunctionTraits<> | 177 // FunctionTraits<> |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 485 |
487 ]] | 486 ]] |
488 }; | 487 }; |
489 | 488 |
490 ]] $$ for ARITY | 489 ]] $$ for ARITY |
491 | 490 |
492 } // namespace internal | 491 } // namespace internal |
493 } // namespace base | 492 } // namespace base |
494 | 493 |
495 #endif // BASE_BIND_INTERNAL_H_ | 494 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |