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