1 // This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
2
3 // Copyright 2007, Google Inc.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following disclaimer
14 // in the documentation and/or other materials provided with the
15 // distribution.
16 // * Neither the name of Google Inc. nor the names of its
17 // contributors may be used to endorse or promote products derived from
18 // this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 //
32 // Author: wan@google.com (Zhanyong Wan)
33
34 // Google Mock - a framework for writing C++ mock classes.
35 //
36 // This file implements some commonly used variadic actions.
37
38 // IWYU pragma: private, include "gmock/gmock.h"
39
40 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
41 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
42
43 #include "gmock/gmock-actions.h"
44 #include "gmock/internal/gmock-port.h"
45
46 namespace testing {
47 namespace internal {
48
49 // InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
50 // function or method with the unpacked values, where F is a function
51 // type that takes N arguments.
52 template <typename Result, typename ArgumentTuple>
53 class InvokeHelper;
54
55 template <typename R>
56 class InvokeHelper<R, ::testing::tuple<> > {
57 public:
58 template <typename Function>
Invoke(Function function,const::testing::tuple<> &)59 static R Invoke(Function function, const ::testing::tuple<>&) {
60 return function();
61 }
62
63 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<> &)64 static R InvokeMethod(Class* obj_ptr,
65 MethodPtr method_ptr,
66 const ::testing::tuple<>&) {
67 return (obj_ptr->*method_ptr)();
68 }
69 };
70
71 template <typename R, typename A1>
72 class InvokeHelper<R, ::testing::tuple<A1> > {
73 public:
74 template <typename Function>
Invoke(Function function,const::testing::tuple<A1> & args)75 static R Invoke(Function function, const ::testing::tuple<A1>& args) {
76 return function(get<0>(args));
77 }
78
79 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1> & args)80 static R InvokeMethod(Class* obj_ptr,
81 MethodPtr method_ptr,
82 const ::testing::tuple<A1>& args) {
83 return (obj_ptr->*method_ptr)(get<0>(args));
84 }
85 };
86
87 template <typename R, typename A1, typename A2>
88 class InvokeHelper<R, ::testing::tuple<A1, A2> > {
89 public:
90 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2> & args)91 static R Invoke(Function function, const ::testing::tuple<A1, A2>& args) {
92 return function(get<0>(args), get<1>(args));
93 }
94
95 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2> & args)96 static R InvokeMethod(Class* obj_ptr,
97 MethodPtr method_ptr,
98 const ::testing::tuple<A1, A2>& args) {
99 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
100 }
101 };
102
103 template <typename R, typename A1, typename A2, typename A3>
104 class InvokeHelper<R, ::testing::tuple<A1, A2, A3> > {
105 public:
106 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3> & args)107 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3>& args) {
108 return function(get<0>(args), get<1>(args), get<2>(args));
109 }
110
111 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3> & args)112 static R InvokeMethod(Class* obj_ptr,
113 MethodPtr method_ptr,
114 const ::testing::tuple<A1, A2, A3>& args) {
115 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
116 get<2>(args));
117 }
118 };
119
120 template <typename R, typename A1, typename A2, typename A3, typename A4>
121 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4> > {
122 public:
123 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3,A4> & args)124 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3,
125 A4>& args) {
126 return function(get<0>(args), get<1>(args), get<2>(args),
127 get<3>(args));
128 }
129
130 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3,A4> & args)131 static R InvokeMethod(Class* obj_ptr,
132 MethodPtr method_ptr,
133 const ::testing::tuple<A1, A2, A3, A4>& args) {
134 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
135 get<2>(args), get<3>(args));
136 }
137 };
138
139 template <typename R, typename A1, typename A2, typename A3, typename A4,
140 typename A5>
141 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5> > {
142 public:
143 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3,A4,A5> & args)144 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4,
145 A5>& args) {
146 return function(get<0>(args), get<1>(args), get<2>(args),
147 get<3>(args), get<4>(args));
148 }
149
150 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3,A4,A5> & args)151 static R InvokeMethod(Class* obj_ptr,
152 MethodPtr method_ptr,
153 const ::testing::tuple<A1, A2, A3, A4, A5>& args) {
154 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
155 get<2>(args), get<3>(args), get<4>(args));
156 }
157 };
158
159 template <typename R, typename A1, typename A2, typename A3, typename A4,
160 typename A5, typename A6>
161 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
162 public:
163 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3,A4,A5,A6> & args)164 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
165 A6>& args) {
166 return function(get<0>(args), get<1>(args), get<2>(args),
167 get<3>(args), get<4>(args), get<5>(args));
168 }
169
170 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3,A4,A5,A6> & args)171 static R InvokeMethod(Class* obj_ptr,
172 MethodPtr method_ptr,
173 const ::testing::tuple<A1, A2, A3, A4, A5, A6>& args) {
174 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
175 get<2>(args), get<3>(args), get<4>(args), get<5>(args));
176 }
177 };
178
179 template <typename R, typename A1, typename A2, typename A3, typename A4,
180 typename A5, typename A6, typename A7>
181 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
182 public:
183 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7> & args)184 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
185 A6, A7>& args) {
186 return function(get<0>(args), get<1>(args), get<2>(args),
187 get<3>(args), get<4>(args), get<5>(args), get<6>(args));
188 }
189
190 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7> & args)191 static R InvokeMethod(Class* obj_ptr,
192 MethodPtr method_ptr,
193 const ::testing::tuple<A1, A2, A3, A4, A5, A6,
194 A7>& args) {
195 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
196 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
197 get<6>(args));
198 }
199 };
200
201 template <typename R, typename A1, typename A2, typename A3, typename A4,
202 typename A5, typename A6, typename A7, typename A8>
203 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
204 public:
205 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7,A8> & args)206 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
207 A6, A7, A8>& args) {
208 return function(get<0>(args), get<1>(args), get<2>(args),
209 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
210 get<7>(args));
211 }
212
213 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7,A8> & args)214 static R InvokeMethod(Class* obj_ptr,
215 MethodPtr method_ptr,
216 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7,
217 A8>& args) {
218 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
219 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
220 get<6>(args), get<7>(args));
221 }
222 };
223
224 template <typename R, typename A1, typename A2, typename A3, typename A4,
225 typename A5, typename A6, typename A7, typename A8, typename A9>
226 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
227 public:
228 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7,A8,A9> & args)229 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
230 A6, A7, A8, A9>& args) {
231 return function(get<0>(args), get<1>(args), get<2>(args),
232 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
233 get<7>(args), get<8>(args));
234 }
235
236 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7,A8,A9> & args)237 static R InvokeMethod(Class* obj_ptr,
238 MethodPtr method_ptr,
239 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
240 A9>& args) {
241 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
242 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
243 get<6>(args), get<7>(args), get<8>(args));
244 }
245 };
246
247 template <typename R, typename A1, typename A2, typename A3, typename A4,
248 typename A5, typename A6, typename A7, typename A8, typename A9,
249 typename A10>
250 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
251 A10> > {
252 public:
253 template <typename Function>
Invoke(Function function,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10> & args)254 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
255 A6, A7, A8, A9, A10>& args) {
256 return function(get<0>(args), get<1>(args), get<2>(args),
257 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
258 get<7>(args), get<8>(args), get<9>(args));
259 }
260
261 template <class Class, typename MethodPtr>
InvokeMethod(Class * obj_ptr,MethodPtr method_ptr,const::testing::tuple<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10> & args)262 static R InvokeMethod(Class* obj_ptr,
263 MethodPtr method_ptr,
264 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
265 A9, A10>& args) {
266 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
267 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
268 get<6>(args), get<7>(args), get<8>(args), get<9>(args));
269 }
270 };
271
272 // An INTERNAL macro for extracting the type of a tuple field. It's
273 // subject to change without notice - DO NOT USE IN USER CODE!
274 #define GMOCK_FIELD_(Tuple, N) \
275 typename ::testing::tuple_element<N, Tuple>::type
276
277 // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
278 // type of an n-ary function whose i-th (1-based) argument type is the
279 // k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
280 // type, and whose return type is Result. For example,
281 // SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
282 // is int(bool, long).
283 //
284 // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
285 // returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
286 // For example,
287 // SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
288 // ::testing::make_tuple(true, 'a', 2.5))
289 // returns tuple (2.5, true).
290 //
291 // The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
292 // in the range [0, 10]. Duplicates are allowed and they don't have
293 // to be in an ascending or descending order.
294
295 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
296 int k4, int k5, int k6, int k7, int k8, int k9, int k10>
297 class SelectArgs {
298 public:
299 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
300 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
301 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
302 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
303 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
304 GMOCK_FIELD_(ArgumentTuple, k10));
305 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)306 static SelectedArgs Select(const ArgumentTuple& args) {
307 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
308 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
309 get<k8>(args), get<k9>(args), get<k10>(args));
310 }
311 };
312
313 template <typename Result, typename ArgumentTuple>
314 class SelectArgs<Result, ArgumentTuple,
315 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
316 public:
317 typedef Result type();
318 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple &)319 static SelectedArgs Select(const ArgumentTuple& /* args */) {
320 return SelectedArgs();
321 }
322 };
323
324 template <typename Result, typename ArgumentTuple, int k1>
325 class SelectArgs<Result, ArgumentTuple,
326 k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
327 public:
328 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
329 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)330 static SelectedArgs Select(const ArgumentTuple& args) {
331 return SelectedArgs(get<k1>(args));
332 }
333 };
334
335 template <typename Result, typename ArgumentTuple, int k1, int k2>
336 class SelectArgs<Result, ArgumentTuple,
337 k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {
338 public:
339 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
340 GMOCK_FIELD_(ArgumentTuple, k2));
341 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)342 static SelectedArgs Select(const ArgumentTuple& args) {
343 return SelectedArgs(get<k1>(args), get<k2>(args));
344 }
345 };
346
347 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
348 class SelectArgs<Result, ArgumentTuple,
349 k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {
350 public:
351 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
352 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
353 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)354 static SelectedArgs Select(const ArgumentTuple& args) {
355 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
356 }
357 };
358
359 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
360 int k4>
361 class SelectArgs<Result, ArgumentTuple,
362 k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {
363 public:
364 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
365 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
366 GMOCK_FIELD_(ArgumentTuple, k4));
367 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)368 static SelectedArgs Select(const ArgumentTuple& args) {
369 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
370 get<k4>(args));
371 }
372 };
373
374 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
375 int k4, int k5>
376 class SelectArgs<Result, ArgumentTuple,
377 k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {
378 public:
379 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
380 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
381 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
382 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)383 static SelectedArgs Select(const ArgumentTuple& args) {
384 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
385 get<k4>(args), get<k5>(args));
386 }
387 };
388
389 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
390 int k4, int k5, int k6>
391 class SelectArgs<Result, ArgumentTuple,
392 k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {
393 public:
394 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
395 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
396 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
397 GMOCK_FIELD_(ArgumentTuple, k6));
398 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)399 static SelectedArgs Select(const ArgumentTuple& args) {
400 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
401 get<k4>(args), get<k5>(args), get<k6>(args));
402 }
403 };
404
405 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
406 int k4, int k5, int k6, int k7>
407 class SelectArgs<Result, ArgumentTuple,
408 k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {
409 public:
410 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
411 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
412 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
413 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
414 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)415 static SelectedArgs Select(const ArgumentTuple& args) {
416 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
417 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
418 }
419 };
420
421 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
422 int k4, int k5, int k6, int k7, int k8>
423 class SelectArgs<Result, ArgumentTuple,
424 k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {
425 public:
426 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
427 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
428 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
429 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
430 GMOCK_FIELD_(ArgumentTuple, k8));
431 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)432 static SelectedArgs Select(const ArgumentTuple& args) {
433 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
434 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
435 get<k8>(args));
436 }
437 };
438
439 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
440 int k4, int k5, int k6, int k7, int k8, int k9>
441 class SelectArgs<Result, ArgumentTuple,
442 k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {
443 public:
444 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
445 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
446 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
447 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
448 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
449 typedef typename Function<type>::ArgumentTuple SelectedArgs;
Select(const ArgumentTuple & args)450 static SelectedArgs Select(const ArgumentTuple& args) {
451 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
452 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
453 get<k8>(args), get<k9>(args));
454 }
455 };
456
457 #undef GMOCK_FIELD_
458
459 // Implements the WithArgs action.
460 template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
461 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
462 int k9 = -1, int k10 = -1>
463 class WithArgsAction {
464 public:
WithArgsAction(const InnerAction & action)465 explicit WithArgsAction(const InnerAction& action) : action_(action) {}
466
467 template <typename F>
468 operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
469
470 private:
471 template <typename F>
472 class Impl : public ActionInterface<F> {
473 public:
474 typedef typename Function<F>::Result Result;
475 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
476
Impl(const InnerAction & action)477 explicit Impl(const InnerAction& action) : action_(action) {}
478
Perform(const ArgumentTuple & args)479 virtual Result Perform(const ArgumentTuple& args) {
480 return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4,
481 k5, k6, k7, k8, k9, k10>::Select(args));
482 }
483
484 private:
485 typedef typename SelectArgs<Result, ArgumentTuple,
486 k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
487
488 Action<InnerFunctionType> action_;
489 };
490
491 const InnerAction action_;
492
493 GTEST_DISALLOW_ASSIGN_(WithArgsAction);
494 };
495
496 // A macro from the ACTION* family (defined later in this file)
497 // defines an action that can be used in a mock function. Typically,
498 // these actions only care about a subset of the arguments of the mock
499 // function. For example, if such an action only uses the second
500 // argument, it can be used in any mock function that takes >= 2
501 // arguments where the type of the second argument is compatible.
502 //
503 // Therefore, the action implementation must be prepared to take more
504 // arguments than it needs. The ExcessiveArg type is used to
505 // represent those excessive arguments. In order to keep the compiler
506 // error messages tractable, we define it in the testing namespace
507 // instead of testing::internal. However, this is an INTERNAL TYPE
508 // and subject to change without notice, so a user MUST NOT USE THIS
509 // TYPE DIRECTLY.
510 struct ExcessiveArg {};
511
512 // A helper class needed for implementing the ACTION* macros.
513 template <typename Result, class Impl>
514 class ActionHelper {
515 public:
Perform(Impl * impl,const::testing::tuple<> & args)516 static Result Perform(Impl* impl, const ::testing::tuple<>& args) {
517 return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
518 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
519 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
520 ExcessiveArg());
521 }
522
523 template <typename A0>
Perform(Impl * impl,const::testing::tuple<A0> & args)524 static Result Perform(Impl* impl, const ::testing::tuple<A0>& args) {
525 return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
526 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
527 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
528 ExcessiveArg());
529 }
530
531 template <typename A0, typename A1>
Perform(Impl * impl,const::testing::tuple<A0,A1> & args)532 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1>& args) {
533 return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
534 get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
535 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
536 ExcessiveArg());
537 }
538
539 template <typename A0, typename A1, typename A2>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2> & args)540 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2>& args) {
541 return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
542 get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
543 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
544 ExcessiveArg());
545 }
546
547 template <typename A0, typename A1, typename A2, typename A3>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2,A3> & args)548 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2,
549 A3>& args) {
550 return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
551 get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
552 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
553 ExcessiveArg());
554 }
555
556 template <typename A0, typename A1, typename A2, typename A3, typename A4>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2,A3,A4> & args)557 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3,
558 A4>& args) {
559 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
560 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
561 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
562 ExcessiveArg());
563 }
564
565 template <typename A0, typename A1, typename A2, typename A3, typename A4,
566 typename A5>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2,A3,A4,A5> & args)567 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
568 A5>& args) {
569 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
570 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
571 get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
572 ExcessiveArg());
573 }
574
575 template <typename A0, typename A1, typename A2, typename A3, typename A4,
576 typename A5, typename A6>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2,A3,A4,A5,A6> & args)577 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
578 A5, A6>& args) {
579 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
580 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
581 get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
582 ExcessiveArg());
583 }
584
585 template <typename A0, typename A1, typename A2, typename A3, typename A4,
586 typename A5, typename A6, typename A7>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2,A3,A4,A5,A6,A7> & args)587 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
588 A5, A6, A7>& args) {
589 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
590 A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
591 get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
592 ExcessiveArg());
593 }
594
595 template <typename A0, typename A1, typename A2, typename A3, typename A4,
596 typename A5, typename A6, typename A7, typename A8>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2,A3,A4,A5,A6,A7,A8> & args)597 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
598 A5, A6, A7, A8>& args) {
599 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
600 A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
601 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
602 ExcessiveArg());
603 }
604
605 template <typename A0, typename A1, typename A2, typename A3, typename A4,
606 typename A5, typename A6, typename A7, typename A8, typename A9>
Perform(Impl * impl,const::testing::tuple<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9> & args)607 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
608 A5, A6, A7, A8, A9>& args) {
609 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
610 A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
611 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
612 get<9>(args));
613 }
614 };
615
616 } // namespace internal
617
618 // Various overloads for Invoke().
619
620 // WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
621 // the selected arguments of the mock function to an_action and
622 // performs it. It serves as an adaptor between actions with
623 // different argument lists. C++ doesn't support default arguments for
624 // function templates, so we have to overload it.
625 template <int k1, typename InnerAction>
626 inline internal::WithArgsAction<InnerAction, k1>
WithArgs(const InnerAction & action)627 WithArgs(const InnerAction& action) {
628 return internal::WithArgsAction<InnerAction, k1>(action);
629 }
630
631 template <int k1, int k2, typename InnerAction>
632 inline internal::WithArgsAction<InnerAction, k1, k2>
WithArgs(const InnerAction & action)633 WithArgs(const InnerAction& action) {
634 return internal::WithArgsAction<InnerAction, k1, k2>(action);
635 }
636
637 template <int k1, int k2, int k3, typename InnerAction>
638 inline internal::WithArgsAction<InnerAction, k1, k2, k3>
WithArgs(const InnerAction & action)639 WithArgs(const InnerAction& action) {
640 return internal::WithArgsAction<InnerAction, k1, k2, k3>(action);
641 }
642
643 template <int k1, int k2, int k3, int k4, typename InnerAction>
644 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4>
WithArgs(const InnerAction & action)645 WithArgs(const InnerAction& action) {
646 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action);
647 }
648
649 template <int k1, int k2, int k3, int k4, int k5, typename InnerAction>
650 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>
WithArgs(const InnerAction & action)651 WithArgs(const InnerAction& action) {
652 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action);
653 }
654
655 template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>
656 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>
WithArgs(const InnerAction & action)657 WithArgs(const InnerAction& action) {
658 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action);
659 }
660
661 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
662 typename InnerAction>
663 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7>
WithArgs(const InnerAction & action)664 WithArgs(const InnerAction& action) {
665 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,
666 k7>(action);
667 }
668
669 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
670 typename InnerAction>
671 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8>
WithArgs(const InnerAction & action)672 WithArgs(const InnerAction& action) {
673 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,
674 k8>(action);
675 }
676
677 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
678 int k9, typename InnerAction>
679 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9>
WithArgs(const InnerAction & action)680 WithArgs(const InnerAction& action) {
681 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
682 k9>(action);
683 }
684
685 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
686 int k9, int k10, typename InnerAction>
687 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
688 k9, k10>
WithArgs(const InnerAction & action)689 WithArgs(const InnerAction& action) {
690 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
691 k9, k10>(action);
692 }
693
694 // Creates an action that does actions a1, a2, ..., sequentially in
695 // each invocation.
696 template <typename Action1, typename Action2>
697 inline internal::DoBothAction<Action1, Action2>
DoAll(Action1 a1,Action2 a2)698 DoAll(Action1 a1, Action2 a2) {
699 return internal::DoBothAction<Action1, Action2>(a1, a2);
700 }
701
702 template <typename Action1, typename Action2, typename Action3>
703 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
704 Action3> >
DoAll(Action1 a1,Action2 a2,Action3 a3)705 DoAll(Action1 a1, Action2 a2, Action3 a3) {
706 return DoAll(a1, DoAll(a2, a3));
707 }
708
709 template <typename Action1, typename Action2, typename Action3,
710 typename Action4>
711 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
712 internal::DoBothAction<Action3, Action4> > >
DoAll(Action1 a1,Action2 a2,Action3 a3,Action4 a4)713 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) {
714 return DoAll(a1, DoAll(a2, a3, a4));
715 }
716
717 template <typename Action1, typename Action2, typename Action3,
718 typename Action4, typename Action5>
719 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
720 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
721 Action5> > > >
DoAll(Action1 a1,Action2 a2,Action3 a3,Action4 a4,Action5 a5)722 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) {
723 return DoAll(a1, DoAll(a2, a3, a4, a5));
724 }
725
726 template <typename Action1, typename Action2, typename Action3,
727 typename Action4, typename Action5, typename Action6>
728 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
729 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
730 internal::DoBothAction<Action5, Action6> > > > >
DoAll(Action1 a1,Action2 a2,Action3 a3,Action4 a4,Action5 a5,Action6 a6)731 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) {
732 return DoAll(a1, DoAll(a2, a3, a4, a5, a6));
733 }
734
735 template <typename Action1, typename Action2, typename Action3,
736 typename Action4, typename Action5, typename Action6, typename Action7>
737 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
738 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
739 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
740 Action7> > > > > >
DoAll(Action1 a1,Action2 a2,Action3 a3,Action4 a4,Action5 a5,Action6 a6,Action7 a7)741 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
742 Action7 a7) {
743 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));
744 }
745
746 template <typename Action1, typename Action2, typename Action3,
747 typename Action4, typename Action5, typename Action6, typename Action7,
748 typename Action8>
749 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
750 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
751 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
752 internal::DoBothAction<Action7, Action8> > > > > > >
DoAll(Action1 a1,Action2 a2,Action3 a3,Action4 a4,Action5 a5,Action6 a6,Action7 a7,Action8 a8)753 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
754 Action7 a7, Action8 a8) {
755 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));
756 }
757
758 template <typename Action1, typename Action2, typename Action3,
759 typename Action4, typename Action5, typename Action6, typename Action7,
760 typename Action8, typename Action9>
761 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
762 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
763 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
764 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
765 Action9> > > > > > > >
DoAll(Action1 a1,Action2 a2,Action3 a3,Action4 a4,Action5 a5,Action6 a6,Action7 a7,Action8 a8,Action9 a9)766 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
767 Action7 a7, Action8 a8, Action9 a9) {
768 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));
769 }
770
771 template <typename Action1, typename Action2, typename Action3,
772 typename Action4, typename Action5, typename Action6, typename Action7,
773 typename Action8, typename Action9, typename Action10>
774 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
775 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
776 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
777 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
778 internal::DoBothAction<Action9, Action10> > > > > > > > >
DoAll(Action1 a1,Action2 a2,Action3 a3,Action4 a4,Action5 a5,Action6 a6,Action7 a7,Action8 a8,Action9 a9,Action10 a10)779 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
780 Action7 a7, Action8 a8, Action9 a9, Action10 a10) {
781 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
782 }
783
784 } // namespace testing
785
786 // The ACTION* family of macros can be used in a namespace scope to
787 // define custom actions easily. The syntax:
788 //
789 // ACTION(name) { statements; }
790 //
791 // will define an action with the given name that executes the
792 // statements. The value returned by the statements will be used as
793 // the return value of the action. Inside the statements, you can
794 // refer to the K-th (0-based) argument of the mock function by
795 // 'argK', and refer to its type by 'argK_type'. For example:
796 //
797 // ACTION(IncrementArg1) {
798 // arg1_type temp = arg1;
799 // return ++(*temp);
800 // }
801 //
802 // allows you to write
803 //
804 // ...WillOnce(IncrementArg1());
805 //
806 // You can also refer to the entire argument tuple and its type by
807 // 'args' and 'args_type', and refer to the mock function type and its
808 // return type by 'function_type' and 'return_type'.
809 //
810 // Note that you don't need to specify the types of the mock function
811 // arguments. However rest assured that your code is still type-safe:
812 // you'll get a compiler error if *arg1 doesn't support the ++
813 // operator, or if the type of ++(*arg1) isn't compatible with the
814 // mock function's return type, for example.
815 //
816 // Sometimes you'll want to parameterize the action. For that you can use
817 // another macro:
818 //
819 // ACTION_P(name, param_name) { statements; }
820 //
821 // For example:
822 //
823 // ACTION_P(Add, n) { return arg0 + n; }
824 //
825 // will allow you to write:
826 //
827 // ...WillOnce(Add(5));
828 //
829 // Note that you don't need to provide the type of the parameter
830 // either. If you need to reference the type of a parameter named
831 // 'foo', you can write 'foo_type'. For example, in the body of
832 // ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
833 // of 'n'.
834 //
835 // We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support
836 // multi-parameter actions.
837 //
838 // For the purpose of typing, you can view
839 //
840 // ACTION_Pk(Foo, p1, ..., pk) { ... }
841 //
842 // as shorthand for
843 //
844 // template <typename p1_type, ..., typename pk_type>
845 // FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
846 //
847 // In particular, you can provide the template type arguments
848 // explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
849 // although usually you can rely on the compiler to infer the types
850 // for you automatically. You can assign the result of expression
851 // Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
852 // pk_type>. This can be useful when composing actions.
853 //
854 // You can also overload actions with different numbers of parameters:
855 //
856 // ACTION_P(Plus, a) { ... }
857 // ACTION_P2(Plus, a, b) { ... }
858 //
859 // While it's tempting to always use the ACTION* macros when defining
860 // a new action, you should also consider implementing ActionInterface
861 // or using MakePolymorphicAction() instead, especially if you need to
862 // use the action a lot. While these approaches require more work,
863 // they give you more control on the types of the mock function
864 // arguments and the action parameters, which in general leads to
865 // better compiler error messages that pay off in the long run. They
866 // also allow overloading actions based on parameter types (as opposed
867 // to just based on the number of parameters).
868 //
869 // CAVEAT:
870 //
871 // ACTION*() can only be used in a namespace scope. The reason is
872 // that C++ doesn't yet allow function-local types to be used to
873 // instantiate templates. The up-coming C++0x standard will fix this.
874 // Once that's done, we'll consider supporting using ACTION*() inside
875 // a function.
876 //
877 // MORE INFORMATION:
878 //
879 // To learn more about using these macros, please search for 'ACTION'
880 // on http://code.google.com/p/googlemock/wiki/CookBook.
881
882 // An internal macro needed for implementing ACTION*().
883 #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
884 const args_type& args GTEST_ATTRIBUTE_UNUSED_, \
885 arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \
886 arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \
887 arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \
888 arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \
889 arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \
890 arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \
891 arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \
892 arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \
893 arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \
894 arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
895
896 // Sometimes you want to give an action explicit template parameters
897 // that cannot be inferred from its value parameters. ACTION() and
898 // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
899 // and can be viewed as an extension to ACTION() and ACTION_P*().
900 //
901 // The syntax:
902 //
903 // ACTION_TEMPLATE(ActionName,
904 // HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
905 // AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
906 //
907 // defines an action template that takes m explicit template
908 // parameters and n value parameters. name_i is the name of the i-th
909 // template parameter, and kind_i specifies whether it's a typename,
910 // an integral constant, or a template. p_i is the name of the i-th
911 // value parameter.
912 //
913 // Example:
914 //
915 // // DuplicateArg<k, T>(output) converts the k-th argument of the mock
916 // // function to type T and copies it to *output.
917 // ACTION_TEMPLATE(DuplicateArg,
918 // HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
919 // AND_1_VALUE_PARAMS(output)) {
920 // *output = T(::testing::get<k>(args));
921 // }
922 // ...
923 // int n;
924 // EXPECT_CALL(mock, Foo(_, _))
925 // .WillOnce(DuplicateArg<1, unsigned char>(&n));
926 //
927 // To create an instance of an action template, write:
928 //
929 // ActionName<t1, ..., t_m>(v1, ..., v_n)
930 //
931 // where the ts are the template arguments and the vs are the value
932 // arguments. The value argument types are inferred by the compiler.
933 // If you want to explicitly specify the value argument types, you can
934 // provide additional template arguments:
935 //
936 // ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
937 //
938 // where u_i is the desired type of v_i.
939 //
940 // ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
941 // number of value parameters, but not on the number of template
942 // parameters. Without the restriction, the meaning of the following
943 // is unclear:
944 //
945 // OverloadedAction<int, bool>(x);
946 //
947 // Are we using a single-template-parameter action where 'bool' refers
948 // to the type of x, or are we using a two-template-parameter action
949 // where the compiler is asked to infer the type of x?
950 //
951 // Implementation notes:
952 //
953 // GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
954 // GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
955 // implementing ACTION_TEMPLATE. The main trick we use is to create
956 // new macro invocations when expanding a macro. For example, we have
957 //
958 // #define ACTION_TEMPLATE(name, template_params, value_params)
959 // ... GMOCK_INTERNAL_DECL_##template_params ...
960 //
961 // which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
962 // to expand to
963 //
964 // ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
965 //
966 // Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
967 // preprocessor will continue to expand it to
968 //
969 // ... typename T ...
970 //
971 // This technique conforms to the C++ standard and is portable. It
972 // allows us to implement action templates using O(N) code, where N is
973 // the maximum number of template/value parameters supported. Without
974 // using it, we'd have to devote O(N^2) amount of code to implement all
975 // combinations of m and n.
976
977 // Declares the template parameters.
978 #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
979 #define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
980 name1) kind0 name0, kind1 name1
981 #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
982 kind2, name2) kind0 name0, kind1 name1, kind2 name2
983 #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
984 kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
985 kind3 name3
986 #define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
987 kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
988 kind2 name2, kind3 name3, kind4 name4
989 #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
990 kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
991 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
992 #define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
993 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
994 name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
995 kind5 name5, kind6 name6
996 #define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
997 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
998 kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
999 kind4 name4, kind5 name5, kind6 name6, kind7 name7
1000 #define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1001 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
1002 kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
1003 kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
1004 kind8 name8
1005 #define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
1006 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
1007 name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
1008 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
1009 kind6 name6, kind7 name7, kind8 name8, kind9 name9
1010
1011 // Lists the template parameters.
1012 #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
1013 #define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
1014 name1) name0, name1
1015 #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1016 kind2, name2) name0, name1, name2
1017 #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1018 kind2, name2, kind3, name3) name0, name1, name2, name3
1019 #define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1020 kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
1021 name4
1022 #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1023 kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
1024 name2, name3, name4, name5
1025 #define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1026 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
1027 name6) name0, name1, name2, name3, name4, name5, name6
1028 #define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1029 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
1030 kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
1031 #define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1032 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
1033 kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
1034 name6, name7, name8
1035 #define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
1036 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
1037 name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
1038 name3, name4, name5, name6, name7, name8, name9
1039
1040 // Declares the types of value parameters.
1041 #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
1042 #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
1043 #define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
1044 typename p0##_type, typename p1##_type
1045 #define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
1046 typename p0##_type, typename p1##_type, typename p2##_type
1047 #define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
1048 typename p0##_type, typename p1##_type, typename p2##_type, \
1049 typename p3##_type
1050 #define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
1051 typename p0##_type, typename p1##_type, typename p2##_type, \
1052 typename p3##_type, typename p4##_type
1053 #define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
1054 typename p0##_type, typename p1##_type, typename p2##_type, \
1055 typename p3##_type, typename p4##_type, typename p5##_type
1056 #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1057 p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
1058 typename p3##_type, typename p4##_type, typename p5##_type, \
1059 typename p6##_type
1060 #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1061 p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
1062 typename p3##_type, typename p4##_type, typename p5##_type, \
1063 typename p6##_type, typename p7##_type
1064 #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1065 p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
1066 typename p3##_type, typename p4##_type, typename p5##_type, \
1067 typename p6##_type, typename p7##_type, typename p8##_type
1068 #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1069 p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
1070 typename p2##_type, typename p3##_type, typename p4##_type, \
1071 typename p5##_type, typename p6##_type, typename p7##_type, \
1072 typename p8##_type, typename p9##_type
1073
1074 // Initializes the value parameters.
1075 #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
1076 ()
1077 #define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
1078 (p0##_type gmock_p0) : p0(gmock_p0)
1079 #define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
1080 (p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)
1081 #define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
1082 (p0##_type gmock_p0, p1##_type gmock_p1, \
1083 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)
1084 #define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
1085 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1086 p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1087 p3(gmock_p3)
1088 #define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
1089 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1090 p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), \
1091 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4)
1092 #define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
1093 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1094 p3##_type gmock_p3, p4##_type gmock_p4, \
1095 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1096 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5)
1097 #define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
1098 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1099 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1100 p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1101 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6)
1102 #define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
1103 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1104 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1105 p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), \
1106 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1107 p7(gmock_p7)
1108 #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1109 p7, p8)\
1110 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1111 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1112 p6##_type gmock_p6, p7##_type gmock_p7, \
1113 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1114 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1115 p8(gmock_p8)
1116 #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1117 p7, p8, p9)\
1118 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1119 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1120 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
1121 p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1122 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1123 p8(gmock_p8), p9(gmock_p9)
1124
1125 // Declares the fields for storing the value parameters.
1126 #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
1127 #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
1128 #define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
1129 p1##_type p1;
1130 #define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
1131 p1##_type p1; p2##_type p2;
1132 #define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
1133 p1##_type p1; p2##_type p2; p3##_type p3;
1134 #define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
1135 p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
1136 #define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
1137 p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
1138 p5##_type p5;
1139 #define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1140 p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
1141 p5##_type p5; p6##_type p6;
1142 #define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1143 p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
1144 p5##_type p5; p6##_type p6; p7##_type p7;
1145 #define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1146 p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
1147 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
1148 #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1149 p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
1150 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
1151 p9##_type p9;
1152
1153 // Lists the value parameters.
1154 #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
1155 #define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
1156 #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
1157 #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
1158 #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
1159 #define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
1160 p2, p3, p4
1161 #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
1162 p1, p2, p3, p4, p5
1163 #define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1164 p6) p0, p1, p2, p3, p4, p5, p6
1165 #define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1166 p7) p0, p1, p2, p3, p4, p5, p6, p7
1167 #define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1168 p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
1169 #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1170 p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
1171
1172 // Lists the value parameter types.
1173 #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
1174 #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
1175 #define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
1176 p1##_type
1177 #define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
1178 p1##_type, p2##_type
1179 #define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
1180 p0##_type, p1##_type, p2##_type, p3##_type
1181 #define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
1182 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
1183 #define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
1184 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
1185 #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1186 p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
1187 p6##_type
1188 #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1189 p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1190 p5##_type, p6##_type, p7##_type
1191 #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1192 p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1193 p5##_type, p6##_type, p7##_type, p8##_type
1194 #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1195 p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1196 p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
1197
1198 // Declares the value parameters.
1199 #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
1200 #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
1201 #define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
1202 p1##_type p1
1203 #define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
1204 p1##_type p1, p2##_type p2
1205 #define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
1206 p1##_type p1, p2##_type p2, p3##_type p3
1207 #define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
1208 p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
1209 #define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
1210 p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
1211 p5##_type p5
1212 #define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1213 p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
1214 p5##_type p5, p6##_type p6
1215 #define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1216 p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
1217 p5##_type p5, p6##_type p6, p7##_type p7
1218 #define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1219 p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1220 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
1221 #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1222 p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1223 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
1224 p9##_type p9
1225
1226 // The suffix of the class template implementing the action template.
1227 #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
1228 #define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
1229 #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
1230 #define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
1231 #define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
1232 #define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
1233 #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
1234 #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
1235 #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1236 p7) P8
1237 #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1238 p7, p8) P9
1239 #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1240 p7, p8, p9) P10
1241
1242 // The name of the class template implementing the action template.
1243 #define GMOCK_ACTION_CLASS_(name, value_params)\
1244 GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
1245
1246 #define ACTION_TEMPLATE(name, template_params, value_params)\
1247 template <GMOCK_INTERNAL_DECL_##template_params\
1248 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
1249 class GMOCK_ACTION_CLASS_(name, value_params) {\
1250 public:\
1251 explicit GMOCK_ACTION_CLASS_(name, value_params)\
1252 GMOCK_INTERNAL_INIT_##value_params {}\
1253 template <typename F>\
1254 class gmock_Impl : public ::testing::ActionInterface<F> {\
1255 public:\
1256 typedef F function_type;\
1257 typedef typename ::testing::internal::Function<F>::Result return_type;\
1258 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1259 args_type;\
1260 explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
1261 virtual return_type Perform(const args_type& args) {\
1262 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1263 Perform(this, args);\
1264 }\
1265 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1266 typename arg3_type, typename arg4_type, typename arg5_type, \
1267 typename arg6_type, typename arg7_type, typename arg8_type, \
1268 typename arg9_type>\
1269 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1270 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1271 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1272 arg9_type arg9) const;\
1273 GMOCK_INTERNAL_DEFN_##value_params\
1274 private:\
1275 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1276 };\
1277 template <typename F> operator ::testing::Action<F>() const {\
1278 return ::testing::Action<F>(\
1279 new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
1280 }\
1281 GMOCK_INTERNAL_DEFN_##value_params\
1282 private:\
1283 GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
1284 };\
1285 template <GMOCK_INTERNAL_DECL_##template_params\
1286 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
1287 inline GMOCK_ACTION_CLASS_(name, value_params)<\
1288 GMOCK_INTERNAL_LIST_##template_params\
1289 GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
1290 GMOCK_INTERNAL_DECL_##value_params) {\
1291 return GMOCK_ACTION_CLASS_(name, value_params)<\
1292 GMOCK_INTERNAL_LIST_##template_params\
1293 GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
1294 GMOCK_INTERNAL_LIST_##value_params);\
1295 }\
1296 template <GMOCK_INTERNAL_DECL_##template_params\
1297 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
1298 template <typename F>\
1299 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1300 typename arg3_type, typename arg4_type, typename arg5_type, \
1301 typename arg6_type, typename arg7_type, typename arg8_type, \
1302 typename arg9_type>\
1303 typename ::testing::internal::Function<F>::Result\
1304 GMOCK_ACTION_CLASS_(name, value_params)<\
1305 GMOCK_INTERNAL_LIST_##template_params\
1306 GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
1307 gmock_PerformImpl(\
1308 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1309
1310 #define ACTION(name)\
1311 class name##Action {\
1312 public:\
1313 name##Action() {}\
1314 template <typename F>\
1315 class gmock_Impl : public ::testing::ActionInterface<F> {\
1316 public:\
1317 typedef F function_type;\
1318 typedef typename ::testing::internal::Function<F>::Result return_type;\
1319 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1320 args_type;\
1321 gmock_Impl() {}\
1322 virtual return_type Perform(const args_type& args) {\
1323 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1324 Perform(this, args);\
1325 }\
1326 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1327 typename arg3_type, typename arg4_type, typename arg5_type, \
1328 typename arg6_type, typename arg7_type, typename arg8_type, \
1329 typename arg9_type>\
1330 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1331 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1332 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1333 arg9_type arg9) const;\
1334 private:\
1335 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1336 };\
1337 template <typename F> operator ::testing::Action<F>() const {\
1338 return ::testing::Action<F>(new gmock_Impl<F>());\
1339 }\
1340 private:\
1341 GTEST_DISALLOW_ASSIGN_(name##Action);\
1342 };\
1343 inline name##Action name() {\
1344 return name##Action();\
1345 }\
1346 template <typename F>\
1347 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1348 typename arg3_type, typename arg4_type, typename arg5_type, \
1349 typename arg6_type, typename arg7_type, typename arg8_type, \
1350 typename arg9_type>\
1351 typename ::testing::internal::Function<F>::Result\
1352 name##Action::gmock_Impl<F>::gmock_PerformImpl(\
1353 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1354
1355 #define ACTION_P(name, p0)\
1356 template <typename p0##_type>\
1357 class name##ActionP {\
1358 public:\
1359 explicit name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
1360 template <typename F>\
1361 class gmock_Impl : public ::testing::ActionInterface<F> {\
1362 public:\
1363 typedef F function_type;\
1364 typedef typename ::testing::internal::Function<F>::Result return_type;\
1365 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1366 args_type;\
1367 explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\
1368 virtual return_type Perform(const args_type& args) {\
1369 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1370 Perform(this, args);\
1371 }\
1372 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1373 typename arg3_type, typename arg4_type, typename arg5_type, \
1374 typename arg6_type, typename arg7_type, typename arg8_type, \
1375 typename arg9_type>\
1376 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1377 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1378 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1379 arg9_type arg9) const;\
1380 p0##_type p0;\
1381 private:\
1382 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1383 };\
1384 template <typename F> operator ::testing::Action<F>() const {\
1385 return ::testing::Action<F>(new gmock_Impl<F>(p0));\
1386 }\
1387 p0##_type p0;\
1388 private:\
1389 GTEST_DISALLOW_ASSIGN_(name##ActionP);\
1390 };\
1391 template <typename p0##_type>\
1392 inline name##ActionP<p0##_type> name(p0##_type p0) {\
1393 return name##ActionP<p0##_type>(p0);\
1394 }\
1395 template <typename p0##_type>\
1396 template <typename F>\
1397 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1398 typename arg3_type, typename arg4_type, typename arg5_type, \
1399 typename arg6_type, typename arg7_type, typename arg8_type, \
1400 typename arg9_type>\
1401 typename ::testing::internal::Function<F>::Result\
1402 name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1403 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1404
1405 #define ACTION_P2(name, p0, p1)\
1406 template <typename p0##_type, typename p1##_type>\
1407 class name##ActionP2 {\
1408 public:\
1409 name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1410 p1(gmock_p1) {}\
1411 template <typename F>\
1412 class gmock_Impl : public ::testing::ActionInterface<F> {\
1413 public:\
1414 typedef F function_type;\
1415 typedef typename ::testing::internal::Function<F>::Result return_type;\
1416 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1417 args_type;\
1418 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1419 p1(gmock_p1) {}\
1420 virtual return_type Perform(const args_type& args) {\
1421 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1422 Perform(this, args);\
1423 }\
1424 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1425 typename arg3_type, typename arg4_type, typename arg5_type, \
1426 typename arg6_type, typename arg7_type, typename arg8_type, \
1427 typename arg9_type>\
1428 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1429 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1430 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1431 arg9_type arg9) const;\
1432 p0##_type p0;\
1433 p1##_type p1;\
1434 private:\
1435 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1436 };\
1437 template <typename F> operator ::testing::Action<F>() const {\
1438 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
1439 }\
1440 p0##_type p0;\
1441 p1##_type p1;\
1442 private:\
1443 GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
1444 };\
1445 template <typename p0##_type, typename p1##_type>\
1446 inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
1447 p1##_type p1) {\
1448 return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
1449 }\
1450 template <typename p0##_type, typename p1##_type>\
1451 template <typename F>\
1452 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1453 typename arg3_type, typename arg4_type, typename arg5_type, \
1454 typename arg6_type, typename arg7_type, typename arg8_type, \
1455 typename arg9_type>\
1456 typename ::testing::internal::Function<F>::Result\
1457 name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1458 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1459
1460 #define ACTION_P3(name, p0, p1, p2)\
1461 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1462 class name##ActionP3 {\
1463 public:\
1464 name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1465 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
1466 template <typename F>\
1467 class gmock_Impl : public ::testing::ActionInterface<F> {\
1468 public:\
1469 typedef F function_type;\
1470 typedef typename ::testing::internal::Function<F>::Result return_type;\
1471 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1472 args_type;\
1473 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
1474 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
1475 virtual return_type Perform(const args_type& args) {\
1476 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1477 Perform(this, args);\
1478 }\
1479 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1480 typename arg3_type, typename arg4_type, typename arg5_type, \
1481 typename arg6_type, typename arg7_type, typename arg8_type, \
1482 typename arg9_type>\
1483 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1484 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1485 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1486 arg9_type arg9) const;\
1487 p0##_type p0;\
1488 p1##_type p1;\
1489 p2##_type p2;\
1490 private:\
1491 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1492 };\
1493 template <typename F> operator ::testing::Action<F>() const {\
1494 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
1495 }\
1496 p0##_type p0;\
1497 p1##_type p1;\
1498 p2##_type p2;\
1499 private:\
1500 GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
1501 };\
1502 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1503 inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1504 p1##_type p1, p2##_type p2) {\
1505 return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1506 }\
1507 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1508 template <typename F>\
1509 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1510 typename arg3_type, typename arg4_type, typename arg5_type, \
1511 typename arg6_type, typename arg7_type, typename arg8_type, \
1512 typename arg9_type>\
1513 typename ::testing::internal::Function<F>::Result\
1514 name##ActionP3<p0##_type, p1##_type, \
1515 p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1516 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1517
1518 #define ACTION_P4(name, p0, p1, p2, p3)\
1519 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1520 typename p3##_type>\
1521 class name##ActionP4 {\
1522 public:\
1523 name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1524 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1525 p2(gmock_p2), p3(gmock_p3) {}\
1526 template <typename F>\
1527 class gmock_Impl : public ::testing::ActionInterface<F> {\
1528 public:\
1529 typedef F function_type;\
1530 typedef typename ::testing::internal::Function<F>::Result return_type;\
1531 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1532 args_type;\
1533 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1534 p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1535 p3(gmock_p3) {}\
1536 virtual return_type Perform(const args_type& args) {\
1537 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1538 Perform(this, args);\
1539 }\
1540 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1541 typename arg3_type, typename arg4_type, typename arg5_type, \
1542 typename arg6_type, typename arg7_type, typename arg8_type, \
1543 typename arg9_type>\
1544 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1545 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1546 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1547 arg9_type arg9) const;\
1548 p0##_type p0;\
1549 p1##_type p1;\
1550 p2##_type p2;\
1551 p3##_type p3;\
1552 private:\
1553 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1554 };\
1555 template <typename F> operator ::testing::Action<F>() const {\
1556 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
1557 }\
1558 p0##_type p0;\
1559 p1##_type p1;\
1560 p2##_type p2;\
1561 p3##_type p3;\
1562 private:\
1563 GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
1564 };\
1565 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1566 typename p3##_type>\
1567 inline name##ActionP4<p0##_type, p1##_type, p2##_type, \
1568 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1569 p3##_type p3) {\
1570 return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \
1571 p2, p3);\
1572 }\
1573 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1574 typename p3##_type>\
1575 template <typename F>\
1576 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1577 typename arg3_type, typename arg4_type, typename arg5_type, \
1578 typename arg6_type, typename arg7_type, typename arg8_type, \
1579 typename arg9_type>\
1580 typename ::testing::internal::Function<F>::Result\
1581 name##ActionP4<p0##_type, p1##_type, p2##_type, \
1582 p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1583 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1584
1585 #define ACTION_P5(name, p0, p1, p2, p3, p4)\
1586 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1587 typename p3##_type, typename p4##_type>\
1588 class name##ActionP5 {\
1589 public:\
1590 name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1591 p2##_type gmock_p2, p3##_type gmock_p3, \
1592 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1593 p3(gmock_p3), p4(gmock_p4) {}\
1594 template <typename F>\
1595 class gmock_Impl : public ::testing::ActionInterface<F> {\
1596 public:\
1597 typedef F function_type;\
1598 typedef typename ::testing::internal::Function<F>::Result return_type;\
1599 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1600 args_type;\
1601 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1602 p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \
1603 p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\
1604 virtual return_type Perform(const args_type& args) {\
1605 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1606 Perform(this, args);\
1607 }\
1608 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1609 typename arg3_type, typename arg4_type, typename arg5_type, \
1610 typename arg6_type, typename arg7_type, typename arg8_type, \
1611 typename arg9_type>\
1612 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1613 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1614 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1615 arg9_type arg9) const;\
1616 p0##_type p0;\
1617 p1##_type p1;\
1618 p2##_type p2;\
1619 p3##_type p3;\
1620 p4##_type p4;\
1621 private:\
1622 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1623 };\
1624 template <typename F> operator ::testing::Action<F>() const {\
1625 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
1626 }\
1627 p0##_type p0;\
1628 p1##_type p1;\
1629 p2##_type p2;\
1630 p3##_type p3;\
1631 p4##_type p4;\
1632 private:\
1633 GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
1634 };\
1635 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1636 typename p3##_type, typename p4##_type>\
1637 inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1638 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1639 p4##_type p4) {\
1640 return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1641 p4##_type>(p0, p1, p2, p3, p4);\
1642 }\
1643 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1644 typename p3##_type, typename p4##_type>\
1645 template <typename F>\
1646 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1647 typename arg3_type, typename arg4_type, typename arg5_type, \
1648 typename arg6_type, typename arg7_type, typename arg8_type, \
1649 typename arg9_type>\
1650 typename ::testing::internal::Function<F>::Result\
1651 name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1652 p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1653 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1654
1655 #define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
1656 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1657 typename p3##_type, typename p4##_type, typename p5##_type>\
1658 class name##ActionP6 {\
1659 public:\
1660 name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1661 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1662 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1663 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
1664 template <typename F>\
1665 class gmock_Impl : public ::testing::ActionInterface<F> {\
1666 public:\
1667 typedef F function_type;\
1668 typedef typename ::testing::internal::Function<F>::Result return_type;\
1669 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1670 args_type;\
1671 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1672 p3##_type gmock_p3, p4##_type gmock_p4, \
1673 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1674 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
1675 virtual return_type Perform(const args_type& args) {\
1676 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1677 Perform(this, args);\
1678 }\
1679 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1680 typename arg3_type, typename arg4_type, typename arg5_type, \
1681 typename arg6_type, typename arg7_type, typename arg8_type, \
1682 typename arg9_type>\
1683 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1684 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1685 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1686 arg9_type arg9) const;\
1687 p0##_type p0;\
1688 p1##_type p1;\
1689 p2##_type p2;\
1690 p3##_type p3;\
1691 p4##_type p4;\
1692 p5##_type p5;\
1693 private:\
1694 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1695 };\
1696 template <typename F> operator ::testing::Action<F>() const {\
1697 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
1698 }\
1699 p0##_type p0;\
1700 p1##_type p1;\
1701 p2##_type p2;\
1702 p3##_type p3;\
1703 p4##_type p4;\
1704 p5##_type p5;\
1705 private:\
1706 GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
1707 };\
1708 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1709 typename p3##_type, typename p4##_type, typename p5##_type>\
1710 inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1711 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1712 p3##_type p3, p4##_type p4, p5##_type p5) {\
1713 return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1714 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1715 }\
1716 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1717 typename p3##_type, typename p4##_type, typename p5##_type>\
1718 template <typename F>\
1719 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1720 typename arg3_type, typename arg4_type, typename arg5_type, \
1721 typename arg6_type, typename arg7_type, typename arg8_type, \
1722 typename arg9_type>\
1723 typename ::testing::internal::Function<F>::Result\
1724 name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1725 p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1726 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1727
1728 #define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
1729 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1730 typename p3##_type, typename p4##_type, typename p5##_type, \
1731 typename p6##_type>\
1732 class name##ActionP7 {\
1733 public:\
1734 name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1735 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1736 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1737 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1738 p6(gmock_p6) {}\
1739 template <typename F>\
1740 class gmock_Impl : public ::testing::ActionInterface<F> {\
1741 public:\
1742 typedef F function_type;\
1743 typedef typename ::testing::internal::Function<F>::Result return_type;\
1744 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1745 args_type;\
1746 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1747 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1748 p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1749 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
1750 virtual return_type Perform(const args_type& args) {\
1751 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1752 Perform(this, args);\
1753 }\
1754 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1755 typename arg3_type, typename arg4_type, typename arg5_type, \
1756 typename arg6_type, typename arg7_type, typename arg8_type, \
1757 typename arg9_type>\
1758 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1759 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1760 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1761 arg9_type arg9) const;\
1762 p0##_type p0;\
1763 p1##_type p1;\
1764 p2##_type p2;\
1765 p3##_type p3;\
1766 p4##_type p4;\
1767 p5##_type p5;\
1768 p6##_type p6;\
1769 private:\
1770 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1771 };\
1772 template <typename F> operator ::testing::Action<F>() const {\
1773 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
1774 p6));\
1775 }\
1776 p0##_type p0;\
1777 p1##_type p1;\
1778 p2##_type p2;\
1779 p3##_type p3;\
1780 p4##_type p4;\
1781 p5##_type p5;\
1782 p6##_type p6;\
1783 private:\
1784 GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
1785 };\
1786 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1787 typename p3##_type, typename p4##_type, typename p5##_type, \
1788 typename p6##_type>\
1789 inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1790 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1791 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1792 p6##_type p6) {\
1793 return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1794 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1795 }\
1796 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1797 typename p3##_type, typename p4##_type, typename p5##_type, \
1798 typename p6##_type>\
1799 template <typename F>\
1800 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1801 typename arg3_type, typename arg4_type, typename arg5_type, \
1802 typename arg6_type, typename arg7_type, typename arg8_type, \
1803 typename arg9_type>\
1804 typename ::testing::internal::Function<F>::Result\
1805 name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1806 p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1807 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1808
1809 #define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
1810 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1811 typename p3##_type, typename p4##_type, typename p5##_type, \
1812 typename p6##_type, typename p7##_type>\
1813 class name##ActionP8 {\
1814 public:\
1815 name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1816 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1817 p5##_type gmock_p5, p6##_type gmock_p6, \
1818 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1819 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1820 p7(gmock_p7) {}\
1821 template <typename F>\
1822 class gmock_Impl : public ::testing::ActionInterface<F> {\
1823 public:\
1824 typedef F function_type;\
1825 typedef typename ::testing::internal::Function<F>::Result return_type;\
1826 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1827 args_type;\
1828 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1829 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1830 p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \
1831 p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \
1832 p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
1833 virtual return_type Perform(const args_type& args) {\
1834 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1835 Perform(this, args);\
1836 }\
1837 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1838 typename arg3_type, typename arg4_type, typename arg5_type, \
1839 typename arg6_type, typename arg7_type, typename arg8_type, \
1840 typename arg9_type>\
1841 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1842 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1843 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1844 arg9_type arg9) const;\
1845 p0##_type p0;\
1846 p1##_type p1;\
1847 p2##_type p2;\
1848 p3##_type p3;\
1849 p4##_type p4;\
1850 p5##_type p5;\
1851 p6##_type p6;\
1852 p7##_type p7;\
1853 private:\
1854 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1855 };\
1856 template <typename F> operator ::testing::Action<F>() const {\
1857 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
1858 p6, p7));\
1859 }\
1860 p0##_type p0;\
1861 p1##_type p1;\
1862 p2##_type p2;\
1863 p3##_type p3;\
1864 p4##_type p4;\
1865 p5##_type p5;\
1866 p6##_type p6;\
1867 p7##_type p7;\
1868 private:\
1869 GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
1870 };\
1871 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1872 typename p3##_type, typename p4##_type, typename p5##_type, \
1873 typename p6##_type, typename p7##_type>\
1874 inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1875 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1876 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1877 p6##_type p6, p7##_type p7) {\
1878 return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1879 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1880 p6, p7);\
1881 }\
1882 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1883 typename p3##_type, typename p4##_type, typename p5##_type, \
1884 typename p6##_type, typename p7##_type>\
1885 template <typename F>\
1886 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1887 typename arg3_type, typename arg4_type, typename arg5_type, \
1888 typename arg6_type, typename arg7_type, typename arg8_type, \
1889 typename arg9_type>\
1890 typename ::testing::internal::Function<F>::Result\
1891 name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1892 p5##_type, p6##_type, \
1893 p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1894 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1895
1896 #define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
1897 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1898 typename p3##_type, typename p4##_type, typename p5##_type, \
1899 typename p6##_type, typename p7##_type, typename p8##_type>\
1900 class name##ActionP9 {\
1901 public:\
1902 name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
1903 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1904 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1905 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1906 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1907 p8(gmock_p8) {}\
1908 template <typename F>\
1909 class gmock_Impl : public ::testing::ActionInterface<F> {\
1910 public:\
1911 typedef F function_type;\
1912 typedef typename ::testing::internal::Function<F>::Result return_type;\
1913 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1914 args_type;\
1915 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1916 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1917 p6##_type gmock_p6, p7##_type gmock_p7, \
1918 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1919 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1920 p7(gmock_p7), p8(gmock_p8) {}\
1921 virtual return_type Perform(const args_type& args) {\
1922 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1923 Perform(this, args);\
1924 }\
1925 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1926 typename arg3_type, typename arg4_type, typename arg5_type, \
1927 typename arg6_type, typename arg7_type, typename arg8_type, \
1928 typename arg9_type>\
1929 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1930 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1931 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1932 arg9_type arg9) const;\
1933 p0##_type p0;\
1934 p1##_type p1;\
1935 p2##_type p2;\
1936 p3##_type p3;\
1937 p4##_type p4;\
1938 p5##_type p5;\
1939 p6##_type p6;\
1940 p7##_type p7;\
1941 p8##_type p8;\
1942 private:\
1943 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1944 };\
1945 template <typename F> operator ::testing::Action<F>() const {\
1946 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
1947 p6, p7, p8));\
1948 }\
1949 p0##_type p0;\
1950 p1##_type p1;\
1951 p2##_type p2;\
1952 p3##_type p3;\
1953 p4##_type p4;\
1954 p5##_type p5;\
1955 p6##_type p6;\
1956 p7##_type p7;\
1957 p8##_type p8;\
1958 private:\
1959 GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
1960 };\
1961 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1962 typename p3##_type, typename p4##_type, typename p5##_type, \
1963 typename p6##_type, typename p7##_type, typename p8##_type>\
1964 inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1965 p4##_type, p5##_type, p6##_type, p7##_type, \
1966 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1967 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
1968 p8##_type p8) {\
1969 return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
1970 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
1971 p3, p4, p5, p6, p7, p8);\
1972 }\
1973 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1974 typename p3##_type, typename p4##_type, typename p5##_type, \
1975 typename p6##_type, typename p7##_type, typename p8##_type>\
1976 template <typename F>\
1977 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1978 typename arg3_type, typename arg4_type, typename arg5_type, \
1979 typename arg6_type, typename arg7_type, typename arg8_type, \
1980 typename arg9_type>\
1981 typename ::testing::internal::Function<F>::Result\
1982 name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1983 p5##_type, p6##_type, p7##_type, \
1984 p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1985 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1986
1987 #define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
1988 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1989 typename p3##_type, typename p4##_type, typename p5##_type, \
1990 typename p6##_type, typename p7##_type, typename p8##_type, \
1991 typename p9##_type>\
1992 class name##ActionP10 {\
1993 public:\
1994 name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
1995 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1996 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
1997 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
1998 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1999 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
2000 template <typename F>\
2001 class gmock_Impl : public ::testing::ActionInterface<F> {\
2002 public:\
2003 typedef F function_type;\
2004 typedef typename ::testing::internal::Function<F>::Result return_type;\
2005 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
2006 args_type;\
2007 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2008 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2009 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
2010 p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2011 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2012 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
2013 virtual return_type Perform(const args_type& args) {\
2014 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
2015 Perform(this, args);\
2016 }\
2017 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2018 typename arg3_type, typename arg4_type, typename arg5_type, \
2019 typename arg6_type, typename arg7_type, typename arg8_type, \
2020 typename arg9_type>\
2021 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
2022 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
2023 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
2024 arg9_type arg9) const;\
2025 p0##_type p0;\
2026 p1##_type p1;\
2027 p2##_type p2;\
2028 p3##_type p3;\
2029 p4##_type p4;\
2030 p5##_type p5;\
2031 p6##_type p6;\
2032 p7##_type p7;\
2033 p8##_type p8;\
2034 p9##_type p9;\
2035 private:\
2036 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2037 };\
2038 template <typename F> operator ::testing::Action<F>() const {\
2039 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
2040 p6, p7, p8, p9));\
2041 }\
2042 p0##_type p0;\
2043 p1##_type p1;\
2044 p2##_type p2;\
2045 p3##_type p3;\
2046 p4##_type p4;\
2047 p5##_type p5;\
2048 p6##_type p6;\
2049 p7##_type p7;\
2050 p8##_type p8;\
2051 p9##_type p9;\
2052 private:\
2053 GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
2054 };\
2055 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2056 typename p3##_type, typename p4##_type, typename p5##_type, \
2057 typename p6##_type, typename p7##_type, typename p8##_type, \
2058 typename p9##_type>\
2059 inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2060 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2061 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2062 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
2063 p9##_type p9) {\
2064 return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2065 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
2066 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
2067 }\
2068 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2069 typename p3##_type, typename p4##_type, typename p5##_type, \
2070 typename p6##_type, typename p7##_type, typename p8##_type, \
2071 typename p9##_type>\
2072 template <typename F>\
2073 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2074 typename arg3_type, typename arg4_type, typename arg5_type, \
2075 typename arg6_type, typename arg7_type, typename arg8_type, \
2076 typename arg9_type>\
2077 typename ::testing::internal::Function<F>::Result\
2078 name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
2079 p5##_type, p6##_type, p7##_type, p8##_type, \
2080 p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
2081 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
2082
2083 namespace testing {
2084
2085
2086 // The ACTION*() macros trigger warning C4100 (unreferenced formal
2087 // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
2088 // the macro definition, as the warnings are generated when the macro
2089 // is expanded and macro expansion cannot contain #pragma. Therefore
2090 // we suppress them here.
2091 #ifdef _MSC_VER
2092 # pragma warning(push)
2093 # pragma warning(disable:4100)
2094 #endif
2095
2096 // Various overloads for InvokeArgument<N>().
2097 //
2098 // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
2099 // (0-based) argument, which must be a k-ary callable, of the mock
2100 // function, with arguments a1, a2, ..., a_k.
2101 //
2102 // Notes:
2103 //
2104 // 1. The arguments are passed by value by default. If you need to
2105 // pass an argument by reference, wrap it inside ByRef(). For
2106 // example,
2107 //
2108 // InvokeArgument<1>(5, string("Hello"), ByRef(foo))
2109 //
2110 // passes 5 and string("Hello") by value, and passes foo by
2111 // reference.
2112 //
2113 // 2. If the callable takes an argument by reference but ByRef() is
2114 // not used, it will receive the reference to a copy of the value,
2115 // instead of the original value. For example, when the 0-th
2116 // argument of the mock function takes a const string&, the action
2117 //
2118 // InvokeArgument<0>(string("Hello"))
2119 //
2120 // makes a copy of the temporary string("Hello") object and passes a
2121 // reference of the copy, instead of the original temporary object,
2122 // to the callable. This makes it easy for a user to define an
2123 // InvokeArgument action from temporary values and have it performed
2124 // later.
2125
2126 namespace internal {
2127 namespace invoke_argument {
2128
2129 // Appears in InvokeArgumentAdl's argument list to help avoid
2130 // accidental calls to user functions of the same name.
2131 struct AdlTag {};
2132
2133 // InvokeArgumentAdl - a helper for InvokeArgument.
2134 // The basic overloads are provided here for generic functors.
2135 // Overloads for other custom-callables are provided in the
2136 // internal/custom/callback-actions.h header.
2137
2138 template <typename R, typename F>
InvokeArgumentAdl(AdlTag,F f)2139 R InvokeArgumentAdl(AdlTag, F f) {
2140 return f();
2141 }
2142 template <typename R, typename F, typename A1>
InvokeArgumentAdl(AdlTag,F f,A1 a1)2143 R InvokeArgumentAdl(AdlTag, F f, A1 a1) {
2144 return f(a1);
2145 }
2146 template <typename R, typename F, typename A1, typename A2>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2)2147 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2) {
2148 return f(a1, a2);
2149 }
2150 template <typename R, typename F, typename A1, typename A2, typename A3>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3)2151 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3) {
2152 return f(a1, a2, a3);
2153 }
2154 template <typename R, typename F, typename A1, typename A2, typename A3,
2155 typename A4>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3,A4 a4)2156 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4) {
2157 return f(a1, a2, a3, a4);
2158 }
2159 template <typename R, typename F, typename A1, typename A2, typename A3,
2160 typename A4, typename A5>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5)2161 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
2162 return f(a1, a2, a3, a4, a5);
2163 }
2164 template <typename R, typename F, typename A1, typename A2, typename A3,
2165 typename A4, typename A5, typename A6>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6)2166 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
2167 return f(a1, a2, a3, a4, a5, a6);
2168 }
2169 template <typename R, typename F, typename A1, typename A2, typename A3,
2170 typename A4, typename A5, typename A6, typename A7>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7)2171 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2172 A7 a7) {
2173 return f(a1, a2, a3, a4, a5, a6, a7);
2174 }
2175 template <typename R, typename F, typename A1, typename A2, typename A3,
2176 typename A4, typename A5, typename A6, typename A7, typename A8>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8)2177 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2178 A7 a7, A8 a8) {
2179 return f(a1, a2, a3, a4, a5, a6, a7, a8);
2180 }
2181 template <typename R, typename F, typename A1, typename A2, typename A3,
2182 typename A4, typename A5, typename A6, typename A7, typename A8,
2183 typename A9>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9)2184 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2185 A7 a7, A8 a8, A9 a9) {
2186 return f(a1, a2, a3, a4, a5, a6, a7, a8, a9);
2187 }
2188 template <typename R, typename F, typename A1, typename A2, typename A3,
2189 typename A4, typename A5, typename A6, typename A7, typename A8,
2190 typename A9, typename A10>
InvokeArgumentAdl(AdlTag,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10)2191 R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
2192 A7 a7, A8 a8, A9 a9, A10 a10) {
2193 return f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
2194 }
2195 } // namespace invoke_argument
2196 } // namespace internal
2197
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_0_VALUE_PARAMS ())2198 ACTION_TEMPLATE(InvokeArgument,
2199 HAS_1_TEMPLATE_PARAMS(int, k),
2200 AND_0_VALUE_PARAMS()) {
2201 using internal::invoke_argument::InvokeArgumentAdl;
2202 return InvokeArgumentAdl<return_type>(
2203 internal::invoke_argument::AdlTag(),
2204 ::testing::get<k>(args));
2205 }
2206
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_1_VALUE_PARAMS (p0))2207 ACTION_TEMPLATE(InvokeArgument,
2208 HAS_1_TEMPLATE_PARAMS(int, k),
2209 AND_1_VALUE_PARAMS(p0)) {
2210 using internal::invoke_argument::InvokeArgumentAdl;
2211 return InvokeArgumentAdl<return_type>(
2212 internal::invoke_argument::AdlTag(),
2213 ::testing::get<k>(args), p0);
2214 }
2215
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_2_VALUE_PARAMS (p0,p1))2216 ACTION_TEMPLATE(InvokeArgument,
2217 HAS_1_TEMPLATE_PARAMS(int, k),
2218 AND_2_VALUE_PARAMS(p0, p1)) {
2219 using internal::invoke_argument::InvokeArgumentAdl;
2220 return InvokeArgumentAdl<return_type>(
2221 internal::invoke_argument::AdlTag(),
2222 ::testing::get<k>(args), p0, p1);
2223 }
2224
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_3_VALUE_PARAMS (p0,p1,p2))2225 ACTION_TEMPLATE(InvokeArgument,
2226 HAS_1_TEMPLATE_PARAMS(int, k),
2227 AND_3_VALUE_PARAMS(p0, p1, p2)) {
2228 using internal::invoke_argument::InvokeArgumentAdl;
2229 return InvokeArgumentAdl<return_type>(
2230 internal::invoke_argument::AdlTag(),
2231 ::testing::get<k>(args), p0, p1, p2);
2232 }
2233
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_4_VALUE_PARAMS (p0,p1,p2,p3))2234 ACTION_TEMPLATE(InvokeArgument,
2235 HAS_1_TEMPLATE_PARAMS(int, k),
2236 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
2237 using internal::invoke_argument::InvokeArgumentAdl;
2238 return InvokeArgumentAdl<return_type>(
2239 internal::invoke_argument::AdlTag(),
2240 ::testing::get<k>(args), p0, p1, p2, p3);
2241 }
2242
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_5_VALUE_PARAMS (p0,p1,p2,p3,p4))2243 ACTION_TEMPLATE(InvokeArgument,
2244 HAS_1_TEMPLATE_PARAMS(int, k),
2245 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
2246 using internal::invoke_argument::InvokeArgumentAdl;
2247 return InvokeArgumentAdl<return_type>(
2248 internal::invoke_argument::AdlTag(),
2249 ::testing::get<k>(args), p0, p1, p2, p3, p4);
2250 }
2251
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_6_VALUE_PARAMS (p0,p1,p2,p3,p4,p5))2252 ACTION_TEMPLATE(InvokeArgument,
2253 HAS_1_TEMPLATE_PARAMS(int, k),
2254 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
2255 using internal::invoke_argument::InvokeArgumentAdl;
2256 return InvokeArgumentAdl<return_type>(
2257 internal::invoke_argument::AdlTag(),
2258 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5);
2259 }
2260
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_7_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6))2261 ACTION_TEMPLATE(InvokeArgument,
2262 HAS_1_TEMPLATE_PARAMS(int, k),
2263 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
2264 using internal::invoke_argument::InvokeArgumentAdl;
2265 return InvokeArgumentAdl<return_type>(
2266 internal::invoke_argument::AdlTag(),
2267 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
2268 }
2269
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_8_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6,p7))2270 ACTION_TEMPLATE(InvokeArgument,
2271 HAS_1_TEMPLATE_PARAMS(int, k),
2272 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
2273 using internal::invoke_argument::InvokeArgumentAdl;
2274 return InvokeArgumentAdl<return_type>(
2275 internal::invoke_argument::AdlTag(),
2276 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
2277 }
2278
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_9_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6,p7,p8))2279 ACTION_TEMPLATE(InvokeArgument,
2280 HAS_1_TEMPLATE_PARAMS(int, k),
2281 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
2282 using internal::invoke_argument::InvokeArgumentAdl;
2283 return InvokeArgumentAdl<return_type>(
2284 internal::invoke_argument::AdlTag(),
2285 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
2286 }
2287
ACTION_TEMPLATE(InvokeArgument,HAS_1_TEMPLATE_PARAMS (int,k),AND_10_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6,p7,p8,p9))2288 ACTION_TEMPLATE(InvokeArgument,
2289 HAS_1_TEMPLATE_PARAMS(int, k),
2290 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
2291 using internal::invoke_argument::InvokeArgumentAdl;
2292 return InvokeArgumentAdl<return_type>(
2293 internal::invoke_argument::AdlTag(),
2294 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2295 }
2296
2297 // Various overloads for ReturnNew<T>().
2298 //
2299 // The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
2300 // instance of type T, constructed on the heap with constructor arguments
2301 // a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_0_VALUE_PARAMS ())2302 ACTION_TEMPLATE(ReturnNew,
2303 HAS_1_TEMPLATE_PARAMS(typename, T),
2304 AND_0_VALUE_PARAMS()) {
2305 return new T();
2306 }
2307
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_1_VALUE_PARAMS (p0))2308 ACTION_TEMPLATE(ReturnNew,
2309 HAS_1_TEMPLATE_PARAMS(typename, T),
2310 AND_1_VALUE_PARAMS(p0)) {
2311 return new T(p0);
2312 }
2313
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_2_VALUE_PARAMS (p0,p1))2314 ACTION_TEMPLATE(ReturnNew,
2315 HAS_1_TEMPLATE_PARAMS(typename, T),
2316 AND_2_VALUE_PARAMS(p0, p1)) {
2317 return new T(p0, p1);
2318 }
2319
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_3_VALUE_PARAMS (p0,p1,p2))2320 ACTION_TEMPLATE(ReturnNew,
2321 HAS_1_TEMPLATE_PARAMS(typename, T),
2322 AND_3_VALUE_PARAMS(p0, p1, p2)) {
2323 return new T(p0, p1, p2);
2324 }
2325
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_4_VALUE_PARAMS (p0,p1,p2,p3))2326 ACTION_TEMPLATE(ReturnNew,
2327 HAS_1_TEMPLATE_PARAMS(typename, T),
2328 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
2329 return new T(p0, p1, p2, p3);
2330 }
2331
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_5_VALUE_PARAMS (p0,p1,p2,p3,p4))2332 ACTION_TEMPLATE(ReturnNew,
2333 HAS_1_TEMPLATE_PARAMS(typename, T),
2334 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
2335 return new T(p0, p1, p2, p3, p4);
2336 }
2337
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_6_VALUE_PARAMS (p0,p1,p2,p3,p4,p5))2338 ACTION_TEMPLATE(ReturnNew,
2339 HAS_1_TEMPLATE_PARAMS(typename, T),
2340 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
2341 return new T(p0, p1, p2, p3, p4, p5);
2342 }
2343
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_7_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6))2344 ACTION_TEMPLATE(ReturnNew,
2345 HAS_1_TEMPLATE_PARAMS(typename, T),
2346 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
2347 return new T(p0, p1, p2, p3, p4, p5, p6);
2348 }
2349
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_8_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6,p7))2350 ACTION_TEMPLATE(ReturnNew,
2351 HAS_1_TEMPLATE_PARAMS(typename, T),
2352 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
2353 return new T(p0, p1, p2, p3, p4, p5, p6, p7);
2354 }
2355
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_9_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6,p7,p8))2356 ACTION_TEMPLATE(ReturnNew,
2357 HAS_1_TEMPLATE_PARAMS(typename, T),
2358 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
2359 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
2360 }
2361
ACTION_TEMPLATE(ReturnNew,HAS_1_TEMPLATE_PARAMS (typename,T),AND_10_VALUE_PARAMS (p0,p1,p2,p3,p4,p5,p6,p7,p8,p9))2362 ACTION_TEMPLATE(ReturnNew,
2363 HAS_1_TEMPLATE_PARAMS(typename, T),
2364 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
2365 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2366 }
2367
2368 #ifdef _MSC_VER
2369 # pragma warning(pop)
2370 #endif
2371
2372 } // namespace testing
2373
2374 // Include any custom actions added by the local installation.
2375 // We must include this header at the end to make sure it can use the
2376 // declarations from this file.
2377 #include "gmock/internal/custom/gmock-generated-actions.h"
2378
2379 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
2380