2 $$ This is a Pump source file. Please use Pump to convert it to
3 $$ gmock-generated-function-mockers.h.
5 $var n = 10 $$ The maximum arity we support.
6 // Copyright 2007, Google Inc.
7 // All rights reserved.
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
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
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.
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.
35 // Author: wan@google.com (Zhanyong Wan)
37 // Google Mock - a framework for writing C++ mock classes.
39 // This file contains template meta-programming utility classes needed
40 // for implementing Google Mock.
42 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
43 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
45 #include "gmock/internal/gmock-port.h"
54 // An IgnoredValue object can be implicitly constructed from ANY value.
55 // This is used in implementing the IgnoreResult(a) action.
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.
64 IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
67 // MatcherTuple<T>::type is a tuple type where each field is a Matcher
68 // for the corresponding field in tuple type T.
69 template <typename Tuple>
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>]]]]
79 template <$typename_As>
80 struct MatcherTuple< ::testing::tuple<$As> > {
81 typedef ::testing::tuple<$matcher_As > type;
86 // Template struct Function<F>, where F must be a function type, contains
87 // the following typedefs:
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
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.
102 template <typename R>
103 struct Function<R()> {
105 typedef ::testing::tuple<> ArgumentTuple;
106 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
107 typedef void MakeResultVoid();
108 typedef IgnoredValue MakeResultIgnoredValue();
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>]]]]
119 $var prev_As = [[$for k, [[A$k]]]]
120 template <typename R$typename_As>
121 struct 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);
132 } // namespace internal
134 } // namespace testing
136 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_