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.
36 // Google Mock - a framework for writing C++ mock classes.
38 // This file contains template meta-programming utility classes needed
39 // for implementing Google Mock.
41 // GOOGLETEST_CM0002 DO NOT DELETE
43 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
44 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
46 #include "gmock/internal/gmock-port.h"
55 // An IgnoredValue object can be implicitly constructed from ANY value.
56 // This is used in implementing the IgnoreResult(a) action.
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.
65 IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
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>
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;
87 // Template struct Function<F>, where F must be a function type, contains
88 // the following typedefs:
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
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>
103 template <typename R>
104 struct Function<R()> {
106 typedef ::testing::tuple<> ArgumentTuple;
107 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
108 typedef void MakeResultVoid();
109 typedef IgnoredValue MakeResultIgnoredValue();
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>]]]]
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);
133 } // namespace internal
135 } // namespace testing
137 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_