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