mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Removed round parenthesis in signature support for compilers without variadic macros
VS2015 has fixed the double parenthesis trick which was allowed in function signatures.
This commit is contained in:
parent
f052ea4c89
commit
94bedbd653
4 changed files with 20 additions and 19 deletions
|
|
@ -10,6 +10,9 @@
|
||||||
[section unreleased]
|
[section unreleased]
|
||||||
Not yet released
|
Not yet released
|
||||||
|
|
||||||
|
* Fixed MOCK_FUNCTOR compilation with VS2015
|
||||||
|
* Removed round parenthesis in signature support for compilers without variadic macros
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section 1.2.8]
|
[section 1.2.8]
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,6 @@ Synopsis :
|
||||||
|
|
||||||
[note The signature cannot be omitted for the _TPL familly of macros, see the related [link turtle.limitations.template_base_class_methods_cannot_be_mocked_without_specifying_the_signature limitation section].]
|
[note The signature cannot be omitted for the _TPL familly of macros, see the related [link turtle.limitations.template_base_class_methods_cannot_be_mocked_without_specifying_the_signature limitation section].]
|
||||||
|
|
||||||
[note The signature must be surrounded with round parenthesis if the return type contains a comma.]
|
|
||||||
|
|
||||||
[note [link turtle.reference.creation.constructor Constructors], [link turtle.reference.creation.destructor destructors] and [link turtle.reference.creation.conversion_operator conversion operators] require special care.]
|
[note [link turtle.reference.creation.constructor Constructors], [link turtle.reference.creation.destructor destructors] and [link turtle.reference.creation.conversion_operator conversion operators] require special care.]
|
||||||
|
|
||||||
[note In case of a calling convention specified, all four parameters must be provided.]
|
[note In case of a calling convention specified, all four parameters must be provided.]
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
struct T : mock::object
|
struct T : mock::object
|
||||||
|
|
||||||
#define MOCK_FUNCTION_TYPE(S, tpn) \
|
#define MOCK_FUNCTION_TYPE(S, tpn) \
|
||||||
tpn boost::remove_pointer< tpn BOOST_IDENTITY_TYPE((S)) >::type
|
tpn boost::remove_pointer< tpn BOOST_IDENTITY_TYPE(S) >::type
|
||||||
|
|
||||||
#ifdef MOCK_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
|
|
@ -47,10 +47,10 @@
|
||||||
struct T : B, mock::object, mock::detail::base< B >
|
struct T : B, mock::object, mock::detail::base< B >
|
||||||
|
|
||||||
#define MOCK_FUNCTOR(f, S) \
|
#define MOCK_FUNCTOR(f, S) \
|
||||||
mock::detail::functor< MOCK_FUNCTION_TYPE(S,) > f, f##_mock
|
mock::detail::functor< MOCK_FUNCTION_TYPE((S),) > f, f##_mock
|
||||||
#define MOCK_FUNCTOR_TPL(f, S) \
|
#define MOCK_FUNCTOR_TPL(f, S) \
|
||||||
mock::detail::functor< \
|
mock::detail::functor< \
|
||||||
MOCK_FUNCTION_TYPE(S, typename) > f, f##_mock
|
MOCK_FUNCTION_TYPE((S), typename) > f, f##_mock
|
||||||
|
|
||||||
#endif // MOCK_VARIADIC_MACROS
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
|
|
@ -60,8 +60,8 @@
|
||||||
t##_mock( mock::detail::root, "?." )
|
t##_mock( mock::detail::root, "?." )
|
||||||
|
|
||||||
#define MOCK_METHOD_HELPER(S, t, tpn) \
|
#define MOCK_METHOD_HELPER(S, t, tpn) \
|
||||||
mutable mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) > t##_mock_; \
|
mutable mock::detail::function< MOCK_FUNCTION_TYPE((S), tpn) > t##_mock_; \
|
||||||
mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) >& t##_mock( \
|
mock::detail::function< MOCK_FUNCTION_TYPE((S), tpn) >& t##_mock( \
|
||||||
const mock::detail::context&, \
|
const mock::detail::context&, \
|
||||||
boost::unit_test::const_string instance ) const \
|
boost::unit_test::const_string instance ) const \
|
||||||
{ \
|
{ \
|
||||||
|
|
@ -76,10 +76,10 @@
|
||||||
BOOST_PP_COMMA_IF(n) d, 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< MOCK_FUNCTION_TYPE(S, tpn))
|
tpn mock::detail::parameter< MOCK_FUNCTION_TYPE((S), tpn))
|
||||||
#define MOCK_DECL(M, n, S, c, tpn) \
|
#define MOCK_DECL(M, n, S, c, tpn) \
|
||||||
tpn boost::function_types::result_type< \
|
tpn boost::function_types::result_type< \
|
||||||
MOCK_FUNCTION_TYPE(S, tpn) >::type M( \
|
MOCK_FUNCTION_TYPE((S), tpn) >::type M( \
|
||||||
MOCK_PARAMS(n, S, tpn) ) c
|
MOCK_PARAMS(n, S, tpn) ) c
|
||||||
|
|
||||||
#define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \
|
#define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
{ \
|
{ \
|
||||||
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
||||||
boost::function_types::function_arity< \
|
boost::function_types::function_arity< \
|
||||||
MOCK_FUNCTION_TYPE(S, tpn) >::value ); \
|
MOCK_FUNCTION_TYPE((S), tpn) >::value ); \
|
||||||
return MOCK_ANONYMOUS_HELPER(t)( \
|
return MOCK_ANONYMOUS_HELPER(t)( \
|
||||||
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
|
|
@ -137,11 +137,11 @@
|
||||||
MOCK_METHOD_HELPER(T(), t, typename)
|
MOCK_METHOD_HELPER(T(), t, typename)
|
||||||
|
|
||||||
#define MOCK_FUNCTION_HELPER(S, t, s, tpn) \
|
#define MOCK_FUNCTION_HELPER(S, t, s, tpn) \
|
||||||
s mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) >& t##_mock( \
|
s mock::detail::function< MOCK_FUNCTION_TYPE((S), tpn) >& t##_mock( \
|
||||||
mock::detail::context& context, \
|
mock::detail::context& context, \
|
||||||
boost::unit_test::const_string instance ) \
|
boost::unit_test::const_string instance ) \
|
||||||
{ \
|
{ \
|
||||||
static mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) > f; \
|
static mock::detail::function< MOCK_FUNCTION_TYPE((S), tpn) > f; \
|
||||||
return f( context, instance ); \
|
return f( context, instance ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@
|
||||||
{ \
|
{ \
|
||||||
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
||||||
boost::function_types::function_arity< \
|
boost::function_types::function_arity< \
|
||||||
MOCK_FUNCTION_TYPE(S, tpn) >::value ); \
|
MOCK_FUNCTION_TYPE((S), tpn) >::value ); \
|
||||||
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@
|
||||||
#define MOCK_VARIADIC_ELEM_2(e0, e1, e2, ...) e2
|
#define MOCK_VARIADIC_ELEM_2(e0, e1, e2, ...) e2
|
||||||
|
|
||||||
#define MOCK_METHOD_SIGNATURE(M, n, S, t) \
|
#define MOCK_METHOD_SIGNATURE(M, n, S, t) \
|
||||||
typedef MOCK_FUNCTION_TYPE(S,) BOOST_PP_CAT(t,_sig_type); \
|
typedef MOCK_FUNCTION_TYPE((S),) BOOST_PP_CAT(t,_sig_type); \
|
||||||
MOCK_METHOD_EXT(M, n, BOOST_PP_CAT(t,_sig_type), t)
|
MOCK_METHOD_EXT(M, n, BOOST_PP_CAT(t,_sig_type), t)
|
||||||
#define MOCK_METHOD(M, ...) \
|
#define MOCK_METHOD(M, ...) \
|
||||||
MOCK_METHOD_SIGNATURE(M, \
|
MOCK_METHOD_SIGNATURE(M, \
|
||||||
|
|
|
||||||
|
|
@ -346,11 +346,11 @@ namespace
|
||||||
{
|
{
|
||||||
MOCK_CLASS( round_parenthesized_signature )
|
MOCK_CLASS( round_parenthesized_signature )
|
||||||
{
|
{
|
||||||
MOCK_METHOD_EXT( m0, 0, (std::map< int, int >()), m0 )
|
MOCK_METHOD_EXT( m0, 0, BOOST_IDENTITY_TYPE((std::map< int, int >())), m0 )
|
||||||
MOCK_STATIC_METHOD( m1, 0, (std::map< int, int >()), m1 )
|
MOCK_STATIC_METHOD( m1, 0, BOOST_IDENTITY_TYPE((std::map< int, int >())), m1 )
|
||||||
MOCK_FUNCTOR( f0, (std::map< int, int >()) );
|
MOCK_FUNCTOR( f0, BOOST_IDENTITY_TYPE((std::map< int, int >())) );
|
||||||
};
|
};
|
||||||
MOCK_FUNCTION( fun0, 0, (std::map< int, int >()), fun0 )
|
MOCK_FUNCTION( fun0, 0, BOOST_IDENTITY_TYPE((std::map< int, int >())), fun0 )
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOCK_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
@ -397,7 +397,7 @@ namespace
|
||||||
|
|
||||||
MOCK_FUNCTION( fun1, 0, void() )
|
MOCK_FUNCTION( fun1, 0, void() )
|
||||||
MOCK_FUNCTION( fun2, 0, void(), fun2 )
|
MOCK_FUNCTION( fun2, 0, void(), fun2 )
|
||||||
MOCK_FUNCTION( fun3, 0, (std::map< int, int >()) )
|
MOCK_FUNCTION( fun3, 0, BOOST_IDENTITY_TYPE((std::map< int, int >())) )
|
||||||
|
|
||||||
MOCK_FUNCTOR( f_variadic, std::map< int, int >() );
|
MOCK_FUNCTOR( f_variadic, std::map< int, int >() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue