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 
  35 
  36 // Google Mock - a framework for writing C++ mock classes.
  37 //
  38 // This file contains template meta-programming utility classes needed
  39 // for implementing Google Mock.
  40 
  41 // GOOGLETEST_CM0002 DO NOT DELETE
  42 
  43 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
  44 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
  45 
  46 #include "gmock/internal/gmock-port.h"
  47 
  48 namespace testing {
  49 
  50 template <typename T>
  51 class Matcher;
  52 
  53 namespace internal {
  54 
  55 // An IgnoredValue object can be implicitly constructed from ANY value.
  56 // This is used in implementing the IgnoreResult(a) action.
  57 class IgnoredValue {
  58  public:
  59   // This constructor template allows any value to be implicitly
  60   // converted to IgnoredValue.  The object has no data member and
  61   // doesn't try to remember anything about the argument.  We
  62   // deliberately omit the 'explicit' keyword in order to allow the
  63   // conversion to be implicit.
  64   template <typename T>
  65   IgnoredValue(const T& /* ignored */) {}  // NOLINT(runtime/explicit)
  66 };
  67 
  68 // MatcherTuple<T>::type is a tuple type where each field is a Matcher
  69 // for the corresponding field in tuple type T.
  70 template <typename Tuple>
  71 struct MatcherTuple;
  72 
  73 
  74 $range i 0..n
  75 $for i [[
  76 $range j 1..i
  77 $var typename_As = [[$for j, [[typename A$j]]]]
  78 $var As = [[$for j, [[A$j]]]]
  79 $var matcher_As = [[$for j, [[Matcher<A$j>]]]]
  80 template <$typename_As>
  81 struct MatcherTuple< ::testing::tuple<$As> > {
  82   typedef ::testing::tuple<$matcher_As > type;
  83 };
  84 
  85 
  86 ]]
  87 // Template struct Function<F>, where F must be a function type, contains
  88 // the following typedefs:
  89 //
  90 //   Result:               the function's return type.
  91 //   ArgumentN:            the type of the N-th argument, where N starts with 1.
  92 //   ArgumentTuple:        the tuple type consisting of all parameters of F.
  93 //   ArgumentMatcherTuple: the tuple type consisting of Matchers for all
  94 //                         parameters of F.
  95 //   MakeResultVoid:       the function type obtained by substituting void
  96 //                         for the return type of F.
  97 //   MakeResultIgnoredValue:
  98 //                         the function type obtained by substituting Something
  99 //                         for the return type of F.
 100 template <typename F>
 101 struct Function;
 102 
 103 template <typename R>
 104 struct Function<R()> {
 105   typedef R Result;
 106   typedef ::testing::tuple<> ArgumentTuple;
 107   typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
 108   typedef void MakeResultVoid();
 109   typedef IgnoredValue MakeResultIgnoredValue();
 110 };
 111 
 112 
 113 $range i 1..n
 114 $for i [[
 115 $range j 1..i
 116 $var typename_As = [[$for j [[, typename A$j]]]]
 117 $var As = [[$for j, [[A$j]]]]
 118 $var matcher_As = [[$for j, [[Matcher<A$j>]]]]
 119 $range k 1..i-1
 120 $var prev_As = [[$for k, [[A$k]]]]
 121 template <typename R$typename_As>
 122 struct Function<R($As)>
 123     : Function<R($prev_As)> {
 124   typedef A$i Argument$i;
 125   typedef ::testing::tuple<$As> ArgumentTuple;
 126   typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
 127   typedef void MakeResultVoid($As);
 128   typedef IgnoredValue MakeResultIgnoredValue($As);
 129 };
 130 
 131 
 132 ]]
 133 }  // namespace internal
 134 
 135 }  // namespace testing
 136 
 137 #endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_