diff --git a/build/vc100/turtle.vcxproj b/build/vc100/turtle.vcxproj
index 063d2b1..5fa42e7 100644
--- a/build/vc100/turtle.vcxproj
+++ b/build/vc100/turtle.vcxproj
@@ -37,7 +37,6 @@
-
diff --git a/build/vc100/turtle.vcxproj.filters b/build/vc100/turtle.vcxproj.filters
index 397e0f6..ff9b677 100644
--- a/build/vc100/turtle.vcxproj.filters
+++ b/build/vc100/turtle.vcxproj.filters
@@ -37,9 +37,6 @@
Source Files\detail
-
- Source Files\detail
-
Source Files\detail
diff --git a/turtle/detail/action.hpp b/turtle/detail/action.hpp
index c87d27c..2acfd49 100644
--- a/turtle/detail/action.hpp
+++ b/turtle/detail/action.hpp
@@ -10,13 +10,13 @@
#define MOCK_ACTION_HPP_INCLUDED
#include "../config.hpp"
-#include "lambda.hpp"
#include
#include
#include
#include
#include
#include
+#include
#include
namespace mock
@@ -29,16 +29,19 @@ namespace detail
private:
typedef boost::function< Signature > functor_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
+ bool valid() const
{
- return a_;
+ return f_ || a_;
+ }
+ Result trigger() const
+ {
+ return a_();
}
void calls( const functor_type& f )
@@ -51,7 +54,7 @@ namespace detail
template< typename Exception >
void throws( Exception e )
{
- a_ = lambda_type::make_throw( e );
+ a_ = boost::bind( &do_throw< Exception >, e );
}
protected:
@@ -62,7 +65,19 @@ namespace detail
template< typename Y >
void set( const boost::reference_wrapper< Y >& r )
{
- a_ = lambda_type::make_ref( r );
+ a_ = boost::bind( &do_ref< Y >, r.get_pointer() );
+ }
+
+ private:
+ template< typename T >
+ static T& do_ref( T* t )
+ {
+ return *t;
+ }
+ template< typename T >
+ static Result do_throw( T t )
+ {
+ throw t;
}
functor_type f_;
@@ -97,40 +112,42 @@ namespace detail
void moves( BOOST_RV_REF( Value ) v )
{
this->set(
- lambda_type::make_move( v_.store( boost::move( v ) ) ) );
+ boost::bind(
+ &boost::move< BOOST_RV_REF( Value ) >,
+ boost::ref( v_.store( boost::move( v ) ) ) ) );
}
private:
- struct holder : boost::noncopyable
- {
- virtual ~holder()
- {}
- };
- template< typename T >
- struct holder_imp : holder
- {
- holder_imp( BOOST_RV_REF( T ) t )
- : t_( boost::move( t ) )
- {}
- holder_imp( const T& t )
- : t_( t )
- {}
- T t_;
- };
-
struct value
{
+ struct holder : boost::noncopyable
+ {
+ virtual ~holder()
+ {}
+ };
+ template< typename T >
+ struct holder_imp : holder
+ {
+ holder_imp( BOOST_RV_REF( T ) t )
+ : t_( boost::move( t ) )
+ {}
+ holder_imp( const T& t )
+ : t_( t )
+ {}
+ T t_;
+ };
+
template< typename T >
T& store( BOOST_RV_REF( T ) t )
{
h_.reset( new holder_imp< T >( boost::move( t ) ) );
- return static_cast< holder_imp< T >* >( h_.get() )->t_;
+ return static_cast< holder_imp< T >& >( *h_ ).t_;
}
template< typename T >
T& store( const T& t )
{
h_.reset( new holder_imp< T >( t ) );
- return static_cast< holder_imp< T >* >( h_.get() )->t_;
+ return static_cast< holder_imp< T >& >( *h_ ).t_;
}
boost::shared_ptr< holder > h_;
};
@@ -142,30 +159,37 @@ namespace detail
class action< Result*, Signature >
: public action_base< Result*, Signature >
{
- typedef lambda< Result* > lambda_type;
-
public:
void returns( Result* r )
{
- this->set( lambda_type::make_val( r ) );
+ this->set( boost::bind( &do_val< Result* >, r ) );
}
template< typename Y >
void returns( const boost::reference_wrapper< Y >& r )
{
this->set( r );
}
+
+ private:
+ template< typename T >
+ static T do_val( T t )
+ {
+ return t;
+ }
};
template< typename Signature >
class action< void, Signature > : public action_base< void, Signature >
{
- typedef lambda< void > lambda_type;
-
public:
action()
{
- this->set( lambda_type::make_nothing() );
+ this->set( boost::bind( &do_nothing ) );
}
+
+ private:
+ static void do_nothing()
+ {}
};
template< typename Result, typename Signature >
diff --git a/turtle/detail/function_impl_template.hpp b/turtle/detail/function_impl_template.hpp
index ab9baaa..1b7d41d 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() && ! it->actionn() )
+ if( ! it->valid() )
{
error_type::fail( "missing action",
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
@@ -219,7 +219,7 @@ namespace detail
if( it->functor() )
return it->functor()(
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
- return it->actionn()();
+ return it->trigger();
}
error_type::fail( "unexpected call", MOCK_FUNCTION_CONTEXT );
return error_type::abort();
diff --git a/turtle/detail/lambda.hpp b/turtle/detail/lambda.hpp
deleted file mode 100644
index 4da0003..0000000
--- a/turtle/detail/lambda.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2011
-//
-// 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_LAMBDA_HPP_INCLUDED
-#define MOCK_LAMBDA_HPP_INCLUDED
-
-#include "../config.hpp"
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- template< typename Result >
- struct lambda
- {
- typedef boost::function< Result() > functor_type;
-
- template< typename T >
- static functor_type make_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 boost::bind( &do_ref< T >, t.get_pointer() );
- }
- template< typename T >
- static functor_type make_move( T& t )
- {
- return boost::bind( &do_move< T >, &t );
- }
- template< typename T >
- static functor_type make_throw( T t )
- {
- return boost::bind( &do_throw< T >, t );
- }
- static functor_type make_nothing()
- {
- return boost::bind( &do_nothing );
- }
-
- private:
- template< typename T >
- static T do_val( T t )
- {
- return t;
- }
- template< typename T >
- static T do_move( T* t )
- {
- return boost::move( *t );
- }
- template< typename T >
- static T& do_ref( T* t )
- {
- return *t;
- }
- template< typename T >
- static Result do_throw( T t )
- {
- throw t;
- }
- static void do_nothing()
- {}
- };
-}
-} // mock
-
-#endif // MOCK_LAMBDA_HPP_INCLUDED