]> git.proxmox.com Git - ceph.git/blob - ceph/src/googletest/googlemock/include/gmock/gmock-generated-actions.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / googletest / googlemock / include / gmock / gmock-generated-actions.h
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"
48 #include "gmock/internal/gmock-port.h"
49
50 // Include any custom callback actions added by the local installation.
51 #include "gmock/internal/custom/gmock-generated-actions.h"
52
53 // Sometimes you want to give an action explicit template parameters
54 // that cannot be inferred from its value parameters. ACTION() and
55 // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
56 // and can be viewed as an extension to ACTION() and ACTION_P*().
57 //
58 // The syntax:
59 //
60 // ACTION_TEMPLATE(ActionName,
61 // HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
62 // AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
63 //
64 // defines an action template that takes m explicit template
65 // parameters and n value parameters. name_i is the name of the i-th
66 // template parameter, and kind_i specifies whether it's a typename,
67 // an integral constant, or a template. p_i is the name of the i-th
68 // value parameter.
69 //
70 // Example:
71 //
72 // // DuplicateArg<k, T>(output) converts the k-th argument of the mock
73 // // function to type T and copies it to *output.
74 // ACTION_TEMPLATE(DuplicateArg,
75 // HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
76 // AND_1_VALUE_PARAMS(output)) {
77 // *output = T(::std::get<k>(args));
78 // }
79 // ...
80 // int n;
81 // EXPECT_CALL(mock, Foo(_, _))
82 // .WillOnce(DuplicateArg<1, unsigned char>(&n));
83 //
84 // To create an instance of an action template, write:
85 //
86 // ActionName<t1, ..., t_m>(v1, ..., v_n)
87 //
88 // where the ts are the template arguments and the vs are the value
89 // arguments. The value argument types are inferred by the compiler.
90 // If you want to explicitly specify the value argument types, you can
91 // provide additional template arguments:
92 //
93 // ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
94 //
95 // where u_i is the desired type of v_i.
96 //
97 // ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
98 // number of value parameters, but not on the number of template
99 // parameters. Without the restriction, the meaning of the following
100 // is unclear:
101 //
102 // OverloadedAction<int, bool>(x);
103 //
104 // Are we using a single-template-parameter action where 'bool' refers
105 // to the type of x, or are we using a two-template-parameter action
106 // where the compiler is asked to infer the type of x?
107 //
108 // Implementation notes:
109 //
110 // GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
111 // GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
112 // implementing ACTION_TEMPLATE. The main trick we use is to create
113 // new macro invocations when expanding a macro. For example, we have
114 //
115 // #define ACTION_TEMPLATE(name, template_params, value_params)
116 // ... GMOCK_INTERNAL_DECL_##template_params ...
117 //
118 // which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
119 // to expand to
120 //
121 // ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
122 //
123 // Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
124 // preprocessor will continue to expand it to
125 //
126 // ... typename T ...
127 //
128 // This technique conforms to the C++ standard and is portable. It
129 // allows us to implement action templates using O(N) code, where N is
130 // the maximum number of template/value parameters supported. Without
131 // using it, we'd have to devote O(N^2) amount of code to implement all
132 // combinations of m and n.
133
134 // Declares the template parameters.
135 #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
136 #define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
137 name1) kind0 name0, kind1 name1
138 #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
139 kind2, name2) kind0 name0, kind1 name1, kind2 name2
140 #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
141 kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
142 kind3 name3
143 #define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
144 kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
145 kind2 name2, kind3 name3, kind4 name4
146 #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
147 kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
148 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
149 #define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
150 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
151 name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
152 kind5 name5, kind6 name6
153 #define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
154 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
155 kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
156 kind4 name4, kind5 name5, kind6 name6, kind7 name7
157 #define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
158 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
159 kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
160 kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
161 kind8 name8
162 #define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
163 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
164 name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
165 kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
166 kind6 name6, kind7 name7, kind8 name8, kind9 name9
167
168 // Lists the template parameters.
169 #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
170 #define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
171 name1) name0, name1
172 #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
173 kind2, name2) name0, name1, name2
174 #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
175 kind2, name2, kind3, name3) name0, name1, name2, name3
176 #define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
177 kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
178 name4
179 #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
180 kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
181 name2, name3, name4, name5
182 #define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
183 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
184 name6) name0, name1, name2, name3, name4, name5, name6
185 #define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
186 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
187 kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
188 #define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
189 kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
190 kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
191 name6, name7, name8
192 #define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
193 name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
194 name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
195 name3, name4, name5, name6, name7, name8, name9
196
197 // Declares the types of value parameters.
198 #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
199 #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
200 #define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
201 typename p0##_type, typename p1##_type
202 #define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
203 typename p0##_type, typename p1##_type, typename p2##_type
204 #define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
205 typename p0##_type, typename p1##_type, typename p2##_type, \
206 typename p3##_type
207 #define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
208 typename p0##_type, typename p1##_type, typename p2##_type, \
209 typename p3##_type, typename p4##_type
210 #define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
211 typename p0##_type, typename p1##_type, typename p2##_type, \
212 typename p3##_type, typename p4##_type, typename p5##_type
213 #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
214 p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
215 typename p3##_type, typename p4##_type, typename p5##_type, \
216 typename p6##_type
217 #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
218 p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
219 typename p3##_type, typename p4##_type, typename p5##_type, \
220 typename p6##_type, typename p7##_type
221 #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
222 p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
223 typename p3##_type, typename p4##_type, typename p5##_type, \
224 typename p6##_type, typename p7##_type, typename p8##_type
225 #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
226 p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
227 typename p2##_type, typename p3##_type, typename p4##_type, \
228 typename p5##_type, typename p6##_type, typename p7##_type, \
229 typename p8##_type, typename p9##_type
230
231 // Initializes the value parameters.
232 #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
233 ()
234 #define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
235 (p0##_type gmock_p0) : p0(::std::move(gmock_p0))
236 #define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
237 (p0##_type gmock_p0, p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \
238 p1(::std::move(gmock_p1))
239 #define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
240 (p0##_type gmock_p0, p1##_type gmock_p1, \
241 p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \
242 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2))
243 #define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
244 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
245 p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \
246 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
247 p3(::std::move(gmock_p3))
248 #define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
249 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
250 p3##_type gmock_p3, p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \
251 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
252 p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4))
253 #define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
254 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
255 p3##_type gmock_p3, p4##_type gmock_p4, \
256 p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \
257 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
258 p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
259 p5(::std::move(gmock_p5))
260 #define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
261 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
262 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
263 p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \
264 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
265 p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
266 p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6))
267 #define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
268 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
269 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
270 p6##_type gmock_p6, p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \
271 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
272 p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
273 p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
274 p7(::std::move(gmock_p7))
275 #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
276 p7, p8)\
277 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
278 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
279 p6##_type gmock_p6, p7##_type gmock_p7, \
280 p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \
281 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
282 p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
283 p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
284 p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8))
285 #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
286 p7, p8, p9)\
287 (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
288 p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
289 p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
290 p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \
291 p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
292 p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
293 p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
294 p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \
295 p9(::std::move(gmock_p9))
296
297 // Defines the copy constructor
298 #define GMOCK_INTERNAL_DEFN_COPY_AND_0_VALUE_PARAMS() \
299 noexcept {} // Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82134
300 #define GMOCK_INTERNAL_DEFN_COPY_AND_1_VALUE_PARAMS(...) = default;
301 #define GMOCK_INTERNAL_DEFN_COPY_AND_2_VALUE_PARAMS(...) = default;
302 #define GMOCK_INTERNAL_DEFN_COPY_AND_3_VALUE_PARAMS(...) = default;
303 #define GMOCK_INTERNAL_DEFN_COPY_AND_4_VALUE_PARAMS(...) = default;
304 #define GMOCK_INTERNAL_DEFN_COPY_AND_5_VALUE_PARAMS(...) = default;
305 #define GMOCK_INTERNAL_DEFN_COPY_AND_6_VALUE_PARAMS(...) = default;
306 #define GMOCK_INTERNAL_DEFN_COPY_AND_7_VALUE_PARAMS(...) = default;
307 #define GMOCK_INTERNAL_DEFN_COPY_AND_8_VALUE_PARAMS(...) = default;
308 #define GMOCK_INTERNAL_DEFN_COPY_AND_9_VALUE_PARAMS(...) = default;
309 #define GMOCK_INTERNAL_DEFN_COPY_AND_10_VALUE_PARAMS(...) = default;
310
311 // Declares the fields for storing the value parameters.
312 #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
313 #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
314 #define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
315 p1##_type p1;
316 #define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
317 p1##_type p1; p2##_type p2;
318 #define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
319 p1##_type p1; p2##_type p2; p3##_type p3;
320 #define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
321 p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
322 #define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
323 p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
324 p5##_type p5;
325 #define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
326 p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
327 p5##_type p5; p6##_type p6;
328 #define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
329 p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
330 p5##_type p5; p6##_type p6; p7##_type p7;
331 #define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
332 p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
333 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
334 #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
335 p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
336 p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
337 p9##_type p9;
338
339 // Lists the value parameters.
340 #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
341 #define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
342 #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
343 #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
344 #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
345 #define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
346 p2, p3, p4
347 #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
348 p1, p2, p3, p4, p5
349 #define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
350 p6) p0, p1, p2, p3, p4, p5, p6
351 #define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
352 p7) p0, p1, p2, p3, p4, p5, p6, p7
353 #define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
354 p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
355 #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
356 p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
357
358 // Lists the value parameter types.
359 #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
360 #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
361 #define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
362 p1##_type
363 #define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
364 p1##_type, p2##_type
365 #define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
366 p0##_type, p1##_type, p2##_type, p3##_type
367 #define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
368 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
369 #define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
370 p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
371 #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
372 p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
373 p6##_type
374 #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
375 p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
376 p5##_type, p6##_type, p7##_type
377 #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
378 p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
379 p5##_type, p6##_type, p7##_type, p8##_type
380 #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
381 p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
382 p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
383
384 // Declares the value parameters.
385 #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
386 #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
387 #define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
388 p1##_type p1
389 #define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
390 p1##_type p1, p2##_type p2
391 #define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
392 p1##_type p1, p2##_type p2, p3##_type p3
393 #define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
394 p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
395 #define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
396 p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
397 p5##_type p5
398 #define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
399 p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
400 p5##_type p5, p6##_type p6
401 #define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
402 p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
403 p5##_type p5, p6##_type p6, p7##_type p7
404 #define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
405 p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
406 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
407 #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
408 p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
409 p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
410 p9##_type p9
411
412 // The suffix of the class template implementing the action template.
413 #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
414 #define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
415 #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
416 #define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
417 #define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
418 #define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
419 #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
420 #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
421 #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
422 p7) P8
423 #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
424 p7, p8) P9
425 #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
426 p7, p8, p9) P10
427
428 // The name of the class template implementing the action template.
429 #define GMOCK_ACTION_CLASS_(name, value_params)\
430 GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
431
432 #define ACTION_TEMPLATE(name, template_params, value_params) \
433 template <GMOCK_INTERNAL_DECL_##template_params \
434 GMOCK_INTERNAL_DECL_TYPE_##value_params> \
435 class GMOCK_ACTION_CLASS_(name, value_params) { \
436 public: \
437 explicit GMOCK_ACTION_CLASS_(name, value_params)( \
438 GMOCK_INTERNAL_DECL_##value_params) \
439 GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
440 = default; , \
441 : impl_(std::make_shared<gmock_Impl>( \
442 GMOCK_INTERNAL_LIST_##value_params)) { }) \
443 GMOCK_ACTION_CLASS_(name, value_params)( \
444 const GMOCK_ACTION_CLASS_(name, value_params)&) \
445 GMOCK_INTERNAL_DEFN_COPY_##value_params \
446 GMOCK_ACTION_CLASS_(name, value_params)( \
447 GMOCK_ACTION_CLASS_(name, value_params)&&) \
448 GMOCK_INTERNAL_DEFN_COPY_##value_params \
449 template <typename F> \
450 operator ::testing::Action<F>() const { \
451 return GMOCK_PP_IF( \
452 GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
453 (::testing::internal::MakeAction<F, gmock_Impl>()), \
454 (::testing::internal::MakeAction<F>(impl_))); \
455 } \
456 private: \
457 class gmock_Impl { \
458 public: \
459 explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {} \
460 template <typename function_type, typename return_type, \
461 typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
462 return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
463 GMOCK_INTERNAL_DEFN_##value_params \
464 }; \
465 GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
466 , std::shared_ptr<const gmock_Impl> impl_;) \
467 }; \
468 template <GMOCK_INTERNAL_DECL_##template_params \
469 GMOCK_INTERNAL_DECL_TYPE_##value_params> \
470 GMOCK_ACTION_CLASS_(name, value_params)< \
471 GMOCK_INTERNAL_LIST_##template_params \
472 GMOCK_INTERNAL_LIST_TYPE_##value_params> name( \
473 GMOCK_INTERNAL_DECL_##value_params) GTEST_MUST_USE_RESULT_; \
474 template <GMOCK_INTERNAL_DECL_##template_params \
475 GMOCK_INTERNAL_DECL_TYPE_##value_params> \
476 inline GMOCK_ACTION_CLASS_(name, value_params)< \
477 GMOCK_INTERNAL_LIST_##template_params \
478 GMOCK_INTERNAL_LIST_TYPE_##value_params> name( \
479 GMOCK_INTERNAL_DECL_##value_params) { \
480 return GMOCK_ACTION_CLASS_(name, value_params)< \
481 GMOCK_INTERNAL_LIST_##template_params \
482 GMOCK_INTERNAL_LIST_TYPE_##value_params>( \
483 GMOCK_INTERNAL_LIST_##value_params); \
484 } \
485 template <GMOCK_INTERNAL_DECL_##template_params \
486 GMOCK_INTERNAL_DECL_TYPE_##value_params> \
487 template <typename function_type, typename return_type, typename args_type, \
488 GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
489 return_type GMOCK_ACTION_CLASS_(name, value_params)< \
490 GMOCK_INTERNAL_LIST_##template_params \
491 GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::gmock_PerformImpl( \
492 GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
493
494 namespace testing {
495
496 // The ACTION*() macros trigger warning C4100 (unreferenced formal
497 // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
498 // the macro definition, as the warnings are generated when the macro
499 // is expanded and macro expansion cannot contain #pragma. Therefore
500 // we suppress them here.
501 #ifdef _MSC_VER
502 # pragma warning(push)
503 # pragma warning(disable:4100)
504 #endif
505
506 namespace internal {
507
508 // internal::InvokeArgument - a helper for InvokeArgument action.
509 // The basic overloads are provided here for generic functors.
510 // Overloads for other custom-callables are provided in the
511 // internal/custom/gmock-generated-actions.h header.
512 template <typename F, typename... Args>
513 auto InvokeArgument(F f, Args... args) -> decltype(f(args...)) {
514 return f(args...);
515 }
516
517 template <std::size_t index, typename... Params>
518 struct InvokeArgumentAction {
519 template <typename... Args>
520 auto operator()(Args&&... args) const -> decltype(internal::InvokeArgument(
521 std::get<index>(std::forward_as_tuple(std::forward<Args>(args)...)),
522 std::declval<const Params&>()...)) {
523 internal::FlatTuple<Args&&...> args_tuple(FlatTupleConstructTag{},
524 std::forward<Args>(args)...);
525 return params.Apply([&](const Params&... unpacked_params) {
526 auto&& callable = args_tuple.template Get<index>();
527 return internal::InvokeArgument(
528 std::forward<decltype(callable)>(callable), unpacked_params...);
529 });
530 }
531
532 internal::FlatTuple<Params...> params;
533 };
534
535 } // namespace internal
536
537 // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
538 // (0-based) argument, which must be a k-ary callable, of the mock
539 // function, with arguments a1, a2, ..., a_k.
540 //
541 // Notes:
542 //
543 // 1. The arguments are passed by value by default. If you need to
544 // pass an argument by reference, wrap it inside std::ref(). For
545 // example,
546 //
547 // InvokeArgument<1>(5, string("Hello"), std::ref(foo))
548 //
549 // passes 5 and string("Hello") by value, and passes foo by
550 // reference.
551 //
552 // 2. If the callable takes an argument by reference but std::ref() is
553 // not used, it will receive the reference to a copy of the value,
554 // instead of the original value. For example, when the 0-th
555 // argument of the mock function takes a const string&, the action
556 //
557 // InvokeArgument<0>(string("Hello"))
558 //
559 // makes a copy of the temporary string("Hello") object and passes a
560 // reference of the copy, instead of the original temporary object,
561 // to the callable. This makes it easy for a user to define an
562 // InvokeArgument action from temporary values and have it performed
563 // later.
564 template <std::size_t index, typename... Params>
565 internal::InvokeArgumentAction<index, typename std::decay<Params>::type...>
566 InvokeArgument(Params&&... params) {
567 return {internal::FlatTuple<typename std::decay<Params>::type...>(
568 internal::FlatTupleConstructTag{}, std::forward<Params>(params)...)};
569 }
570
571 #ifdef _MSC_VER
572 # pragma warning(pop)
573 #endif
574
575 } // namespace testing
576
577 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_