gmock-generated-internal-utils.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. // This file was GENERATED by command:
  2. // pump.py gmock-generated-internal-utils.h.pump
  3. // DO NOT EDIT BY HAND!!!
  4. // Copyright 2007, Google Inc.
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. //
  11. // * Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. // * Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Google Inc. nor the names of its
  18. // contributors may be used to endorse or promote products derived from
  19. // this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. // Author: wan@google.com (Zhanyong Wan)
  34. // Google Mock - a framework for writing C++ mock classes.
  35. //
  36. // This file contains template meta-programming utility classes needed
  37. // for implementing Google Mock.
  38. #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
  39. #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
  40. #include "gmock/internal/gmock-port.h"
  41. namespace testing {
  42. template <typename T>
  43. class Matcher;
  44. namespace internal {
  45. // An IgnoredValue object can be implicitly constructed from ANY value.
  46. // This is used in implementing the IgnoreResult(a) action.
  47. class IgnoredValue {
  48. public:
  49. // This constructor template allows any value to be implicitly
  50. // converted to IgnoredValue. The object has no data member and
  51. // doesn't try to remember anything about the argument. We
  52. // deliberately omit the 'explicit' keyword in order to allow the
  53. // conversion to be implicit.
  54. template <typename T>
  55. IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
  56. };
  57. // MatcherTuple<T>::type is a tuple type where each field is a Matcher
  58. // for the corresponding field in tuple type T.
  59. template <typename Tuple>
  60. struct MatcherTuple;
  61. template <>
  62. struct MatcherTuple< ::testing::tuple<> > {
  63. typedef ::testing::tuple< > type;
  64. };
  65. template <typename A1>
  66. struct MatcherTuple< ::testing::tuple<A1> > {
  67. typedef ::testing::tuple<Matcher<A1> > type;
  68. };
  69. template <typename A1, typename A2>
  70. struct MatcherTuple< ::testing::tuple<A1, A2> > {
  71. typedef ::testing::tuple<Matcher<A1>, Matcher<A2> > type;
  72. };
  73. template <typename A1, typename A2, typename A3>
  74. struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
  75. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
  76. };
  77. template <typename A1, typename A2, typename A3, typename A4>
  78. struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4> > {
  79. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
  80. Matcher<A4> > type;
  81. };
  82. template <typename A1, typename A2, typename A3, typename A4, typename A5>
  83. struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5> > {
  84. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
  85. Matcher<A5> > type;
  86. };
  87. template <typename A1, typename A2, typename A3, typename A4, typename A5,
  88. typename A6>
  89. struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
  90. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
  91. Matcher<A5>, Matcher<A6> > type;
  92. };
  93. template <typename A1, typename A2, typename A3, typename A4, typename A5,
  94. typename A6, typename A7>
  95. struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
  96. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
  97. Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
  98. };
  99. template <typename A1, typename A2, typename A3, typename A4, typename A5,
  100. typename A6, typename A7, typename A8>
  101. struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
  102. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
  103. Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
  104. };
  105. template <typename A1, typename A2, typename A3, typename A4, typename A5,
  106. typename A6, typename A7, typename A8, typename A9>
  107. struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
  108. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
  109. Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
  110. };
  111. template <typename A1, typename A2, typename A3, typename A4, typename A5,
  112. typename A6, typename A7, typename A8, typename A9, typename A10>
  113. struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
  114. A10> > {
  115. typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
  116. Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
  117. Matcher<A10> > type;
  118. };
  119. // Template struct Function<F>, where F must be a function type, contains
  120. // the following typedefs:
  121. //
  122. // Result: the function's return type.
  123. // ArgumentN: the type of the N-th argument, where N starts with 1.
  124. // ArgumentTuple: the tuple type consisting of all parameters of F.
  125. // ArgumentMatcherTuple: the tuple type consisting of Matchers for all
  126. // parameters of F.
  127. // MakeResultVoid: the function type obtained by substituting void
  128. // for the return type of F.
  129. // MakeResultIgnoredValue:
  130. // the function type obtained by substituting Something
  131. // for the return type of F.
  132. template <typename F>
  133. struct Function;
  134. template <typename R>
  135. struct Function<R()> {
  136. typedef R Result;
  137. typedef ::testing::tuple<> ArgumentTuple;
  138. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  139. typedef void MakeResultVoid();
  140. typedef IgnoredValue MakeResultIgnoredValue();
  141. };
  142. template <typename R, typename A1>
  143. struct Function<R(A1)>
  144. : Function<R()> {
  145. typedef A1 Argument1;
  146. typedef ::testing::tuple<A1> ArgumentTuple;
  147. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  148. typedef void MakeResultVoid(A1);
  149. typedef IgnoredValue MakeResultIgnoredValue(A1);
  150. };
  151. template <typename R, typename A1, typename A2>
  152. struct Function<R(A1, A2)>
  153. : Function<R(A1)> {
  154. typedef A2 Argument2;
  155. typedef ::testing::tuple<A1, A2> ArgumentTuple;
  156. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  157. typedef void MakeResultVoid(A1, A2);
  158. typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
  159. };
  160. template <typename R, typename A1, typename A2, typename A3>
  161. struct Function<R(A1, A2, A3)>
  162. : Function<R(A1, A2)> {
  163. typedef A3 Argument3;
  164. typedef ::testing::tuple<A1, A2, A3> ArgumentTuple;
  165. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  166. typedef void MakeResultVoid(A1, A2, A3);
  167. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
  168. };
  169. template <typename R, typename A1, typename A2, typename A3, typename A4>
  170. struct Function<R(A1, A2, A3, A4)>
  171. : Function<R(A1, A2, A3)> {
  172. typedef A4 Argument4;
  173. typedef ::testing::tuple<A1, A2, A3, A4> ArgumentTuple;
  174. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  175. typedef void MakeResultVoid(A1, A2, A3, A4);
  176. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
  177. };
  178. template <typename R, typename A1, typename A2, typename A3, typename A4,
  179. typename A5>
  180. struct Function<R(A1, A2, A3, A4, A5)>
  181. : Function<R(A1, A2, A3, A4)> {
  182. typedef A5 Argument5;
  183. typedef ::testing::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
  184. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  185. typedef void MakeResultVoid(A1, A2, A3, A4, A5);
  186. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
  187. };
  188. template <typename R, typename A1, typename A2, typename A3, typename A4,
  189. typename A5, typename A6>
  190. struct Function<R(A1, A2, A3, A4, A5, A6)>
  191. : Function<R(A1, A2, A3, A4, A5)> {
  192. typedef A6 Argument6;
  193. typedef ::testing::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
  194. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  195. typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
  196. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
  197. };
  198. template <typename R, typename A1, typename A2, typename A3, typename A4,
  199. typename A5, typename A6, typename A7>
  200. struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
  201. : Function<R(A1, A2, A3, A4, A5, A6)> {
  202. typedef A7 Argument7;
  203. typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
  204. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  205. typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
  206. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
  207. };
  208. template <typename R, typename A1, typename A2, typename A3, typename A4,
  209. typename A5, typename A6, typename A7, typename A8>
  210. struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
  211. : Function<R(A1, A2, A3, A4, A5, A6, A7)> {
  212. typedef A8 Argument8;
  213. typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
  214. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  215. typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
  216. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
  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. struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
  221. : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
  222. typedef A9 Argument9;
  223. typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
  224. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  225. typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
  226. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
  227. A9);
  228. };
  229. template <typename R, typename A1, typename A2, typename A3, typename A4,
  230. typename A5, typename A6, typename A7, typename A8, typename A9,
  231. typename A10>
  232. struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
  233. : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
  234. typedef A10 Argument10;
  235. typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
  236. A10> ArgumentTuple;
  237. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  238. typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
  239. typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
  240. A9, A10);
  241. };
  242. } // namespace internal
  243. } // namespace testing
  244. #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_