blob: f511bc8b7dabc49bedc68294a32687e497c6db1d [file] [log] [blame]
shiqiane35fdd92008-12-10 05:08:54 +00001// 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
zhanyong.wan53e08c42010-09-14 05:38:21 +000041#include "gmock/gmock-actions.h"
42#include "gmock/internal/gmock-port.h"
shiqiane35fdd92008-12-10 05:08:54 +000043
44namespace testing {
45namespace internal {
46
47// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
48// function or method with the unpacked values, where F is a function
49// type that takes N arguments.
50template <typename Result, typename ArgumentTuple>
51class InvokeHelper;
52
53template <typename R>
kosakbd018832014-04-02 20:30:00 +000054class InvokeHelper<R, ::testing::tuple<> > {
shiqiane35fdd92008-12-10 05:08:54 +000055 public:
56 template <typename Function>
kosakbd018832014-04-02 20:30:00 +000057 static R Invoke(Function function, const ::testing::tuple<>&) {
58 return function();
shiqiane35fdd92008-12-10 05:08:54 +000059 }
60
61 template <class Class, typename MethodPtr>
62 static R InvokeMethod(Class* obj_ptr,
63 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +000064 const ::testing::tuple<>&) {
65 return (obj_ptr->*method_ptr)();
shiqiane35fdd92008-12-10 05:08:54 +000066 }
67};
68
69template <typename R, typename A1>
kosakbd018832014-04-02 20:30:00 +000070class InvokeHelper<R, ::testing::tuple<A1> > {
shiqiane35fdd92008-12-10 05:08:54 +000071 public:
72 template <typename Function>
kosakbd018832014-04-02 20:30:00 +000073 static R Invoke(Function function, const ::testing::tuple<A1>& args) {
74 return function(get<0>(args));
shiqiane35fdd92008-12-10 05:08:54 +000075 }
76
77 template <class Class, typename MethodPtr>
78 static R InvokeMethod(Class* obj_ptr,
79 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +000080 const ::testing::tuple<A1>& args) {
81 return (obj_ptr->*method_ptr)(get<0>(args));
shiqiane35fdd92008-12-10 05:08:54 +000082 }
83};
84
85template <typename R, typename A1, typename A2>
kosakbd018832014-04-02 20:30:00 +000086class InvokeHelper<R, ::testing::tuple<A1, A2> > {
shiqiane35fdd92008-12-10 05:08:54 +000087 public:
88 template <typename Function>
kosakbd018832014-04-02 20:30:00 +000089 static R Invoke(Function function, const ::testing::tuple<A1, A2>& args) {
90 return function(get<0>(args), get<1>(args));
shiqiane35fdd92008-12-10 05:08:54 +000091 }
92
93 template <class Class, typename MethodPtr>
94 static R InvokeMethod(Class* obj_ptr,
95 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +000096 const ::testing::tuple<A1, A2>& args) {
97 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
shiqiane35fdd92008-12-10 05:08:54 +000098 }
99};
100
101template <typename R, typename A1, typename A2, typename A3>
kosakbd018832014-04-02 20:30:00 +0000102class InvokeHelper<R, ::testing::tuple<A1, A2, A3> > {
shiqiane35fdd92008-12-10 05:08:54 +0000103 public:
104 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000105 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3>& args) {
106 return function(get<0>(args), get<1>(args), get<2>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000107 }
108
109 template <class Class, typename MethodPtr>
110 static R InvokeMethod(Class* obj_ptr,
111 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000112 const ::testing::tuple<A1, A2, A3>& args) {
113 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
114 get<2>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000115 }
116};
117
118template <typename R, typename A1, typename A2, typename A3, typename A4>
kosakbd018832014-04-02 20:30:00 +0000119class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4> > {
shiqiane35fdd92008-12-10 05:08:54 +0000120 public:
121 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000122 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3,
shiqiane35fdd92008-12-10 05:08:54 +0000123 A4>& args) {
kosakbd018832014-04-02 20:30:00 +0000124 return function(get<0>(args), get<1>(args), get<2>(args),
125 get<3>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000126 }
127
128 template <class Class, typename MethodPtr>
129 static R InvokeMethod(Class* obj_ptr,
130 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000131 const ::testing::tuple<A1, A2, A3, A4>& args) {
132 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
133 get<2>(args), get<3>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000134 }
135};
136
137template <typename R, typename A1, typename A2, typename A3, typename A4,
138 typename A5>
kosakbd018832014-04-02 20:30:00 +0000139class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5> > {
shiqiane35fdd92008-12-10 05:08:54 +0000140 public:
141 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000142 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4,
shiqiane35fdd92008-12-10 05:08:54 +0000143 A5>& args) {
kosakbd018832014-04-02 20:30:00 +0000144 return function(get<0>(args), get<1>(args), get<2>(args),
145 get<3>(args), get<4>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000146 }
147
148 template <class Class, typename MethodPtr>
149 static R InvokeMethod(Class* obj_ptr,
150 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000151 const ::testing::tuple<A1, A2, A3, A4, A5>& args) {
152 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
153 get<2>(args), get<3>(args), get<4>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000154 }
155};
156
157template <typename R, typename A1, typename A2, typename A3, typename A4,
158 typename A5, typename A6>
kosakbd018832014-04-02 20:30:00 +0000159class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
shiqiane35fdd92008-12-10 05:08:54 +0000160 public:
161 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000162 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
163 A6>& args) {
164 return function(get<0>(args), get<1>(args), get<2>(args),
165 get<3>(args), get<4>(args), get<5>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000166 }
167
168 template <class Class, typename MethodPtr>
169 static R InvokeMethod(Class* obj_ptr,
170 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000171 const ::testing::tuple<A1, A2, A3, A4, A5, A6>& args) {
172 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
173 get<2>(args), get<3>(args), get<4>(args), get<5>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000174 }
175};
176
177template <typename R, typename A1, typename A2, typename A3, typename A4,
178 typename A5, typename A6, typename A7>
kosakbd018832014-04-02 20:30:00 +0000179class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
shiqiane35fdd92008-12-10 05:08:54 +0000180 public:
181 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000182 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
183 A6, A7>& args) {
184 return function(get<0>(args), get<1>(args), get<2>(args),
185 get<3>(args), get<4>(args), get<5>(args), get<6>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000186 }
187
188 template <class Class, typename MethodPtr>
189 static R InvokeMethod(Class* obj_ptr,
190 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000191 const ::testing::tuple<A1, A2, A3, A4, A5, A6,
shiqiane35fdd92008-12-10 05:08:54 +0000192 A7>& args) {
kosakbd018832014-04-02 20:30:00 +0000193 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
194 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
195 get<6>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000196 }
197};
198
199template <typename R, typename A1, typename A2, typename A3, typename A4,
200 typename A5, typename A6, typename A7, typename A8>
kosakbd018832014-04-02 20:30:00 +0000201class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
shiqiane35fdd92008-12-10 05:08:54 +0000202 public:
203 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000204 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
205 A6, A7, A8>& args) {
206 return function(get<0>(args), get<1>(args), get<2>(args),
207 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
208 get<7>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000209 }
210
211 template <class Class, typename MethodPtr>
212 static R InvokeMethod(Class* obj_ptr,
213 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000214 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7,
shiqiane35fdd92008-12-10 05:08:54 +0000215 A8>& args) {
kosakbd018832014-04-02 20:30:00 +0000216 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
217 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
218 get<6>(args), get<7>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000219 }
220};
221
222template <typename R, typename A1, typename A2, typename A3, typename A4,
223 typename A5, typename A6, typename A7, typename A8, typename A9>
kosakbd018832014-04-02 20:30:00 +0000224class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
shiqiane35fdd92008-12-10 05:08:54 +0000225 public:
226 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000227 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
228 A6, A7, A8, A9>& args) {
229 return function(get<0>(args), get<1>(args), get<2>(args),
230 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
231 get<7>(args), get<8>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000232 }
233
234 template <class Class, typename MethodPtr>
235 static R InvokeMethod(Class* obj_ptr,
236 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000237 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
shiqiane35fdd92008-12-10 05:08:54 +0000238 A9>& args) {
kosakbd018832014-04-02 20:30:00 +0000239 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
240 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
241 get<6>(args), get<7>(args), get<8>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000242 }
243};
244
245template <typename R, typename A1, typename A2, typename A3, typename A4,
246 typename A5, typename A6, typename A7, typename A8, typename A9,
247 typename A10>
kosakbd018832014-04-02 20:30:00 +0000248class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
shiqiane35fdd92008-12-10 05:08:54 +0000249 A10> > {
250 public:
251 template <typename Function>
kosakbd018832014-04-02 20:30:00 +0000252 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
253 A6, A7, A8, A9, A10>& args) {
254 return function(get<0>(args), get<1>(args), get<2>(args),
255 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
256 get<7>(args), get<8>(args), get<9>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000257 }
258
259 template <class Class, typename MethodPtr>
260 static R InvokeMethod(Class* obj_ptr,
261 MethodPtr method_ptr,
kosakbd018832014-04-02 20:30:00 +0000262 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
shiqiane35fdd92008-12-10 05:08:54 +0000263 A9, A10>& args) {
kosakbd018832014-04-02 20:30:00 +0000264 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
265 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
266 get<6>(args), get<7>(args), get<8>(args), get<9>(args));
shiqiane35fdd92008-12-10 05:08:54 +0000267 }
268};
269
shiqiane35fdd92008-12-10 05:08:54 +0000270// CallableHelper has static methods for invoking "callables",
271// i.e. function pointers and functors. It uses overloading to
272// provide a uniform interface for invoking different kinds of
273// callables. In particular, you can use:
274//
275// CallableHelper<R>::Call(callable, a1, a2, ..., an)
276//
277// to invoke an n-ary callable, where R is its return type. If an
278// argument, say a2, needs to be passed by reference, you should write
279// ByRef(a2) instead of a2 in the above expression.
280template <typename R>
281class CallableHelper {
282 public:
283 // Calls a nullary callable.
284 template <typename Function>
285 static R Call(Function function) { return function(); }
286
287 // Calls a unary callable.
288
289 // We deliberately pass a1 by value instead of const reference here
290 // in case it is a C-string literal. If we had declared the
291 // parameter as 'const A1& a1' and write Call(function, "Hi"), the
292 // compiler would've thought A1 is 'char[3]', which causes trouble
293 // when you need to copy a value of type A1. By declaring the
294 // parameter as 'A1 a1', the compiler will correctly infer that A1
295 // is 'const char*' when it sees Call(function, "Hi").
296 //
297 // Since this function is defined inline, the compiler can get rid
298 // of the copying of the arguments. Therefore the performance won't
299 // be hurt.
300 template <typename Function, typename A1>
301 static R Call(Function function, A1 a1) { return function(a1); }
302
303 // Calls a binary callable.
304 template <typename Function, typename A1, typename A2>
305 static R Call(Function function, A1 a1, A2 a2) {
306 return function(a1, a2);
307 }
308
309 // Calls a ternary callable.
310 template <typename Function, typename A1, typename A2, typename A3>
311 static R Call(Function function, A1 a1, A2 a2, A3 a3) {
312 return function(a1, a2, a3);
313 }
314
315 // Calls a 4-ary callable.
316 template <typename Function, typename A1, typename A2, typename A3,
317 typename A4>
318 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4) {
319 return function(a1, a2, a3, a4);
320 }
321
322 // Calls a 5-ary callable.
323 template <typename Function, typename A1, typename A2, typename A3,
324 typename A4, typename A5>
325 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
326 return function(a1, a2, a3, a4, a5);
327 }
328
329 // Calls a 6-ary callable.
330 template <typename Function, typename A1, typename A2, typename A3,
331 typename A4, typename A5, typename A6>
332 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
333 return function(a1, a2, a3, a4, a5, a6);
334 }
335
336 // Calls a 7-ary callable.
337 template <typename Function, typename A1, typename A2, typename A3,
338 typename A4, typename A5, typename A6, typename A7>
339 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
340 A7 a7) {
341 return function(a1, a2, a3, a4, a5, a6, a7);
342 }
343
344 // Calls a 8-ary callable.
345 template <typename Function, typename A1, typename A2, typename A3,
346 typename A4, typename A5, typename A6, typename A7, typename A8>
347 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
348 A7 a7, A8 a8) {
349 return function(a1, a2, a3, a4, a5, a6, a7, a8);
350 }
351
352 // Calls a 9-ary callable.
353 template <typename Function, typename A1, typename A2, typename A3,
354 typename A4, typename A5, typename A6, typename A7, typename A8,
355 typename A9>
356 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
357 A7 a7, A8 a8, A9 a9) {
358 return function(a1, a2, a3, a4, a5, a6, a7, a8, a9);
359 }
360
361 // Calls a 10-ary callable.
362 template <typename Function, typename A1, typename A2, typename A3,
363 typename A4, typename A5, typename A6, typename A7, typename A8,
364 typename A9, typename A10>
365 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
366 A7 a7, A8 a8, A9 a9, A10 a10) {
367 return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
368 }
shiqiane35fdd92008-12-10 05:08:54 +0000369}; // class CallableHelper
370
shiqiane35fdd92008-12-10 05:08:54 +0000371// An INTERNAL macro for extracting the type of a tuple field. It's
372// subject to change without notice - DO NOT USE IN USER CODE!
zhanyong.wane0d051e2009-02-19 00:33:37 +0000373#define GMOCK_FIELD_(Tuple, N) \
kosakbd018832014-04-02 20:30:00 +0000374 typename ::testing::tuple_element<N, Tuple>::type
shiqiane35fdd92008-12-10 05:08:54 +0000375
376// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
377// type of an n-ary function whose i-th (1-based) argument type is the
378// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
379// type, and whose return type is Result. For example,
kosakbd018832014-04-02 20:30:00 +0000380// SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
shiqiane35fdd92008-12-10 05:08:54 +0000381// is int(bool, long).
382//
383// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
384// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
385// For example,
kosakbd018832014-04-02 20:30:00 +0000386// SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
387// ::testing::make_tuple(true, 'a', 2.5))
388// returns tuple (2.5, true).
shiqiane35fdd92008-12-10 05:08:54 +0000389//
390// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
391// in the range [0, 10]. Duplicates are allowed and they don't have
392// to be in an ascending or descending order.
393
394template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
395 int k4, int k5, int k6, int k7, int k8, int k9, int k10>
396class SelectArgs {
397 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000398 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
399 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
400 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
401 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
402 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
403 GMOCK_FIELD_(ArgumentTuple, k10));
shiqiane35fdd92008-12-10 05:08:54 +0000404 typedef typename Function<type>::ArgumentTuple SelectedArgs;
405 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000406 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
407 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
408 get<k8>(args), get<k9>(args), get<k10>(args));
409 }
410};
411
412template <typename Result, typename ArgumentTuple>
413class SelectArgs<Result, ArgumentTuple,
414 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
415 public:
416 typedef Result type();
417 typedef typename Function<type>::ArgumentTuple SelectedArgs;
zhanyong.wan3fbd2dd2009-03-26 19:06:45 +0000418 static SelectedArgs Select(const ArgumentTuple& /* args */) {
shiqiane35fdd92008-12-10 05:08:54 +0000419 return SelectedArgs();
420 }
421};
422
423template <typename Result, typename ArgumentTuple, int k1>
424class SelectArgs<Result, ArgumentTuple,
425 k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
426 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000427 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
shiqiane35fdd92008-12-10 05:08:54 +0000428 typedef typename Function<type>::ArgumentTuple SelectedArgs;
429 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000430 return SelectedArgs(get<k1>(args));
431 }
432};
433
434template <typename Result, typename ArgumentTuple, int k1, int k2>
435class SelectArgs<Result, ArgumentTuple,
436 k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {
437 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000438 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
439 GMOCK_FIELD_(ArgumentTuple, k2));
shiqiane35fdd92008-12-10 05:08:54 +0000440 typedef typename Function<type>::ArgumentTuple SelectedArgs;
441 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000442 return SelectedArgs(get<k1>(args), get<k2>(args));
443 }
444};
445
446template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
447class SelectArgs<Result, ArgumentTuple,
448 k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {
449 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000450 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
451 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
shiqiane35fdd92008-12-10 05:08:54 +0000452 typedef typename Function<type>::ArgumentTuple SelectedArgs;
453 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000454 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
455 }
456};
457
458template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
459 int k4>
460class SelectArgs<Result, ArgumentTuple,
461 k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {
462 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000463 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
464 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
465 GMOCK_FIELD_(ArgumentTuple, k4));
shiqiane35fdd92008-12-10 05:08:54 +0000466 typedef typename Function<type>::ArgumentTuple SelectedArgs;
467 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000468 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
469 get<k4>(args));
470 }
471};
472
473template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
474 int k4, int k5>
475class SelectArgs<Result, ArgumentTuple,
476 k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {
477 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000478 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
479 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
480 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
shiqiane35fdd92008-12-10 05:08:54 +0000481 typedef typename Function<type>::ArgumentTuple SelectedArgs;
482 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000483 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
484 get<k4>(args), get<k5>(args));
485 }
486};
487
488template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
489 int k4, int k5, int k6>
490class SelectArgs<Result, ArgumentTuple,
491 k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {
492 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000493 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
494 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
495 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
496 GMOCK_FIELD_(ArgumentTuple, k6));
shiqiane35fdd92008-12-10 05:08:54 +0000497 typedef typename Function<type>::ArgumentTuple SelectedArgs;
498 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000499 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
500 get<k4>(args), get<k5>(args), get<k6>(args));
501 }
502};
503
504template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
505 int k4, int k5, int k6, int k7>
506class SelectArgs<Result, ArgumentTuple,
507 k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {
508 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000509 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
510 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
511 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
512 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
shiqiane35fdd92008-12-10 05:08:54 +0000513 typedef typename Function<type>::ArgumentTuple SelectedArgs;
514 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000515 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
516 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
517 }
518};
519
520template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
521 int k4, int k5, int k6, int k7, int k8>
522class SelectArgs<Result, ArgumentTuple,
523 k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {
524 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000525 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
526 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
527 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
528 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
529 GMOCK_FIELD_(ArgumentTuple, k8));
shiqiane35fdd92008-12-10 05:08:54 +0000530 typedef typename Function<type>::ArgumentTuple SelectedArgs;
531 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000532 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
533 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
534 get<k8>(args));
535 }
536};
537
538template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
539 int k4, int k5, int k6, int k7, int k8, int k9>
540class SelectArgs<Result, ArgumentTuple,
541 k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {
542 public:
zhanyong.wane0d051e2009-02-19 00:33:37 +0000543 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
544 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
545 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
546 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
547 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
shiqiane35fdd92008-12-10 05:08:54 +0000548 typedef typename Function<type>::ArgumentTuple SelectedArgs;
549 static SelectedArgs Select(const ArgumentTuple& args) {
shiqiane35fdd92008-12-10 05:08:54 +0000550 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
551 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
552 get<k8>(args), get<k9>(args));
553 }
554};
555
zhanyong.wane0d051e2009-02-19 00:33:37 +0000556#undef GMOCK_FIELD_
shiqiane35fdd92008-12-10 05:08:54 +0000557
558// Implements the WithArgs action.
559template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
560 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
561 int k9 = -1, int k10 = -1>
562class WithArgsAction {
563 public:
564 explicit WithArgsAction(const InnerAction& action) : action_(action) {}
565
566 template <typename F>
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000567 operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
568
569 private:
570 template <typename F>
571 class Impl : public ActionInterface<F> {
572 public:
shiqiane35fdd92008-12-10 05:08:54 +0000573 typedef typename Function<F>::Result Result;
574 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000575
576 explicit Impl(const InnerAction& action) : action_(action) {}
577
578 virtual Result Perform(const ArgumentTuple& args) {
579 return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4,
580 k5, k6, k7, k8, k9, k10>::Select(args));
581 }
582
583 private:
shiqiane35fdd92008-12-10 05:08:54 +0000584 typedef typename SelectArgs<Result, ArgumentTuple,
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000585 k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
shiqiane35fdd92008-12-10 05:08:54 +0000586
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000587 Action<InnerFunctionType> action_;
588 };
shiqiane35fdd92008-12-10 05:08:54 +0000589
shiqiane35fdd92008-12-10 05:08:54 +0000590 const InnerAction action_;
zhanyong.wan32de5f52009-12-23 00:13:23 +0000591
592 GTEST_DISALLOW_ASSIGN_(WithArgsAction);
shiqiane35fdd92008-12-10 05:08:54 +0000593};
594
shiqian326aa562009-01-09 21:43:57 +0000595// A macro from the ACTION* family (defined later in this file)
596// defines an action that can be used in a mock function. Typically,
597// these actions only care about a subset of the arguments of the mock
598// function. For example, if such an action only uses the second
599// argument, it can be used in any mock function that takes >= 2
600// arguments where the type of the second argument is compatible.
601//
602// Therefore, the action implementation must be prepared to take more
603// arguments than it needs. The ExcessiveArg type is used to
604// represent those excessive arguments. In order to keep the compiler
605// error messages tractable, we define it in the testing namespace
606// instead of testing::internal. However, this is an INTERNAL TYPE
607// and subject to change without notice, so a user MUST NOT USE THIS
608// TYPE DIRECTLY.
609struct ExcessiveArg {};
610
611// A helper class needed for implementing the ACTION* macros.
612template <typename Result, class Impl>
613class ActionHelper {
614 public:
kosakbd018832014-04-02 20:30:00 +0000615 static Result Perform(Impl* impl, const ::testing::tuple<>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000616 return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
shiqian326aa562009-01-09 21:43:57 +0000617 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000618 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
619 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000620 }
621
622 template <typename A0>
kosakbd018832014-04-02 20:30:00 +0000623 static Result Perform(Impl* impl, const ::testing::tuple<A0>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000624 return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
shiqian326aa562009-01-09 21:43:57 +0000625 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000626 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
627 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000628 }
629
630 template <typename A0, typename A1>
kosakbd018832014-04-02 20:30:00 +0000631 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000632 return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
633 get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
shiqian326aa562009-01-09 21:43:57 +0000634 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000635 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000636 }
637
638 template <typename A0, typename A1, typename A2>
kosakbd018832014-04-02 20:30:00 +0000639 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000640 return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
641 get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
642 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
643 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000644 }
645
646 template <typename A0, typename A1, typename A2, typename A3>
kosakbd018832014-04-02 20:30:00 +0000647 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2,
shiqian326aa562009-01-09 21:43:57 +0000648 A3>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000649 return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
650 get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
651 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
652 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000653 }
654
655 template <typename A0, typename A1, typename A2, typename A3, typename A4>
kosakbd018832014-04-02 20:30:00 +0000656 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3,
shiqian326aa562009-01-09 21:43:57 +0000657 A4>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000658 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
659 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
660 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
661 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000662 }
663
664 template <typename A0, typename A1, typename A2, typename A3, typename A4,
665 typename A5>
kosakbd018832014-04-02 20:30:00 +0000666 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
shiqian326aa562009-01-09 21:43:57 +0000667 A5>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000668 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
669 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
670 get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
671 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000672 }
673
674 template <typename A0, typename A1, typename A2, typename A3, typename A4,
675 typename A5, typename A6>
kosakbd018832014-04-02 20:30:00 +0000676 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
shiqian326aa562009-01-09 21:43:57 +0000677 A5, A6>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000678 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
679 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
680 get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
681 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000682 }
683
684 template <typename A0, typename A1, typename A2, typename A3, typename A4,
685 typename A5, typename A6, typename A7>
kosakbd018832014-04-02 20:30:00 +0000686 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
shiqian326aa562009-01-09 21:43:57 +0000687 A5, A6, A7>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000688 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
689 A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
690 get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
691 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000692 }
693
694 template <typename A0, typename A1, typename A2, typename A3, typename A4,
695 typename A5, typename A6, typename A7, typename A8>
kosakbd018832014-04-02 20:30:00 +0000696 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
shiqian326aa562009-01-09 21:43:57 +0000697 A5, A6, A7, A8>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000698 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
699 A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
700 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
701 ExcessiveArg());
shiqian326aa562009-01-09 21:43:57 +0000702 }
703
704 template <typename A0, typename A1, typename A2, typename A3, typename A4,
705 typename A5, typename A6, typename A7, typename A8, typename A9>
kosakbd018832014-04-02 20:30:00 +0000706 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
shiqian326aa562009-01-09 21:43:57 +0000707 A5, A6, A7, A8, A9>& args) {
zhanyong.wan7f4c2c02009-02-19 22:38:27 +0000708 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
709 A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
710 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
711 get<9>(args));
shiqian326aa562009-01-09 21:43:57 +0000712 }
713};
714
shiqiane35fdd92008-12-10 05:08:54 +0000715} // namespace internal
716
717// Various overloads for Invoke().
718
shiqiane35fdd92008-12-10 05:08:54 +0000719// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
720// the selected arguments of the mock function to an_action and
721// performs it. It serves as an adaptor between actions with
722// different argument lists. C++ doesn't support default arguments for
723// function templates, so we have to overload it.
724template <int k1, typename InnerAction>
725inline internal::WithArgsAction<InnerAction, k1>
726WithArgs(const InnerAction& action) {
727 return internal::WithArgsAction<InnerAction, k1>(action);
728}
729
730template <int k1, int k2, typename InnerAction>
731inline internal::WithArgsAction<InnerAction, k1, k2>
732WithArgs(const InnerAction& action) {
733 return internal::WithArgsAction<InnerAction, k1, k2>(action);
734}
735
736template <int k1, int k2, int k3, typename InnerAction>
737inline internal::WithArgsAction<InnerAction, k1, k2, k3>
738WithArgs(const InnerAction& action) {
739 return internal::WithArgsAction<InnerAction, k1, k2, k3>(action);
740}
741
742template <int k1, int k2, int k3, int k4, typename InnerAction>
743inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4>
744WithArgs(const InnerAction& action) {
745 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action);
746}
747
748template <int k1, int k2, int k3, int k4, int k5, typename InnerAction>
749inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>
750WithArgs(const InnerAction& action) {
751 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action);
752}
753
754template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>
755inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>
756WithArgs(const InnerAction& action) {
757 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action);
758}
759
760template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
761 typename InnerAction>
762inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7>
763WithArgs(const InnerAction& action) {
764 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,
765 k7>(action);
766}
767
768template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
769 typename InnerAction>
770inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8>
771WithArgs(const InnerAction& action) {
772 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,
773 k8>(action);
774}
775
776template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
777 int k9, typename InnerAction>
778inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9>
779WithArgs(const InnerAction& action) {
780 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
781 k9>(action);
782}
783
784template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
785 int k9, int k10, typename InnerAction>
786inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
787 k9, k10>
788WithArgs(const InnerAction& action) {
789 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
790 k9, k10>(action);
791}
792
793// Creates an action that does actions a1, a2, ..., sequentially in
794// each invocation.
795template <typename Action1, typename Action2>
796inline internal::DoBothAction<Action1, Action2>
797DoAll(Action1 a1, Action2 a2) {
798 return internal::DoBothAction<Action1, Action2>(a1, a2);
799}
800
801template <typename Action1, typename Action2, typename Action3>
802inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
803 Action3> >
804DoAll(Action1 a1, Action2 a2, Action3 a3) {
805 return DoAll(a1, DoAll(a2, a3));
806}
807
808template <typename Action1, typename Action2, typename Action3,
809 typename Action4>
810inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
811 internal::DoBothAction<Action3, Action4> > >
812DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) {
813 return DoAll(a1, DoAll(a2, a3, a4));
814}
815
816template <typename Action1, typename Action2, typename Action3,
817 typename Action4, typename Action5>
818inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
819 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
820 Action5> > > >
821DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) {
822 return DoAll(a1, DoAll(a2, a3, a4, a5));
823}
824
825template <typename Action1, typename Action2, typename Action3,
826 typename Action4, typename Action5, typename Action6>
827inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
828 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
829 internal::DoBothAction<Action5, Action6> > > > >
830DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) {
831 return DoAll(a1, DoAll(a2, a3, a4, a5, a6));
832}
833
834template <typename Action1, typename Action2, typename Action3,
835 typename Action4, typename Action5, typename Action6, typename Action7>
836inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
837 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
838 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
839 Action7> > > > > >
840DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
841 Action7 a7) {
842 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));
843}
844
845template <typename Action1, typename Action2, typename Action3,
846 typename Action4, typename Action5, typename Action6, typename Action7,
847 typename Action8>
848inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
849 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
850 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
851 internal::DoBothAction<Action7, Action8> > > > > > >
852DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
853 Action7 a7, Action8 a8) {
854 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));
855}
856
857template <typename Action1, typename Action2, typename Action3,
858 typename Action4, typename Action5, typename Action6, typename Action7,
859 typename Action8, typename Action9>
860inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
861 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
862 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
863 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
864 Action9> > > > > > > >
865DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
866 Action7 a7, Action8 a8, Action9 a9) {
867 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));
868}
869
870template <typename Action1, typename Action2, typename Action3,
871 typename Action4, typename Action5, typename Action6, typename Action7,
872 typename Action8, typename Action9, typename Action10>
873inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
874 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
875 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
876 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
877 internal::DoBothAction<Action9, Action10> > > > > > > > >
878DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
879 Action7 a7, Action8 a8, Action9 a9, Action10 a10) {
880 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
881}
882
883} // namespace testing
884
shiqian326aa562009-01-09 21:43:57 +0000885// The ACTION* family of macros can be used in a namespace scope to
886// define custom actions easily. The syntax:
887//
888// ACTION(name) { statements; }
889//
890// will define an action with the given name that executes the
891// statements. The value returned by the statements will be used as
892// the return value of the action. Inside the statements, you can
893// refer to the K-th (0-based) argument of the mock function by
894// 'argK', and refer to its type by 'argK_type'. For example:
895//
896// ACTION(IncrementArg1) {
897// arg1_type temp = arg1;
898// return ++(*temp);
899// }
900//
901// allows you to write
902//
903// ...WillOnce(IncrementArg1());
904//
905// You can also refer to the entire argument tuple and its type by
906// 'args' and 'args_type', and refer to the mock function type and its
907// return type by 'function_type' and 'return_type'.
908//
909// Note that you don't need to specify the types of the mock function
910// arguments. However rest assured that your code is still type-safe:
911// you'll get a compiler error if *arg1 doesn't support the ++
912// operator, or if the type of ++(*arg1) isn't compatible with the
913// mock function's return type, for example.
914//
915// Sometimes you'll want to parameterize the action. For that you can use
916// another macro:
917//
918// ACTION_P(name, param_name) { statements; }
919//
920// For example:
921//
922// ACTION_P(Add, n) { return arg0 + n; }
923//
924// will allow you to write:
925//
926// ...WillOnce(Add(5));
927//
928// Note that you don't need to provide the type of the parameter
929// either. If you need to reference the type of a parameter named
930// 'foo', you can write 'foo_type'. For example, in the body of
931// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
932// of 'n'.
933//
934// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support
935// multi-parameter actions.
936//
937// For the purpose of typing, you can view
938//
939// ACTION_Pk(Foo, p1, ..., pk) { ... }
940//
941// as shorthand for
942//
943// template <typename p1_type, ..., typename pk_type>
944// FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
945//
946// In particular, you can provide the template type arguments
947// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
948// although usually you can rely on the compiler to infer the types
949// for you automatically. You can assign the result of expression
950// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
951// pk_type>. This can be useful when composing actions.
952//
953// You can also overload actions with different numbers of parameters:
954//
955// ACTION_P(Plus, a) { ... }
956// ACTION_P2(Plus, a, b) { ... }
957//
958// While it's tempting to always use the ACTION* macros when defining
959// a new action, you should also consider implementing ActionInterface
960// or using MakePolymorphicAction() instead, especially if you need to
961// use the action a lot. While these approaches require more work,
962// they give you more control on the types of the mock function
963// arguments and the action parameters, which in general leads to
964// better compiler error messages that pay off in the long run. They
965// also allow overloading actions based on parameter types (as opposed
966// to just based on the number of parameters).
967//
968// CAVEAT:
969//
970// ACTION*() can only be used in a namespace scope. The reason is
971// that C++ doesn't yet allow function-local types to be used to
972// instantiate templates. The up-coming C++0x standard will fix this.
973// Once that's done, we'll consider supporting using ACTION*() inside
974// a function.
975//
976// MORE INFORMATION:
977//
978// To learn more about using these macros, please search for 'ACTION'
979// on http://code.google.com/p/googlemock/wiki/CookBook.
980
zhanyong.wan33c0af02009-04-03 00:10:12 +0000981// An internal macro needed for implementing ACTION*().
982#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
jgm79a367e2012-04-10 16:02:11 +0000983 const args_type& args GTEST_ATTRIBUTE_UNUSED_, \
984 arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \
985 arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \
986 arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \
987 arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \
988 arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \
989 arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \
990 arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \
991 arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \
992 arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \
zhanyong.wan33c0af02009-04-03 00:10:12 +0000993 arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
994
zhanyong.wan18490652009-05-11 18:54:08 +0000995// Sometimes you want to give an action explicit template parameters
996// that cannot be inferred from its value parameters. ACTION() and
997// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
998// and can be viewed as an extension to ACTION() and ACTION_P*().
999//
1000// The syntax:
1001//
1002// ACTION_TEMPLATE(ActionName,
1003// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
1004// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
1005//
1006// defines an action template that takes m explicit template
1007// parameters and n value parameters. name_i is the name of the i-th
1008// template parameter, and kind_i specifies whether it's a typename,
1009// an integral constant, or a template. p_i is the name of the i-th
1010// value parameter.
1011//
1012// Example:
1013//
1014// // DuplicateArg<k, T>(output) converts the k-th argument of the mock
1015// // function to type T and copies it to *output.
1016// ACTION_TEMPLATE(DuplicateArg,
1017// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
1018// AND_1_VALUE_PARAMS(output)) {
kosakbd018832014-04-02 20:30:00 +00001019// *output = T(::testing::get<k>(args));
zhanyong.wan18490652009-05-11 18:54:08 +00001020// }
1021// ...
1022// int n;
1023// EXPECT_CALL(mock, Foo(_, _))
1024// .WillOnce(DuplicateArg<1, unsigned char>(&n));
1025//
1026// To create an instance of an action template, write:
1027//
1028// ActionName<t1, ..., t_m>(v1, ..., v_n)
1029//
1030// where the ts are the template arguments and the vs are the value
1031// arguments. The value argument types are inferred by the compiler.
1032// If you want to explicitly specify the value argument types, you can
1033// provide additional template arguments:
1034//
1035// ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
1036//
1037// where u_i is the desired type of v_i.
1038//
1039// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
1040// number of value parameters, but not on the number of template
1041// parameters. Without the restriction, the meaning of the following
1042// is unclear:
1043//
1044// OverloadedAction<int, bool>(x);
1045//
1046// Are we using a single-template-parameter action where 'bool' refers
1047// to the type of x, or are we using a two-template-parameter action
1048// where the compiler is asked to infer the type of x?
1049//
1050// Implementation notes:
1051//
1052// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
1053// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
1054// implementing ACTION_TEMPLATE. The main trick we use is to create
1055// new macro invocations when expanding a macro. For example, we have
1056//
1057// #define ACTION_TEMPLATE(name, template_params, value_params)
1058// ... GMOCK_INTERNAL_DECL_##template_params ...
1059//
1060// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
1061// to expand to
1062//
1063// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
1064//
1065// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
1066// preprocessor will continue to expand it to
1067//
1068// ... typename T ...
1069//
1070// This technique conforms to the C++ standard and is portable. It
1071// allows us to implement action templates using O(N) code, where N is
1072// the maximum number of template/value parameters supported. Without
1073// using it, we'd have to devote O(N^2) amount of code to implement all
1074// combinations of m and n.
1075
1076// Declares the template parameters.
1077#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
1078#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
1079 name1) kind0 name0, kind1 name1
1080#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1081 kind2, name2) kind0 name0, kind1 name1, kind2 name2
1082#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1083 kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
1084 kind3 name3
1085#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1086 kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
1087 kind2 name2, kind3 name3, kind4 name4
1088#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1089 kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
1090 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
1091#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1092 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
1093 name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
1094 kind5 name5, kind6 name6
1095#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1096 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
1097 kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
1098 kind4 name4, kind5 name5, kind6 name6, kind7 name7
1099#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1100 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
1101 kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
1102 kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
1103 kind8 name8
1104#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
1105 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
1106 name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
1107 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
1108 kind6 name6, kind7 name7, kind8 name8, kind9 name9
1109
1110// Lists the template parameters.
1111#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
1112#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
1113 name1) name0, name1
1114#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1115 kind2, name2) name0, name1, name2
1116#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1117 kind2, name2, kind3, name3) name0, name1, name2, name3
1118#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1119 kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
1120 name4
1121#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1122 kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
1123 name2, name3, name4, name5
1124#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1125 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
1126 name6) name0, name1, name2, name3, name4, name5, name6
1127#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1128 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
1129 kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
1130#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
1131 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
1132 kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
1133 name6, name7, name8
1134#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
1135 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
1136 name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
1137 name3, name4, name5, name6, name7, name8, name9
1138
1139// Declares the types of value parameters.
1140#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
1141#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
1142#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
1143 typename p0##_type, typename p1##_type
1144#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
1145 typename p0##_type, typename p1##_type, typename p2##_type
1146#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
1147 typename p0##_type, typename p1##_type, typename p2##_type, \
1148 typename p3##_type
1149#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
1150 typename p0##_type, typename p1##_type, typename p2##_type, \
1151 typename p3##_type, typename p4##_type
1152#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
1153 typename p0##_type, typename p1##_type, typename p2##_type, \
1154 typename p3##_type, typename p4##_type, typename p5##_type
1155#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1156 p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
1157 typename p3##_type, typename p4##_type, typename p5##_type, \
1158 typename p6##_type
1159#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1160 p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
1161 typename p3##_type, typename p4##_type, typename p5##_type, \
1162 typename p6##_type, typename p7##_type
1163#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1164 p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
1165 typename p3##_type, typename p4##_type, typename p5##_type, \
1166 typename p6##_type, typename p7##_type, typename p8##_type
1167#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1168 p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
1169 typename p2##_type, typename p3##_type, typename p4##_type, \
1170 typename p5##_type, typename p6##_type, typename p7##_type, \
1171 typename p8##_type, typename p9##_type
1172
1173// Initializes the value parameters.
1174#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
1175 ()
1176#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
1177 (p0##_type gmock_p0) : p0(gmock_p0)
1178#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
1179 (p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)
1180#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
1181 (p0##_type gmock_p0, p1##_type gmock_p1, \
1182 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)
1183#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
1184 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1185 p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1186 p3(gmock_p3)
1187#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
1188 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1189 p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), \
1190 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4)
1191#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
1192 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1193 p3##_type gmock_p3, p4##_type gmock_p4, \
1194 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1195 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5)
1196#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
1197 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1198 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1199 p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1200 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6)
1201#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
1202 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1203 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1204 p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), \
1205 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1206 p7(gmock_p7)
1207#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1208 p7, p8)\
1209 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1210 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1211 p6##_type gmock_p6, p7##_type gmock_p7, \
1212 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1213 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1214 p8(gmock_p8)
1215#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1216 p7, p8, p9)\
1217 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1218 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1219 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
1220 p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1221 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
1222 p8(gmock_p8), p9(gmock_p9)
1223
1224// Declares the fields for storing the value parameters.
1225#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
1226#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
1227#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
1228 p1##_type p1;
1229#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
1230 p1##_type p1; p2##_type p2;
1231#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
1232 p1##_type p1; p2##_type p2; p3##_type p3;
1233#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
1234 p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
1235#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
1236 p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
1237 p5##_type p5;
1238#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1239 p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
1240 p5##_type p5; p6##_type p6;
1241#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1242 p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
1243 p5##_type p5; p6##_type p6; p7##_type p7;
1244#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1245 p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
1246 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
1247#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1248 p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
1249 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
1250 p9##_type p9;
1251
1252// Lists the value parameters.
1253#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
1254#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
1255#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
1256#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
1257#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
1258#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
1259 p2, p3, p4
1260#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
1261 p1, p2, p3, p4, p5
1262#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1263 p6) p0, p1, p2, p3, p4, p5, p6
1264#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1265 p7) p0, p1, p2, p3, p4, p5, p6, p7
1266#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1267 p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
1268#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1269 p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
1270
1271// Lists the value parameter types.
1272#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
1273#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
1274#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
1275 p1##_type
1276#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
1277 p1##_type, p2##_type
1278#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
1279 p0##_type, p1##_type, p2##_type, p3##_type
1280#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
1281 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
1282#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
1283 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
1284#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1285 p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
1286 p6##_type
1287#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1288 p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1289 p5##_type, p6##_type, p7##_type
1290#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1291 p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1292 p5##_type, p6##_type, p7##_type, p8##_type
1293#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1294 p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1295 p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
1296
1297// Declares the value parameters.
1298#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
1299#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
1300#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
1301 p1##_type p1
1302#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
1303 p1##_type p1, p2##_type p2
1304#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
1305 p1##_type p1, p2##_type p2, p3##_type p3
1306#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
1307 p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
1308#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
1309 p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
1310 p5##_type p5
1311#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
1312 p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
1313 p5##_type p5, p6##_type p6
1314#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1315 p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
1316 p5##_type p5, p6##_type p6, p7##_type p7
1317#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1318 p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1319 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
1320#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1321 p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1322 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
1323 p9##_type p9
1324
1325// The suffix of the class template implementing the action template.
1326#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
1327#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
1328#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
1329#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
1330#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
1331#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
1332#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
1333#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
1334#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1335 p7) P8
1336#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1337 p7, p8) P9
1338#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1339 p7, p8, p9) P10
1340
1341// The name of the class template implementing the action template.
1342#define GMOCK_ACTION_CLASS_(name, value_params)\
zhanyong.wanccedc1c2010-08-09 22:46:12 +00001343 GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
zhanyong.wan18490652009-05-11 18:54:08 +00001344
1345#define ACTION_TEMPLATE(name, template_params, value_params)\
1346 template <GMOCK_INTERNAL_DECL_##template_params\
1347 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
1348 class GMOCK_ACTION_CLASS_(name, value_params) {\
1349 public:\
1350 GMOCK_ACTION_CLASS_(name, value_params)\
1351 GMOCK_INTERNAL_INIT_##value_params {}\
1352 template <typename F>\
1353 class gmock_Impl : public ::testing::ActionInterface<F> {\
1354 public:\
1355 typedef F function_type;\
1356 typedef typename ::testing::internal::Function<F>::Result return_type;\
1357 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1358 args_type;\
1359 explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
1360 virtual return_type Perform(const args_type& args) {\
1361 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1362 Perform(this, args);\
1363 }\
1364 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1365 typename arg3_type, typename arg4_type, typename arg5_type, \
1366 typename arg6_type, typename arg7_type, typename arg8_type, \
1367 typename arg9_type>\
1368 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1369 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1370 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1371 arg9_type arg9) const;\
1372 GMOCK_INTERNAL_DEFN_##value_params\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001373 private:\
1374 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
zhanyong.wan18490652009-05-11 18:54:08 +00001375 };\
1376 template <typename F> operator ::testing::Action<F>() const {\
1377 return ::testing::Action<F>(\
1378 new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
1379 }\
1380 GMOCK_INTERNAL_DEFN_##value_params\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001381 private:\
1382 GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
zhanyong.wan18490652009-05-11 18:54:08 +00001383 };\
1384 template <GMOCK_INTERNAL_DECL_##template_params\
1385 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
1386 inline GMOCK_ACTION_CLASS_(name, value_params)<\
1387 GMOCK_INTERNAL_LIST_##template_params\
1388 GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
1389 GMOCK_INTERNAL_DECL_##value_params) {\
1390 return GMOCK_ACTION_CLASS_(name, value_params)<\
1391 GMOCK_INTERNAL_LIST_##template_params\
1392 GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
1393 GMOCK_INTERNAL_LIST_##value_params);\
1394 }\
1395 template <GMOCK_INTERNAL_DECL_##template_params\
1396 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
1397 template <typename F>\
jgm79a367e2012-04-10 16:02:11 +00001398 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1399 typename arg3_type, typename arg4_type, typename arg5_type, \
1400 typename arg6_type, typename arg7_type, typename arg8_type, \
zhanyong.wan18490652009-05-11 18:54:08 +00001401 typename arg9_type>\
1402 typename ::testing::internal::Function<F>::Result\
1403 GMOCK_ACTION_CLASS_(name, value_params)<\
1404 GMOCK_INTERNAL_LIST_##template_params\
1405 GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
1406 gmock_PerformImpl(\
1407 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1408
shiqian326aa562009-01-09 21:43:57 +00001409#define ACTION(name)\
1410 class name##Action {\
1411 public:\
1412 name##Action() {}\
1413 template <typename F>\
1414 class gmock_Impl : public ::testing::ActionInterface<F> {\
1415 public:\
1416 typedef F function_type;\
1417 typedef typename ::testing::internal::Function<F>::Result return_type;\
1418 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1419 args_type;\
1420 gmock_Impl() {}\
1421 virtual return_type Perform(const args_type& args) {\
1422 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1423 Perform(this, args);\
1424 }\
1425 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1426 typename arg3_type, typename arg4_type, typename arg5_type, \
1427 typename arg6_type, typename arg7_type, typename arg8_type, \
1428 typename arg9_type>\
1429 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1430 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1431 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1432 arg9_type arg9) const;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001433 private:\
1434 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001435 };\
1436 template <typename F> operator ::testing::Action<F>() const {\
1437 return ::testing::Action<F>(new gmock_Impl<F>());\
1438 }\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001439 private:\
1440 GTEST_DISALLOW_ASSIGN_(name##Action);\
shiqian326aa562009-01-09 21:43:57 +00001441 };\
1442 inline name##Action name() {\
1443 return name##Action();\
1444 }\
1445 template <typename F>\
1446 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1447 typename arg3_type, typename arg4_type, typename arg5_type, \
1448 typename arg6_type, typename arg7_type, typename arg8_type, \
1449 typename arg9_type>\
1450 typename ::testing::internal::Function<F>::Result\
zhanyong.wan33c0af02009-04-03 00:10:12 +00001451 name##Action::gmock_Impl<F>::gmock_PerformImpl(\
1452 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001453
1454#define ACTION_P(name, p0)\
1455 template <typename p0##_type>\
1456 class name##ActionP {\
1457 public:\
1458 name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
1459 template <typename F>\
1460 class gmock_Impl : public ::testing::ActionInterface<F> {\
1461 public:\
1462 typedef F function_type;\
1463 typedef typename ::testing::internal::Function<F>::Result return_type;\
1464 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1465 args_type;\
1466 explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\
1467 virtual return_type Perform(const args_type& args) {\
1468 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1469 Perform(this, args);\
1470 }\
1471 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1472 typename arg3_type, typename arg4_type, typename arg5_type, \
1473 typename arg6_type, typename arg7_type, typename arg8_type, \
1474 typename arg9_type>\
1475 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1476 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1477 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1478 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001479 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001480 private:\
1481 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001482 };\
1483 template <typename F> operator ::testing::Action<F>() const {\
1484 return ::testing::Action<F>(new gmock_Impl<F>(p0));\
1485 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001486 p0##_type p0;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001487 private:\
1488 GTEST_DISALLOW_ASSIGN_(name##ActionP);\
shiqian326aa562009-01-09 21:43:57 +00001489 };\
1490 template <typename p0##_type>\
1491 inline name##ActionP<p0##_type> name(p0##_type p0) {\
1492 return name##ActionP<p0##_type>(p0);\
1493 }\
1494 template <typename p0##_type>\
1495 template <typename F>\
1496 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1497 typename arg3_type, typename arg4_type, typename arg5_type, \
1498 typename arg6_type, typename arg7_type, typename arg8_type, \
1499 typename arg9_type>\
1500 typename ::testing::internal::Function<F>::Result\
zhanyong.wan33c0af02009-04-03 00:10:12 +00001501 name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1502 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001503
1504#define ACTION_P2(name, p0, p1)\
1505 template <typename p0##_type, typename p1##_type>\
1506 class name##ActionP2 {\
1507 public:\
1508 name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1509 p1(gmock_p1) {}\
1510 template <typename F>\
1511 class gmock_Impl : public ::testing::ActionInterface<F> {\
1512 public:\
1513 typedef F function_type;\
1514 typedef typename ::testing::internal::Function<F>::Result return_type;\
1515 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1516 args_type;\
1517 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1518 p1(gmock_p1) {}\
1519 virtual return_type Perform(const args_type& args) {\
1520 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1521 Perform(this, args);\
1522 }\
1523 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1524 typename arg3_type, typename arg4_type, typename arg5_type, \
1525 typename arg6_type, typename arg7_type, typename arg8_type, \
1526 typename arg9_type>\
1527 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1528 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1529 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1530 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001531 p0##_type p0;\
1532 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001533 private:\
1534 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001535 };\
1536 template <typename F> operator ::testing::Action<F>() const {\
1537 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
1538 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001539 p0##_type p0;\
1540 p1##_type p1;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001541 private:\
1542 GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
shiqian326aa562009-01-09 21:43:57 +00001543 };\
1544 template <typename p0##_type, typename p1##_type>\
1545 inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
1546 p1##_type p1) {\
1547 return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
1548 }\
1549 template <typename p0##_type, typename p1##_type>\
1550 template <typename F>\
1551 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1552 typename arg3_type, typename arg4_type, typename arg5_type, \
1553 typename arg6_type, typename arg7_type, typename arg8_type, \
1554 typename arg9_type>\
1555 typename ::testing::internal::Function<F>::Result\
zhanyong.wan33c0af02009-04-03 00:10:12 +00001556 name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1557 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001558
1559#define ACTION_P3(name, p0, p1, p2)\
1560 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1561 class name##ActionP3 {\
1562 public:\
1563 name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
1564 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
1565 template <typename F>\
1566 class gmock_Impl : public ::testing::ActionInterface<F> {\
1567 public:\
1568 typedef F function_type;\
1569 typedef typename ::testing::internal::Function<F>::Result return_type;\
1570 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1571 args_type;\
1572 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
1573 p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
1574 virtual return_type Perform(const args_type& args) {\
1575 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1576 Perform(this, args);\
1577 }\
1578 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1579 typename arg3_type, typename arg4_type, typename arg5_type, \
1580 typename arg6_type, typename arg7_type, typename arg8_type, \
1581 typename arg9_type>\
1582 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1583 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1584 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1585 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001586 p0##_type p0;\
1587 p1##_type p1;\
1588 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001589 private:\
1590 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001591 };\
1592 template <typename F> operator ::testing::Action<F>() const {\
1593 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
1594 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001595 p0##_type p0;\
1596 p1##_type p1;\
1597 p2##_type p2;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001598 private:\
1599 GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
shiqian326aa562009-01-09 21:43:57 +00001600 };\
1601 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1602 inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
1603 p1##_type p1, p2##_type p2) {\
1604 return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
1605 }\
1606 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1607 template <typename F>\
1608 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1609 typename arg3_type, typename arg4_type, typename arg5_type, \
1610 typename arg6_type, typename arg7_type, typename arg8_type, \
1611 typename arg9_type>\
1612 typename ::testing::internal::Function<F>::Result\
zhanyong.wan33c0af02009-04-03 00:10:12 +00001613 name##ActionP3<p0##_type, p1##_type, \
1614 p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1615 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001616
1617#define ACTION_P4(name, p0, p1, p2, p3)\
1618 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1619 typename p3##_type>\
1620 class name##ActionP4 {\
1621 public:\
1622 name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \
1623 p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
1624 p2(gmock_p2), p3(gmock_p3) {}\
1625 template <typename F>\
1626 class gmock_Impl : public ::testing::ActionInterface<F> {\
1627 public:\
1628 typedef F function_type;\
1629 typedef typename ::testing::internal::Function<F>::Result return_type;\
1630 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1631 args_type;\
1632 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1633 p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1634 p3(gmock_p3) {}\
1635 virtual return_type Perform(const args_type& args) {\
1636 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1637 Perform(this, args);\
1638 }\
1639 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1640 typename arg3_type, typename arg4_type, typename arg5_type, \
1641 typename arg6_type, typename arg7_type, typename arg8_type, \
1642 typename arg9_type>\
1643 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1644 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1645 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1646 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001647 p0##_type p0;\
1648 p1##_type p1;\
1649 p2##_type p2;\
1650 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001651 private:\
1652 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001653 };\
1654 template <typename F> operator ::testing::Action<F>() const {\
1655 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
1656 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001657 p0##_type p0;\
1658 p1##_type p1;\
1659 p2##_type p2;\
1660 p3##_type p3;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001661 private:\
1662 GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
shiqian326aa562009-01-09 21:43:57 +00001663 };\
1664 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1665 typename p3##_type>\
1666 inline name##ActionP4<p0##_type, p1##_type, p2##_type, \
1667 p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1668 p3##_type p3) {\
1669 return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \
1670 p2, p3);\
1671 }\
1672 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1673 typename p3##_type>\
1674 template <typename F>\
1675 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1676 typename arg3_type, typename arg4_type, typename arg5_type, \
1677 typename arg6_type, typename arg7_type, typename arg8_type, \
1678 typename arg9_type>\
1679 typename ::testing::internal::Function<F>::Result\
zhanyong.wan33c0af02009-04-03 00:10:12 +00001680 name##ActionP4<p0##_type, p1##_type, p2##_type, \
1681 p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1682 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001683
1684#define ACTION_P5(name, p0, p1, p2, p3, p4)\
1685 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1686 typename p3##_type, typename p4##_type>\
1687 class name##ActionP5 {\
1688 public:\
1689 name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
1690 p2##_type gmock_p2, p3##_type gmock_p3, \
1691 p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1692 p3(gmock_p3), p4(gmock_p4) {}\
1693 template <typename F>\
1694 class gmock_Impl : public ::testing::ActionInterface<F> {\
1695 public:\
1696 typedef F function_type;\
1697 typedef typename ::testing::internal::Function<F>::Result return_type;\
1698 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1699 args_type;\
1700 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1701 p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \
1702 p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\
1703 virtual return_type Perform(const args_type& args) {\
1704 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1705 Perform(this, args);\
1706 }\
1707 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1708 typename arg3_type, typename arg4_type, typename arg5_type, \
1709 typename arg6_type, typename arg7_type, typename arg8_type, \
1710 typename arg9_type>\
1711 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1712 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1713 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1714 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001715 p0##_type p0;\
1716 p1##_type p1;\
1717 p2##_type p2;\
1718 p3##_type p3;\
1719 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001720 private:\
1721 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001722 };\
1723 template <typename F> operator ::testing::Action<F>() const {\
1724 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
1725 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001726 p0##_type p0;\
1727 p1##_type p1;\
1728 p2##_type p2;\
1729 p3##_type p3;\
1730 p4##_type p4;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001731 private:\
1732 GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
shiqian326aa562009-01-09 21:43:57 +00001733 };\
1734 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1735 typename p3##_type, typename p4##_type>\
1736 inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1737 p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
1738 p4##_type p4) {\
1739 return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1740 p4##_type>(p0, p1, p2, p3, p4);\
1741 }\
1742 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1743 typename p3##_type, typename p4##_type>\
1744 template <typename F>\
1745 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1746 typename arg3_type, typename arg4_type, typename arg5_type, \
1747 typename arg6_type, typename arg7_type, typename arg8_type, \
1748 typename arg9_type>\
1749 typename ::testing::internal::Function<F>::Result\
zhanyong.wan33c0af02009-04-03 00:10:12 +00001750 name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1751 p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1752 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001753
1754#define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
1755 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1756 typename p3##_type, typename p4##_type, typename p5##_type>\
1757 class name##ActionP6 {\
1758 public:\
1759 name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
1760 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1761 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1762 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
1763 template <typename F>\
1764 class gmock_Impl : public ::testing::ActionInterface<F> {\
1765 public:\
1766 typedef F function_type;\
1767 typedef typename ::testing::internal::Function<F>::Result return_type;\
1768 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1769 args_type;\
1770 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1771 p3##_type gmock_p3, p4##_type gmock_p4, \
1772 p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1773 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
1774 virtual return_type Perform(const args_type& args) {\
1775 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1776 Perform(this, args);\
1777 }\
1778 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1779 typename arg3_type, typename arg4_type, typename arg5_type, \
1780 typename arg6_type, typename arg7_type, typename arg8_type, \
1781 typename arg9_type>\
1782 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1783 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1784 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1785 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001786 p0##_type p0;\
1787 p1##_type p1;\
1788 p2##_type p2;\
1789 p3##_type p3;\
1790 p4##_type p4;\
1791 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001792 private:\
1793 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001794 };\
1795 template <typename F> operator ::testing::Action<F>() const {\
1796 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
1797 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001798 p0##_type p0;\
1799 p1##_type p1;\
1800 p2##_type p2;\
1801 p3##_type p3;\
1802 p4##_type p4;\
1803 p5##_type p5;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001804 private:\
1805 GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
shiqian326aa562009-01-09 21:43:57 +00001806 };\
1807 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1808 typename p3##_type, typename p4##_type, typename p5##_type>\
1809 inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1810 p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
1811 p3##_type p3, p4##_type p4, p5##_type p5) {\
1812 return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
1813 p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
1814 }\
1815 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1816 typename p3##_type, typename p4##_type, typename p5##_type>\
1817 template <typename F>\
1818 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1819 typename arg3_type, typename arg4_type, typename arg5_type, \
1820 typename arg6_type, typename arg7_type, typename arg8_type, \
1821 typename arg9_type>\
1822 typename ::testing::internal::Function<F>::Result\
1823 name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan33c0af02009-04-03 00:10:12 +00001824 p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1825 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001826
1827#define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
1828 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1829 typename p3##_type, typename p4##_type, typename p5##_type, \
1830 typename p6##_type>\
1831 class name##ActionP7 {\
1832 public:\
1833 name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
1834 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1835 p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
1836 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
1837 p6(gmock_p6) {}\
1838 template <typename F>\
1839 class gmock_Impl : public ::testing::ActionInterface<F> {\
1840 public:\
1841 typedef F function_type;\
1842 typedef typename ::testing::internal::Function<F>::Result return_type;\
1843 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1844 args_type;\
1845 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1846 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1847 p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1848 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
1849 virtual return_type Perform(const args_type& args) {\
1850 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1851 Perform(this, args);\
1852 }\
1853 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1854 typename arg3_type, typename arg4_type, typename arg5_type, \
1855 typename arg6_type, typename arg7_type, typename arg8_type, \
1856 typename arg9_type>\
1857 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1858 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1859 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1860 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001861 p0##_type p0;\
1862 p1##_type p1;\
1863 p2##_type p2;\
1864 p3##_type p3;\
1865 p4##_type p4;\
1866 p5##_type p5;\
1867 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001868 private:\
1869 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001870 };\
1871 template <typename F> operator ::testing::Action<F>() const {\
1872 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
1873 p6));\
1874 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001875 p0##_type p0;\
1876 p1##_type p1;\
1877 p2##_type p2;\
1878 p3##_type p3;\
1879 p4##_type p4;\
1880 p5##_type p5;\
1881 p6##_type p6;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001882 private:\
1883 GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
shiqian326aa562009-01-09 21:43:57 +00001884 };\
1885 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1886 typename p3##_type, typename p4##_type, typename p5##_type, \
1887 typename p6##_type>\
1888 inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1889 p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
1890 p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1891 p6##_type p6) {\
1892 return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
1893 p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
1894 }\
1895 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1896 typename p3##_type, typename p4##_type, typename p5##_type, \
1897 typename p6##_type>\
1898 template <typename F>\
1899 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1900 typename arg3_type, typename arg4_type, typename arg5_type, \
1901 typename arg6_type, typename arg7_type, typename arg8_type, \
1902 typename arg9_type>\
1903 typename ::testing::internal::Function<F>::Result\
1904 name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan33c0af02009-04-03 00:10:12 +00001905 p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1906 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001907
1908#define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
1909 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1910 typename p3##_type, typename p4##_type, typename p5##_type, \
1911 typename p6##_type, typename p7##_type>\
1912 class name##ActionP8 {\
1913 public:\
1914 name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
1915 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
1916 p5##_type gmock_p5, p6##_type gmock_p6, \
1917 p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
1918 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
1919 p7(gmock_p7) {}\
1920 template <typename F>\
1921 class gmock_Impl : public ::testing::ActionInterface<F> {\
1922 public:\
1923 typedef F function_type;\
1924 typedef typename ::testing::internal::Function<F>::Result return_type;\
1925 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1926 args_type;\
1927 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
1928 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
1929 p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \
1930 p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \
1931 p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
1932 virtual return_type Perform(const args_type& args) {\
1933 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1934 Perform(this, args);\
1935 }\
1936 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1937 typename arg3_type, typename arg4_type, typename arg5_type, \
1938 typename arg6_type, typename arg7_type, typename arg8_type, \
1939 typename arg9_type>\
1940 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
1941 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
1942 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
1943 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001944 p0##_type p0;\
1945 p1##_type p1;\
1946 p2##_type p2;\
1947 p3##_type p3;\
1948 p4##_type p4;\
1949 p5##_type p5;\
1950 p6##_type p6;\
1951 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001952 private:\
1953 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00001954 };\
1955 template <typename F> operator ::testing::Action<F>() const {\
1956 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
1957 p6, p7));\
1958 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00001959 p0##_type p0;\
1960 p1##_type p1;\
1961 p2##_type p2;\
1962 p3##_type p3;\
1963 p4##_type p4;\
1964 p5##_type p5;\
1965 p6##_type p6;\
1966 p7##_type p7;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00001967 private:\
1968 GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
shiqian326aa562009-01-09 21:43:57 +00001969 };\
1970 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1971 typename p3##_type, typename p4##_type, typename p5##_type, \
1972 typename p6##_type, typename p7##_type>\
1973 inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1974 p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
1975 p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
1976 p6##_type p6, p7##_type p7) {\
1977 return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
1978 p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
1979 p6, p7);\
1980 }\
1981 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1982 typename p3##_type, typename p4##_type, typename p5##_type, \
1983 typename p6##_type, typename p7##_type>\
1984 template <typename F>\
1985 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1986 typename arg3_type, typename arg4_type, typename arg5_type, \
1987 typename arg6_type, typename arg7_type, typename arg8_type, \
1988 typename arg9_type>\
1989 typename ::testing::internal::Function<F>::Result\
1990 name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan33c0af02009-04-03 00:10:12 +00001991 p5##_type, p6##_type, \
1992 p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1993 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00001994
1995#define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
1996 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1997 typename p3##_type, typename p4##_type, typename p5##_type, \
1998 typename p6##_type, typename p7##_type, typename p8##_type>\
1999 class name##ActionP9 {\
2000 public:\
2001 name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
2002 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2003 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2004 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2005 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
2006 p8(gmock_p8) {}\
2007 template <typename F>\
2008 class gmock_Impl : public ::testing::ActionInterface<F> {\
2009 public:\
2010 typedef F function_type;\
2011 typedef typename ::testing::internal::Function<F>::Result return_type;\
2012 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
2013 args_type;\
2014 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2015 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2016 p6##_type gmock_p6, p7##_type gmock_p7, \
2017 p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2018 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2019 p7(gmock_p7), p8(gmock_p8) {}\
2020 virtual return_type Perform(const args_type& args) {\
2021 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
2022 Perform(this, args);\
2023 }\
2024 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2025 typename arg3_type, typename arg4_type, typename arg5_type, \
2026 typename arg6_type, typename arg7_type, typename arg8_type, \
2027 typename arg9_type>\
2028 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
2029 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
2030 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
2031 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00002032 p0##_type p0;\
2033 p1##_type p1;\
2034 p2##_type p2;\
2035 p3##_type p3;\
2036 p4##_type p4;\
2037 p5##_type p5;\
2038 p6##_type p6;\
2039 p7##_type p7;\
2040 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002041 private:\
2042 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00002043 };\
2044 template <typename F> operator ::testing::Action<F>() const {\
2045 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
2046 p6, p7, p8));\
2047 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00002048 p0##_type p0;\
2049 p1##_type p1;\
2050 p2##_type p2;\
2051 p3##_type p3;\
2052 p4##_type p4;\
2053 p5##_type p5;\
2054 p6##_type p6;\
2055 p7##_type p7;\
2056 p8##_type p8;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002057 private:\
2058 GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
shiqian326aa562009-01-09 21:43:57 +00002059 };\
2060 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2061 typename p3##_type, typename p4##_type, typename p5##_type, \
2062 typename p6##_type, typename p7##_type, typename p8##_type>\
2063 inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2064 p4##_type, p5##_type, p6##_type, p7##_type, \
2065 p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2066 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
2067 p8##_type p8) {\
2068 return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
2069 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
2070 p3, p4, p5, p6, p7, p8);\
2071 }\
2072 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2073 typename p3##_type, typename p4##_type, typename p5##_type, \
2074 typename p6##_type, typename p7##_type, typename p8##_type>\
2075 template <typename F>\
2076 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2077 typename arg3_type, typename arg4_type, typename arg5_type, \
2078 typename arg6_type, typename arg7_type, typename arg8_type, \
2079 typename arg9_type>\
2080 typename ::testing::internal::Function<F>::Result\
2081 name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan33c0af02009-04-03 00:10:12 +00002082 p5##_type, p6##_type, p7##_type, \
2083 p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
2084 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00002085
2086#define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
2087 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2088 typename p3##_type, typename p4##_type, typename p5##_type, \
2089 typename p6##_type, typename p7##_type, typename p8##_type, \
2090 typename p9##_type>\
2091 class name##ActionP10 {\
2092 public:\
2093 name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
2094 p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
2095 p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
2096 p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
2097 p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2098 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
2099 template <typename F>\
2100 class gmock_Impl : public ::testing::ActionInterface<F> {\
2101 public:\
2102 typedef F function_type;\
2103 typedef typename ::testing::internal::Function<F>::Result return_type;\
2104 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
2105 args_type;\
2106 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
2107 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
2108 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
2109 p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
2110 p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
2111 p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
2112 virtual return_type Perform(const args_type& args) {\
2113 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
2114 Perform(this, args);\
2115 }\
2116 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2117 typename arg3_type, typename arg4_type, typename arg5_type, \
2118 typename arg6_type, typename arg7_type, typename arg8_type, \
2119 typename arg9_type>\
2120 return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
2121 arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
2122 arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
2123 arg9_type arg9) const;\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00002124 p0##_type p0;\
2125 p1##_type p1;\
2126 p2##_type p2;\
2127 p3##_type p3;\
2128 p4##_type p4;\
2129 p5##_type p5;\
2130 p6##_type p6;\
2131 p7##_type p7;\
2132 p8##_type p8;\
2133 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002134 private:\
2135 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
shiqian326aa562009-01-09 21:43:57 +00002136 };\
2137 template <typename F> operator ::testing::Action<F>() const {\
2138 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
2139 p6, p7, p8, p9));\
2140 }\
zhanyong.wanc069d7f2009-02-02 20:51:53 +00002141 p0##_type p0;\
2142 p1##_type p1;\
2143 p2##_type p2;\
2144 p3##_type p3;\
2145 p4##_type p4;\
2146 p5##_type p5;\
2147 p6##_type p6;\
2148 p7##_type p7;\
2149 p8##_type p8;\
2150 p9##_type p9;\
zhanyong.wan32de5f52009-12-23 00:13:23 +00002151 private:\
2152 GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
shiqian326aa562009-01-09 21:43:57 +00002153 };\
2154 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2155 typename p3##_type, typename p4##_type, typename p5##_type, \
2156 typename p6##_type, typename p7##_type, typename p8##_type, \
2157 typename p9##_type>\
2158 inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2159 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
2160 p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
2161 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
2162 p9##_type p9) {\
2163 return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
2164 p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
2165 p1, p2, p3, p4, p5, p6, p7, p8, p9);\
2166 }\
2167 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2168 typename p3##_type, typename p4##_type, typename p5##_type, \
2169 typename p6##_type, typename p7##_type, typename p8##_type, \
2170 typename p9##_type>\
2171 template <typename F>\
2172 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2173 typename arg3_type, typename arg4_type, typename arg5_type, \
2174 typename arg6_type, typename arg7_type, typename arg8_type, \
2175 typename arg9_type>\
2176 typename ::testing::internal::Function<F>::Result\
2177 name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
zhanyong.wan33c0af02009-04-03 00:10:12 +00002178 p5##_type, p6##_type, p7##_type, p8##_type, \
2179 p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
2180 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
shiqian326aa562009-01-09 21:43:57 +00002181
zhanyong.wane1cdce52009-02-06 01:09:43 +00002182namespace testing {
2183
zhanyong.wan32de5f52009-12-23 00:13:23 +00002184// The ACTION*() macros trigger warning C4100 (unreferenced formal
2185// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
2186// the macro definition, as the warnings are generated when the macro
2187// is expanded and macro expansion cannot contain #pragma. Therefore
2188// we suppress them here.
2189#ifdef _MSC_VER
zhanyong.wan658ac0b2011-02-24 07:29:13 +00002190# pragma warning(push)
2191# pragma warning(disable:4100)
zhanyong.wan32de5f52009-12-23 00:13:23 +00002192#endif
2193
zhanyong.wan16cf4732009-05-14 20:55:30 +00002194// Various overloads for InvokeArgument<N>().
2195//
2196// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
2197// (0-based) argument, which must be a k-ary callable, of the mock
2198// function, with arguments a1, a2, ..., a_k.
2199//
2200// Notes:
2201//
2202// 1. The arguments are passed by value by default. If you need to
2203// pass an argument by reference, wrap it inside ByRef(). For
2204// example,
2205//
2206// InvokeArgument<1>(5, string("Hello"), ByRef(foo))
2207//
2208// passes 5 and string("Hello") by value, and passes foo by
2209// reference.
2210//
2211// 2. If the callable takes an argument by reference but ByRef() is
2212// not used, it will receive the reference to a copy of the value,
2213// instead of the original value. For example, when the 0-th
2214// argument of the mock function takes a const string&, the action
2215//
2216// InvokeArgument<0>(string("Hello"))
2217//
2218// makes a copy of the temporary string("Hello") object and passes a
2219// reference of the copy, instead of the original temporary object,
2220// to the callable. This makes it easy for a user to define an
2221// InvokeArgument action from temporary values and have it performed
2222// later.
zhanyong.wan7f4c2c02009-02-19 22:38:27 +00002223
zhanyong.wan16cf4732009-05-14 20:55:30 +00002224ACTION_TEMPLATE(InvokeArgument,
2225 HAS_1_TEMPLATE_PARAMS(int, k),
2226 AND_0_VALUE_PARAMS()) {
2227 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002228 ::testing::get<k>(args));
zhanyong.wan7f4c2c02009-02-19 22:38:27 +00002229}
2230
zhanyong.wan16cf4732009-05-14 20:55:30 +00002231ACTION_TEMPLATE(InvokeArgument,
2232 HAS_1_TEMPLATE_PARAMS(int, k),
2233 AND_1_VALUE_PARAMS(p0)) {
2234 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002235 ::testing::get<k>(args), p0);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002236}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002237
zhanyong.wan16cf4732009-05-14 20:55:30 +00002238ACTION_TEMPLATE(InvokeArgument,
2239 HAS_1_TEMPLATE_PARAMS(int, k),
2240 AND_2_VALUE_PARAMS(p0, p1)) {
2241 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002242 ::testing::get<k>(args), p0, p1);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002243}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002244
zhanyong.wan16cf4732009-05-14 20:55:30 +00002245ACTION_TEMPLATE(InvokeArgument,
2246 HAS_1_TEMPLATE_PARAMS(int, k),
2247 AND_3_VALUE_PARAMS(p0, p1, p2)) {
2248 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002249 ::testing::get<k>(args), p0, p1, p2);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002250}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002251
zhanyong.wan16cf4732009-05-14 20:55:30 +00002252ACTION_TEMPLATE(InvokeArgument,
2253 HAS_1_TEMPLATE_PARAMS(int, k),
2254 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
2255 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002256 ::testing::get<k>(args), p0, p1, p2, p3);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002257}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002258
zhanyong.wan16cf4732009-05-14 20:55:30 +00002259ACTION_TEMPLATE(InvokeArgument,
2260 HAS_1_TEMPLATE_PARAMS(int, k),
2261 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
2262 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002263 ::testing::get<k>(args), p0, p1, p2, p3, p4);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002264}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002265
zhanyong.wan16cf4732009-05-14 20:55:30 +00002266ACTION_TEMPLATE(InvokeArgument,
2267 HAS_1_TEMPLATE_PARAMS(int, k),
2268 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
2269 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002270 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002271}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002272
zhanyong.wan16cf4732009-05-14 20:55:30 +00002273ACTION_TEMPLATE(InvokeArgument,
2274 HAS_1_TEMPLATE_PARAMS(int, k),
2275 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
2276 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002277 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002278}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002279
zhanyong.wan16cf4732009-05-14 20:55:30 +00002280ACTION_TEMPLATE(InvokeArgument,
2281 HAS_1_TEMPLATE_PARAMS(int, k),
2282 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
2283 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002284 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002285}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002286
zhanyong.wan16cf4732009-05-14 20:55:30 +00002287ACTION_TEMPLATE(InvokeArgument,
2288 HAS_1_TEMPLATE_PARAMS(int, k),
2289 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
2290 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002291 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002292}
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002293
zhanyong.wan16cf4732009-05-14 20:55:30 +00002294ACTION_TEMPLATE(InvokeArgument,
2295 HAS_1_TEMPLATE_PARAMS(int, k),
2296 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
2297 return internal::CallableHelper<return_type>::Call(
kosakbd018832014-04-02 20:30:00 +00002298 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
zhanyong.wan16cf4732009-05-14 20:55:30 +00002299}
zhanyong.wan7f4c2c02009-02-19 22:38:27 +00002300
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002301// Various overloads for ReturnNew<T>().
2302//
2303// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
2304// instance of type T, constructed on the heap with constructor arguments
2305// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
zhanyong.wan16cf4732009-05-14 20:55:30 +00002306ACTION_TEMPLATE(ReturnNew,
2307 HAS_1_TEMPLATE_PARAMS(typename, T),
2308 AND_0_VALUE_PARAMS()) {
2309 return new T();
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002310}
2311
zhanyong.wan16cf4732009-05-14 20:55:30 +00002312ACTION_TEMPLATE(ReturnNew,
2313 HAS_1_TEMPLATE_PARAMS(typename, T),
2314 AND_1_VALUE_PARAMS(p0)) {
2315 return new T(p0);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002316}
2317
zhanyong.wan16cf4732009-05-14 20:55:30 +00002318ACTION_TEMPLATE(ReturnNew,
2319 HAS_1_TEMPLATE_PARAMS(typename, T),
2320 AND_2_VALUE_PARAMS(p0, p1)) {
2321 return new T(p0, p1);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002322}
2323
zhanyong.wan16cf4732009-05-14 20:55:30 +00002324ACTION_TEMPLATE(ReturnNew,
2325 HAS_1_TEMPLATE_PARAMS(typename, T),
2326 AND_3_VALUE_PARAMS(p0, p1, p2)) {
2327 return new T(p0, p1, p2);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002328}
2329
zhanyong.wan16cf4732009-05-14 20:55:30 +00002330ACTION_TEMPLATE(ReturnNew,
2331 HAS_1_TEMPLATE_PARAMS(typename, T),
2332 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
2333 return new T(p0, p1, p2, p3);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002334}
2335
zhanyong.wan16cf4732009-05-14 20:55:30 +00002336ACTION_TEMPLATE(ReturnNew,
2337 HAS_1_TEMPLATE_PARAMS(typename, T),
2338 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
2339 return new T(p0, p1, p2, p3, p4);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002340}
2341
zhanyong.wan16cf4732009-05-14 20:55:30 +00002342ACTION_TEMPLATE(ReturnNew,
2343 HAS_1_TEMPLATE_PARAMS(typename, T),
2344 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
2345 return new T(p0, p1, p2, p3, p4, p5);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002346}
2347
zhanyong.wan16cf4732009-05-14 20:55:30 +00002348ACTION_TEMPLATE(ReturnNew,
2349 HAS_1_TEMPLATE_PARAMS(typename, T),
2350 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
2351 return new T(p0, p1, p2, p3, p4, p5, p6);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002352}
2353
zhanyong.wan16cf4732009-05-14 20:55:30 +00002354ACTION_TEMPLATE(ReturnNew,
2355 HAS_1_TEMPLATE_PARAMS(typename, T),
2356 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
2357 return new T(p0, p1, p2, p3, p4, p5, p6, p7);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002358}
2359
zhanyong.wan16cf4732009-05-14 20:55:30 +00002360ACTION_TEMPLATE(ReturnNew,
2361 HAS_1_TEMPLATE_PARAMS(typename, T),
2362 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
2363 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002364}
2365
zhanyong.wan16cf4732009-05-14 20:55:30 +00002366ACTION_TEMPLATE(ReturnNew,
2367 HAS_1_TEMPLATE_PARAMS(typename, T),
2368 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
2369 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
zhanyong.wan1c8eb1c2009-04-09 07:29:58 +00002370}
2371
zhanyong.wan32de5f52009-12-23 00:13:23 +00002372#ifdef _MSC_VER
zhanyong.wan658ac0b2011-02-24 07:29:13 +00002373# pragma warning(pop)
zhanyong.wan32de5f52009-12-23 00:13:23 +00002374#endif
2375
zhanyong.wane1cdce52009-02-06 01:09:43 +00002376} // namespace testing
2377
shiqiane35fdd92008-12-10 05:08:54 +00002378#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_