1 // This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
3 // Copyright 2007, Google Inc.
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
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
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.
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.
32 // Author: wan@google.com (Zhanyong Wan)
34 // Google Mock - a framework for writing C++ mock classes.
36 // This file implements some commonly used variadic actions.
38 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
39 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
41 #include "gmock/gmock-actions.h"
42 #include "gmock/internal/gmock-port.h"
47 // InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
48 // function or method with the unpacked values, where F is a function
49 // type that takes N arguments.
50 template <typename Result, typename ArgumentTuple>
54 class InvokeHelper<R, ::testing::tuple<> > {
56 template <typename Function>
57 static R Invoke(Function function, const ::testing::tuple<>&) {
61 template <class Class, typename MethodPtr>
62 static R InvokeMethod(Class* obj_ptr,
64 const ::testing::tuple<>&) {
65 return (obj_ptr->*method_ptr)();
69 template <typename R, typename A1>
70 class InvokeHelper<R, ::testing::tuple<A1> > {
72 template <typename Function>
73 static R Invoke(Function function, const ::testing::tuple<A1>& args) {
74 return function(get<0>(args));
77 template <class Class, typename MethodPtr>
78 static R InvokeMethod(Class* obj_ptr,
80 const ::testing::tuple<A1>& args) {
81 return (obj_ptr->*method_ptr)(get<0>(args));
85 template <typename R, typename A1, typename A2>
86 class InvokeHelper<R, ::testing::tuple<A1, A2> > {
88 template <typename Function>
89 static R Invoke(Function function, const ::testing::tuple<A1, A2>& args) {
90 return function(get<0>(args), get<1>(args));
93 template <class Class, typename MethodPtr>
94 static R InvokeMethod(Class* obj_ptr,
96 const ::testing::tuple<A1, A2>& args) {
97 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
101 template <typename R, typename A1, typename A2, typename A3>
102 class InvokeHelper<R, ::testing::tuple<A1, A2, A3> > {
104 template <typename Function>
105 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3>& args) {
106 return function(get<0>(args), get<1>(args), get<2>(args));
109 template <class Class, typename MethodPtr>
110 static R InvokeMethod(Class* obj_ptr,
111 MethodPtr method_ptr,
112 const ::testing::tuple<A1, A2, A3>& args) {
113 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
118 template <typename R, typename A1, typename A2, typename A3, typename A4>
119 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4> > {
121 template <typename Function>
122 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3,
124 return function(get<0>(args), get<1>(args), get<2>(args),
128 template <class Class, typename MethodPtr>
129 static R InvokeMethod(Class* obj_ptr,
130 MethodPtr method_ptr,
131 const ::testing::tuple<A1, A2, A3, A4>& args) {
132 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
133 get<2>(args), get<3>(args));
137 template <typename R, typename A1, typename A2, typename A3, typename A4,
139 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5> > {
141 template <typename Function>
142 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4,
144 return function(get<0>(args), get<1>(args), get<2>(args),
145 get<3>(args), get<4>(args));
148 template <class Class, typename MethodPtr>
149 static R InvokeMethod(Class* obj_ptr,
150 MethodPtr method_ptr,
151 const ::testing::tuple<A1, A2, A3, A4, A5>& args) {
152 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
153 get<2>(args), get<3>(args), get<4>(args));
157 template <typename R, typename A1, typename A2, typename A3, typename A4,
158 typename A5, typename A6>
159 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
161 template <typename Function>
162 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
164 return function(get<0>(args), get<1>(args), get<2>(args),
165 get<3>(args), get<4>(args), get<5>(args));
168 template <class Class, typename MethodPtr>
169 static R InvokeMethod(Class* obj_ptr,
170 MethodPtr method_ptr,
171 const ::testing::tuple<A1, A2, A3, A4, A5, A6>& args) {
172 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
173 get<2>(args), get<3>(args), get<4>(args), get<5>(args));
177 template <typename R, typename A1, typename A2, typename A3, typename A4,
178 typename A5, typename A6, typename A7>
179 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
181 template <typename Function>
182 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
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));
188 template <class Class, typename MethodPtr>
189 static R InvokeMethod(Class* obj_ptr,
190 MethodPtr method_ptr,
191 const ::testing::tuple<A1, A2, A3, A4, A5, A6,
193 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
194 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
199 template <typename R, typename A1, typename A2, typename A3, typename A4,
200 typename A5, typename A6, typename A7, typename A8>
201 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
203 template <typename Function>
204 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
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),
211 template <class Class, typename MethodPtr>
212 static R InvokeMethod(Class* obj_ptr,
213 MethodPtr method_ptr,
214 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7,
216 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
217 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
218 get<6>(args), get<7>(args));
222 template <typename R, typename A1, typename A2, typename A3, typename A4,
223 typename A5, typename A6, typename A7, typename A8, typename A9>
224 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
226 template <typename Function>
227 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
228 A6, A7, A8, A9>& args) {
229 return function(get<0>(args), get<1>(args), get<2>(args),
230 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
231 get<7>(args), get<8>(args));
234 template <class Class, typename MethodPtr>
235 static R InvokeMethod(Class* obj_ptr,
236 MethodPtr method_ptr,
237 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
239 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
240 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
241 get<6>(args), get<7>(args), get<8>(args));
245 template <typename R, typename A1, typename A2, typename A3, typename A4,
246 typename A5, typename A6, typename A7, typename A8, typename A9,
248 class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
251 template <typename Function>
252 static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
253 A6, A7, A8, A9, A10>& args) {
254 return function(get<0>(args), get<1>(args), get<2>(args),
255 get<3>(args), get<4>(args), get<5>(args), get<6>(args),
256 get<7>(args), get<8>(args), get<9>(args));
259 template <class Class, typename MethodPtr>
260 static R InvokeMethod(Class* obj_ptr,
261 MethodPtr method_ptr,
262 const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
264 return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
265 get<2>(args), get<3>(args), get<4>(args), get<5>(args),
266 get<6>(args), get<7>(args), get<8>(args), get<9>(args));
270 // CallableHelper has static methods for invoking "callables",
271 // i.e. function pointers and functors. It uses overloading to
272 // provide a uniform interface for invoking different kinds of
273 // callables. In particular, you can use:
275 // CallableHelper<R>::Call(callable, a1, a2, ..., an)
277 // to invoke an n-ary callable, where R is its return type. If an
278 // argument, say a2, needs to be passed by reference, you should write
279 // ByRef(a2) instead of a2 in the above expression.
280 template <typename R>
281 class CallableHelper {
283 // Calls a nullary callable.
284 template <typename Function>
285 static R Call(Function function) { return function(); }
287 // Calls a unary callable.
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").
297 // Since this function is defined inline, the compiler can get rid
298 // of the copying of the arguments. Therefore the performance won't
300 template <typename Function, typename A1>
301 static R Call(Function function, A1 a1) { return function(a1); }
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);
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);
315 // Calls a 4-ary callable.
316 template <typename Function, typename A1, typename A2, typename A3,
318 static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4) {
319 return function(a1, a2, a3, a4);
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);
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);
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,
341 return function(a1, a2, a3, a4, a5, a6, a7);
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,
349 return function(a1, a2, a3, a4, a5, a6, a7, a8);
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,
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);
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);
369 }; // class CallableHelper
371 // An INTERNAL macro for extracting the type of a tuple field. It's
372 // subject to change without notice - DO NOT USE IN USER CODE!
373 #define GMOCK_FIELD_(Tuple, N) \
374 typename ::testing::tuple_element<N, Tuple>::type
376 // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
377 // type of an n-ary function whose i-th (1-based) argument type is the
378 // k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
379 // type, and whose return type is Result. For example,
380 // SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
381 // is int(bool, long).
383 // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
384 // returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
386 // SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
387 // ::testing::make_tuple(true, 'a', 2.5))
388 // returns tuple (2.5, true).
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.
394 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
395 int k4, int k5, int k6, int k7, int k8, int k9, int k10>
398 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
399 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
400 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
401 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
402 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
403 GMOCK_FIELD_(ArgumentTuple, k10));
404 typedef typename Function<type>::ArgumentTuple SelectedArgs;
405 static SelectedArgs Select(const ArgumentTuple& args) {
406 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
407 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
408 get<k8>(args), get<k9>(args), get<k10>(args));
412 template <typename Result, typename ArgumentTuple>
413 class SelectArgs<Result, ArgumentTuple,
414 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
416 typedef Result type();
417 typedef typename Function<type>::ArgumentTuple SelectedArgs;
418 static SelectedArgs Select(const ArgumentTuple& /* args */) {
419 return SelectedArgs();
423 template <typename Result, typename ArgumentTuple, int k1>
424 class SelectArgs<Result, ArgumentTuple,
425 k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
427 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
428 typedef typename Function<type>::ArgumentTuple SelectedArgs;
429 static SelectedArgs Select(const ArgumentTuple& args) {
430 return SelectedArgs(get<k1>(args));
434 template <typename Result, typename ArgumentTuple, int k1, int k2>
435 class SelectArgs<Result, ArgumentTuple,
436 k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {
438 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
439 GMOCK_FIELD_(ArgumentTuple, k2));
440 typedef typename Function<type>::ArgumentTuple SelectedArgs;
441 static SelectedArgs Select(const ArgumentTuple& args) {
442 return SelectedArgs(get<k1>(args), get<k2>(args));
446 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
447 class SelectArgs<Result, ArgumentTuple,
448 k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {
450 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
451 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
452 typedef typename Function<type>::ArgumentTuple SelectedArgs;
453 static SelectedArgs Select(const ArgumentTuple& args) {
454 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
458 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
460 class SelectArgs<Result, ArgumentTuple,
461 k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {
463 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
464 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
465 GMOCK_FIELD_(ArgumentTuple, k4));
466 typedef typename Function<type>::ArgumentTuple SelectedArgs;
467 static SelectedArgs Select(const ArgumentTuple& args) {
468 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
473 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
475 class SelectArgs<Result, ArgumentTuple,
476 k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {
478 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
479 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
480 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
481 typedef typename Function<type>::ArgumentTuple SelectedArgs;
482 static SelectedArgs Select(const ArgumentTuple& args) {
483 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
484 get<k4>(args), get<k5>(args));
488 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
489 int k4, int k5, int k6>
490 class SelectArgs<Result, ArgumentTuple,
491 k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {
493 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
494 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
495 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
496 GMOCK_FIELD_(ArgumentTuple, k6));
497 typedef typename Function<type>::ArgumentTuple SelectedArgs;
498 static SelectedArgs Select(const ArgumentTuple& args) {
499 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
500 get<k4>(args), get<k5>(args), get<k6>(args));
504 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
505 int k4, int k5, int k6, int k7>
506 class SelectArgs<Result, ArgumentTuple,
507 k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {
509 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
510 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
511 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
512 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
513 typedef typename Function<type>::ArgumentTuple SelectedArgs;
514 static SelectedArgs Select(const ArgumentTuple& args) {
515 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
516 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
520 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
521 int k4, int k5, int k6, int k7, int k8>
522 class SelectArgs<Result, ArgumentTuple,
523 k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {
525 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
526 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
527 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
528 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
529 GMOCK_FIELD_(ArgumentTuple, k8));
530 typedef typename Function<type>::ArgumentTuple SelectedArgs;
531 static SelectedArgs Select(const ArgumentTuple& args) {
532 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
533 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
538 template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
539 int k4, int k5, int k6, int k7, int k8, int k9>
540 class SelectArgs<Result, ArgumentTuple,
541 k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {
543 typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
544 GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
545 GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
546 GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
547 GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
548 typedef typename Function<type>::ArgumentTuple SelectedArgs;
549 static SelectedArgs Select(const ArgumentTuple& args) {
550 return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
551 get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
552 get<k8>(args), get<k9>(args));
558 // Implements the WithArgs action.
559 template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
560 int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
561 int k9 = -1, int k10 = -1>
562 class WithArgsAction {
564 explicit WithArgsAction(const InnerAction& action) : action_(action) {}
566 template <typename F>
567 operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
570 template <typename F>
571 class Impl : public ActionInterface<F> {
573 typedef typename Function<F>::Result Result;
574 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
576 explicit Impl(const InnerAction& action) : action_(action) {}
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));
584 typedef typename SelectArgs<Result, ArgumentTuple,
585 k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
587 Action<InnerFunctionType> action_;
590 const InnerAction action_;
592 GTEST_DISALLOW_ASSIGN_(WithArgsAction);
595 // A macro from the ACTION* family (defined later in this file)
596 // defines an action that can be used in a mock function. Typically,
597 // these actions only care about a subset of the arguments of the mock
598 // function. For example, if such an action only uses the second
599 // argument, it can be used in any mock function that takes >= 2
600 // arguments where the type of the second argument is compatible.
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
609 struct ExcessiveArg {};
611 // A helper class needed for implementing the ACTION* macros.
612 template <typename Result, class Impl>
615 static Result Perform(Impl* impl, const ::testing::tuple<>& args) {
616 return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
617 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
618 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
622 template <typename A0>
623 static Result Perform(Impl* impl, const ::testing::tuple<A0>& args) {
624 return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
625 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
626 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
630 template <typename A0, typename A1>
631 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1>& args) {
632 return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
633 get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
634 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
638 template <typename A0, typename A1, typename A2>
639 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2>& args) {
640 return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
641 get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
642 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
646 template <typename A0, typename A1, typename A2, typename A3>
647 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2,
649 return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
650 get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
651 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
655 template <typename A0, typename A1, typename A2, typename A3, typename A4>
656 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3,
658 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
659 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
660 ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
664 template <typename A0, typename A1, typename A2, typename A3, typename A4,
666 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
668 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
669 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
670 get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
674 template <typename A0, typename A1, typename A2, typename A3, typename A4,
675 typename A5, typename A6>
676 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
678 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
679 get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
680 get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
684 template <typename A0, typename A1, typename A2, typename A3, typename A4,
685 typename A5, typename A6, typename A7>
686 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
688 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
689 A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
690 get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
694 template <typename A0, typename A1, typename A2, typename A3, typename A4,
695 typename A5, typename A6, typename A7, typename A8>
696 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
697 A5, A6, A7, A8>& args) {
698 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
699 A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
700 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
704 template <typename A0, typename A1, typename A2, typename A3, typename A4,
705 typename A5, typename A6, typename A7, typename A8, typename A9>
706 static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
707 A5, A6, A7, A8, A9>& args) {
708 return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
709 A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
710 get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
715 } // namespace internal
717 // Various overloads for Invoke().
719 // WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
720 // the selected arguments of the mock function to an_action and
721 // performs it. It serves as an adaptor between actions with
722 // different argument lists. C++ doesn't support default arguments for
723 // function templates, so we have to overload it.
724 template <int k1, typename InnerAction>
725 inline internal::WithArgsAction<InnerAction, k1>
726 WithArgs(const InnerAction& action) {
727 return internal::WithArgsAction<InnerAction, k1>(action);
730 template <int k1, int k2, typename InnerAction>
731 inline internal::WithArgsAction<InnerAction, k1, k2>
732 WithArgs(const InnerAction& action) {
733 return internal::WithArgsAction<InnerAction, k1, k2>(action);
736 template <int k1, int k2, int k3, typename InnerAction>
737 inline internal::WithArgsAction<InnerAction, k1, k2, k3>
738 WithArgs(const InnerAction& action) {
739 return internal::WithArgsAction<InnerAction, k1, k2, k3>(action);
742 template <int k1, int k2, int k3, int k4, typename InnerAction>
743 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4>
744 WithArgs(const InnerAction& action) {
745 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action);
748 template <int k1, int k2, int k3, int k4, int k5, typename InnerAction>
749 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>
750 WithArgs(const InnerAction& action) {
751 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action);
754 template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>
755 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>
756 WithArgs(const InnerAction& action) {
757 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action);
760 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
761 typename InnerAction>
762 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7>
763 WithArgs(const InnerAction& action) {
764 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,
768 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
769 typename InnerAction>
770 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8>
771 WithArgs(const InnerAction& action) {
772 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,
776 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
777 int k9, typename InnerAction>
778 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9>
779 WithArgs(const InnerAction& action) {
780 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
784 template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
785 int k9, int k10, typename InnerAction>
786 inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
788 WithArgs(const InnerAction& action) {
789 return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
793 // Creates an action that does actions a1, a2, ..., sequentially in
795 template <typename Action1, typename Action2>
796 inline internal::DoBothAction<Action1, Action2>
797 DoAll(Action1 a1, Action2 a2) {
798 return internal::DoBothAction<Action1, Action2>(a1, a2);
801 template <typename Action1, typename Action2, typename Action3>
802 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
804 DoAll(Action1 a1, Action2 a2, Action3 a3) {
805 return DoAll(a1, DoAll(a2, a3));
808 template <typename Action1, typename Action2, typename Action3,
810 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
811 internal::DoBothAction<Action3, Action4> > >
812 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) {
813 return DoAll(a1, DoAll(a2, a3, a4));
816 template <typename Action1, typename Action2, typename Action3,
817 typename Action4, typename Action5>
818 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
819 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
821 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) {
822 return DoAll(a1, DoAll(a2, a3, a4, a5));
825 template <typename Action1, typename Action2, typename Action3,
826 typename Action4, typename Action5, typename Action6>
827 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
828 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
829 internal::DoBothAction<Action5, Action6> > > > >
830 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) {
831 return DoAll(a1, DoAll(a2, a3, a4, a5, a6));
834 template <typename Action1, typename Action2, typename Action3,
835 typename Action4, typename Action5, typename Action6, typename Action7>
836 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
837 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
838 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
840 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
842 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));
845 template <typename Action1, typename Action2, typename Action3,
846 typename Action4, typename Action5, typename Action6, typename Action7,
848 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
849 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
850 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
851 internal::DoBothAction<Action7, Action8> > > > > > >
852 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
853 Action7 a7, Action8 a8) {
854 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));
857 template <typename Action1, typename Action2, typename Action3,
858 typename Action4, typename Action5, typename Action6, typename Action7,
859 typename Action8, typename Action9>
860 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
861 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
862 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
863 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
864 Action9> > > > > > > >
865 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
866 Action7 a7, Action8 a8, Action9 a9) {
867 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));
870 template <typename Action1, typename Action2, typename Action3,
871 typename Action4, typename Action5, typename Action6, typename Action7,
872 typename Action8, typename Action9, typename Action10>
873 inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
874 internal::DoBothAction<Action3, internal::DoBothAction<Action4,
875 internal::DoBothAction<Action5, internal::DoBothAction<Action6,
876 internal::DoBothAction<Action7, internal::DoBothAction<Action8,
877 internal::DoBothAction<Action9, Action10> > > > > > > > >
878 DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
879 Action7 a7, Action8 a8, Action9 a9, Action10 a10) {
880 return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
883 } // namespace testing
885 // The ACTION* family of macros can be used in a namespace scope to
886 // define custom actions easily. The syntax:
888 // ACTION(name) { statements; }
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:
896 // ACTION(IncrementArg1) {
897 // arg1_type temp = arg1;
901 // allows you to write
903 // ...WillOnce(IncrementArg1());
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'.
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.
915 // Sometimes you'll want to parameterize the action. For that you can use
918 // ACTION_P(name, param_name) { statements; }
922 // ACTION_P(Add, n) { return arg0 + n; }
924 // will allow you to write:
926 // ...WillOnce(Add(5));
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
934 // We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support
935 // multi-parameter actions.
937 // For the purpose of typing, you can view
939 // ACTION_Pk(Foo, p1, ..., pk) { ... }
943 // template <typename p1_type, ..., typename pk_type>
944 // FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
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.
953 // You can also overload actions with different numbers of parameters:
955 // ACTION_P(Plus, a) { ... }
956 // ACTION_P2(Plus, a, b) { ... }
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).
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
978 // To learn more about using these macros, please search for 'ACTION'
979 // on http://code.google.com/p/googlemock/wiki/CookBook.
981 // An internal macro needed for implementing ACTION*().
982 #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
983 const args_type& args GTEST_ATTRIBUTE_UNUSED_, \
984 arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \
985 arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \
986 arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \
987 arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \
988 arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \
989 arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \
990 arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \
991 arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \
992 arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \
993 arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
995 // Sometimes you want to give an action explicit template parameters
996 // that cannot be inferred from its value parameters. ACTION() and
997 // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
998 // and can be viewed as an extension to ACTION() and ACTION_P*().
1002 // ACTION_TEMPLATE(ActionName,
1003 // HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
1004 // AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
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
1014 // // DuplicateArg<k, T>(output) converts the k-th argument of the mock
1015 // // function to type T and copies it to *output.
1016 // ACTION_TEMPLATE(DuplicateArg,
1017 // HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
1018 // AND_1_VALUE_PARAMS(output)) {
1019 // *output = T(::testing::get<k>(args));
1023 // EXPECT_CALL(mock, Foo(_, _))
1024 // .WillOnce(DuplicateArg<1, unsigned char>(&n));
1026 // To create an instance of an action template, write:
1028 // ActionName<t1, ..., t_m>(v1, ..., v_n)
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:
1035 // ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
1037 // where u_i is the desired type of v_i.
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
1044 // OverloadedAction<int, bool>(x);
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?
1050 // Implementation notes:
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
1057 // #define ACTION_TEMPLATE(name, template_params, value_params)
1058 // ... GMOCK_INTERNAL_DECL_##template_params ...
1060 // which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
1063 // ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
1065 // Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
1066 // preprocessor will continue to expand it to
1068 // ... typename T ...
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.
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, \
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, \
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
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, \
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, \
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, \
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
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, \
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, \
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
1173 // Initializes the value parameters.
1174 #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
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), \
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), \
1207 #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
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), \
1215 #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
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)
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; \
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; \
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; \
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, \
1260 #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
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
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, \
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, \
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
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, \
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, \
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, \
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, \
1336 #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1338 #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
1341 // The name of the class template implementing the action template.
1342 #define GMOCK_ACTION_CLASS_(name, value_params)\
1343 GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
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) {\
1350 explicit GMOCK_ACTION_CLASS_(name, value_params)\
1351 GMOCK_INTERNAL_INIT_##value_params {}\
1352 template <typename F>\
1353 class gmock_Impl : public ::testing::ActionInterface<F> {\
1355 typedef F function_type;\
1356 typedef typename ::testing::internal::Function<F>::Result return_type;\
1357 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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\
1374 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1376 template <typename F> operator ::testing::Action<F>() const {\
1377 return ::testing::Action<F>(\
1378 new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
1380 GMOCK_INTERNAL_DEFN_##value_params\
1382 GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
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);\
1395 template <GMOCK_INTERNAL_DECL_##template_params\
1396 GMOCK_INTERNAL_DECL_TYPE_##value_params>\
1397 template <typename F>\
1398 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1399 typename arg3_type, typename arg4_type, typename arg5_type, \
1400 typename arg6_type, typename arg7_type, typename arg8_type, \
1401 typename arg9_type>\
1402 typename ::testing::internal::Function<F>::Result\
1403 GMOCK_ACTION_CLASS_(name, value_params)<\
1404 GMOCK_INTERNAL_LIST_##template_params\
1405 GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
1407 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1409 #define ACTION(name)\
1410 class name##Action {\
1413 template <typename F>\
1414 class gmock_Impl : public ::testing::ActionInterface<F> {\
1416 typedef F function_type;\
1417 typedef typename ::testing::internal::Function<F>::Result return_type;\
1418 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1421 virtual return_type Perform(const args_type& args) {\
1422 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1423 Perform(this, args);\
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;\
1434 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1436 template <typename F> operator ::testing::Action<F>() const {\
1437 return ::testing::Action<F>(new gmock_Impl<F>());\
1440 GTEST_DISALLOW_ASSIGN_(name##Action);\
1442 inline name##Action name() {\
1443 return name##Action();\
1445 template <typename F>\
1446 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1447 typename arg3_type, typename arg4_type, typename arg5_type, \
1448 typename arg6_type, typename arg7_type, typename arg8_type, \
1449 typename arg9_type>\
1450 typename ::testing::internal::Function<F>::Result\
1451 name##Action::gmock_Impl<F>::gmock_PerformImpl(\
1452 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1454 #define ACTION_P(name, p0)\
1455 template <typename p0##_type>\
1456 class name##ActionP {\
1458 explicit name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
1459 template <typename F>\
1460 class gmock_Impl : public ::testing::ActionInterface<F> {\
1462 typedef F function_type;\
1463 typedef typename ::testing::internal::Function<F>::Result return_type;\
1464 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
1481 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1483 template <typename F> operator ::testing::Action<F>() const {\
1484 return ::testing::Action<F>(new gmock_Impl<F>(p0));\
1488 GTEST_DISALLOW_ASSIGN_(name##ActionP);\
1490 template <typename p0##_type>\
1491 inline name##ActionP<p0##_type> name(p0##_type p0) {\
1492 return name##ActionP<p0##_type>(p0);\
1494 template <typename p0##_type>\
1495 template <typename F>\
1496 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1497 typename arg3_type, typename arg4_type, typename arg5_type, \
1498 typename arg6_type, typename arg7_type, typename arg8_type, \
1499 typename arg9_type>\
1500 typename ::testing::internal::Function<F>::Result\
1501 name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1502 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1504 #define ACTION_P2(name, p0, p1)\
1505 template <typename p0##_type, typename p1##_type>\
1506 class name##ActionP2 {\
1508 name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1510 template <typename F>\
1511 class gmock_Impl : public ::testing::ActionInterface<F> {\
1513 typedef F function_type;\
1514 typedef typename ::testing::internal::Function<F>::Result return_type;\
1515 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
1517 gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
1519 virtual return_type Perform(const args_type& args) {\
1520 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1521 Perform(this, args);\
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;\
1534 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1536 template <typename F> operator ::testing::Action<F>() const {\
1537 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
1542 GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
1544 template <typename p0##_type, typename p1##_type>\
1545 inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
1547 return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
1549 template <typename p0##_type, typename p1##_type>\
1550 template <typename F>\
1551 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1552 typename arg3_type, typename arg4_type, typename arg5_type, \
1553 typename arg6_type, typename arg7_type, typename arg8_type, \
1554 typename arg9_type>\
1555 typename ::testing::internal::Function<F>::Result\
1556 name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1557 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
1559 #define ACTION_P3(name, p0, p1, p2)\
1560 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1561 class name##ActionP3 {\
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> {\
1568 typedef F function_type;\
1569 typedef typename ::testing::internal::Function<F>::Result return_type;\
1570 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
1590 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1592 template <typename F> operator ::testing::Action<F>() const {\
1593 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
1599 GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
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);\
1606 template <typename p0##_type, typename p1##_type, typename p2##_type>\
1607 template <typename F>\
1608 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1609 typename arg3_type, typename arg4_type, typename arg5_type, \
1610 typename arg6_type, typename arg7_type, typename arg8_type, \
1611 typename arg9_type>\
1612 typename ::testing::internal::Function<F>::Result\
1613 name##ActionP3<p0##_type, p1##_type, \
1614 p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1615 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 {\
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> {\
1628 typedef F function_type;\
1629 typedef typename ::testing::internal::Function<F>::Result return_type;\
1630 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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), \
1635 virtual return_type Perform(const args_type& args) {\
1636 return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
1637 Perform(this, args);\
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;\
1652 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1654 template <typename F> operator ::testing::Action<F>() const {\
1655 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
1662 GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
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, \
1669 return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \
1672 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1673 typename p3##_type>\
1674 template <typename F>\
1675 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1676 typename arg3_type, typename arg4_type, typename arg5_type, \
1677 typename arg6_type, typename arg7_type, typename arg8_type, \
1678 typename arg9_type>\
1679 typename ::testing::internal::Function<F>::Result\
1680 name##ActionP4<p0##_type, p1##_type, p2##_type, \
1681 p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1682 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 {\
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> {\
1696 typedef F function_type;\
1697 typedef typename ::testing::internal::Function<F>::Result return_type;\
1698 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
1721 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1723 template <typename F> operator ::testing::Action<F>() const {\
1724 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
1732 GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
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, \
1739 return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1740 p4##_type>(p0, p1, p2, p3, p4);\
1742 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1743 typename p3##_type, typename p4##_type>\
1744 template <typename F>\
1745 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1746 typename arg3_type, typename arg4_type, typename arg5_type, \
1747 typename arg6_type, typename arg7_type, typename arg8_type, \
1748 typename arg9_type>\
1749 typename ::testing::internal::Function<F>::Result\
1750 name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
1751 p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1752 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 {\
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> {\
1766 typedef F function_type;\
1767 typedef typename ::testing::internal::Function<F>::Result return_type;\
1768 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
1793 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1795 template <typename F> operator ::testing::Action<F>() const {\
1796 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
1805 GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
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);\
1815 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1816 typename p3##_type, typename p4##_type, typename p5##_type>\
1817 template <typename F>\
1818 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1819 typename arg3_type, typename arg4_type, typename arg5_type, \
1820 typename arg6_type, typename arg7_type, typename arg8_type, \
1821 typename arg9_type>\
1822 typename ::testing::internal::Function<F>::Result\
1823 name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1824 p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1825 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 {\
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), \
1838 template <typename F>\
1839 class gmock_Impl : public ::testing::ActionInterface<F> {\
1841 typedef F function_type;\
1842 typedef typename ::testing::internal::Function<F>::Result return_type;\
1843 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
1869 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1871 template <typename F> operator ::testing::Action<F>() const {\
1872 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
1883 GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
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, \
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);\
1895 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1896 typename p3##_type, typename p4##_type, typename p5##_type, \
1897 typename p6##_type>\
1898 template <typename F>\
1899 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1900 typename arg3_type, typename arg4_type, typename arg5_type, \
1901 typename arg6_type, typename arg7_type, typename arg8_type, \
1902 typename arg9_type>\
1903 typename ::testing::internal::Function<F>::Result\
1904 name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1905 p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1906 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 {\
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), \
1920 template <typename F>\
1921 class gmock_Impl : public ::testing::ActionInterface<F> {\
1923 typedef F function_type;\
1924 typedef typename ::testing::internal::Function<F>::Result return_type;\
1925 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
1953 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
1955 template <typename F> operator ::testing::Action<F>() const {\
1956 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
1968 GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
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, \
1981 template <typename p0##_type, typename p1##_type, typename p2##_type, \
1982 typename p3##_type, typename p4##_type, typename p5##_type, \
1983 typename p6##_type, typename p7##_type>\
1984 template <typename F>\
1985 template <typename arg0_type, typename arg1_type, typename arg2_type, \
1986 typename arg3_type, typename arg4_type, typename arg5_type, \
1987 typename arg6_type, typename arg7_type, typename arg8_type, \
1988 typename arg9_type>\
1989 typename ::testing::internal::Function<F>::Result\
1990 name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
1991 p5##_type, p6##_type, \
1992 p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
1993 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 {\
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), \
2007 template <typename F>\
2008 class gmock_Impl : public ::testing::ActionInterface<F> {\
2010 typedef F function_type;\
2011 typedef typename ::testing::internal::Function<F>::Result return_type;\
2012 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
2042 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2044 template <typename F> operator ::testing::Action<F>() const {\
2045 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
2058 GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
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, \
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);\
2072 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2073 typename p3##_type, typename p4##_type, typename p5##_type, \
2074 typename p6##_type, typename p7##_type, typename p8##_type>\
2075 template <typename F>\
2076 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2077 typename arg3_type, typename arg4_type, typename arg5_type, \
2078 typename arg6_type, typename arg7_type, typename arg8_type, \
2079 typename arg9_type>\
2080 typename ::testing::internal::Function<F>::Result\
2081 name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
2082 p5##_type, p6##_type, p7##_type, \
2083 p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
2084 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 {\
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> {\
2102 typedef F function_type;\
2103 typedef typename ::testing::internal::Function<F>::Result return_type;\
2104 typedef typename ::testing::internal::Function<F>::ArgumentTuple\
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);\
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;\
2135 GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
2137 template <typename F> operator ::testing::Action<F>() const {\
2138 return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
2152 GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
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, \
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);\
2167 template <typename p0##_type, typename p1##_type, typename p2##_type, \
2168 typename p3##_type, typename p4##_type, typename p5##_type, \
2169 typename p6##_type, typename p7##_type, typename p8##_type, \
2170 typename p9##_type>\
2171 template <typename F>\
2172 template <typename arg0_type, typename arg1_type, typename arg2_type, \
2173 typename arg3_type, typename arg4_type, typename arg5_type, \
2174 typename arg6_type, typename arg7_type, typename arg8_type, \
2175 typename arg9_type>\
2176 typename ::testing::internal::Function<F>::Result\
2177 name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
2178 p5##_type, p6##_type, p7##_type, p8##_type, \
2179 p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
2180 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
2184 // The ACTION*() macros trigger warning C4100 (unreferenced formal
2185 // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
2186 // the macro definition, as the warnings are generated when the macro
2187 // is expanded and macro expansion cannot contain #pragma. Therefore
2188 // we suppress them here.
2190 # pragma warning(push)
2191 # pragma warning(disable:4100)
2194 // Various overloads for InvokeArgument<N>().
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.
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
2206 // InvokeArgument<1>(5, string("Hello"), ByRef(foo))
2208 // passes 5 and string("Hello") by value, and passes foo by
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
2216 // InvokeArgument<0>(string("Hello"))
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
2224 ACTION_TEMPLATE(InvokeArgument,
2225 HAS_1_TEMPLATE_PARAMS(int, k),
2226 AND_0_VALUE_PARAMS()) {
2227 return internal::CallableHelper<return_type>::Call(
2228 ::testing::get<k>(args));
2231 ACTION_TEMPLATE(InvokeArgument,
2232 HAS_1_TEMPLATE_PARAMS(int, k),
2233 AND_1_VALUE_PARAMS(p0)) {
2234 return internal::CallableHelper<return_type>::Call(
2235 ::testing::get<k>(args), p0);
2238 ACTION_TEMPLATE(InvokeArgument,
2239 HAS_1_TEMPLATE_PARAMS(int, k),
2240 AND_2_VALUE_PARAMS(p0, p1)) {
2241 return internal::CallableHelper<return_type>::Call(
2242 ::testing::get<k>(args), p0, p1);
2245 ACTION_TEMPLATE(InvokeArgument,
2246 HAS_1_TEMPLATE_PARAMS(int, k),
2247 AND_3_VALUE_PARAMS(p0, p1, p2)) {
2248 return internal::CallableHelper<return_type>::Call(
2249 ::testing::get<k>(args), p0, p1, p2);
2252 ACTION_TEMPLATE(InvokeArgument,
2253 HAS_1_TEMPLATE_PARAMS(int, k),
2254 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
2255 return internal::CallableHelper<return_type>::Call(
2256 ::testing::get<k>(args), p0, p1, p2, p3);
2259 ACTION_TEMPLATE(InvokeArgument,
2260 HAS_1_TEMPLATE_PARAMS(int, k),
2261 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
2262 return internal::CallableHelper<return_type>::Call(
2263 ::testing::get<k>(args), p0, p1, p2, p3, p4);
2266 ACTION_TEMPLATE(InvokeArgument,
2267 HAS_1_TEMPLATE_PARAMS(int, k),
2268 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
2269 return internal::CallableHelper<return_type>::Call(
2270 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5);
2273 ACTION_TEMPLATE(InvokeArgument,
2274 HAS_1_TEMPLATE_PARAMS(int, k),
2275 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
2276 return internal::CallableHelper<return_type>::Call(
2277 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
2280 ACTION_TEMPLATE(InvokeArgument,
2281 HAS_1_TEMPLATE_PARAMS(int, k),
2282 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
2283 return internal::CallableHelper<return_type>::Call(
2284 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
2287 ACTION_TEMPLATE(InvokeArgument,
2288 HAS_1_TEMPLATE_PARAMS(int, k),
2289 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
2290 return internal::CallableHelper<return_type>::Call(
2291 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
2294 ACTION_TEMPLATE(InvokeArgument,
2295 HAS_1_TEMPLATE_PARAMS(int, k),
2296 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
2297 return internal::CallableHelper<return_type>::Call(
2298 ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2301 // Various overloads for ReturnNew<T>().
2303 // The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
2304 // instance of type T, constructed on the heap with constructor arguments
2305 // a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
2306 ACTION_TEMPLATE(ReturnNew,
2307 HAS_1_TEMPLATE_PARAMS(typename, T),
2308 AND_0_VALUE_PARAMS()) {
2312 ACTION_TEMPLATE(ReturnNew,
2313 HAS_1_TEMPLATE_PARAMS(typename, T),
2314 AND_1_VALUE_PARAMS(p0)) {
2318 ACTION_TEMPLATE(ReturnNew,
2319 HAS_1_TEMPLATE_PARAMS(typename, T),
2320 AND_2_VALUE_PARAMS(p0, p1)) {
2321 return new T(p0, p1);
2324 ACTION_TEMPLATE(ReturnNew,
2325 HAS_1_TEMPLATE_PARAMS(typename, T),
2326 AND_3_VALUE_PARAMS(p0, p1, p2)) {
2327 return new T(p0, p1, p2);
2330 ACTION_TEMPLATE(ReturnNew,
2331 HAS_1_TEMPLATE_PARAMS(typename, T),
2332 AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
2333 return new T(p0, p1, p2, p3);
2336 ACTION_TEMPLATE(ReturnNew,
2337 HAS_1_TEMPLATE_PARAMS(typename, T),
2338 AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
2339 return new T(p0, p1, p2, p3, p4);
2342 ACTION_TEMPLATE(ReturnNew,
2343 HAS_1_TEMPLATE_PARAMS(typename, T),
2344 AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
2345 return new T(p0, p1, p2, p3, p4, p5);
2348 ACTION_TEMPLATE(ReturnNew,
2349 HAS_1_TEMPLATE_PARAMS(typename, T),
2350 AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
2351 return new T(p0, p1, p2, p3, p4, p5, p6);
2354 ACTION_TEMPLATE(ReturnNew,
2355 HAS_1_TEMPLATE_PARAMS(typename, T),
2356 AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
2357 return new T(p0, p1, p2, p3, p4, p5, p6, p7);
2360 ACTION_TEMPLATE(ReturnNew,
2361 HAS_1_TEMPLATE_PARAMS(typename, T),
2362 AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
2363 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
2366 ACTION_TEMPLATE(ReturnNew,
2367 HAS_1_TEMPLATE_PARAMS(typename, T),
2368 AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
2369 return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2373 # pragma warning(pop)
2376 } // namespace testing
2378 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_