Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gmock-generated-actions.h
Go to the documentation of this file.
1 // This file was GENERATED by command:
2 // pump.py gmock-generated-actions.h.pump
3 // DO NOT EDIT BY HAND!!!
4 
5 // Copyright 2007, Google Inc.
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following disclaimer
16 // in the documentation and/or other materials provided with the
17 // distribution.
18 // * Neither the name of Google Inc. nor the names of its
19 // contributors may be used to endorse or promote products derived from
20 // this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 
35 // Google Mock - a framework for writing C++ mock classes.
36 //
37 // This file implements some commonly used variadic actions.
38 
39 // GOOGLETEST_CM0002 DO NOT DELETE
40 
41 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
42 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
43 
44 #include <memory>
45 #include <utility>
46 
47 #include "gmock/gmock-actions.h"
49 
50 
51 // Sometimes you want to give an action explicit template parameters
52 // that cannot be inferred from its value parameters. ACTION() and
53 // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
54 // and can be viewed as an extension to ACTION() and ACTION_P*().
55 //
56 // The syntax:
57 //
58 // ACTION_TEMPLATE(ActionName,
59 // HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
60 // AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
61 //
62 // defines an action template that takes m explicit template
63 // parameters and n value parameters. name_i is the name of the i-th
64 // template parameter, and kind_i specifies whether it's a typename,
65 // an integral constant, or a template. p_i is the name of the i-th
66 // value parameter.
67 //
68 // Example:
69 //
70 // // DuplicateArg<k, T>(output) converts the k-th argument of the mock
71 // // function to type T and copies it to *output.
72 // ACTION_TEMPLATE(DuplicateArg,
73 // HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
74 // AND_1_VALUE_PARAMS(output)) {
75 // *output = T(::std::get<k>(args));
76 // }
77 // ...
78 // int n;
79 // EXPECT_CALL(mock, Foo(_, _))
80 // .WillOnce(DuplicateArg<1, unsigned char>(&n));
81 //
82 // To create an instance of an action template, write:
83 //
84 // ActionName<t1, ..., t_m>(v1, ..., v_n)
85 //
86 // where the ts are the template arguments and the vs are the value
87 // arguments. The value argument types are inferred by the compiler.
88 // If you want to explicitly specify the value argument types, you can
89 // provide additional template arguments:
90 //
91 // ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
92 //
93 // where u_i is the desired type of v_i.
94 //
95 // ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
96 // number of value parameters, but not on the number of template
97 // parameters. Without the restriction, the meaning of the following
98 // is unclear:
99 //
100 // OverloadedAction<int, bool>(x);
101 //
102 // Are we using a single-template-parameter action where 'bool' refers
103 // to the type of x, or are we using a two-template-parameter action
104 // where the compiler is asked to infer the type of x?
105 //
106 // Implementation notes:
107 //
108 // GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
109 // GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
110 // implementing ACTION_TEMPLATE. The main trick we use is to create
111 // new macro invocations when expanding a macro. For example, we have
112 //
113 // #define ACTION_TEMPLATE(name, template_params, value_params)
114 // ... GMOCK_INTERNAL_DECL_##template_params ...
115 //
116 // which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
117 // to expand to
118 //
119 // ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
120 //
121 // Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
122 // preprocessor will continue to expand it to
123 //
124 // ... typename T ...
125 //
126 // This technique conforms to the C++ standard and is portable. It
127 // allows us to implement action templates using O(N) code, where N is
128 // the maximum number of template/value parameters supported. Without
129 // using it, we'd have to devote O(N^2) amount of code to implement all
130 // combinations of m and n.
131 
132 // Declares the template parameters.
133 #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
134 #define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
135  name1) kind0 name0, kind1 name1
136 #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
137  kind2, name2) kind0 name0, kind1 name1, kind2 name2
138 #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
139  kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
140  kind3 name3
141 #define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
142  kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
143  kind2 name2, kind3 name3, kind4 name4
144 #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
145  kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
146  kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
147 #define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
148  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
149  name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
150  kind5 name5, kind6 name6
151 #define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
152  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
153  kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
154  kind4 name4, kind5 name5, kind6 name6, kind7 name7
155 #define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
156  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
157  kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
158  kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
159  kind8 name8
160 #define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
161  name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
162  name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
163  kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
164  kind6 name6, kind7 name7, kind8 name8, kind9 name9
165 
166 // Lists the template parameters.
167 #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
168 #define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
169  name1) name0, name1
170 #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
171  kind2, name2) name0, name1, name2
172 #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
173  kind2, name2, kind3, name3) name0, name1, name2, name3
174 #define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
175  kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
176  name4
177 #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
178  kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
179  name2, name3, name4, name5
180 #define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
181  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
182  name6) name0, name1, name2, name3, name4, name5, name6
183 #define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
184  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
185  kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
186 #define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
187  kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
188  kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
189  name6, name7, name8
190 #define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
191  name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
192  name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
193  name3, name4, name5, name6, name7, name8, name9
194 
195 // Declares the types of value parameters.
196 #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
197 #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
198 #define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
199  typename p0##_type, typename p1##_type
200 #define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
201  typename p0##_type, typename p1##_type, typename p2##_type
202 #define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
203  typename p0##_type, typename p1##_type, typename p2##_type, \
204  typename p3##_type
205 #define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
206  typename p0##_type, typename p1##_type, typename p2##_type, \
207  typename p3##_type, typename p4##_type
208 #define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
209  typename p0##_type, typename p1##_type, typename p2##_type, \
210  typename p3##_type, typename p4##_type, typename p5##_type
211 #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
212  p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
213  typename p3##_type, typename p4##_type, typename p5##_type, \
214  typename p6##_type
215 #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
216  p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
217  typename p3##_type, typename p4##_type, typename p5##_type, \
218  typename p6##_type, typename p7##_type
219 #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
220  p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
221  typename p3##_type, typename p4##_type, typename p5##_type, \
222  typename p6##_type, typename p7##_type, typename p8##_type
223 #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
224  p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
225  typename p2##_type, typename p3##_type, typename p4##_type, \
226  typename p5##_type, typename p6##_type, typename p7##_type, \
227  typename p8##_type, typename p9##_type
228 
229 // Initializes the value parameters.
230 #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
231  ()
232 #define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
233  (p0##_type gmock_p0) : p0(::std::move(gmock_p0))
234 #define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
235  (p0##_type gmock_p0, p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \
236  p1(::std::move(gmock_p1))
237 #define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
238  (p0##_type gmock_p0, p1##_type gmock_p1, \
239  p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \
240  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2))
241 #define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
242  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
243  p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \
244  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
245  p3(::std::move(gmock_p3))
246 #define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
247  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
248  p3##_type gmock_p3, p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \
249  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
250  p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4))
251 #define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
252  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
253  p3##_type gmock_p3, p4##_type gmock_p4, \
254  p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \
255  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
256  p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
257  p5(::std::move(gmock_p5))
258 #define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
259  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
260  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
261  p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \
262  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
263  p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
264  p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6))
265 #define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
266  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
267  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
268  p6##_type gmock_p6, p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \
269  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
270  p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
271  p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
272  p7(::std::move(gmock_p7))
273 #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
274  p7, p8)\
275  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
276  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
277  p6##_type gmock_p6, p7##_type gmock_p7, \
278  p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \
279  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
280  p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
281  p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
282  p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8))
283 #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
284  p7, p8, p9)\
285  (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
286  p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
287  p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
288  p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \
289  p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
290  p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
291  p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
292  p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \
293  p9(::std::move(gmock_p9))
294 
295 // Declares the fields for storing the value parameters.
296 #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
297 #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
298 #define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
299  p1##_type p1;
300 #define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
301  p1##_type p1; p2##_type p2;
302 #define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
303  p1##_type p1; p2##_type p2; p3##_type p3;
304 #define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
305  p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
306 #define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
307  p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
308  p5##_type p5;
309 #define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
310  p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
311  p5##_type p5; p6##_type p6;
312 #define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
313  p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
314  p5##_type p5; p6##_type p6; p7##_type p7;
315 #define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
316  p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
317  p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
318 #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
319  p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
320  p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
321  p9##_type p9;
322 
323 // Lists the value parameters.
324 #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
325 #define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
326 #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
327 #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
328 #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
329 #define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
330  p2, p3, p4
331 #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
332  p1, p2, p3, p4, p5
333 #define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
334  p6) p0, p1, p2, p3, p4, p5, p6
335 #define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
336  p7) p0, p1, p2, p3, p4, p5, p6, p7
337 #define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
338  p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
339 #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
340  p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
341 
342 // Lists the value parameter types.
343 #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
344 #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
345 #define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
346  p1##_type
347 #define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
348  p1##_type, p2##_type
349 #define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
350  p0##_type, p1##_type, p2##_type, p3##_type
351 #define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
352  p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
353 #define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
354  p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
355 #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
356  p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
357  p6##_type
358 #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
359  p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
360  p5##_type, p6##_type, p7##_type
361 #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
362  p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
363  p5##_type, p6##_type, p7##_type, p8##_type
364 #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
365  p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
366  p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
367 
368 // Declares the value parameters.
369 #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
370 #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
371 #define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
372  p1##_type p1
373 #define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
374  p1##_type p1, p2##_type p2
375 #define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
376  p1##_type p1, p2##_type p2, p3##_type p3
377 #define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
378  p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
379 #define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
380  p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
381  p5##_type p5
382 #define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
383  p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
384  p5##_type p5, p6##_type p6
385 #define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
386  p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
387  p5##_type p5, p6##_type p6, p7##_type p7
388 #define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
389  p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
390  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
391 #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
392  p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
393  p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
394  p9##_type p9
395 
396 // The suffix of the class template implementing the action template.
397 #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
398 #define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
399 #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
400 #define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
401 #define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
402 #define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
403 #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
404 #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
405 #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
406  p7) P8
407 #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
408  p7, p8) P9
409 #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
410  p7, p8, p9) P10
411 
412 // The name of the class template implementing the action template.
413 #define GMOCK_ACTION_CLASS_(name, value_params)\
414  GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
415 
416 #define ACTION_TEMPLATE(name, template_params, value_params)\
417  template <GMOCK_INTERNAL_DECL_##template_params\
418  GMOCK_INTERNAL_DECL_TYPE_##value_params>\
419  class GMOCK_ACTION_CLASS_(name, value_params) {\
420  public:\
421  explicit GMOCK_ACTION_CLASS_(name, value_params)\
422  GMOCK_INTERNAL_INIT_##value_params {}\
423  template <typename F>\
424  class gmock_Impl : public ::testing::ActionInterface<F> {\
425  public:\
426  typedef F function_type;\
427  typedef typename ::testing::internal::Function<F>::Result return_type;\
428  typedef typename ::testing::internal::Function<F>::ArgumentTuple\
429  args_type;\
430  explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
431  return_type Perform(const args_type& args) override {\
432  return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
433  Perform(this, args);\
434  }\
435  template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\
436  return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\
437  GMOCK_INTERNAL_DEFN_##value_params\
438  };\
439  template <typename F> operator ::testing::Action<F>() const {\
440  return ::testing::Action<F>(\
441  new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
442  }\
443  GMOCK_INTERNAL_DEFN_##value_params\
444  };\
445  template <GMOCK_INTERNAL_DECL_##template_params\
446  GMOCK_INTERNAL_DECL_TYPE_##value_params>\
447  inline GMOCK_ACTION_CLASS_(name, value_params)<\
448  GMOCK_INTERNAL_LIST_##template_params\
449  GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
450  GMOCK_INTERNAL_DECL_##value_params) {\
451  return GMOCK_ACTION_CLASS_(name, value_params)<\
452  GMOCK_INTERNAL_LIST_##template_params\
453  GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
454  GMOCK_INTERNAL_LIST_##value_params);\
455  }\
456  template <GMOCK_INTERNAL_DECL_##template_params\
457  GMOCK_INTERNAL_DECL_TYPE_##value_params>\
458  template <typename F>\
459  template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\
460  typename ::testing::internal::Function<F>::Result\
461  GMOCK_ACTION_CLASS_(name, value_params)<\
462  GMOCK_INTERNAL_LIST_##template_params\
463  GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
464  gmock_PerformImpl(\
465  GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
466 
467 
468 namespace testing {
469 
470 
471 // The ACTION*() macros trigger warning C4100 (unreferenced formal
472 // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
473 // the macro definition, as the warnings are generated when the macro
474 // is expanded and macro expansion cannot contain #pragma. Therefore
475 // we suppress them here.
476 #ifdef _MSC_VER
477 # pragma warning(push)
478 # pragma warning(disable:4100)
479 #endif
480 
481 // Various overloads for InvokeArgument<N>().
482 //
483 // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
484 // (0-based) argument, which must be a k-ary callable, of the mock
485 // function, with arguments a1, a2, ..., a_k.
486 //
487 // Notes:
488 //
489 // 1. The arguments are passed by value by default. If you need to
490 // pass an argument by reference, wrap it inside ByRef(). For
491 // example,
492 //
493 // InvokeArgument<1>(5, string("Hello"), ByRef(foo))
494 //
495 // passes 5 and string("Hello") by value, and passes foo by
496 // reference.
497 //
498 // 2. If the callable takes an argument by reference but ByRef() is
499 // not used, it will receive the reference to a copy of the value,
500 // instead of the original value. For example, when the 0-th
501 // argument of the mock function takes a const string&, the action
502 //
503 // InvokeArgument<0>(string("Hello"))
504 //
505 // makes a copy of the temporary string("Hello") object and passes a
506 // reference of the copy, instead of the original temporary object,
507 // to the callable. This makes it easy for a user to define an
508 // InvokeArgument action from temporary values and have it performed
509 // later.
510 
511 ACTION_TEMPLATE(InvokeArgument,
512  HAS_1_TEMPLATE_PARAMS(int, k),
513  AND_0_VALUE_PARAMS()) {
516  ::std::get<k>(args));
517 }
518 
519 ACTION_TEMPLATE(InvokeArgument,
520  HAS_1_TEMPLATE_PARAMS(int, k),
521  AND_1_VALUE_PARAMS(p0)) {
524  ::std::get<k>(args), p0);
525 }
526 
527 ACTION_TEMPLATE(InvokeArgument,
528  HAS_1_TEMPLATE_PARAMS(int, k),
529  AND_2_VALUE_PARAMS(p0, p1)) {
532  ::std::get<k>(args), p0, p1);
533 }
534 
535 ACTION_TEMPLATE(InvokeArgument,
536  HAS_1_TEMPLATE_PARAMS(int, k),
537  AND_3_VALUE_PARAMS(p0, p1, p2)) {
540  ::std::get<k>(args), p0, p1, p2);
541 }
542 
543 ACTION_TEMPLATE(InvokeArgument,
544  HAS_1_TEMPLATE_PARAMS(int, k),
545  AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
548  ::std::get<k>(args), p0, p1, p2, p3);
549 }
550 
551 ACTION_TEMPLATE(InvokeArgument,
552  HAS_1_TEMPLATE_PARAMS(int, k),
553  AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
556  ::std::get<k>(args), p0, p1, p2, p3, p4);
557 }
558 
559 ACTION_TEMPLATE(InvokeArgument,
560  HAS_1_TEMPLATE_PARAMS(int, k),
561  AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
564  ::std::get<k>(args), p0, p1, p2, p3, p4, p5);
565 }
566 
567 ACTION_TEMPLATE(InvokeArgument,
568  HAS_1_TEMPLATE_PARAMS(int, k),
569  AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
572  ::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
573 }
574 
575 ACTION_TEMPLATE(InvokeArgument,
576  HAS_1_TEMPLATE_PARAMS(int, k),
577  AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
580  ::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
581 }
582 
583 ACTION_TEMPLATE(InvokeArgument,
584  HAS_1_TEMPLATE_PARAMS(int, k),
585  AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
588  ::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7,
589  p8);
590 }
591 
592 ACTION_TEMPLATE(InvokeArgument,
593  HAS_1_TEMPLATE_PARAMS(int, k),
594  AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
597  ::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7,
598  p8, p9);
599 }
600 
601 #ifdef _MSC_VER
602 # pragma warning(pop)
603 #endif
604 
605 } // namespace testing
606 
607 // Include any custom callback actions added by the local installation.
608 // We must include this header at the end to make sure it can use the
609 // declarations from this file.
611 
612 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
auto InvokeArgumentAdl(AdlTag, F f, Args...args) -> decltype(f(args...))
ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_0_VALUE_PARAMS())