mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Refactoring
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@502 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
aca2a2768e
commit
4e54ac1830
5 changed files with 21 additions and 63 deletions
|
|
@ -25,7 +25,6 @@
|
||||||
<ClCompile Include="..\..\test\detail\test_function.cpp" />
|
<ClCompile Include="..\..\test\detail\test_function.cpp" />
|
||||||
<ClCompile Include="..\..\test\detail\test_invocation.cpp" />
|
<ClCompile Include="..\..\test\detail\test_invocation.cpp" />
|
||||||
<ClCompile Include="..\..\test\detail\test_is_functor.cpp" />
|
<ClCompile Include="..\..\test\detail\test_is_functor.cpp" />
|
||||||
<ClCompile Include="..\..\test\detail\test_parameters.cpp" />
|
|
||||||
<ClCompile Include="..\..\test\detail\test_signature.cpp" />
|
<ClCompile Include="..\..\test\detail\test_signature.cpp" />
|
||||||
<ClCompile Include="..\..\test\detail\test_type_name.cpp" />
|
<ClCompile Include="..\..\test\detail\test_type_name.cpp" />
|
||||||
<ClCompile Include="..\..\test\test_constraints.cpp" />
|
<ClCompile Include="..\..\test\test_constraints.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,6 @@
|
||||||
<ClCompile Include="..\..\test\detail\test_type_name.cpp">
|
<ClCompile Include="..\..\test\detail\test_type_name.cpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
<Filter>Source Files\detail</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\test\detail\test_parameters.cpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\test\detail\test_function.cpp">
|
<ClCompile Include="..\..\test\detail\test_function.cpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
<Filter>Source Files\detail</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
||||||
|
|
@ -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 <turtle/detail/parameters.hpp>
|
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
|
||||||
#include <boost/mpl/assert.hpp>
|
|
||||||
|
|
||||||
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 > ));
|
|
||||||
|
|
@ -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 <boost/function_types/parameter_types.hpp>
|
|
||||||
#include <boost/function_types/function_arity.hpp>
|
|
||||||
#include <boost/mpl/at.hpp>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
@ -13,16 +13,30 @@
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
#include "detail/function.hpp"
|
#include "detail/function.hpp"
|
||||||
#include "detail/type_name.hpp"
|
#include "detail/type_name.hpp"
|
||||||
#include "detail/parameters.hpp"
|
|
||||||
#include "detail/signature.hpp"
|
#include "detail/signature.hpp"
|
||||||
#include "detail/cleanup.hpp"
|
#include "detail/cleanup.hpp"
|
||||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
|
#include <boost/function_types/parameter_types.hpp>
|
||||||
|
#include <boost/function_types/function_arity.hpp>
|
||||||
|
#include <boost/mpl/assert.hpp>
|
||||||
|
#include <boost/mpl/at.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
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 >
|
template< typename S >
|
||||||
struct functor : mock::detail::function< S >
|
struct functor : mock::detail::function< S >
|
||||||
{
|
{
|
||||||
|
|
@ -67,11 +81,10 @@ namespace detail
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MOCK_PARAM(z, n, d) \
|
#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) \
|
#define MOCK_PARAMS(n, S, tpn) \
|
||||||
BOOST_PP_REPEAT(n, MOCK_PARAM, \
|
BOOST_PP_REPEAT(n, MOCK_PARAM, tpn mock::detail::parameter< S)
|
||||||
tpn mock::detail::parameters< S BOOST_PP_COMMA() n >)
|
|
||||||
|
|
||||||
#define MOCK_DECL(M, n, S, c, tpn) \
|
#define MOCK_DECL(M, n, S, c, tpn) \
|
||||||
tpn boost::function_types::result_type< S >::type M( \
|
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) \
|
#define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \
|
||||||
MOCK_DECL(M, n, S, 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)( \
|
return MOCK_ANONYMOUS_HELPER(t)( \
|
||||||
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
|
|
@ -148,6 +163,8 @@ namespace detail
|
||||||
MOCK_FUNCTION_HELPER(S, t, s) \
|
MOCK_FUNCTION_HELPER(S, t, s) \
|
||||||
s MOCK_DECL(F, n, S,,tpn) \
|
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) ); \
|
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
#define MOCK_FUNCTION(F, n, S, t) \
|
#define MOCK_FUNCTION(F, n, S, t) \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue