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