Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1 | // This file was GENERATED by command: |
| 2 | // pump.py gmock-generated-actions.h.pump |
| 3 | // DO NOT EDIT BY HAND!!! |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 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 | // Author: wan@google.com (Zhanyong Wan) |
| 35 | |
| 36 | // Google Mock - a framework for writing C++ mock classes. |
| 37 | // |
| 38 | // This file implements some commonly used variadic actions. |
| 39 | |
Gennadiy Civil | 984cba3 | 2018-07-27 11:15:08 -0400 | [diff] [blame] | 40 | // GOOGLETEST_CM0002 DO NOT DELETE |
| 41 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 42 | #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ |
| 43 | #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ |
| 44 | |
zhanyong.wan | 53e08c4 | 2010-09-14 05:38:21 +0000 | [diff] [blame] | 45 | #include "gmock/gmock-actions.h" |
| 46 | #include "gmock/internal/gmock-port.h" |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 47 | |
| 48 | namespace testing { |
| 49 | namespace internal { |
| 50 | |
| 51 | // InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 52 | // function, method, or callback with the unpacked values, where F is |
| 53 | // a function type that takes N arguments. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 54 | template <typename Result, typename ArgumentTuple> |
| 55 | class InvokeHelper; |
| 56 | |
| 57 | template <typename R> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 58 | class InvokeHelper<R, ::testing::tuple<> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 59 | public: |
| 60 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 61 | static R Invoke(Function function, const ::testing::tuple<>&) { |
| 62 | return function(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | template <class Class, typename MethodPtr> |
| 66 | static R InvokeMethod(Class* obj_ptr, |
| 67 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 68 | const ::testing::tuple<>&) { |
| 69 | return (obj_ptr->*method_ptr)(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 70 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 71 | |
| 72 | template <typename CallbackType> |
| 73 | static R InvokeCallback(CallbackType* callback, |
| 74 | const ::testing::tuple<>&) { |
| 75 | return callback->Run(); |
| 76 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | template <typename R, typename A1> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 80 | class InvokeHelper<R, ::testing::tuple<A1> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 81 | public: |
| 82 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 83 | static R Invoke(Function function, const ::testing::tuple<A1>& args) { |
| 84 | return function(get<0>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | template <class Class, typename MethodPtr> |
| 88 | static R InvokeMethod(Class* obj_ptr, |
| 89 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 90 | const ::testing::tuple<A1>& args) { |
| 91 | return (obj_ptr->*method_ptr)(get<0>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 92 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 93 | |
| 94 | template <typename CallbackType> |
| 95 | static R InvokeCallback(CallbackType* callback, |
| 96 | const ::testing::tuple<A1>& args) { |
| 97 | return callback->Run(get<0>(args)); |
| 98 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | template <typename R, typename A1, typename A2> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 102 | class InvokeHelper<R, ::testing::tuple<A1, A2> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 103 | public: |
| 104 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 105 | static R Invoke(Function function, const ::testing::tuple<A1, A2>& args) { |
| 106 | return function(get<0>(args), get<1>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | template <class Class, typename MethodPtr> |
| 110 | static R InvokeMethod(Class* obj_ptr, |
| 111 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 112 | const ::testing::tuple<A1, A2>& args) { |
| 113 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 114 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 115 | |
| 116 | template <typename CallbackType> |
| 117 | static R InvokeCallback(CallbackType* callback, |
| 118 | const ::testing::tuple<A1, A2>& args) { |
| 119 | return callback->Run(get<0>(args), get<1>(args)); |
| 120 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | template <typename R, typename A1, typename A2, typename A3> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 124 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 125 | public: |
| 126 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 127 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3>& args) { |
| 128 | return function(get<0>(args), get<1>(args), get<2>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | template <class Class, typename MethodPtr> |
| 132 | static R InvokeMethod(Class* obj_ptr, |
| 133 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 134 | const ::testing::tuple<A1, A2, A3>& args) { |
| 135 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 136 | get<2>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 137 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 138 | |
| 139 | template <typename CallbackType> |
| 140 | static R InvokeCallback(CallbackType* callback, |
| 141 | const ::testing::tuple<A1, A2, A3>& args) { |
| 142 | return callback->Run(get<0>(args), get<1>(args), get<2>(args)); |
| 143 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | template <typename R, typename A1, typename A2, typename A3, typename A4> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 147 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 148 | public: |
| 149 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 150 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 151 | A4>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 152 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 153 | get<3>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | template <class Class, typename MethodPtr> |
| 157 | static R InvokeMethod(Class* obj_ptr, |
| 158 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 159 | const ::testing::tuple<A1, A2, A3, A4>& args) { |
| 160 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 161 | get<2>(args), get<3>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 162 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 163 | |
| 164 | template <typename CallbackType> |
| 165 | static R InvokeCallback(CallbackType* callback, |
| 166 | const ::testing::tuple<A1, A2, A3, A4>& args) { |
| 167 | return callback->Run(get<0>(args), get<1>(args), get<2>(args), |
| 168 | get<3>(args)); |
| 169 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 173 | typename A5> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 174 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 175 | public: |
| 176 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 177 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 178 | A5>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 179 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 180 | get<3>(args), get<4>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | template <class Class, typename MethodPtr> |
| 184 | static R InvokeMethod(Class* obj_ptr, |
| 185 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 186 | const ::testing::tuple<A1, A2, A3, A4, A5>& args) { |
| 187 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 188 | get<2>(args), get<3>(args), get<4>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 189 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 190 | |
| 191 | template <typename CallbackType> |
| 192 | static R InvokeCallback(CallbackType* callback, |
| 193 | const ::testing::tuple<A1, A2, A3, A4, A5>& args) { |
| 194 | return callback->Run(get<0>(args), get<1>(args), get<2>(args), |
| 195 | get<3>(args), get<4>(args)); |
| 196 | } |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 200 | typename A5, typename A6> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 201 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 202 | public: |
| 203 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 204 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 205 | A6>& args) { |
| 206 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 207 | get<3>(args), get<4>(args), get<5>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | template <class Class, typename MethodPtr> |
| 211 | static R InvokeMethod(Class* obj_ptr, |
| 212 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 213 | const ::testing::tuple<A1, A2, A3, A4, A5, A6>& args) { |
| 214 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 215 | get<2>(args), get<3>(args), get<4>(args), get<5>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 216 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 217 | |
| 218 | // There is no InvokeCallback() for 6-tuples, as google3 callbacks |
| 219 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 223 | typename A5, typename A6, typename A7> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 224 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 225 | public: |
| 226 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 227 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 228 | A6, A7>& args) { |
| 229 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 230 | get<3>(args), get<4>(args), get<5>(args), get<6>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | template <class Class, typename MethodPtr> |
| 234 | static R InvokeMethod(Class* obj_ptr, |
| 235 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 236 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 237 | A7>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 238 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 239 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 240 | get<6>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 241 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 242 | |
| 243 | // There is no InvokeCallback() for 7-tuples, as google3 callbacks |
| 244 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 248 | typename A5, typename A6, typename A7, typename A8> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 249 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 250 | public: |
| 251 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 252 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 253 | A6, A7, A8>& args) { |
| 254 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 255 | get<3>(args), get<4>(args), get<5>(args), get<6>(args), |
| 256 | get<7>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | template <class Class, typename MethodPtr> |
| 260 | static R InvokeMethod(Class* obj_ptr, |
| 261 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 262 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 263 | A8>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 264 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 265 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 266 | get<6>(args), get<7>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 267 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 268 | |
| 269 | // There is no InvokeCallback() for 8-tuples, as google3 callbacks |
| 270 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 274 | typename A5, typename A6, typename A7, typename A8, typename A9> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 275 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 276 | public: |
| 277 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 278 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 279 | A6, A7, A8, A9>& args) { |
| 280 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 281 | get<3>(args), get<4>(args), get<5>(args), get<6>(args), |
| 282 | get<7>(args), get<8>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | template <class Class, typename MethodPtr> |
| 286 | static R InvokeMethod(Class* obj_ptr, |
| 287 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 288 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 289 | A9>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 290 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 291 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 292 | get<6>(args), get<7>(args), get<8>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 293 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 294 | |
| 295 | // There is no InvokeCallback() for 9-tuples, as google3 callbacks |
| 296 | // support 5 arguments at most. |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | template <typename R, typename A1, typename A2, typename A3, typename A4, |
| 300 | typename A5, typename A6, typename A7, typename A8, typename A9, |
| 301 | typename A10> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 302 | class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 303 | A10> > { |
| 304 | public: |
| 305 | template <typename Function> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 306 | static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5, |
| 307 | A6, A7, A8, A9, A10>& args) { |
| 308 | return function(get<0>(args), get<1>(args), get<2>(args), |
| 309 | get<3>(args), get<4>(args), get<5>(args), get<6>(args), |
| 310 | get<7>(args), get<8>(args), get<9>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | template <class Class, typename MethodPtr> |
| 314 | static R InvokeMethod(Class* obj_ptr, |
| 315 | MethodPtr method_ptr, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 316 | const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 317 | A9, A10>& args) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 318 | return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), |
| 319 | get<2>(args), get<3>(args), get<4>(args), get<5>(args), |
| 320 | get<6>(args), get<7>(args), get<8>(args), get<9>(args)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 321 | } |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 322 | |
| 323 | // There is no InvokeCallback() for 10-tuples, as google3 callbacks |
| 324 | // support 5 arguments at most. |
| 325 | }; |
| 326 | |
| 327 | // Implements the Invoke(callback) action. |
| 328 | template <typename CallbackType> |
| 329 | class InvokeCallbackAction { |
| 330 | public: |
| 331 | // The c'tor takes ownership of the callback. |
| 332 | explicit InvokeCallbackAction(CallbackType* callback) |
| 333 | : callback_(callback) { |
| 334 | callback->CheckIsRepeatable(); // Makes sure the callback is permanent. |
| 335 | } |
| 336 | |
| 337 | // This type conversion operator template allows Invoke(callback) to |
| 338 | // be used wherever the callback's type is compatible with that of |
| 339 | // the mock function, i.e. if the mock function's arguments can be |
| 340 | // implicitly converted to the callback's arguments and the |
| 341 | // callback's result can be implicitly converted to the mock |
| 342 | // function's result. |
| 343 | template <typename Result, typename ArgumentTuple> |
| 344 | Result Perform(const ArgumentTuple& args) const { |
| 345 | return InvokeHelper<Result, ArgumentTuple>::InvokeCallback( |
| 346 | callback_.get(), args); |
| 347 | } |
| 348 | private: |
| 349 | const linked_ptr<CallbackType> callback_; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 350 | }; |
| 351 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 352 | // An INTERNAL macro for extracting the type of a tuple field. It's |
| 353 | // subject to change without notice - DO NOT USE IN USER CODE! |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 354 | #define GMOCK_FIELD_(Tuple, N) \ |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 355 | typename ::testing::tuple_element<N, Tuple>::type |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 356 | |
| 357 | // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the |
| 358 | // type of an n-ary function whose i-th (1-based) argument type is the |
| 359 | // k{i}-th (0-based) field of ArgumentTuple, which must be a tuple |
| 360 | // type, and whose return type is Result. For example, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 361 | // SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 362 | // is int(bool, long). |
| 363 | // |
| 364 | // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args) |
| 365 | // returns the selected fields (k1, k2, ..., k_n) of args as a tuple. |
| 366 | // For example, |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 367 | // SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select( |
| 368 | // ::testing::make_tuple(true, 'a', 2.5)) |
| 369 | // returns tuple (2.5, true). |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 370 | // |
| 371 | // The numbers in list k1, k2, ..., k_n must be >= 0, where n can be |
| 372 | // in the range [0, 10]. Duplicates are allowed and they don't have |
| 373 | // to be in an ascending or descending order. |
| 374 | |
| 375 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 376 | int k4, int k5, int k6, int k7, int k8, int k9, int k10> |
| 377 | class SelectArgs { |
| 378 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 379 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 380 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 381 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 382 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), |
| 383 | GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9), |
| 384 | GMOCK_FIELD_(ArgumentTuple, k10)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 385 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 386 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 387 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 388 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), |
| 389 | get<k8>(args), get<k9>(args), get<k10>(args)); |
| 390 | } |
| 391 | }; |
| 392 | |
| 393 | template <typename Result, typename ArgumentTuple> |
| 394 | class SelectArgs<Result, ArgumentTuple, |
| 395 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { |
| 396 | public: |
| 397 | typedef Result type(); |
| 398 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
zhanyong.wan | 3fbd2dd | 2009-03-26 19:06:45 +0000 | [diff] [blame] | 399 | static SelectedArgs Select(const ArgumentTuple& /* args */) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 400 | return SelectedArgs(); |
| 401 | } |
| 402 | }; |
| 403 | |
| 404 | template <typename Result, typename ArgumentTuple, int k1> |
| 405 | class SelectArgs<Result, ArgumentTuple, |
| 406 | k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { |
| 407 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 408 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 409 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 410 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 411 | return SelectedArgs(get<k1>(args)); |
| 412 | } |
| 413 | }; |
| 414 | |
| 415 | template <typename Result, typename ArgumentTuple, int k1, int k2> |
| 416 | class SelectArgs<Result, ArgumentTuple, |
| 417 | k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> { |
| 418 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 419 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 420 | GMOCK_FIELD_(ArgumentTuple, k2)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 421 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 422 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 423 | return SelectedArgs(get<k1>(args), get<k2>(args)); |
| 424 | } |
| 425 | }; |
| 426 | |
| 427 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3> |
| 428 | class SelectArgs<Result, ArgumentTuple, |
| 429 | k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> { |
| 430 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 431 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 432 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 433 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 434 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 435 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args)); |
| 436 | } |
| 437 | }; |
| 438 | |
| 439 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 440 | int k4> |
| 441 | class SelectArgs<Result, ArgumentTuple, |
| 442 | k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> { |
| 443 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 444 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 445 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 446 | GMOCK_FIELD_(ArgumentTuple, k4)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 447 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 448 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 449 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 450 | get<k4>(args)); |
| 451 | } |
| 452 | }; |
| 453 | |
| 454 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 455 | int k4, int k5> |
| 456 | class SelectArgs<Result, ArgumentTuple, |
| 457 | k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> { |
| 458 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 459 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 460 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 461 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 462 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 463 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 464 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 465 | get<k4>(args), get<k5>(args)); |
| 466 | } |
| 467 | }; |
| 468 | |
| 469 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 470 | int k4, int k5, int k6> |
| 471 | class SelectArgs<Result, ArgumentTuple, |
| 472 | k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> { |
| 473 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 474 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 475 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 476 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 477 | GMOCK_FIELD_(ArgumentTuple, k6)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 478 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 479 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 480 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 481 | get<k4>(args), get<k5>(args), get<k6>(args)); |
| 482 | } |
| 483 | }; |
| 484 | |
| 485 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 486 | int k4, int k5, int k6, int k7> |
| 487 | class SelectArgs<Result, ArgumentTuple, |
| 488 | k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> { |
| 489 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 490 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 491 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 492 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 493 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 494 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 495 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 496 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 497 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args)); |
| 498 | } |
| 499 | }; |
| 500 | |
| 501 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 502 | int k4, int k5, int k6, int k7, int k8> |
| 503 | class SelectArgs<Result, ArgumentTuple, |
| 504 | k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> { |
| 505 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 506 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 507 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 508 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 509 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), |
| 510 | GMOCK_FIELD_(ArgumentTuple, k8)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 511 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 512 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 513 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 514 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), |
| 515 | get<k8>(args)); |
| 516 | } |
| 517 | }; |
| 518 | |
| 519 | template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, |
| 520 | int k4, int k5, int k6, int k7, int k8, int k9> |
| 521 | class SelectArgs<Result, ArgumentTuple, |
| 522 | k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> { |
| 523 | public: |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 524 | typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1), |
| 525 | GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3), |
| 526 | GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5), |
| 527 | GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7), |
| 528 | GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9)); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 529 | typedef typename Function<type>::ArgumentTuple SelectedArgs; |
| 530 | static SelectedArgs Select(const ArgumentTuple& args) { |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 531 | return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), |
| 532 | get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), |
| 533 | get<k8>(args), get<k9>(args)); |
| 534 | } |
| 535 | }; |
| 536 | |
zhanyong.wan | e0d051e | 2009-02-19 00:33:37 +0000 | [diff] [blame] | 537 | #undef GMOCK_FIELD_ |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 538 | |
| 539 | // Implements the WithArgs action. |
| 540 | template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1, |
| 541 | int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1, |
| 542 | int k9 = -1, int k10 = -1> |
| 543 | class WithArgsAction { |
| 544 | public: |
| 545 | explicit WithArgsAction(const InnerAction& action) : action_(action) {} |
| 546 | |
| 547 | template <typename F> |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 548 | operator Action<F>() const { return MakeAction(new Impl<F>(action_)); } |
| 549 | |
| 550 | private: |
| 551 | template <typename F> |
| 552 | class Impl : public ActionInterface<F> { |
| 553 | public: |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 554 | typedef typename Function<F>::Result Result; |
| 555 | typedef typename Function<F>::ArgumentTuple ArgumentTuple; |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 556 | |
| 557 | explicit Impl(const InnerAction& action) : action_(action) {} |
| 558 | |
| 559 | virtual Result Perform(const ArgumentTuple& args) { |
| 560 | return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4, |
| 561 | k5, k6, k7, k8, k9, k10>::Select(args)); |
| 562 | } |
| 563 | |
| 564 | private: |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 565 | typedef typename SelectArgs<Result, ArgumentTuple, |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 566 | k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 567 | |
zhanyong.wan | 38ca64d | 2009-02-19 22:30:22 +0000 | [diff] [blame] | 568 | Action<InnerFunctionType> action_; |
| 569 | }; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 570 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 571 | const InnerAction action_; |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 572 | |
| 573 | GTEST_DISALLOW_ASSIGN_(WithArgsAction); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 574 | }; |
| 575 | |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 576 | // A macro from the ACTION* family (defined later in this file) |
| 577 | // defines an action that can be used in a mock function. Typically, |
| 578 | // these actions only care about a subset of the arguments of the mock |
| 579 | // function. For example, if such an action only uses the second |
| 580 | // argument, it can be used in any mock function that takes >= 2 |
| 581 | // arguments where the type of the second argument is compatible. |
| 582 | // |
| 583 | // Therefore, the action implementation must be prepared to take more |
| 584 | // arguments than it needs. The ExcessiveArg type is used to |
| 585 | // represent those excessive arguments. In order to keep the compiler |
| 586 | // error messages tractable, we define it in the testing namespace |
| 587 | // instead of testing::internal. However, this is an INTERNAL TYPE |
| 588 | // and subject to change without notice, so a user MUST NOT USE THIS |
| 589 | // TYPE DIRECTLY. |
| 590 | struct ExcessiveArg {}; |
| 591 | |
| 592 | // A helper class needed for implementing the ACTION* macros. |
| 593 | template <typename Result, class Impl> |
| 594 | class ActionHelper { |
| 595 | public: |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 596 | static Result Perform(Impl* impl, const ::testing::tuple<>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 597 | return impl->template gmock_PerformImpl<>(args, ExcessiveArg(), |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 598 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 599 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 600 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | template <typename A0> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 604 | static Result Perform(Impl* impl, const ::testing::tuple<A0>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 605 | return impl->template gmock_PerformImpl<A0>(args, get<0>(args), |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 606 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 607 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 608 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | template <typename A0, typename A1> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 612 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 613 | return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args), |
| 614 | get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 615 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 616 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | template <typename A0, typename A1, typename A2> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 620 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 621 | return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args), |
| 622 | get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(), |
| 623 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 624 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | template <typename A0, typename A1, typename A2, typename A3> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 628 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 629 | A3>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 630 | return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args), |
| 631 | get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(), |
| 632 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 633 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | template <typename A0, typename A1, typename A2, typename A3, typename A4> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 637 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 638 | A4>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 639 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args, |
| 640 | get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), |
| 641 | ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 642 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 646 | typename A5> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 647 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 648 | A5>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 649 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args, |
| 650 | get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), |
| 651 | get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), |
| 652 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 656 | typename A5, typename A6> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 657 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 658 | A5, A6>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 659 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args, |
| 660 | get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args), |
| 661 | get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(), |
| 662 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 666 | typename A5, typename A6, typename A7> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 667 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 668 | A5, A6, A7>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 669 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, |
| 670 | A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), |
| 671 | get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(), |
| 672 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 676 | typename A5, typename A6, typename A7, typename A8> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 677 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 678 | A5, A6, A7, A8>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 679 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, |
| 680 | A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), |
| 681 | get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args), |
| 682 | ExcessiveArg()); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | template <typename A0, typename A1, typename A2, typename A3, typename A4, |
| 686 | typename A5, typename A6, typename A7, typename A8, typename A9> |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 687 | static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4, |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 688 | A5, A6, A7, A8, A9>& args) { |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 689 | return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8, |
| 690 | A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), |
| 691 | get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args), |
| 692 | get<9>(args)); |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 693 | } |
| 694 | }; |
| 695 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 696 | } // namespace internal |
| 697 | |
| 698 | // Various overloads for Invoke(). |
| 699 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 700 | // WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes |
| 701 | // the selected arguments of the mock function to an_action and |
| 702 | // performs it. It serves as an adaptor between actions with |
| 703 | // different argument lists. C++ doesn't support default arguments for |
| 704 | // function templates, so we have to overload it. |
| 705 | template <int k1, typename InnerAction> |
| 706 | inline internal::WithArgsAction<InnerAction, k1> |
| 707 | WithArgs(const InnerAction& action) { |
| 708 | return internal::WithArgsAction<InnerAction, k1>(action); |
| 709 | } |
| 710 | |
| 711 | template <int k1, int k2, typename InnerAction> |
| 712 | inline internal::WithArgsAction<InnerAction, k1, k2> |
| 713 | WithArgs(const InnerAction& action) { |
| 714 | return internal::WithArgsAction<InnerAction, k1, k2>(action); |
| 715 | } |
| 716 | |
| 717 | template <int k1, int k2, int k3, typename InnerAction> |
| 718 | inline internal::WithArgsAction<InnerAction, k1, k2, k3> |
| 719 | WithArgs(const InnerAction& action) { |
| 720 | return internal::WithArgsAction<InnerAction, k1, k2, k3>(action); |
| 721 | } |
| 722 | |
| 723 | template <int k1, int k2, int k3, int k4, typename InnerAction> |
| 724 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4> |
| 725 | WithArgs(const InnerAction& action) { |
| 726 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action); |
| 727 | } |
| 728 | |
| 729 | template <int k1, int k2, int k3, int k4, int k5, typename InnerAction> |
| 730 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5> |
| 731 | WithArgs(const InnerAction& action) { |
| 732 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action); |
| 733 | } |
| 734 | |
| 735 | template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction> |
| 736 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6> |
| 737 | WithArgs(const InnerAction& action) { |
| 738 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action); |
| 739 | } |
| 740 | |
| 741 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, |
| 742 | typename InnerAction> |
| 743 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7> |
| 744 | WithArgs(const InnerAction& action) { |
| 745 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, |
| 746 | k7>(action); |
| 747 | } |
| 748 | |
| 749 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8, |
| 750 | typename InnerAction> |
| 751 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8> |
| 752 | WithArgs(const InnerAction& action) { |
| 753 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, |
| 754 | k8>(action); |
| 755 | } |
| 756 | |
| 757 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8, |
| 758 | int k9, typename InnerAction> |
| 759 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9> |
| 760 | WithArgs(const InnerAction& action) { |
| 761 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, |
| 762 | k9>(action); |
| 763 | } |
| 764 | |
| 765 | template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8, |
| 766 | int k9, int k10, typename InnerAction> |
| 767 | inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, |
| 768 | k9, k10> |
| 769 | WithArgs(const InnerAction& action) { |
| 770 | return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, |
| 771 | k9, k10>(action); |
| 772 | } |
| 773 | |
| 774 | // Creates an action that does actions a1, a2, ..., sequentially in |
| 775 | // each invocation. |
| 776 | template <typename Action1, typename Action2> |
| 777 | inline internal::DoBothAction<Action1, Action2> |
| 778 | DoAll(Action1 a1, Action2 a2) { |
| 779 | return internal::DoBothAction<Action1, Action2>(a1, a2); |
| 780 | } |
| 781 | |
| 782 | template <typename Action1, typename Action2, typename Action3> |
| 783 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 784 | Action3> > |
| 785 | DoAll(Action1 a1, Action2 a2, Action3 a3) { |
| 786 | return DoAll(a1, DoAll(a2, a3)); |
| 787 | } |
| 788 | |
| 789 | template <typename Action1, typename Action2, typename Action3, |
| 790 | typename Action4> |
| 791 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 792 | internal::DoBothAction<Action3, Action4> > > |
| 793 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) { |
| 794 | return DoAll(a1, DoAll(a2, a3, a4)); |
| 795 | } |
| 796 | |
| 797 | template <typename Action1, typename Action2, typename Action3, |
| 798 | typename Action4, typename Action5> |
| 799 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 800 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 801 | Action5> > > > |
| 802 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) { |
| 803 | return DoAll(a1, DoAll(a2, a3, a4, a5)); |
| 804 | } |
| 805 | |
| 806 | template <typename Action1, typename Action2, typename Action3, |
| 807 | typename Action4, typename Action5, typename Action6> |
| 808 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 809 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 810 | internal::DoBothAction<Action5, Action6> > > > > |
| 811 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) { |
| 812 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6)); |
| 813 | } |
| 814 | |
| 815 | template <typename Action1, typename Action2, typename Action3, |
| 816 | typename Action4, typename Action5, typename Action6, typename Action7> |
| 817 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 818 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 819 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 820 | Action7> > > > > > |
| 821 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 822 | Action7 a7) { |
| 823 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7)); |
| 824 | } |
| 825 | |
| 826 | template <typename Action1, typename Action2, typename Action3, |
| 827 | typename Action4, typename Action5, typename Action6, typename Action7, |
| 828 | typename Action8> |
| 829 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 830 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 831 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 832 | internal::DoBothAction<Action7, Action8> > > > > > > |
| 833 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 834 | Action7 a7, Action8 a8) { |
| 835 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8)); |
| 836 | } |
| 837 | |
| 838 | template <typename Action1, typename Action2, typename Action3, |
| 839 | typename Action4, typename Action5, typename Action6, typename Action7, |
| 840 | typename Action8, typename Action9> |
| 841 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 842 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 843 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 844 | internal::DoBothAction<Action7, internal::DoBothAction<Action8, |
| 845 | Action9> > > > > > > > |
| 846 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 847 | Action7 a7, Action8 a8, Action9 a9) { |
| 848 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9)); |
| 849 | } |
| 850 | |
| 851 | template <typename Action1, typename Action2, typename Action3, |
| 852 | typename Action4, typename Action5, typename Action6, typename Action7, |
| 853 | typename Action8, typename Action9, typename Action10> |
| 854 | inline internal::DoBothAction<Action1, internal::DoBothAction<Action2, |
| 855 | internal::DoBothAction<Action3, internal::DoBothAction<Action4, |
| 856 | internal::DoBothAction<Action5, internal::DoBothAction<Action6, |
| 857 | internal::DoBothAction<Action7, internal::DoBothAction<Action8, |
| 858 | internal::DoBothAction<Action9, Action10> > > > > > > > > |
| 859 | DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, |
| 860 | Action7 a7, Action8 a8, Action9 a9, Action10 a10) { |
| 861 | return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10)); |
| 862 | } |
| 863 | |
| 864 | } // namespace testing |
| 865 | |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 866 | // The ACTION* family of macros can be used in a namespace scope to |
| 867 | // define custom actions easily. The syntax: |
| 868 | // |
| 869 | // ACTION(name) { statements; } |
| 870 | // |
| 871 | // will define an action with the given name that executes the |
| 872 | // statements. The value returned by the statements will be used as |
| 873 | // the return value of the action. Inside the statements, you can |
| 874 | // refer to the K-th (0-based) argument of the mock function by |
| 875 | // 'argK', and refer to its type by 'argK_type'. For example: |
| 876 | // |
| 877 | // ACTION(IncrementArg1) { |
| 878 | // arg1_type temp = arg1; |
| 879 | // return ++(*temp); |
| 880 | // } |
| 881 | // |
| 882 | // allows you to write |
| 883 | // |
| 884 | // ...WillOnce(IncrementArg1()); |
| 885 | // |
| 886 | // You can also refer to the entire argument tuple and its type by |
| 887 | // 'args' and 'args_type', and refer to the mock function type and its |
| 888 | // return type by 'function_type' and 'return_type'. |
| 889 | // |
| 890 | // Note that you don't need to specify the types of the mock function |
| 891 | // arguments. However rest assured that your code is still type-safe: |
| 892 | // you'll get a compiler error if *arg1 doesn't support the ++ |
| 893 | // operator, or if the type of ++(*arg1) isn't compatible with the |
| 894 | // mock function's return type, for example. |
| 895 | // |
| 896 | // Sometimes you'll want to parameterize the action. For that you can use |
| 897 | // another macro: |
| 898 | // |
| 899 | // ACTION_P(name, param_name) { statements; } |
| 900 | // |
| 901 | // For example: |
| 902 | // |
| 903 | // ACTION_P(Add, n) { return arg0 + n; } |
| 904 | // |
| 905 | // will allow you to write: |
| 906 | // |
| 907 | // ...WillOnce(Add(5)); |
| 908 | // |
| 909 | // Note that you don't need to provide the type of the parameter |
| 910 | // either. If you need to reference the type of a parameter named |
| 911 | // 'foo', you can write 'foo_type'. For example, in the body of |
| 912 | // ACTION_P(Add, n) above, you can write 'n_type' to refer to the type |
| 913 | // of 'n'. |
| 914 | // |
| 915 | // We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support |
| 916 | // multi-parameter actions. |
| 917 | // |
| 918 | // For the purpose of typing, you can view |
| 919 | // |
| 920 | // ACTION_Pk(Foo, p1, ..., pk) { ... } |
| 921 | // |
| 922 | // as shorthand for |
| 923 | // |
| 924 | // template <typename p1_type, ..., typename pk_type> |
| 925 | // FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... } |
| 926 | // |
| 927 | // In particular, you can provide the template type arguments |
| 928 | // explicitly when invoking Foo(), as in Foo<long, bool>(5, false); |
| 929 | // although usually you can rely on the compiler to infer the types |
| 930 | // for you automatically. You can assign the result of expression |
| 931 | // Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ..., |
| 932 | // pk_type>. This can be useful when composing actions. |
| 933 | // |
| 934 | // You can also overload actions with different numbers of parameters: |
| 935 | // |
| 936 | // ACTION_P(Plus, a) { ... } |
| 937 | // ACTION_P2(Plus, a, b) { ... } |
| 938 | // |
| 939 | // While it's tempting to always use the ACTION* macros when defining |
| 940 | // a new action, you should also consider implementing ActionInterface |
| 941 | // or using MakePolymorphicAction() instead, especially if you need to |
| 942 | // use the action a lot. While these approaches require more work, |
| 943 | // they give you more control on the types of the mock function |
| 944 | // arguments and the action parameters, which in general leads to |
| 945 | // better compiler error messages that pay off in the long run. They |
| 946 | // also allow overloading actions based on parameter types (as opposed |
| 947 | // to just based on the number of parameters). |
| 948 | // |
| 949 | // CAVEAT: |
| 950 | // |
| 951 | // ACTION*() can only be used in a namespace scope. The reason is |
| 952 | // that C++ doesn't yet allow function-local types to be used to |
| 953 | // instantiate templates. The up-coming C++0x standard will fix this. |
| 954 | // Once that's done, we'll consider supporting using ACTION*() inside |
| 955 | // a function. |
| 956 | // |
| 957 | // MORE INFORMATION: |
| 958 | // |
| 959 | // To learn more about using these macros, please search for 'ACTION' |
Herbert Thielen | e033d8c | 2017-08-31 18:12:17 +0200 | [diff] [blame] | 960 | // on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 961 | |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 962 | // An internal macro needed for implementing ACTION*(). |
| 963 | #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\ |
jgm | 79a367e | 2012-04-10 16:02:11 +0000 | [diff] [blame] | 964 | const args_type& args GTEST_ATTRIBUTE_UNUSED_, \ |
| 965 | arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \ |
| 966 | arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \ |
| 967 | arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \ |
| 968 | arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \ |
| 969 | arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \ |
| 970 | arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \ |
| 971 | arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \ |
| 972 | arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \ |
| 973 | arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 974 | arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_ |
| 975 | |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 976 | // Sometimes you want to give an action explicit template parameters |
| 977 | // that cannot be inferred from its value parameters. ACTION() and |
| 978 | // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that |
| 979 | // and can be viewed as an extension to ACTION() and ACTION_P*(). |
| 980 | // |
| 981 | // The syntax: |
| 982 | // |
| 983 | // ACTION_TEMPLATE(ActionName, |
| 984 | // HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m), |
| 985 | // AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; } |
| 986 | // |
| 987 | // defines an action template that takes m explicit template |
| 988 | // parameters and n value parameters. name_i is the name of the i-th |
| 989 | // template parameter, and kind_i specifies whether it's a typename, |
| 990 | // an integral constant, or a template. p_i is the name of the i-th |
| 991 | // value parameter. |
| 992 | // |
| 993 | // Example: |
| 994 | // |
| 995 | // // DuplicateArg<k, T>(output) converts the k-th argument of the mock |
| 996 | // // function to type T and copies it to *output. |
| 997 | // ACTION_TEMPLATE(DuplicateArg, |
| 998 | // HAS_2_TEMPLATE_PARAMS(int, k, typename, T), |
| 999 | // AND_1_VALUE_PARAMS(output)) { |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 1000 | // *output = T(::testing::get<k>(args)); |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1001 | // } |
| 1002 | // ... |
| 1003 | // int n; |
| 1004 | // EXPECT_CALL(mock, Foo(_, _)) |
| 1005 | // .WillOnce(DuplicateArg<1, unsigned char>(&n)); |
| 1006 | // |
| 1007 | // To create an instance of an action template, write: |
| 1008 | // |
| 1009 | // ActionName<t1, ..., t_m>(v1, ..., v_n) |
| 1010 | // |
| 1011 | // where the ts are the template arguments and the vs are the value |
| 1012 | // arguments. The value argument types are inferred by the compiler. |
| 1013 | // If you want to explicitly specify the value argument types, you can |
| 1014 | // provide additional template arguments: |
| 1015 | // |
| 1016 | // ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n) |
| 1017 | // |
| 1018 | // where u_i is the desired type of v_i. |
| 1019 | // |
| 1020 | // ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the |
| 1021 | // number of value parameters, but not on the number of template |
| 1022 | // parameters. Without the restriction, the meaning of the following |
| 1023 | // is unclear: |
| 1024 | // |
| 1025 | // OverloadedAction<int, bool>(x); |
| 1026 | // |
| 1027 | // Are we using a single-template-parameter action where 'bool' refers |
| 1028 | // to the type of x, or are we using a two-template-parameter action |
| 1029 | // where the compiler is asked to infer the type of x? |
| 1030 | // |
| 1031 | // Implementation notes: |
| 1032 | // |
| 1033 | // GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and |
| 1034 | // GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for |
| 1035 | // implementing ACTION_TEMPLATE. The main trick we use is to create |
| 1036 | // new macro invocations when expanding a macro. For example, we have |
| 1037 | // |
| 1038 | // #define ACTION_TEMPLATE(name, template_params, value_params) |
| 1039 | // ... GMOCK_INTERNAL_DECL_##template_params ... |
| 1040 | // |
| 1041 | // which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...) |
| 1042 | // to expand to |
| 1043 | // |
| 1044 | // ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ... |
| 1045 | // |
| 1046 | // Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the |
| 1047 | // preprocessor will continue to expand it to |
| 1048 | // |
| 1049 | // ... typename T ... |
| 1050 | // |
| 1051 | // This technique conforms to the C++ standard and is portable. It |
| 1052 | // allows us to implement action templates using O(N) code, where N is |
| 1053 | // the maximum number of template/value parameters supported. Without |
| 1054 | // using it, we'd have to devote O(N^2) amount of code to implement all |
| 1055 | // combinations of m and n. |
| 1056 | |
| 1057 | // Declares the template parameters. |
| 1058 | #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0 |
| 1059 | #define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1060 | name1) kind0 name0, kind1 name1 |
| 1061 | #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1062 | kind2, name2) kind0 name0, kind1 name1, kind2 name2 |
| 1063 | #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1064 | kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \ |
| 1065 | kind3 name3 |
| 1066 | #define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1067 | kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \ |
| 1068 | kind2 name2, kind3 name3, kind4 name4 |
| 1069 | #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1070 | kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \ |
| 1071 | kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5 |
| 1072 | #define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1073 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1074 | name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ |
| 1075 | kind5 name5, kind6 name6 |
| 1076 | #define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1077 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1078 | kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \ |
| 1079 | kind4 name4, kind5 name5, kind6 name6, kind7 name7 |
| 1080 | #define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1081 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1082 | kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \ |
| 1083 | kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \ |
| 1084 | kind8 name8 |
| 1085 | #define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1086 | name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1087 | name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \ |
| 1088 | kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \ |
| 1089 | kind6 name6, kind7 name7, kind8 name8, kind9 name9 |
| 1090 | |
| 1091 | // Lists the template parameters. |
| 1092 | #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0 |
| 1093 | #define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1094 | name1) name0, name1 |
| 1095 | #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1096 | kind2, name2) name0, name1, name2 |
| 1097 | #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1098 | kind2, name2, kind3, name3) name0, name1, name2, name3 |
| 1099 | #define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1100 | kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \ |
| 1101 | name4 |
| 1102 | #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1103 | kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \ |
| 1104 | name2, name3, name4, name5 |
| 1105 | #define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1106 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1107 | name6) name0, name1, name2, name3, name4, name5, name6 |
| 1108 | #define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1109 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1110 | kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7 |
| 1111 | #define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ |
| 1112 | kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ |
| 1113 | kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \ |
| 1114 | name6, name7, name8 |
| 1115 | #define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ |
| 1116 | name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ |
| 1117 | name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \ |
| 1118 | name3, name4, name5, name6, name7, name8, name9 |
| 1119 | |
| 1120 | // Declares the types of value parameters. |
| 1121 | #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS() |
| 1122 | #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type |
| 1123 | #define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \ |
| 1124 | typename p0##_type, typename p1##_type |
| 1125 | #define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \ |
| 1126 | typename p0##_type, typename p1##_type, typename p2##_type |
| 1127 | #define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ |
| 1128 | typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1129 | typename p3##_type |
| 1130 | #define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ |
| 1131 | typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1132 | typename p3##_type, typename p4##_type |
| 1133 | #define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ |
| 1134 | typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1135 | typename p3##_type, typename p4##_type, typename p5##_type |
| 1136 | #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1137 | p6) , typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1138 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1139 | typename p6##_type |
| 1140 | #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1141 | p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1142 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1143 | typename p6##_type, typename p7##_type |
| 1144 | #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1145 | p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1146 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1147 | typename p6##_type, typename p7##_type, typename p8##_type |
| 1148 | #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1149 | p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \ |
| 1150 | typename p2##_type, typename p3##_type, typename p4##_type, \ |
| 1151 | typename p5##_type, typename p6##_type, typename p7##_type, \ |
| 1152 | typename p8##_type, typename p9##_type |
| 1153 | |
| 1154 | // Initializes the value parameters. |
| 1155 | #define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\ |
| 1156 | () |
| 1157 | #define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1158 | (p0##_type gmock_p0) : p0(::testing::internal::move(gmock_p0)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1159 | #define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1160 | (p0##_type gmock_p0, \ |
| 1161 | p1##_type gmock_p1) : p0(::testing::internal::move(gmock_p0)), \ |
| 1162 | p1(::testing::internal::move(gmock_p1)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1163 | #define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\ |
| 1164 | (p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1165 | p2##_type gmock_p2) : p0(::testing::internal::move(gmock_p0)), \ |
| 1166 | p1(::testing::internal::move(gmock_p1)), \ |
| 1167 | p2(::testing::internal::move(gmock_p2)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1168 | #define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\ |
| 1169 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1170 | p3##_type gmock_p3) : p0(::testing::internal::move(gmock_p0)), \ |
| 1171 | p1(::testing::internal::move(gmock_p1)), \ |
| 1172 | p2(::testing::internal::move(gmock_p2)), \ |
| 1173 | p3(::testing::internal::move(gmock_p3)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1174 | #define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\ |
| 1175 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1176 | p3##_type gmock_p3, \ |
| 1177 | p4##_type gmock_p4) : p0(::testing::internal::move(gmock_p0)), \ |
| 1178 | p1(::testing::internal::move(gmock_p1)), \ |
| 1179 | p2(::testing::internal::move(gmock_p2)), \ |
| 1180 | p3(::testing::internal::move(gmock_p3)), \ |
| 1181 | p4(::testing::internal::move(gmock_p4)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1182 | #define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\ |
| 1183 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1184 | p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1185 | p5##_type gmock_p5) : p0(::testing::internal::move(gmock_p0)), \ |
| 1186 | p1(::testing::internal::move(gmock_p1)), \ |
| 1187 | p2(::testing::internal::move(gmock_p2)), \ |
| 1188 | p3(::testing::internal::move(gmock_p3)), \ |
| 1189 | p4(::testing::internal::move(gmock_p4)), \ |
| 1190 | p5(::testing::internal::move(gmock_p5)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1191 | #define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\ |
| 1192 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1193 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1194 | p6##_type gmock_p6) : p0(::testing::internal::move(gmock_p0)), \ |
| 1195 | p1(::testing::internal::move(gmock_p1)), \ |
| 1196 | p2(::testing::internal::move(gmock_p2)), \ |
| 1197 | p3(::testing::internal::move(gmock_p3)), \ |
| 1198 | p4(::testing::internal::move(gmock_p4)), \ |
| 1199 | p5(::testing::internal::move(gmock_p5)), \ |
| 1200 | p6(::testing::internal::move(gmock_p6)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1201 | #define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\ |
| 1202 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1203 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1204 | p6##_type gmock_p6, \ |
| 1205 | p7##_type gmock_p7) : p0(::testing::internal::move(gmock_p0)), \ |
| 1206 | p1(::testing::internal::move(gmock_p1)), \ |
| 1207 | p2(::testing::internal::move(gmock_p2)), \ |
| 1208 | p3(::testing::internal::move(gmock_p3)), \ |
| 1209 | p4(::testing::internal::move(gmock_p4)), \ |
| 1210 | p5(::testing::internal::move(gmock_p5)), \ |
| 1211 | p6(::testing::internal::move(gmock_p6)), \ |
| 1212 | p7(::testing::internal::move(gmock_p7)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1213 | #define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1214 | p7, p8)\ |
| 1215 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1216 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 1217 | p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1218 | p8##_type gmock_p8) : p0(::testing::internal::move(gmock_p0)), \ |
| 1219 | p1(::testing::internal::move(gmock_p1)), \ |
| 1220 | p2(::testing::internal::move(gmock_p2)), \ |
| 1221 | p3(::testing::internal::move(gmock_p3)), \ |
| 1222 | p4(::testing::internal::move(gmock_p4)), \ |
| 1223 | p5(::testing::internal::move(gmock_p5)), \ |
| 1224 | p6(::testing::internal::move(gmock_p6)), \ |
| 1225 | p7(::testing::internal::move(gmock_p7)), \ |
| 1226 | p8(::testing::internal::move(gmock_p8)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1227 | #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1228 | p7, p8, p9)\ |
| 1229 | (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1230 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 1231 | p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1232 | p9##_type gmock_p9) : p0(::testing::internal::move(gmock_p0)), \ |
| 1233 | p1(::testing::internal::move(gmock_p1)), \ |
| 1234 | p2(::testing::internal::move(gmock_p2)), \ |
| 1235 | p3(::testing::internal::move(gmock_p3)), \ |
| 1236 | p4(::testing::internal::move(gmock_p4)), \ |
| 1237 | p5(::testing::internal::move(gmock_p5)), \ |
| 1238 | p6(::testing::internal::move(gmock_p6)), \ |
| 1239 | p7(::testing::internal::move(gmock_p7)), \ |
| 1240 | p8(::testing::internal::move(gmock_p8)), \ |
| 1241 | p9(::testing::internal::move(gmock_p9)) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1242 | |
| 1243 | // Declares the fields for storing the value parameters. |
| 1244 | #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS() |
| 1245 | #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0; |
| 1246 | #define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \ |
| 1247 | p1##_type p1; |
| 1248 | #define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \ |
| 1249 | p1##_type p1; p2##_type p2; |
| 1250 | #define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \ |
| 1251 | p1##_type p1; p2##_type p2; p3##_type p3; |
| 1252 | #define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ |
| 1253 | p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; |
| 1254 | #define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ |
| 1255 | p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ |
| 1256 | p5##_type p5; |
| 1257 | #define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1258 | p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ |
| 1259 | p5##_type p5; p6##_type p6; |
| 1260 | #define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1261 | p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ |
| 1262 | p5##_type p5; p6##_type p6; p7##_type p7; |
| 1263 | #define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1264 | p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ |
| 1265 | p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; |
| 1266 | #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1267 | p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ |
| 1268 | p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \ |
| 1269 | p9##_type p9; |
| 1270 | |
| 1271 | // Lists the value parameters. |
| 1272 | #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS() |
| 1273 | #define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0 |
| 1274 | #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1 |
| 1275 | #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2 |
| 1276 | #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3 |
| 1277 | #define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \ |
| 1278 | p2, p3, p4 |
| 1279 | #define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \ |
| 1280 | p1, p2, p3, p4, p5 |
| 1281 | #define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1282 | p6) p0, p1, p2, p3, p4, p5, p6 |
| 1283 | #define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1284 | p7) p0, p1, p2, p3, p4, p5, p6, p7 |
| 1285 | #define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1286 | p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8 |
| 1287 | #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1288 | p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 |
| 1289 | |
| 1290 | // Lists the value parameter types. |
| 1291 | #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS() |
| 1292 | #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type |
| 1293 | #define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \ |
| 1294 | p1##_type |
| 1295 | #define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \ |
| 1296 | p1##_type, p2##_type |
| 1297 | #define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ |
| 1298 | p0##_type, p1##_type, p2##_type, p3##_type |
| 1299 | #define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ |
| 1300 | p0##_type, p1##_type, p2##_type, p3##_type, p4##_type |
| 1301 | #define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ |
| 1302 | p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type |
| 1303 | #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1304 | p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ |
| 1305 | p6##_type |
| 1306 | #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1307 | p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
| 1308 | p5##_type, p6##_type, p7##_type |
| 1309 | #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1310 | p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
| 1311 | p5##_type, p6##_type, p7##_type, p8##_type |
| 1312 | #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1313 | p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
| 1314 | p5##_type, p6##_type, p7##_type, p8##_type, p9##_type |
| 1315 | |
| 1316 | // Declares the value parameters. |
| 1317 | #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS() |
| 1318 | #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0 |
| 1319 | #define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \ |
| 1320 | p1##_type p1 |
| 1321 | #define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \ |
| 1322 | p1##_type p1, p2##_type p2 |
| 1323 | #define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \ |
| 1324 | p1##_type p1, p2##_type p2, p3##_type p3 |
| 1325 | #define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ |
| 1326 | p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4 |
| 1327 | #define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ |
| 1328 | p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ |
| 1329 | p5##_type p5 |
| 1330 | #define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ |
| 1331 | p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ |
| 1332 | p5##_type p5, p6##_type p6 |
| 1333 | #define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1334 | p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ |
| 1335 | p5##_type p5, p6##_type p6, p7##_type p7 |
| 1336 | #define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1337 | p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 1338 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8 |
| 1339 | #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1340 | p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 1341 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ |
| 1342 | p9##_type p9 |
| 1343 | |
| 1344 | // The suffix of the class template implementing the action template. |
| 1345 | #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS() |
| 1346 | #define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P |
| 1347 | #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2 |
| 1348 | #define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3 |
| 1349 | #define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4 |
| 1350 | #define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5 |
| 1351 | #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6 |
| 1352 | #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7 |
| 1353 | #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1354 | p7) P8 |
| 1355 | #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1356 | p7, p8) P9 |
| 1357 | #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ |
| 1358 | p7, p8, p9) P10 |
| 1359 | |
| 1360 | // The name of the class template implementing the action template. |
| 1361 | #define GMOCK_ACTION_CLASS_(name, value_params)\ |
zhanyong.wan | ccedc1c | 2010-08-09 22:46:12 +0000 | [diff] [blame] | 1362 | GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params) |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1363 | |
| 1364 | #define ACTION_TEMPLATE(name, template_params, value_params)\ |
| 1365 | template <GMOCK_INTERNAL_DECL_##template_params\ |
| 1366 | GMOCK_INTERNAL_DECL_TYPE_##value_params>\ |
| 1367 | class GMOCK_ACTION_CLASS_(name, value_params) {\ |
| 1368 | public:\ |
billydonahue | 1f5fdea | 2014-05-19 17:54:51 +0000 | [diff] [blame] | 1369 | explicit GMOCK_ACTION_CLASS_(name, value_params)\ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1370 | GMOCK_INTERNAL_INIT_##value_params {}\ |
| 1371 | template <typename F>\ |
| 1372 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1373 | public:\ |
| 1374 | typedef F function_type;\ |
| 1375 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1376 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1377 | args_type;\ |
| 1378 | explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\ |
| 1379 | virtual return_type Perform(const args_type& args) {\ |
| 1380 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1381 | Perform(this, args);\ |
| 1382 | }\ |
| 1383 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1384 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1385 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1386 | typename arg9_type>\ |
| 1387 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1388 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1389 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1390 | arg9_type arg9) const;\ |
| 1391 | GMOCK_INTERNAL_DEFN_##value_params\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1392 | private:\ |
| 1393 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1394 | };\ |
| 1395 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1396 | return ::testing::Action<F>(\ |
| 1397 | new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\ |
| 1398 | }\ |
| 1399 | GMOCK_INTERNAL_DEFN_##value_params\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1400 | private:\ |
| 1401 | GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1402 | };\ |
| 1403 | template <GMOCK_INTERNAL_DECL_##template_params\ |
| 1404 | GMOCK_INTERNAL_DECL_TYPE_##value_params>\ |
| 1405 | inline GMOCK_ACTION_CLASS_(name, value_params)<\ |
| 1406 | GMOCK_INTERNAL_LIST_##template_params\ |
| 1407 | GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ |
| 1408 | GMOCK_INTERNAL_DECL_##value_params) {\ |
| 1409 | return GMOCK_ACTION_CLASS_(name, value_params)<\ |
| 1410 | GMOCK_INTERNAL_LIST_##template_params\ |
| 1411 | GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ |
| 1412 | GMOCK_INTERNAL_LIST_##value_params);\ |
| 1413 | }\ |
| 1414 | template <GMOCK_INTERNAL_DECL_##template_params\ |
| 1415 | GMOCK_INTERNAL_DECL_TYPE_##value_params>\ |
| 1416 | template <typename F>\ |
jgm | 79a367e | 2012-04-10 16:02:11 +0000 | [diff] [blame] | 1417 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1418 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1419 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
zhanyong.wan | 1849065 | 2009-05-11 18:54:08 +0000 | [diff] [blame] | 1420 | typename arg9_type>\ |
| 1421 | typename ::testing::internal::Function<F>::Result\ |
| 1422 | GMOCK_ACTION_CLASS_(name, value_params)<\ |
| 1423 | GMOCK_INTERNAL_LIST_##template_params\ |
| 1424 | GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\ |
| 1425 | gmock_PerformImpl(\ |
| 1426 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
| 1427 | |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1428 | #define ACTION(name)\ |
| 1429 | class name##Action {\ |
| 1430 | public:\ |
| 1431 | name##Action() {}\ |
| 1432 | template <typename F>\ |
| 1433 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1434 | public:\ |
| 1435 | typedef F function_type;\ |
| 1436 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1437 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1438 | args_type;\ |
| 1439 | gmock_Impl() {}\ |
| 1440 | virtual return_type Perform(const args_type& args) {\ |
| 1441 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1442 | Perform(this, args);\ |
| 1443 | }\ |
| 1444 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1445 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1446 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1447 | typename arg9_type>\ |
| 1448 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1449 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1450 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1451 | arg9_type arg9) const;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1452 | private:\ |
| 1453 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1454 | };\ |
| 1455 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1456 | return ::testing::Action<F>(new gmock_Impl<F>());\ |
| 1457 | }\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1458 | private:\ |
| 1459 | GTEST_DISALLOW_ASSIGN_(name##Action);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1460 | };\ |
| 1461 | inline name##Action name() {\ |
| 1462 | return name##Action();\ |
| 1463 | }\ |
| 1464 | template <typename F>\ |
| 1465 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1466 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1467 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1468 | typename arg9_type>\ |
| 1469 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1470 | name##Action::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1471 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1472 | |
| 1473 | #define ACTION_P(name, p0)\ |
| 1474 | template <typename p0##_type>\ |
| 1475 | class name##ActionP {\ |
| 1476 | public:\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1477 | explicit name##ActionP(p0##_type gmock_p0) : \ |
| 1478 | p0(::testing::internal::forward<p0##_type>(gmock_p0)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1479 | template <typename F>\ |
| 1480 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1481 | public:\ |
| 1482 | typedef F function_type;\ |
| 1483 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1484 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1485 | args_type;\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1486 | explicit gmock_Impl(p0##_type gmock_p0) : \ |
| 1487 | p0(::testing::internal::forward<p0##_type>(gmock_p0)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1488 | virtual return_type Perform(const args_type& args) {\ |
| 1489 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1490 | Perform(this, args);\ |
| 1491 | }\ |
| 1492 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1493 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1494 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1495 | typename arg9_type>\ |
| 1496 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1497 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1498 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1499 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1500 | p0##_type p0;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1501 | private:\ |
| 1502 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1503 | };\ |
| 1504 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1505 | return ::testing::Action<F>(new gmock_Impl<F>(p0));\ |
| 1506 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1507 | p0##_type p0;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1508 | private:\ |
| 1509 | GTEST_DISALLOW_ASSIGN_(name##ActionP);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1510 | };\ |
| 1511 | template <typename p0##_type>\ |
| 1512 | inline name##ActionP<p0##_type> name(p0##_type p0) {\ |
| 1513 | return name##ActionP<p0##_type>(p0);\ |
| 1514 | }\ |
| 1515 | template <typename p0##_type>\ |
| 1516 | template <typename F>\ |
| 1517 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1518 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1519 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1520 | typename arg9_type>\ |
| 1521 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1522 | name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1523 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1524 | |
| 1525 | #define ACTION_P2(name, p0, p1)\ |
| 1526 | template <typename p0##_type, typename p1##_type>\ |
| 1527 | class name##ActionP2 {\ |
| 1528 | public:\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1529 | name##ActionP2(p0##_type gmock_p0, \ |
| 1530 | p1##_type gmock_p1) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1531 | p1(::testing::internal::forward<p1##_type>(gmock_p1)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1532 | template <typename F>\ |
| 1533 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1534 | public:\ |
| 1535 | typedef F function_type;\ |
| 1536 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1537 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1538 | args_type;\ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1539 | gmock_Impl(p0##_type gmock_p0, \ |
| 1540 | p1##_type gmock_p1) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1541 | p1(::testing::internal::forward<p1##_type>(gmock_p1)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1542 | virtual return_type Perform(const args_type& args) {\ |
| 1543 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1544 | Perform(this, args);\ |
| 1545 | }\ |
| 1546 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1547 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1548 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1549 | typename arg9_type>\ |
| 1550 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1551 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1552 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1553 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1554 | p0##_type p0;\ |
| 1555 | p1##_type p1;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1556 | private:\ |
| 1557 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1558 | };\ |
| 1559 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1560 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\ |
| 1561 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1562 | p0##_type p0;\ |
| 1563 | p1##_type p1;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1564 | private:\ |
| 1565 | GTEST_DISALLOW_ASSIGN_(name##ActionP2);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1566 | };\ |
| 1567 | template <typename p0##_type, typename p1##_type>\ |
| 1568 | inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \ |
| 1569 | p1##_type p1) {\ |
| 1570 | return name##ActionP2<p0##_type, p1##_type>(p0, p1);\ |
| 1571 | }\ |
| 1572 | template <typename p0##_type, typename p1##_type>\ |
| 1573 | template <typename F>\ |
| 1574 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1575 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1576 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1577 | typename arg9_type>\ |
| 1578 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1579 | name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1580 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1581 | |
| 1582 | #define ACTION_P3(name, p0, p1, p2)\ |
| 1583 | template <typename p0##_type, typename p1##_type, typename p2##_type>\ |
| 1584 | class name##ActionP3 {\ |
| 1585 | public:\ |
| 1586 | name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1587 | p2##_type gmock_p2) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1588 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1589 | p2(::testing::internal::forward<p2##_type>(gmock_p2)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1590 | template <typename F>\ |
| 1591 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1592 | public:\ |
| 1593 | typedef F function_type;\ |
| 1594 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1595 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1596 | args_type;\ |
| 1597 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1598 | p2##_type gmock_p2) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1599 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1600 | p2(::testing::internal::forward<p2##_type>(gmock_p2)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1601 | virtual return_type Perform(const args_type& args) {\ |
| 1602 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1603 | Perform(this, args);\ |
| 1604 | }\ |
| 1605 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1606 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1607 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1608 | typename arg9_type>\ |
| 1609 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1610 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1611 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1612 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1613 | p0##_type p0;\ |
| 1614 | p1##_type p1;\ |
| 1615 | p2##_type p2;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1616 | private:\ |
| 1617 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1618 | };\ |
| 1619 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1620 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\ |
| 1621 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1622 | p0##_type p0;\ |
| 1623 | p1##_type p1;\ |
| 1624 | p2##_type p2;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1625 | private:\ |
| 1626 | GTEST_DISALLOW_ASSIGN_(name##ActionP3);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1627 | };\ |
| 1628 | template <typename p0##_type, typename p1##_type, typename p2##_type>\ |
| 1629 | inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \ |
| 1630 | p1##_type p1, p2##_type p2) {\ |
| 1631 | return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\ |
| 1632 | }\ |
| 1633 | template <typename p0##_type, typename p1##_type, typename p2##_type>\ |
| 1634 | template <typename F>\ |
| 1635 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1636 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1637 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1638 | typename arg9_type>\ |
| 1639 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1640 | name##ActionP3<p0##_type, p1##_type, \ |
| 1641 | p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1642 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1643 | |
| 1644 | #define ACTION_P4(name, p0, p1, p2, p3)\ |
| 1645 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1646 | typename p3##_type>\ |
| 1647 | class name##ActionP4 {\ |
| 1648 | public:\ |
| 1649 | name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1650 | p2##_type gmock_p2, \ |
| 1651 | p3##_type gmock_p3) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1652 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1653 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1654 | p3(::testing::internal::forward<p3##_type>(gmock_p3)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1655 | template <typename F>\ |
| 1656 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1657 | public:\ |
| 1658 | typedef F function_type;\ |
| 1659 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1660 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1661 | args_type;\ |
| 1662 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1663 | p3##_type gmock_p3) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1664 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1665 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1666 | p3(::testing::internal::forward<p3##_type>(gmock_p3)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1667 | virtual return_type Perform(const args_type& args) {\ |
| 1668 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1669 | Perform(this, args);\ |
| 1670 | }\ |
| 1671 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1672 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1673 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1674 | typename arg9_type>\ |
| 1675 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1676 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1677 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1678 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1679 | p0##_type p0;\ |
| 1680 | p1##_type p1;\ |
| 1681 | p2##_type p2;\ |
| 1682 | p3##_type p3;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1683 | private:\ |
| 1684 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1685 | };\ |
| 1686 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1687 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\ |
| 1688 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1689 | p0##_type p0;\ |
| 1690 | p1##_type p1;\ |
| 1691 | p2##_type p2;\ |
| 1692 | p3##_type p3;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1693 | private:\ |
| 1694 | GTEST_DISALLOW_ASSIGN_(name##ActionP4);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1695 | };\ |
| 1696 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1697 | typename p3##_type>\ |
| 1698 | inline name##ActionP4<p0##_type, p1##_type, p2##_type, \ |
| 1699 | p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ |
| 1700 | p3##_type p3) {\ |
| 1701 | return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \ |
| 1702 | p2, p3);\ |
| 1703 | }\ |
| 1704 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1705 | typename p3##_type>\ |
| 1706 | template <typename F>\ |
| 1707 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1708 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1709 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1710 | typename arg9_type>\ |
| 1711 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1712 | name##ActionP4<p0##_type, p1##_type, p2##_type, \ |
| 1713 | p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1714 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1715 | |
| 1716 | #define ACTION_P5(name, p0, p1, p2, p3, p4)\ |
| 1717 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1718 | typename p3##_type, typename p4##_type>\ |
| 1719 | class name##ActionP5 {\ |
| 1720 | public:\ |
| 1721 | name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1722 | p2##_type gmock_p2, p3##_type gmock_p3, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1723 | p4##_type gmock_p4) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1724 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1725 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1726 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1727 | p4(::testing::internal::forward<p4##_type>(gmock_p4)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1728 | template <typename F>\ |
| 1729 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1730 | public:\ |
| 1731 | typedef F function_type;\ |
| 1732 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1733 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1734 | args_type;\ |
| 1735 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1736 | p3##_type gmock_p3, \ |
| 1737 | p4##_type gmock_p4) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1738 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1739 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1740 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1741 | p4(::testing::internal::forward<p4##_type>(gmock_p4)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1742 | virtual return_type Perform(const args_type& args) {\ |
| 1743 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1744 | Perform(this, args);\ |
| 1745 | }\ |
| 1746 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1747 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1748 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1749 | typename arg9_type>\ |
| 1750 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1751 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1752 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1753 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1754 | p0##_type p0;\ |
| 1755 | p1##_type p1;\ |
| 1756 | p2##_type p2;\ |
| 1757 | p3##_type p3;\ |
| 1758 | p4##_type p4;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1759 | private:\ |
| 1760 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1761 | };\ |
| 1762 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1763 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\ |
| 1764 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1765 | p0##_type p0;\ |
| 1766 | p1##_type p1;\ |
| 1767 | p2##_type p2;\ |
| 1768 | p3##_type p3;\ |
| 1769 | p4##_type p4;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1770 | private:\ |
| 1771 | GTEST_DISALLOW_ASSIGN_(name##ActionP5);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1772 | };\ |
| 1773 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1774 | typename p3##_type, typename p4##_type>\ |
| 1775 | inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1776 | p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 1777 | p4##_type p4) {\ |
| 1778 | return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1779 | p4##_type>(p0, p1, p2, p3, p4);\ |
| 1780 | }\ |
| 1781 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1782 | typename p3##_type, typename p4##_type>\ |
| 1783 | template <typename F>\ |
| 1784 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1785 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1786 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1787 | typename arg9_type>\ |
| 1788 | typename ::testing::internal::Function<F>::Result\ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1789 | name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1790 | p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1791 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1792 | |
| 1793 | #define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\ |
| 1794 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1795 | typename p3##_type, typename p4##_type, typename p5##_type>\ |
| 1796 | class name##ActionP6 {\ |
| 1797 | public:\ |
| 1798 | name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1799 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1800 | p5##_type gmock_p5) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1801 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1802 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1803 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1804 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1805 | p5(::testing::internal::forward<p5##_type>(gmock_p5)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1806 | template <typename F>\ |
| 1807 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1808 | public:\ |
| 1809 | typedef F function_type;\ |
| 1810 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1811 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1812 | args_type;\ |
| 1813 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1814 | p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1815 | p5##_type gmock_p5) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1816 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1817 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1818 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1819 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1820 | p5(::testing::internal::forward<p5##_type>(gmock_p5)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1821 | virtual return_type Perform(const args_type& args) {\ |
| 1822 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1823 | Perform(this, args);\ |
| 1824 | }\ |
| 1825 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1826 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1827 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1828 | typename arg9_type>\ |
| 1829 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1830 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1831 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1832 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1833 | p0##_type p0;\ |
| 1834 | p1##_type p1;\ |
| 1835 | p2##_type p2;\ |
| 1836 | p3##_type p3;\ |
| 1837 | p4##_type p4;\ |
| 1838 | p5##_type p5;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1839 | private:\ |
| 1840 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1841 | };\ |
| 1842 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1843 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\ |
| 1844 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1845 | p0##_type p0;\ |
| 1846 | p1##_type p1;\ |
| 1847 | p2##_type p2;\ |
| 1848 | p3##_type p3;\ |
| 1849 | p4##_type p4;\ |
| 1850 | p5##_type p5;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1851 | private:\ |
| 1852 | GTEST_DISALLOW_ASSIGN_(name##ActionP6);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1853 | };\ |
| 1854 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1855 | typename p3##_type, typename p4##_type, typename p5##_type>\ |
| 1856 | inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1857 | p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ |
| 1858 | p3##_type p3, p4##_type p4, p5##_type p5) {\ |
| 1859 | return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1860 | p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\ |
| 1861 | }\ |
| 1862 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1863 | typename p3##_type, typename p4##_type, typename p5##_type>\ |
| 1864 | template <typename F>\ |
| 1865 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1866 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1867 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1868 | typename arg9_type>\ |
| 1869 | typename ::testing::internal::Function<F>::Result\ |
| 1870 | name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1871 | p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1872 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1873 | |
| 1874 | #define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\ |
| 1875 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1876 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1877 | typename p6##_type>\ |
| 1878 | class name##ActionP7 {\ |
| 1879 | public:\ |
| 1880 | name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1881 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1882 | p5##_type gmock_p5, \ |
| 1883 | p6##_type gmock_p6) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1884 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1885 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1886 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1887 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1888 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1889 | p6(::testing::internal::forward<p6##_type>(gmock_p6)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1890 | template <typename F>\ |
| 1891 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1892 | public:\ |
| 1893 | typedef F function_type;\ |
| 1894 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1895 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1896 | args_type;\ |
| 1897 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1898 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1899 | p6##_type gmock_p6) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1900 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1901 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1902 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1903 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1904 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1905 | p6(::testing::internal::forward<p6##_type>(gmock_p6)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1906 | virtual return_type Perform(const args_type& args) {\ |
| 1907 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 1908 | Perform(this, args);\ |
| 1909 | }\ |
| 1910 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1911 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1912 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1913 | typename arg9_type>\ |
| 1914 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 1915 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 1916 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 1917 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1918 | p0##_type p0;\ |
| 1919 | p1##_type p1;\ |
| 1920 | p2##_type p2;\ |
| 1921 | p3##_type p3;\ |
| 1922 | p4##_type p4;\ |
| 1923 | p5##_type p5;\ |
| 1924 | p6##_type p6;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1925 | private:\ |
| 1926 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1927 | };\ |
| 1928 | template <typename F> operator ::testing::Action<F>() const {\ |
| 1929 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 1930 | p6));\ |
| 1931 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 1932 | p0##_type p0;\ |
| 1933 | p1##_type p1;\ |
| 1934 | p2##_type p2;\ |
| 1935 | p3##_type p3;\ |
| 1936 | p4##_type p4;\ |
| 1937 | p5##_type p5;\ |
| 1938 | p6##_type p6;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 1939 | private:\ |
| 1940 | GTEST_DISALLOW_ASSIGN_(name##ActionP7);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1941 | };\ |
| 1942 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1943 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1944 | typename p6##_type>\ |
| 1945 | inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1946 | p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \ |
| 1947 | p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ |
| 1948 | p6##_type p6) {\ |
| 1949 | return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 1950 | p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\ |
| 1951 | }\ |
| 1952 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1953 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1954 | typename p6##_type>\ |
| 1955 | template <typename F>\ |
| 1956 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 1957 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 1958 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 1959 | typename arg9_type>\ |
| 1960 | typename ::testing::internal::Function<F>::Result\ |
| 1961 | name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 1962 | p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 1963 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1964 | |
| 1965 | #define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\ |
| 1966 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 1967 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 1968 | typename p6##_type, typename p7##_type>\ |
| 1969 | class name##ActionP8 {\ |
| 1970 | public:\ |
| 1971 | name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 1972 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
| 1973 | p5##_type gmock_p5, p6##_type gmock_p6, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1974 | p7##_type gmock_p7) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1975 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1976 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1977 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1978 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1979 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1980 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 1981 | p7(::testing::internal::forward<p7##_type>(gmock_p7)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 1982 | template <typename F>\ |
| 1983 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 1984 | public:\ |
| 1985 | typedef F function_type;\ |
| 1986 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 1987 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 1988 | args_type;\ |
| 1989 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 1990 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 1991 | p6##_type gmock_p6, \ |
| 1992 | p7##_type gmock_p7) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 1993 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 1994 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 1995 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 1996 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 1997 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 1998 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 1999 | p7(::testing::internal::forward<p7##_type>(gmock_p7)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2000 | virtual return_type Perform(const args_type& args) {\ |
| 2001 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 2002 | Perform(this, args);\ |
| 2003 | }\ |
| 2004 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2005 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2006 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2007 | typename arg9_type>\ |
| 2008 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 2009 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 2010 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 2011 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2012 | p0##_type p0;\ |
| 2013 | p1##_type p1;\ |
| 2014 | p2##_type p2;\ |
| 2015 | p3##_type p3;\ |
| 2016 | p4##_type p4;\ |
| 2017 | p5##_type p5;\ |
| 2018 | p6##_type p6;\ |
| 2019 | p7##_type p7;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2020 | private:\ |
| 2021 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2022 | };\ |
| 2023 | template <typename F> operator ::testing::Action<F>() const {\ |
| 2024 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 2025 | p6, p7));\ |
| 2026 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2027 | p0##_type p0;\ |
| 2028 | p1##_type p1;\ |
| 2029 | p2##_type p2;\ |
| 2030 | p3##_type p3;\ |
| 2031 | p4##_type p4;\ |
| 2032 | p5##_type p5;\ |
| 2033 | p6##_type p6;\ |
| 2034 | p7##_type p7;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2035 | private:\ |
| 2036 | GTEST_DISALLOW_ASSIGN_(name##ActionP8);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2037 | };\ |
| 2038 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2039 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2040 | typename p6##_type, typename p7##_type>\ |
| 2041 | inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2042 | p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \ |
| 2043 | p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ |
| 2044 | p6##_type p6, p7##_type p7) {\ |
| 2045 | return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2046 | p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \ |
| 2047 | p6, p7);\ |
| 2048 | }\ |
| 2049 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2050 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2051 | typename p6##_type, typename p7##_type>\ |
| 2052 | template <typename F>\ |
| 2053 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2054 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2055 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2056 | typename arg9_type>\ |
| 2057 | typename ::testing::internal::Function<F>::Result\ |
| 2058 | name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 2059 | p5##_type, p6##_type, \ |
| 2060 | p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 2061 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2062 | |
| 2063 | #define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\ |
| 2064 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2065 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2066 | typename p6##_type, typename p7##_type, typename p8##_type>\ |
| 2067 | class name##ActionP9 {\ |
| 2068 | public:\ |
| 2069 | name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 2070 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
| 2071 | p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 2072 | p8##_type gmock_p8) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2073 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2074 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2075 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2076 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2077 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2078 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2079 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2080 | p8(::testing::internal::forward<p8##_type>(gmock_p8)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2081 | template <typename F>\ |
| 2082 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 2083 | public:\ |
| 2084 | typedef F function_type;\ |
| 2085 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 2086 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 2087 | args_type;\ |
| 2088 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 2089 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 2090 | p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 2091 | p8##_type gmock_p8) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2092 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2093 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2094 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2095 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2096 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2097 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2098 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2099 | p8(::testing::internal::forward<p8##_type>(gmock_p8)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2100 | virtual return_type Perform(const args_type& args) {\ |
| 2101 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 2102 | Perform(this, args);\ |
| 2103 | }\ |
| 2104 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2105 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2106 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2107 | typename arg9_type>\ |
| 2108 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 2109 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 2110 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 2111 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2112 | p0##_type p0;\ |
| 2113 | p1##_type p1;\ |
| 2114 | p2##_type p2;\ |
| 2115 | p3##_type p3;\ |
| 2116 | p4##_type p4;\ |
| 2117 | p5##_type p5;\ |
| 2118 | p6##_type p6;\ |
| 2119 | p7##_type p7;\ |
| 2120 | p8##_type p8;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2121 | private:\ |
| 2122 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2123 | };\ |
| 2124 | template <typename F> operator ::testing::Action<F>() const {\ |
| 2125 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 2126 | p6, p7, p8));\ |
| 2127 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2128 | p0##_type p0;\ |
| 2129 | p1##_type p1;\ |
| 2130 | p2##_type p2;\ |
| 2131 | p3##_type p3;\ |
| 2132 | p4##_type p4;\ |
| 2133 | p5##_type p5;\ |
| 2134 | p6##_type p6;\ |
| 2135 | p7##_type p7;\ |
| 2136 | p8##_type p8;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2137 | private:\ |
| 2138 | GTEST_DISALLOW_ASSIGN_(name##ActionP9);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2139 | };\ |
| 2140 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2141 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2142 | typename p6##_type, typename p7##_type, typename p8##_type>\ |
| 2143 | inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2144 | p4##_type, p5##_type, p6##_type, p7##_type, \ |
| 2145 | p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 2146 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ |
| 2147 | p8##_type p8) {\ |
| 2148 | return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2149 | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \ |
| 2150 | p3, p4, p5, p6, p7, p8);\ |
| 2151 | }\ |
| 2152 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2153 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2154 | typename p6##_type, typename p7##_type, typename p8##_type>\ |
| 2155 | template <typename F>\ |
| 2156 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2157 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2158 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2159 | typename arg9_type>\ |
| 2160 | typename ::testing::internal::Function<F>::Result\ |
| 2161 | name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 2162 | p5##_type, p6##_type, p7##_type, \ |
| 2163 | p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 2164 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2165 | |
| 2166 | #define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\ |
| 2167 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2168 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2169 | typename p6##_type, typename p7##_type, typename p8##_type, \ |
| 2170 | typename p9##_type>\ |
| 2171 | class name##ActionP10 {\ |
| 2172 | public:\ |
| 2173 | name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \ |
| 2174 | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ |
| 2175 | p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 2176 | p8##_type gmock_p8, \ |
| 2177 | p9##_type gmock_p9) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2178 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2179 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2180 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2181 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2182 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2183 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2184 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2185 | p8(::testing::internal::forward<p8##_type>(gmock_p8)), \ |
| 2186 | p9(::testing::internal::forward<p9##_type>(gmock_p9)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2187 | template <typename F>\ |
| 2188 | class gmock_Impl : public ::testing::ActionInterface<F> {\ |
| 2189 | public:\ |
| 2190 | typedef F function_type;\ |
| 2191 | typedef typename ::testing::internal::Function<F>::Result return_type;\ |
| 2192 | typedef typename ::testing::internal::Function<F>::ArgumentTuple\ |
| 2193 | args_type;\ |
| 2194 | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ |
| 2195 | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ |
| 2196 | p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 2197 | p9##_type gmock_p9) : p0(::testing::internal::forward<p0##_type>(gmock_p0)), \ |
| 2198 | p1(::testing::internal::forward<p1##_type>(gmock_p1)), \ |
| 2199 | p2(::testing::internal::forward<p2##_type>(gmock_p2)), \ |
| 2200 | p3(::testing::internal::forward<p3##_type>(gmock_p3)), \ |
| 2201 | p4(::testing::internal::forward<p4##_type>(gmock_p4)), \ |
| 2202 | p5(::testing::internal::forward<p5##_type>(gmock_p5)), \ |
| 2203 | p6(::testing::internal::forward<p6##_type>(gmock_p6)), \ |
| 2204 | p7(::testing::internal::forward<p7##_type>(gmock_p7)), \ |
| 2205 | p8(::testing::internal::forward<p8##_type>(gmock_p8)), \ |
| 2206 | p9(::testing::internal::forward<p9##_type>(gmock_p9)) {}\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2207 | virtual return_type Perform(const args_type& args) {\ |
| 2208 | return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ |
| 2209 | Perform(this, args);\ |
| 2210 | }\ |
| 2211 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2212 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2213 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2214 | typename arg9_type>\ |
| 2215 | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \ |
| 2216 | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ |
| 2217 | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ |
| 2218 | arg9_type arg9) const;\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2219 | p0##_type p0;\ |
| 2220 | p1##_type p1;\ |
| 2221 | p2##_type p2;\ |
| 2222 | p3##_type p3;\ |
| 2223 | p4##_type p4;\ |
| 2224 | p5##_type p5;\ |
| 2225 | p6##_type p6;\ |
| 2226 | p7##_type p7;\ |
| 2227 | p8##_type p8;\ |
| 2228 | p9##_type p9;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2229 | private:\ |
| 2230 | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2231 | };\ |
| 2232 | template <typename F> operator ::testing::Action<F>() const {\ |
| 2233 | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \ |
| 2234 | p6, p7, p8, p9));\ |
| 2235 | }\ |
zhanyong.wan | c069d7f | 2009-02-02 20:51:53 +0000 | [diff] [blame] | 2236 | p0##_type p0;\ |
| 2237 | p1##_type p1;\ |
| 2238 | p2##_type p2;\ |
| 2239 | p3##_type p3;\ |
| 2240 | p4##_type p4;\ |
| 2241 | p5##_type p5;\ |
| 2242 | p6##_type p6;\ |
| 2243 | p7##_type p7;\ |
| 2244 | p8##_type p8;\ |
| 2245 | p9##_type p9;\ |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2246 | private:\ |
| 2247 | GTEST_DISALLOW_ASSIGN_(name##ActionP10);\ |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2248 | };\ |
| 2249 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2250 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2251 | typename p6##_type, typename p7##_type, typename p8##_type, \ |
| 2252 | typename p9##_type>\ |
| 2253 | inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2254 | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \ |
| 2255 | p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ |
| 2256 | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ |
| 2257 | p9##_type p9) {\ |
| 2258 | return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \ |
| 2259 | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \ |
| 2260 | p1, p2, p3, p4, p5, p6, p7, p8, p9);\ |
| 2261 | }\ |
| 2262 | template <typename p0##_type, typename p1##_type, typename p2##_type, \ |
| 2263 | typename p3##_type, typename p4##_type, typename p5##_type, \ |
| 2264 | typename p6##_type, typename p7##_type, typename p8##_type, \ |
| 2265 | typename p9##_type>\ |
| 2266 | template <typename F>\ |
| 2267 | template <typename arg0_type, typename arg1_type, typename arg2_type, \ |
| 2268 | typename arg3_type, typename arg4_type, typename arg5_type, \ |
| 2269 | typename arg6_type, typename arg7_type, typename arg8_type, \ |
| 2270 | typename arg9_type>\ |
| 2271 | typename ::testing::internal::Function<F>::Result\ |
| 2272 | name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ |
zhanyong.wan | 33c0af0 | 2009-04-03 00:10:12 +0000 | [diff] [blame] | 2273 | p5##_type, p6##_type, p7##_type, p8##_type, \ |
| 2274 | p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\ |
| 2275 | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const |
shiqian | 326aa56 | 2009-01-09 21:43:57 +0000 | [diff] [blame] | 2276 | |
zhanyong.wan | e1cdce5 | 2009-02-06 01:09:43 +0000 | [diff] [blame] | 2277 | namespace testing { |
| 2278 | |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2279 | |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2280 | // The ACTION*() macros trigger warning C4100 (unreferenced formal |
| 2281 | // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in |
| 2282 | // the macro definition, as the warnings are generated when the macro |
| 2283 | // is expanded and macro expansion cannot contain #pragma. Therefore |
| 2284 | // we suppress them here. |
| 2285 | #ifdef _MSC_VER |
zhanyong.wan | 658ac0b | 2011-02-24 07:29:13 +0000 | [diff] [blame] | 2286 | # pragma warning(push) |
| 2287 | # pragma warning(disable:4100) |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2288 | #endif |
| 2289 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2290 | // Various overloads for InvokeArgument<N>(). |
| 2291 | // |
| 2292 | // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th |
| 2293 | // (0-based) argument, which must be a k-ary callable, of the mock |
| 2294 | // function, with arguments a1, a2, ..., a_k. |
| 2295 | // |
| 2296 | // Notes: |
| 2297 | // |
| 2298 | // 1. The arguments are passed by value by default. If you need to |
| 2299 | // pass an argument by reference, wrap it inside ByRef(). For |
| 2300 | // example, |
| 2301 | // |
| 2302 | // InvokeArgument<1>(5, string("Hello"), ByRef(foo)) |
| 2303 | // |
| 2304 | // passes 5 and string("Hello") by value, and passes foo by |
| 2305 | // reference. |
| 2306 | // |
| 2307 | // 2. If the callable takes an argument by reference but ByRef() is |
| 2308 | // not used, it will receive the reference to a copy of the value, |
| 2309 | // instead of the original value. For example, when the 0-th |
| 2310 | // argument of the mock function takes a const string&, the action |
| 2311 | // |
| 2312 | // InvokeArgument<0>(string("Hello")) |
| 2313 | // |
| 2314 | // makes a copy of the temporary string("Hello") object and passes a |
| 2315 | // reference of the copy, instead of the original temporary object, |
| 2316 | // to the callable. This makes it easy for a user to define an |
| 2317 | // InvokeArgument action from temporary values and have it performed |
| 2318 | // later. |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 2319 | |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2320 | namespace internal { |
| 2321 | namespace invoke_argument { |
| 2322 | |
| 2323 | // Appears in InvokeArgumentAdl's argument list to help avoid |
| 2324 | // accidental calls to user functions of the same name. |
| 2325 | struct AdlTag {}; |
| 2326 | |
| 2327 | // InvokeArgumentAdl - a helper for InvokeArgument. |
| 2328 | // The basic overloads are provided here for generic functors. |
| 2329 | // Overloads for other custom-callables are provided in the |
| 2330 | // internal/custom/callback-actions.h header. |
| 2331 | |
| 2332 | template <typename R, typename F> |
| 2333 | R InvokeArgumentAdl(AdlTag, F f) { |
| 2334 | return f(); |
| 2335 | } |
| 2336 | template <typename R, typename F, typename A1> |
| 2337 | R InvokeArgumentAdl(AdlTag, F f, A1 a1) { |
| 2338 | return f(a1); |
| 2339 | } |
| 2340 | template <typename R, typename F, typename A1, typename A2> |
| 2341 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2) { |
| 2342 | return f(a1, a2); |
| 2343 | } |
| 2344 | template <typename R, typename F, typename A1, typename A2, typename A3> |
| 2345 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3) { |
| 2346 | return f(a1, a2, a3); |
| 2347 | } |
| 2348 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2349 | typename A4> |
| 2350 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4) { |
| 2351 | return f(a1, a2, a3, a4); |
| 2352 | } |
| 2353 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2354 | typename A4, typename A5> |
| 2355 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { |
| 2356 | return f(a1, a2, a3, a4, a5); |
| 2357 | } |
| 2358 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2359 | typename A4, typename A5, typename A6> |
| 2360 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { |
| 2361 | return f(a1, a2, a3, a4, a5, a6); |
| 2362 | } |
| 2363 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2364 | typename A4, typename A5, typename A6, typename A7> |
| 2365 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2366 | A7 a7) { |
| 2367 | return f(a1, a2, a3, a4, a5, a6, a7); |
| 2368 | } |
| 2369 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2370 | typename A4, typename A5, typename A6, typename A7, typename A8> |
| 2371 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2372 | A7 a7, A8 a8) { |
| 2373 | return f(a1, a2, a3, a4, a5, a6, a7, a8); |
| 2374 | } |
| 2375 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2376 | typename A4, typename A5, typename A6, typename A7, typename A8, |
| 2377 | typename A9> |
| 2378 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2379 | A7 a7, A8 a8, A9 a9) { |
| 2380 | return f(a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| 2381 | } |
| 2382 | template <typename R, typename F, typename A1, typename A2, typename A3, |
| 2383 | typename A4, typename A5, typename A6, typename A7, typename A8, |
| 2384 | typename A9, typename A10> |
| 2385 | R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, |
| 2386 | A7 a7, A8 a8, A9 a9, A10 a10) { |
| 2387 | return f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
| 2388 | } |
| 2389 | } // namespace invoke_argument |
| 2390 | } // namespace internal |
| 2391 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2392 | ACTION_TEMPLATE(InvokeArgument, |
| 2393 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2394 | AND_0_VALUE_PARAMS()) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2395 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2396 | return InvokeArgumentAdl<return_type>( |
| 2397 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2398 | ::testing::get<k>(args)); |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 2399 | } |
| 2400 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2401 | ACTION_TEMPLATE(InvokeArgument, |
| 2402 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2403 | AND_1_VALUE_PARAMS(p0)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2404 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2405 | return InvokeArgumentAdl<return_type>( |
| 2406 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2407 | ::testing::get<k>(args), p0); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2408 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2409 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2410 | ACTION_TEMPLATE(InvokeArgument, |
| 2411 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2412 | AND_2_VALUE_PARAMS(p0, p1)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2413 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2414 | return InvokeArgumentAdl<return_type>( |
| 2415 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2416 | ::testing::get<k>(args), p0, p1); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2417 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2418 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2419 | ACTION_TEMPLATE(InvokeArgument, |
| 2420 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2421 | AND_3_VALUE_PARAMS(p0, p1, p2)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2422 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2423 | return InvokeArgumentAdl<return_type>( |
| 2424 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2425 | ::testing::get<k>(args), p0, p1, p2); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2426 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2427 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2428 | ACTION_TEMPLATE(InvokeArgument, |
| 2429 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2430 | AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2431 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2432 | return InvokeArgumentAdl<return_type>( |
| 2433 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2434 | ::testing::get<k>(args), p0, p1, p2, p3); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2435 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2436 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2437 | ACTION_TEMPLATE(InvokeArgument, |
| 2438 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2439 | AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2440 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2441 | return InvokeArgumentAdl<return_type>( |
| 2442 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2443 | ::testing::get<k>(args), p0, p1, p2, p3, p4); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2444 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2445 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2446 | ACTION_TEMPLATE(InvokeArgument, |
| 2447 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2448 | AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2449 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2450 | return InvokeArgumentAdl<return_type>( |
| 2451 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2452 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2453 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2454 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2455 | ACTION_TEMPLATE(InvokeArgument, |
| 2456 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2457 | AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2458 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2459 | return InvokeArgumentAdl<return_type>( |
| 2460 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2461 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2462 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2463 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2464 | ACTION_TEMPLATE(InvokeArgument, |
| 2465 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2466 | AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2467 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2468 | return InvokeArgumentAdl<return_type>( |
| 2469 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2470 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2471 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2472 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2473 | ACTION_TEMPLATE(InvokeArgument, |
| 2474 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2475 | AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2476 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2477 | return InvokeArgumentAdl<return_type>( |
| 2478 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2479 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2480 | } |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2481 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2482 | ACTION_TEMPLATE(InvokeArgument, |
| 2483 | HAS_1_TEMPLATE_PARAMS(int, k), |
| 2484 | AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2485 | using internal::invoke_argument::InvokeArgumentAdl; |
| 2486 | return InvokeArgumentAdl<return_type>( |
| 2487 | internal::invoke_argument::AdlTag(), |
kosak | bd01883 | 2014-04-02 20:30:00 +0000 | [diff] [blame] | 2488 | ::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2489 | } |
zhanyong.wan | 7f4c2c0 | 2009-02-19 22:38:27 +0000 | [diff] [blame] | 2490 | |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2491 | // Various overloads for ReturnNew<T>(). |
| 2492 | // |
| 2493 | // The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new |
| 2494 | // instance of type T, constructed on the heap with constructor arguments |
| 2495 | // a1, a2, ..., and a_k. The caller assumes ownership of the returned value. |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2496 | ACTION_TEMPLATE(ReturnNew, |
| 2497 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2498 | AND_0_VALUE_PARAMS()) { |
| 2499 | return new T(); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2500 | } |
| 2501 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2502 | ACTION_TEMPLATE(ReturnNew, |
| 2503 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2504 | AND_1_VALUE_PARAMS(p0)) { |
| 2505 | return new T(p0); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2506 | } |
| 2507 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2508 | ACTION_TEMPLATE(ReturnNew, |
| 2509 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2510 | AND_2_VALUE_PARAMS(p0, p1)) { |
| 2511 | return new T(p0, p1); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2512 | } |
| 2513 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2514 | ACTION_TEMPLATE(ReturnNew, |
| 2515 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2516 | AND_3_VALUE_PARAMS(p0, p1, p2)) { |
| 2517 | return new T(p0, p1, p2); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2518 | } |
| 2519 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2520 | ACTION_TEMPLATE(ReturnNew, |
| 2521 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2522 | AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { |
| 2523 | return new T(p0, p1, p2, p3); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2524 | } |
| 2525 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2526 | ACTION_TEMPLATE(ReturnNew, |
| 2527 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2528 | AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { |
| 2529 | return new T(p0, p1, p2, p3, p4); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2530 | } |
| 2531 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2532 | ACTION_TEMPLATE(ReturnNew, |
| 2533 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2534 | AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { |
| 2535 | return new T(p0, p1, p2, p3, p4, p5); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2536 | } |
| 2537 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2538 | ACTION_TEMPLATE(ReturnNew, |
| 2539 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2540 | AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { |
| 2541 | return new T(p0, p1, p2, p3, p4, p5, p6); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2542 | } |
| 2543 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2544 | ACTION_TEMPLATE(ReturnNew, |
| 2545 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2546 | AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { |
| 2547 | return new T(p0, p1, p2, p3, p4, p5, p6, p7); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2548 | } |
| 2549 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2550 | ACTION_TEMPLATE(ReturnNew, |
| 2551 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2552 | AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { |
| 2553 | return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2554 | } |
| 2555 | |
zhanyong.wan | 16cf473 | 2009-05-14 20:55:30 +0000 | [diff] [blame] | 2556 | ACTION_TEMPLATE(ReturnNew, |
| 2557 | HAS_1_TEMPLATE_PARAMS(typename, T), |
| 2558 | AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { |
| 2559 | return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); |
zhanyong.wan | 1c8eb1c | 2009-04-09 07:29:58 +0000 | [diff] [blame] | 2560 | } |
| 2561 | |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2562 | #ifdef _MSC_VER |
zhanyong.wan | 658ac0b | 2011-02-24 07:29:13 +0000 | [diff] [blame] | 2563 | # pragma warning(pop) |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 2564 | #endif |
| 2565 | |
zhanyong.wan | e1cdce5 | 2009-02-06 01:09:43 +0000 | [diff] [blame] | 2566 | } // namespace testing |
| 2567 | |
Gennadiy Civil | e1071eb | 2018-04-10 15:57:16 -0400 | [diff] [blame] | 2568 | // Include any custom callback actions added by the local installation. |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2569 | // We must include this header at the end to make sure it can use the |
| 2570 | // declarations from this file. |
kosak | 6e10872 | 2015-07-28 00:53:13 +0000 | [diff] [blame] | 2571 | #include "gmock/internal/custom/gmock-generated-actions.h" |
kosak | 67c377d | 2015-07-19 20:39:47 +0000 | [diff] [blame] | 2572 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 2573 | #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ |