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


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:05