gmock-generated-actions.h 102 KB

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