From 08a74ccfe3c4dbf0fc5a90db31e5ddd661691e37 Mon Sep 17 00:00:00 2001 From: mat007 Date: Sat, 13 Dec 2014 20:41:15 +0000 Subject: [PATCH] Removed dependency to Boost.Phoenix git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@761 860be788-9bd5-4423-9f1e-828f051e677b --- build/boost/doc/customization.qbk | 1 - turtle/config.hpp | 16 -------------- turtle/detail/action.hpp | 22 +++++++++++-------- turtle/detail/function_impl_template.hpp | 8 ++++--- turtle/detail/lambda.hpp | 28 ++++++------------------ 5 files changed, 25 insertions(+), 50 deletions(-) diff --git a/build/boost/doc/customization.qbk b/build/boost/doc/customization.qbk index 60c61dc..0f48f30 100644 --- a/build/boost/doc/customization.qbk +++ b/build/boost/doc/customization.qbk @@ -123,7 +123,6 @@ The mock object library uses several boost libraries and will adjust some of the * Boost.Function with BOOST_FUNCTION_MAX_ARGS required at MOCK_MAX_ARGS or higher * Boost.FunctionTypes with BOOST_FT_MAX_ARITY required at MOCK_MAX_ARGS + 1 or higher -* Boost.Phoenix (when increasing MOCK_MAX_ARGS over 9 otherwise Boost.Bind is used) with PHOENIX_LIMIT required at MOCK_MAX_ARGS or higher A compilation error will happen if one of those constants is already defined too low. diff --git a/turtle/config.hpp b/turtle/config.hpp index c349404..a09c73a 100644 --- a/turtle/config.hpp +++ b/turtle/config.hpp @@ -22,8 +22,6 @@ #ifndef MOCK_MAX_ARGS # define MOCK_MAX_ARGS 9 -#elif BOOST_PP_LESS(9, MOCK_MAX_ARGS) -# define MOCK_USE_BOOST_PHOENIX #endif #ifndef MOCK_MAX_SEQUENCES @@ -42,20 +40,6 @@ # error BOOST_FT_MAX_ARITY must be set to MOCK_MAX_ARGS + 1 or higher #endif -#ifdef MOCK_USE_BOOST_PHOENIX -# define BOOST_PHOENIX_USE_V2_OVER_V3 // V3 doesn't work due to various bugs including https://svn.boost.org/trac/boost/ticket/8504 -# ifndef BOOST_RESULT_OF_NUM_ARGS -# define BOOST_RESULT_OF_NUM_ARGS MOCK_MAX_ARGS -# elif BOOST_PP_LESS(BOOST_RESULT_OF_NUM_ARGS, MOCK_MAX_ARGS) -# error BOOST_RESULT_OF_NUM_ARGS must be set to MOCK_MAX_ARGS or higher -# endif -# ifndef PHOENIX_LIMIT -# define PHOENIX_LIMIT MOCK_MAX_ARGS -# elif BOOST_PP_LESS(PHOENIX_LIMIT, MOCK_MAX_ARGS) -# error PHOENIX_LIMIT must be set to MOCK_MAX_ARGS or higher -# endif -#endif - #if !defined(BOOST_NO_CXX11_NULLPTR) && !defined(BOOST_NO_NULLPTR) # ifndef MOCK_NO_NULLPTR # define MOCK_NULLPTR diff --git a/turtle/detail/action.hpp b/turtle/detail/action.hpp index 85a5333..c87d27c 100644 --- a/turtle/detail/action.hpp +++ b/turtle/detail/action.hpp @@ -28,13 +28,18 @@ namespace detail { private: typedef boost::function< Signature > functor_type; - typedef lambda< Result, Signature > lambda_type; + typedef boost::function< Result() > action_type; + typedef lambda< Result > lambda_type; public: const functor_type& functor() const { return f_; } + const action_type& actionn() const + { + return a_; + } void calls( const functor_type& f ) { @@ -46,28 +51,27 @@ namespace detail template< typename Exception > void throws( Exception e ) { - f_ = lambda_type::make_throw( e ); + a_ = lambda_type::make_throw( e ); } protected: - void set( const functor_type& f ) + void set( const action_type& a ) { - f_ = f; + a_ = a; } template< typename Y > void set( const boost::reference_wrapper< Y >& r ) { - f_ = lambda_type::make_ref( r ); + a_ = lambda_type::make_ref( r ); } functor_type f_; + action_type a_; }; template< typename Result, typename Signature > class action : public action_base< Result, Signature > { - typedef lambda< Result, Signature > lambda_type; - public: template< typename Value > void returns( const Value& v ) @@ -138,7 +142,7 @@ namespace detail class action< Result*, Signature > : public action_base< Result*, Signature > { - typedef lambda< Result*, Signature > lambda_type; + typedef lambda< Result* > lambda_type; public: void returns( Result* r ) @@ -155,7 +159,7 @@ namespace detail template< typename Signature > class action< void, Signature > : public action_base< void, Signature > { - typedef lambda< void, Signature > lambda_type; + typedef lambda< void > lambda_type; public: action() diff --git a/turtle/detail/function_impl_template.hpp b/turtle/detail/function_impl_template.hpp index b691634..ab9baaa 100644 --- a/turtle/detail/function_impl_template.hpp +++ b/turtle/detail/function_impl_template.hpp @@ -207,7 +207,7 @@ namespace detail MOCK_FUNCTION_CONTEXT, it->file(), it->line() ); return error_type::abort(); } - if( ! it->functor() ) + if( ! it->functor() && ! it->actionn() ) { error_type::fail( "missing action", MOCK_FUNCTION_CONTEXT, it->file(), it->line() ); @@ -216,8 +216,10 @@ namespace detail valid_ = true; error_type::call( MOCK_FUNCTION_CONTEXT, it->file(), it->line() ); - return it->functor()( - BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) ); + if( it->functor() ) + return it->functor()( + BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) ); + return it->actionn()(); } error_type::fail( "unexpected call", MOCK_FUNCTION_CONTEXT ); return error_type::abort(); diff --git a/turtle/detail/lambda.hpp b/turtle/detail/lambda.hpp index 4678a6b..4da0003 100644 --- a/turtle/detail/lambda.hpp +++ b/turtle/detail/lambda.hpp @@ -10,15 +10,7 @@ #define MOCK_LAMBDA_HPP_INCLUDED #include "../config.hpp" -#ifdef MOCK_USE_BOOST_PHOENIX -# ifdef BOOST_PHOENIX_USE_V2_OVER_V3 -#include -# else -#include -# endif -#else #include -#endif #include #include @@ -26,40 +18,34 @@ namespace mock { namespace detail { -#ifdef MOCK_USE_BOOST_PHOENIX - using boost::phoenix::bind; -#else - using boost::bind; -#endif - - template< typename Result, typename Signature > + template< typename Result > struct lambda { - typedef boost::function< Signature > functor_type; + typedef boost::function< Result() > functor_type; template< typename T > static functor_type make_val( T t ) { - return detail::bind( &do_val< T >, t ); + return boost::bind( &do_val< T >, t ); } template< typename T > static functor_type make_ref( const boost::reference_wrapper< T >& t ) { - return detail::bind( &do_ref< T >, t.get_pointer() ); + return boost::bind( &do_ref< T >, t.get_pointer() ); } template< typename T > static functor_type make_move( T& t ) { - return detail::bind( &do_move< T >, &t ); + return boost::bind( &do_move< T >, &t ); } template< typename T > static functor_type make_throw( T t ) { - return detail::bind( &do_throw< T >, t ); + return boost::bind( &do_throw< T >, t ); } static functor_type make_nothing() { - return detail::bind( &do_nothing ); + return boost::bind( &do_nothing ); } private: