From 4e54ac1830e079836bc4e317607451f84b7384e7 Mon Sep 17 00:00:00 2001 From: mat007 Date: Sun, 22 Jul 2012 07:09:52 +0000 Subject: [PATCH] Refactoring git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@502 860be788-9bd5-4423-9f1e-828f051e677b --- build/vc100/turtle_test.vcxproj | 1 - build/vc100/turtle_test.vcxproj.filters | 3 -- test/detail/test_parameters.cpp | 15 ---------- turtle/detail/parameters.hpp | 40 ------------------------- turtle/mock.hpp | 25 +++++++++++++--- 5 files changed, 21 insertions(+), 63 deletions(-) delete mode 100644 test/detail/test_parameters.cpp delete mode 100644 turtle/detail/parameters.hpp diff --git a/build/vc100/turtle_test.vcxproj b/build/vc100/turtle_test.vcxproj index 99c2215..c92c1d5 100644 --- a/build/vc100/turtle_test.vcxproj +++ b/build/vc100/turtle_test.vcxproj @@ -25,7 +25,6 @@ - diff --git a/build/vc100/turtle_test.vcxproj.filters b/build/vc100/turtle_test.vcxproj.filters index cfd1724..d759aa9 100644 --- a/build/vc100/turtle_test.vcxproj.filters +++ b/build/vc100/turtle_test.vcxproj.filters @@ -45,9 +45,6 @@ Source Files\detail - - Source Files\detail - Source Files\detail diff --git a/test/detail/test_parameters.cpp b/test/detail/test_parameters.cpp deleted file mode 100644 index 005a9a0..0000000 --- a/test/detail/test_parameters.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// http://turtle.sourceforge.net -// -// Copyright Mathieu Champlon 2009 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -BOOST_MPL_ASSERT(( boost::is_same< float, mock::detail::parameters< void( float ), 1 >::at< 0 >::type > )); -BOOST_MPL_ASSERT(( boost::is_same< float, mock::detail::parameters< void( float, int ), 2 >::at< 0 >::type > )); -BOOST_MPL_ASSERT(( boost::is_same< int, mock::detail::parameters< void( float, int ), 2 >::at< 1 >::type > )); diff --git a/turtle/detail/parameters.hpp b/turtle/detail/parameters.hpp deleted file mode 100644 index f43d0a6..0000000 --- a/turtle/detail/parameters.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// http://turtle.sourceforge.net -// -// Copyright Mathieu Champlon 2010 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef MOCK_PARAMETERS_HPP_INCLUDED -#define MOCK_PARAMETERS_HPP_INCLUDED - -#include -#include -#include - -namespace mock -{ -namespace detail -{ - template< typename Signature, int Arity > - struct parameters - { - BOOST_MPL_ASSERT_RELATION( Arity, ==, - boost::function_types::function_arity< Signature >::value ); - - template< int n > - struct at - { - typedef BOOST_DEDUCED_TYPENAME - boost::mpl::at_c< - BOOST_DEDUCED_TYPENAME - boost::function_types::parameter_types< Signature >, - n - >::type type; - }; - }; -} -} // mock - -#endif // MOCK_PARAMETERS_HPP_INCLUDED diff --git a/turtle/mock.hpp b/turtle/mock.hpp index 8ca4fe7..cf048f7 100644 --- a/turtle/mock.hpp +++ b/turtle/mock.hpp @@ -13,16 +13,30 @@ #include "object.hpp" #include "detail/function.hpp" #include "detail/type_name.hpp" -#include "detail/parameters.hpp" #include "detail/signature.hpp" #include "detail/cleanup.hpp" #include #include +#include +#include +#include +#include namespace mock { namespace detail { + template< typename Signature, int n > + struct parameter + { + typedef BOOST_DEDUCED_TYPENAME + boost::mpl::at_c< + BOOST_DEDUCED_TYPENAME + boost::function_types::parameter_types< Signature >, + n + >::type type; + }; + template< typename S > struct functor : mock::detail::function< S > { @@ -67,11 +81,10 @@ namespace detail } #define MOCK_PARAM(z, n, d) \ - BOOST_PP_COMMA_IF(n) d::at< n >::type p##n + BOOST_PP_COMMA_IF(n) d, n >::type p##n #define MOCK_PARAMS(n, S, tpn) \ - BOOST_PP_REPEAT(n, MOCK_PARAM, \ - tpn mock::detail::parameters< S BOOST_PP_COMMA() n >) + BOOST_PP_REPEAT(n, MOCK_PARAM, tpn mock::detail::parameter< S) #define MOCK_DECL(M, n, S, c, tpn) \ tpn boost::function_types::result_type< S >::type M( \ @@ -80,6 +93,8 @@ namespace detail #define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \ MOCK_DECL(M, n, S, c, tpn) \ { \ + BOOST_MPL_ASSERT_RELATION( n, ==, \ + boost::function_types::function_arity< S >::value ); \ return MOCK_ANONYMOUS_HELPER(t)( \ BOOST_PP_ENUM_PARAMS(n, p) ); \ } @@ -148,6 +163,8 @@ namespace detail MOCK_FUNCTION_HELPER(S, t, s) \ s MOCK_DECL(F, n, S,,tpn) \ { \ + BOOST_MPL_ASSERT_RELATION( n, ==, \ + boost::function_types::function_arity< S >::value ); \ return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \ } #define MOCK_FUNCTION(F, n, S, t) \