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