Commit 7a8591e6 by Abseil Team Committed by vslashg

Googletest export

Use GMOCK_PP to generate args boilerplate. Move common args describing part to separate macroses that uses GMOCK_PP to generate sequences. PiperOrigin-RevId: 289655624
parent 0b024bd9
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "gmock/internal/gmock-internal-utils.h" #include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-pp.h"
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) # pragma warning(push)
...@@ -1275,6 +1276,21 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { ...@@ -1275,6 +1276,21 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) {
} }
} // namespace invoke_argument } // namespace invoke_argument
#define GMOCK_INTERNAL_ARG_UNUSED(N, data, el) \
, const arg##N##_type& arg##N GTEST_ATTRIBUTE_UNUSED_
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
GMOCK_INTERNAL_ARG_UNUSED, , 10)
#define GMOCK_INTERNAL_ARG(N, data, el) , const arg##N##_type& arg##N
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_ \
const args_type& args GMOCK_PP_REPEAT(GMOCK_INTERNAL_ARG, , 10)
#define GMOCK_INTERNAL_TEMPLATE_ARG(N, data, el) , typename arg##N##_type
#define GMOCK_ACTION_TEMPLATE_ARGS_NAMES_ \
GMOCK_PP_TAIL(GMOCK_PP_REPEAT(GMOCK_INTERNAL_TEMPLATE_ARG, , 10))
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
......
...@@ -147,12 +147,6 @@ $$}} This meta comment fixes auto-indentation in editors. ...@@ -147,12 +147,6 @@ $$}} This meta comment fixes auto-indentation in editors.
$range i 0..n $range i 0..n
$range k 0..n-1 $range k 0..n-1
// An internal macro needed for implementing ACTION*().
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
const args_type& args GTEST_ATTRIBUTE_UNUSED_
$for k [[, \
const arg$k[[]]_type& arg$k GTEST_ATTRIBUTE_UNUSED_]]
// Sometimes you want to give an action explicit template parameters // Sometimes you want to give an action explicit template parameters
// that cannot be inferred from its value parameters. ACTION() and // that cannot be inferred from its value parameters. ACTION() and
...@@ -351,9 +345,8 @@ $range k 0..n-1 ...@@ -351,9 +345,8 @@ $range k 0..n-1
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\ Perform(this, args);\
}\ }\
template <$for k, [[typename arg$k[[]]_type]]>\ template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\
return_type gmock_PerformImpl(const args_type& args[[]] return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\
$for k [[, const arg$k[[]]_type& arg$k]]) const;\
GMOCK_INTERNAL_DEFN_##value_params\ GMOCK_INTERNAL_DEFN_##value_params\
private:\ private:\
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
...@@ -380,10 +373,7 @@ $for k [[, const arg$k[[]]_type& arg$k]]) const;\ ...@@ -380,10 +373,7 @@ $for k [[, const arg$k[[]]_type& arg$k]]) const;\
template <GMOCK_INTERNAL_DECL_##template_params\ template <GMOCK_INTERNAL_DECL_##template_params\
GMOCK_INTERNAL_DECL_TYPE_##value_params>\ GMOCK_INTERNAL_DECL_TYPE_##value_params>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\
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\ typename ::testing::internal::Function<F>::Result\
GMOCK_ACTION_CLASS_(name, value_params)<\ GMOCK_ACTION_CLASS_(name, value_params)<\
GMOCK_INTERNAL_LIST_##template_params\ GMOCK_INTERNAL_LIST_##template_params\
...@@ -439,9 +429,8 @@ $var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]] ...@@ -439,9 +429,8 @@ $var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\ Perform(this, args);\
}\ }\
template <$typename_arg_types>\ template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\
return_type gmock_PerformImpl(const args_type& args, [[]] return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\$param_field_decls
$arg_types_and_names) const;\$param_field_decls
private:\ private:\
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\ };\
...@@ -452,7 +441,7 @@ $arg_types_and_names) const;\$param_field_decls ...@@ -452,7 +441,7 @@ $arg_types_and_names) const;\$param_field_decls
return $class_name$param_types($params);\ return $class_name$param_types($params);\
}\$template }\$template
template <typename F>\ template <typename F>\
template <$typename_arg_types>\ template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
$class_name$param_types::gmock_Impl<F>::gmock_PerformImpl(\ $class_name$param_types::gmock_Impl<F>::gmock_PerformImpl(\
GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment