From 20be7d84d069c717258a759ace2663da860675b6 Mon Sep 17 00:00:00 2001 From: mat007 Date: Sun, 1 Mar 2015 11:28:10 +0000 Subject: [PATCH] Reduced preprocessor macros git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@767 860be788-9bd5-4423-9f1e-828f051e677b --- turtle/detail/expectation_template.hpp | 20 +++++--------------- turtle/detail/function_impl_template.hpp | 6 +++++- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/turtle/detail/expectation_template.hpp b/turtle/detail/expectation_template.hpp index efa0aee..38e4dc9 100644 --- a/turtle/detail/expectation_template.hpp +++ b/turtle/detail/expectation_template.hpp @@ -27,16 +27,6 @@ #define MOCK_EXPECTATION_SERIALIZE(z, n, d) \ BOOST_PP_IF(n, << ", " <<,) *e.c##n##_ -#define MOCK_EXPECTATION_IN_ADD(z, n, d ) \ - s##n.impl_->add( this ); sequences_.push_back( s##n.impl_ ); - -#define MOCK_EXPECTATION_IN(z, n, d) \ - expectation& in( BOOST_PP_ENUM_PARAMS(n, sequence& s) ) \ - { \ - BOOST_PP_REPEAT(n, MOCK_EXPECTATION_IN_ADD, _ ) \ - return *this; \ - } - namespace mock { namespace detail @@ -91,8 +81,11 @@ namespace detail } #endif - BOOST_PP_REPEAT(MOCK_MAX_SEQUENCES, - MOCK_EXPECTATION_IN, _) + void add( sequence& s ) + { + s.impl_->add( this ); + sequences_.push_back( s.impl_ ); + } bool verify() const { @@ -160,12 +153,9 @@ namespace detail } } // mock -#undef MOCK_EXPECTATION_TYPEDEF #undef MOCK_EXPECTATION_INITIALIZE #undef MOCK_EXPECTATION_WITH #undef MOCK_EXPECTATION_MEMBER #undef MOCK_EXPECTATION_ARGS #undef MOCK_EXPECTATION_IS_VALID #undef MOCK_EXPECTATION_SERIALIZE -#undef MOCK_EXPECTATION_IN -#undef MOCK_EXPECTATION_IN_ADD diff --git a/turtle/detail/function_impl_template.hpp b/turtle/detail/function_impl_template.hpp index 65fdc53..d58d128 100644 --- a/turtle/detail/function_impl_template.hpp +++ b/turtle/detail/function_impl_template.hpp @@ -142,10 +142,13 @@ namespace detail } #endif +#define MOCK_FUNCTION_IN_ADD(z, n, d) \ + this->e_->add( s##n ); + #define MOCK_FUNCTION_IN(z, n, d) \ wrapper in( BOOST_PP_ENUM_PARAMS(n, sequence& s) ) \ { \ - this->e_->in( BOOST_PP_ENUM_PARAMS(n, s) ); \ + BOOST_PP_REPEAT(n, MOCK_FUNCTION_IN_ADD, _) \ return *this; \ } @@ -153,6 +156,7 @@ namespace detail MOCK_FUNCTION_IN, _) #undef MOCK_FUNCTION_IN +#undef MOCK_FUNCTION_IN_ADD template< typename TT > void calls( TT t )