gmock-generated-internal-utils.h.pump 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. $$ -*- mode: c++; -*-
  2. $$ This is a Pump source file. Please use Pump to convert it to
  3. $$ gmock-generated-function-mockers.h.
  4. $$
  5. $var n = 10 $$ The maximum arity we support.
  6. // Copyright 2007, Google Inc.
  7. // All rights reserved.
  8. //
  9. // Redistribution and use in source and binary forms, with or without
  10. // modification, are permitted provided that the following conditions are
  11. // met:
  12. //
  13. // * Redistributions of source code must retain the above copyright
  14. // notice, this list of conditions and the following disclaimer.
  15. // * Redistributions in binary form must reproduce the above
  16. // copyright notice, this list of conditions and the following disclaimer
  17. // in the documentation and/or other materials provided with the
  18. // distribution.
  19. // * Neither the name of Google Inc. nor the names of its
  20. // contributors may be used to endorse or promote products derived from
  21. // this software without specific prior written permission.
  22. //
  23. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  27. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  28. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  29. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  30. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  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. // GOOGLETEST_CM0002 DO NOT DELETE
  39. #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
  40. #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
  41. #include "gmock/internal/gmock-port.h"
  42. namespace testing {
  43. template <typename T>
  44. class Matcher;
  45. namespace internal {
  46. // An IgnoredValue object can be implicitly constructed from ANY value.
  47. // This is used in implementing the IgnoreResult(a) action.
  48. class IgnoredValue {
  49. public:
  50. // This constructor template allows any value to be implicitly
  51. // converted to IgnoredValue. The object has no data member and
  52. // doesn't try to remember anything about the argument. We
  53. // deliberately omit the 'explicit' keyword in order to allow the
  54. // conversion to be implicit.
  55. template <typename T>
  56. IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
  57. };
  58. // MatcherTuple<T>::type is a tuple type where each field is a Matcher
  59. // for the corresponding field in tuple type T.
  60. template <typename Tuple>
  61. struct MatcherTuple;
  62. $range i 0..n
  63. $for i [[
  64. $range j 1..i
  65. $var typename_As = [[$for j, [[typename A$j]]]]
  66. $var As = [[$for j, [[A$j]]]]
  67. $var matcher_As = [[$for j, [[Matcher<A$j>]]]]
  68. template <$typename_As>
  69. struct MatcherTuple< ::testing::tuple<$As> > {
  70. typedef ::testing::tuple<$matcher_As > type;
  71. };
  72. ]]
  73. // Template struct Function<F>, where F must be a function type, contains
  74. // the following typedefs:
  75. //
  76. // Result: the function's return type.
  77. // ArgumentN: the type of the N-th argument, where N starts with 1.
  78. // ArgumentTuple: the tuple type consisting of all parameters of F.
  79. // ArgumentMatcherTuple: the tuple type consisting of Matchers for all
  80. // parameters of F.
  81. // MakeResultVoid: the function type obtained by substituting void
  82. // for the return type of F.
  83. // MakeResultIgnoredValue:
  84. // the function type obtained by substituting Something
  85. // for the return type of F.
  86. template <typename F>
  87. struct Function;
  88. template <typename R>
  89. struct Function<R()> {
  90. typedef R Result;
  91. typedef ::testing::tuple<> ArgumentTuple;
  92. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  93. typedef void MakeResultVoid();
  94. typedef IgnoredValue MakeResultIgnoredValue();
  95. };
  96. $range i 1..n
  97. $for i [[
  98. $range j 1..i
  99. $var typename_As = [[$for j [[, typename A$j]]]]
  100. $var As = [[$for j, [[A$j]]]]
  101. $var matcher_As = [[$for j, [[Matcher<A$j>]]]]
  102. $range k 1..i-1
  103. $var prev_As = [[$for k, [[A$k]]]]
  104. template <typename R$typename_As>
  105. struct Function<R($As)>
  106. : Function<R($prev_As)> {
  107. typedef A$i Argument$i;
  108. typedef ::testing::tuple<$As> ArgumentTuple;
  109. typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
  110. typedef void MakeResultVoid($As);
  111. typedef IgnoredValue MakeResultIgnoredValue($As);
  112. };
  113. ]]
  114. } // namespace internal
  115. } // namespace testing
  116. #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_