123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 |
- $$ -*- mode: c++; -*-
- $$ This is a Pump source file. Please use Pump to convert it to
- $$ gmock-generated-actions.h.
- $$
- $var n = 10 $$ The maximum arity we support.
- $$}} This meta comment fixes auto-indentation in editors.
- #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
- #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
- #include "gmock/gmock-actions.h"
- #include "gmock/internal/gmock-port.h"
- namespace testing {
- namespace internal {
- template <typename Result, typename ArgumentTuple>
- class InvokeHelper;
- $var max_callback_arity = 5
- $range i 0..n
- $for i [[
- $range j 1..i
- $var types = [[$for j [[, typename A$j]]]]
- $var as = [[$for j, [[A$j]]]]
- $var args = [[$if i==0 [[]] $else [[ args]]]]
- $var gets = [[$for j, [[get<$(j - 1)>(args)]]]]
- template <typename R$types>
- class InvokeHelper<R, ::testing::tuple<$as> > {
- public:
- template <typename Function>
- static R Invoke(Function function, const ::testing::tuple<$as>&$args) {
- return function($gets);
- }
- template <class Class, typename MethodPtr>
- static R InvokeMethod(Class* obj_ptr,
- MethodPtr method_ptr,
- const ::testing::tuple<$as>&$args) {
- return (obj_ptr->*method_ptr)($gets);
- }
- $if i <= max_callback_arity [[
- template <typename CallbackType>
- static R InvokeCallback(CallbackType* callback,
- const ::testing::tuple<$as>&$args) {
- return callback->Run($gets);
- }
- ]] $else [[
-
- ]]
- };
- ]]
- template <typename CallbackType>
- class InvokeCallbackAction {
- public:
-
- explicit InvokeCallbackAction(CallbackType* callback)
- : callback_(callback) {
- callback->CheckIsRepeatable();
- }
-
-
-
-
-
-
- template <typename Result, typename ArgumentTuple>
- Result Perform(const ArgumentTuple& args) const {
- return InvokeHelper<Result, ArgumentTuple>::InvokeCallback(
- callback_.get(), args);
- }
- private:
- const linked_ptr<CallbackType> callback_;
- };
- #define GMOCK_FIELD_(Tuple, N) \
- typename ::testing::tuple_element<N, Tuple>::type
- $range i 1..n
- template <typename Result, typename ArgumentTuple, $for i, [[int k$i]]>
- class SelectArgs {
- public:
- typedef Result type($for i, [[GMOCK_FIELD_(ArgumentTuple, k$i)]]);
- typedef typename Function<type>::ArgumentTuple SelectedArgs;
- static SelectedArgs Select(const ArgumentTuple& args) {
- return SelectedArgs($for i, [[get<k$i>(args)]]);
- }
- };
- $for i [[
- $range j 1..n
- $range j1 1..i-1
- template <typename Result, typename ArgumentTuple$for j1[[, int k$j1]]>
- class SelectArgs<Result, ArgumentTuple,
- $for j, [[$if j <= i-1 [[k$j]] $else [[-1]]]]> {
- public:
- typedef Result type($for j1, [[GMOCK_FIELD_(ArgumentTuple, k$j1)]]);
- typedef typename Function<type>::ArgumentTuple SelectedArgs;
- static SelectedArgs Select(const ArgumentTuple& [[]]
- $if i == 1 [[]] $else [[args]]) {
- return SelectedArgs($for j1, [[get<k$j1>(args)]]);
- }
- };
- ]]
- #undef GMOCK_FIELD_
- $var ks = [[$for i, [[k$i]]]]
- template <typename InnerAction, $for i, [[int k$i = -1]]>
- class WithArgsAction {
- public:
- explicit WithArgsAction(const InnerAction& action) : action_(action) {}
- template <typename F>
- operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
- private:
- template <typename F>
- class Impl : public ActionInterface<F> {
- public:
- typedef typename Function<F>::Result Result;
- typedef typename Function<F>::ArgumentTuple ArgumentTuple;
- explicit Impl(const InnerAction& action) : action_(action) {}
- virtual Result Perform(const ArgumentTuple& args) {
- return action_.Perform(SelectArgs<Result, ArgumentTuple, $ks>::Select(args));
- }
- private:
- typedef typename SelectArgs<Result, ArgumentTuple,
- $ks>::type InnerFunctionType;
- Action<InnerFunctionType> action_;
- };
- const InnerAction action_;
- GTEST_DISALLOW_ASSIGN_(WithArgsAction);
- };
- struct ExcessiveArg {};
- template <typename Result, class Impl>
- class ActionHelper {
- public:
- $range i 0..n
- $for i
- [[
- $var template = [[$if i==0 [[]] $else [[
- $range j 0..i-1
- template <$for j, [[typename A$j]]>
- ]]]]
- $range j 0..i-1
- $var As = [[$for j, [[A$j]]]]
- $var as = [[$for j, [[get<$j>(args)]]]]
- $range k 1..n-i
- $var eas = [[$for k, [[ExcessiveArg()]]]]
- $var arg_list = [[$if (i==0) | (i==n) [[$as$eas]] $else [[$as, $eas]]]]
- $template
- static Result Perform(Impl* impl, const ::testing::tuple<$As>& args) {
- return impl->template gmock_PerformImpl<$As>(args, $arg_list);
- }
- ]]
- };
- }
- $range i 1..n
- $for i [[
- $range j 1..i
- template <$for j [[int k$j, ]]typename InnerAction>
- inline internal::WithArgsAction<InnerAction$for j [[, k$j]]>
- WithArgs(const InnerAction& action) {
- return internal::WithArgsAction<InnerAction$for j [[, k$j]]>(action);
- }
- ]]
- $range i 2..n
- $for i [[
- $range j 2..i
- $var types = [[$for j, [[typename Action$j]]]]
- $var Aas = [[$for j [[, Action$j a$j]]]]
- template <typename Action1, $types>
- $range k 1..i-1
- inline $for k [[internal::DoBothAction<Action$k, ]]Action$i$for k [[>]]
- DoAll(Action1 a1$Aas) {
- $if i==2 [[
- return internal::DoBothAction<Action1, Action2>(a1, a2);
- ]] $else [[
- $range j2 2..i
- return DoAll(a1, DoAll($for j2, [[a$j2]]));
- ]]
- }
- ]]
- }
- $range i 0..n
- $range k 0..n-1
- #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
- const args_type& args GTEST_ATTRIBUTE_UNUSED_
- $for k [[, \
- arg$k[[]]_type arg$k GTEST_ATTRIBUTE_UNUSED_]]
- $range j 1..n
- $for j [[
- $range m 0..j-1
- #define GMOCK_INTERNAL_DECL_HAS_$j[[]]
- _TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[kind$m name$m]]
- ]]
- $for j [[
- $range m 0..j-1
- #define GMOCK_INTERNAL_LIST_HAS_$j[[]]
- _TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[name$m]]
- ]]
- $for i [[
- $range j 0..i-1
- #define GMOCK_INTERNAL_DECL_TYPE_AND_$i[[]]
- _VALUE_PARAMS($for j, [[p$j]]) $for j [[, typename p$j##_type]]
- ]]
- $for i [[
- $range j 0..i-1
- #define GMOCK_INTERNAL_INIT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])\
- ($for j, [[p$j##_type gmock_p$j]])$if i>0 [[ : ]]$for j, [[p$j(::testing::internal::move(gmock_p$j))]]
- ]]
- $for i [[
- $range j 0..i-1
- #define GMOCK_INTERNAL_DEFN_AND_$i[[]]
- _VALUE_PARAMS($for j, [[p$j]]) $for j [[p$j##_type p$j; ]]
- ]]
- $for i [[
- $range j 0..i-1
- #define GMOCK_INTERNAL_LIST_AND_$i[[]]
- _VALUE_PARAMS($for j, [[p$j]]) $for j, [[p$j]]
- ]]
- $for i [[
- $range j 0..i-1
- #define GMOCK_INTERNAL_LIST_TYPE_AND_$i[[]]
- _VALUE_PARAMS($for j, [[p$j]]) $for j [[, p$j##_type]]
- ]]
- $for i [[
- $range j 0..i-1
- #define GMOCK_INTERNAL_DECL_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]
- $for j, [[p$j##_type p$j]]
- ]]
- $for i [[
- $range j 0..i-1
- #define GMOCK_INTERNAL_COUNT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]
- $if i==1 [[P]] $elif i>=2 [[P$i]]
- ]]
- #define GMOCK_ACTION_CLASS_(name, value_params)\
- GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
- $range k 0..n-1
- #define ACTION_TEMPLATE(name, template_params, value_params)\
- template <GMOCK_INTERNAL_DECL_##template_params\
- GMOCK_INTERNAL_DECL_TYPE_##value_params>\
- class GMOCK_ACTION_CLASS_(name, value_params) {\
- public:\
- explicit GMOCK_ACTION_CLASS_(name, value_params)\
- GMOCK_INTERNAL_INIT_##value_params {}\
- template <typename F>\
- class gmock_Impl : public ::testing::ActionInterface<F> {\
- public:\
- typedef F function_type;\
- typedef typename ::testing::internal::Function<F>::Result return_type;\
- typedef typename ::testing::internal::Function<F>::ArgumentTuple\
- args_type;\
- explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
- virtual return_type Perform(const args_type& args) {\
- return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
- Perform(this, args);\
- }\
- template <$for k, [[typename arg$k[[]]_type]]>\
- return_type gmock_PerformImpl(const args_type& args[[]]
- $for k [[, arg$k[[]]_type arg$k]]) const;\
- GMOCK_INTERNAL_DEFN_##value_params\
- private:\
- GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
- };\
- template <typename F> operator ::testing::Action<F>() const {\
- return ::testing::Action<F>(\
- new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
- }\
- GMOCK_INTERNAL_DEFN_##value_params\
- private:\
- GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
- };\
- template <GMOCK_INTERNAL_DECL_##template_params\
- GMOCK_INTERNAL_DECL_TYPE_##value_params>\
- inline GMOCK_ACTION_CLASS_(name, value_params)<\
- GMOCK_INTERNAL_LIST_##template_params\
- GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
- GMOCK_INTERNAL_DECL_##value_params) {\
- return GMOCK_ACTION_CLASS_(name, value_params)<\
- GMOCK_INTERNAL_LIST_##template_params\
- GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
- GMOCK_INTERNAL_LIST_##value_params);\
- }\
- template <GMOCK_INTERNAL_DECL_##template_params\
- GMOCK_INTERNAL_DECL_TYPE_##value_params>\
- template <typename F>\
- template <typename arg0_type, typename arg1_type, typename arg2_type, \
- typename arg3_type, typename arg4_type, typename arg5_type, \
- typename arg6_type, typename arg7_type, typename arg8_type, \
- typename arg9_type>\
- typename ::testing::internal::Function<F>::Result\
- GMOCK_ACTION_CLASS_(name, value_params)<\
- GMOCK_INTERNAL_LIST_##template_params\
- GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
- gmock_PerformImpl(\
- GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
- $for i
- [[
- $var template = [[$if i==0 [[]] $else [[
- $range j 0..i-1
- template <$for j, [[typename p$j##_type]]>\
- ]]]]
- $var class_name = [[name##Action[[$if i==0 [[]] $elif i==1 [[P]]
- $else [[P$i]]]]]]
- $range j 0..i-1
- $var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
- $var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]
- $var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::testing::internal::forward<p$j##_type>(gmock_p$j))]]]]]]
- $var param_field_decls = [[$for j
- [[
- p$j##_type p$j;\
- ]]]]
- $var param_field_decls2 = [[$for j
- [[
- p$j##_type p$j;\
- ]]]]
- $var params = [[$for j, [[p$j]]]]
- $var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]
- $var typename_arg_types = [[$for k, [[typename arg$k[[]]_type]]]]
- $var arg_types_and_names = [[$for k, [[arg$k[[]]_type arg$k]]]]
- $var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
- $else [[ACTION_P$i]]]]
- #define $macro_name(name$for j [[, p$j]])\$template
- class $class_name {\
- public:\
- [[$if i==1 [[explicit ]]]]$class_name($ctor_param_list)$inits {}\
- template <typename F>\
- class gmock_Impl : public ::testing::ActionInterface<F> {\
- public:\
- typedef F function_type;\
- typedef typename ::testing::internal::Function<F>::Result return_type;\
- typedef typename ::testing::internal::Function<F>::ArgumentTuple\
- args_type;\
- [[$if i==1 [[explicit ]]]]gmock_Impl($ctor_param_list)$inits {}\
- virtual return_type Perform(const args_type& args) {\
- return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
- Perform(this, args);\
- }\
- template <$typename_arg_types>\
- return_type gmock_PerformImpl(const args_type& args, [[]]
- $arg_types_and_names) const;\$param_field_decls
- private:\
- GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
- };\
- template <typename F> operator ::testing::Action<F>() const {\
- return ::testing::Action<F>(new gmock_Impl<F>($params));\
- }\$param_field_decls2
- private:\
- GTEST_DISALLOW_ASSIGN_($class_name);\
- };\$template
- inline $class_name$param_types name($param_types_and_names) {\
- return $class_name$param_types($params);\
- }\$template
- template <typename F>\
- template <$typename_arg_types>\
- typename ::testing::internal::Function<F>::Result\
- $class_name$param_types::gmock_Impl<F>::gmock_PerformImpl(\
- GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
- ]]
- $$ }
- $$
- namespace testing {
- #ifdef _MSC_VER
- # pragma warning(push)
- # pragma warning(disable:4100)
- #endif
- namespace internal {
- namespace invoke_argument {
- struct AdlTag {};
- $range i 0..n
- $for i
- [[
- $range j 1..i
- template <typename R, typename F[[$for j [[, typename A$j]]]]>
- R InvokeArgumentAdl(AdlTag, F f[[$for j [[, A$j a$j]]]]) {
- return f([[$for j, [[a$j]]]]);
- }
- ]]
- }
- }
- $range i 0..n
- $for i [[
- $range j 0..i-1
- ACTION_TEMPLATE(InvokeArgument,
- HAS_1_TEMPLATE_PARAMS(int, k),
- AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) {
- using internal::invoke_argument::InvokeArgumentAdl;
- return InvokeArgumentAdl<return_type>(
- internal::invoke_argument::AdlTag(),
- ::testing::get<k>(args)$for j [[, p$j]]);
- }
- ]]
- $range i 0..n
- $for i [[
- $range j 0..i-1
- $var ps = [[$for j, [[p$j]]]]
- ACTION_TEMPLATE(ReturnNew,
- HAS_1_TEMPLATE_PARAMS(typename, T),
- AND_$i[[]]_VALUE_PARAMS($ps)) {
- return new T($ps);
- }
- ]]
- #ifdef _MSC_VER
- # pragma warning(pop)
- #endif
- }
- #include "gmock/internal/custom/gmock-generated-actions.h"
- #endif
|