FC Updates from BitShares and myself #21
3 changed files with 11 additions and 4 deletions
|
|
@ -12,6 +12,7 @@
|
||||||
#include <fc/exception/exception.hpp>
|
#include <fc/exception/exception.hpp>
|
||||||
#include <fc/safe.hpp>
|
#include <fc/safe.hpp>
|
||||||
#include <fc/io/raw_fwd.hpp>
|
#include <fc/io/raw_fwd.hpp>
|
||||||
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ namespace fc {
|
||||||
{
|
{
|
||||||
FC_ASSERT( _max_depth > 0 );
|
FC_ASSERT( _max_depth > 0 );
|
||||||
--_max_depth;
|
--_max_depth;
|
||||||
fc::raw::pack( s, variant( msg, _max_depth ), _max_depth );
|
fc::raw::pack( s, variant( msg, std::min( _max_depth, uint32_t(FC_MAX_LOG_OBJECT_DEPTH) ) ), _max_depth );
|
||||||
}
|
}
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
inline void unpack( Stream& s, fc::log_message& msg, uint32_t _max_depth )
|
inline void unpack( Stream& s, fc::log_message& msg, uint32_t _max_depth )
|
||||||
|
|
@ -67,7 +68,7 @@ namespace fc {
|
||||||
fc::variant vmsg;
|
fc::variant vmsg;
|
||||||
--_max_depth;
|
--_max_depth;
|
||||||
fc::raw::unpack( s, vmsg, _max_depth );
|
fc::raw::unpack( s, vmsg, _max_depth );
|
||||||
msg = vmsg.as<log_message>( _max_depth );
|
msg = vmsg.as<log_message>( std::min( _max_depth, uint32_t(FC_MAX_LOG_OBJECT_DEPTH) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ namespace fc {
|
||||||
R call_generic( const std::function<R(Arg0,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
R call_generic( const std::function<R(Arg0,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||||
{
|
{
|
||||||
FC_ASSERT( a0 != e );
|
FC_ASSERT( a0 != e );
|
||||||
|
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||||
return call_generic<R,Args...>( bind_first_arg<R,Arg0,Args...>( f, a0->as< typename std::decay<Arg0>::type >( max_depth - 1 ) ), a0+1, e, max_depth - 1 );
|
return call_generic<R,Args...>( bind_first_arg<R,Arg0,Args...>( f, a0->as< typename std::decay<Arg0>::type >( max_depth - 1 ) ), a0+1, e, max_depth - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,6 +53,7 @@ namespace fc {
|
||||||
std::function<variant(const fc::variants&, uint32_t)> to_generic( const std::function<R(Args...)>& f )
|
std::function<variant(const fc::variants&, uint32_t)> to_generic( const std::function<R(Args...)>& f )
|
||||||
{
|
{
|
||||||
return [=]( const variants& args, uint32_t max_depth ) {
|
return [=]( const variants& args, uint32_t max_depth ) {
|
||||||
|
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||||
return variant( call_generic( f, args.begin(), args.end(), max_depth - 1 ), max_depth - 1 );
|
return variant( call_generic( f, args.begin(), args.end(), max_depth - 1 ), max_depth - 1 );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -60,6 +62,7 @@ namespace fc {
|
||||||
std::function<variant(const fc::variants&, uint32_t)> to_generic( const std::function<void(Args...)>& f )
|
std::function<variant(const fc::variants&, uint32_t)> to_generic( const std::function<void(Args...)>& f )
|
||||||
{
|
{
|
||||||
return [=]( const variants& args, uint32_t max_depth ) {
|
return [=]( const variants& args, uint32_t max_depth ) {
|
||||||
|
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||||
call_generic( f, args.begin(), args.end(), max_depth - 1 );
|
call_generic( f, args.begin(), args.end(), max_depth - 1 );
|
||||||
return variant();
|
return variant();
|
||||||
};
|
};
|
||||||
|
|
@ -147,6 +150,7 @@ namespace fc {
|
||||||
R call_generic( const std::function<R(std::function<Signature>,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
R call_generic( const std::function<R(std::function<Signature>,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||||
{
|
{
|
||||||
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
||||||
|
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||||
detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>(1) );
|
detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>(1) );
|
||||||
return call_generic<R,Args...>( this->bind_first_arg<R,std::function<Signature>,Args...>( f, std::function<Signature>(arg0) ), a0+1, e, max_depth - 1 );
|
return call_generic<R,Args...>( this->bind_first_arg<R,std::function<Signature>,Args...>( f, std::function<Signature>(arg0) ), a0+1, e, max_depth - 1 );
|
||||||
}
|
}
|
||||||
|
|
@ -154,6 +158,7 @@ namespace fc {
|
||||||
R call_generic( const std::function<R(const std::function<Signature>&,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
R call_generic( const std::function<R(const std::function<Signature>&,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||||
{
|
{
|
||||||
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
||||||
|
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||||
detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>(1) );
|
detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>(1) );
|
||||||
return call_generic<R,Args...>( this->bind_first_arg<R,const std::function<Signature>&,Args...>( f, arg0 ), a0+1, e, max_depth - 1 );
|
return call_generic<R,Args...>( this->bind_first_arg<R,const std::function<Signature>&,Args...>( f, arg0 ), a0+1, e, max_depth - 1 );
|
||||||
}
|
}
|
||||||
|
|
@ -162,6 +167,7 @@ namespace fc {
|
||||||
R call_generic( const std::function<R(Arg0,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
R call_generic( const std::function<R(Arg0,Args...)>& f, variants::const_iterator a0, variants::const_iterator e, uint32_t max_depth )
|
||||||
{
|
{
|
||||||
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
FC_ASSERT( a0 != e, "too few arguments passed to method" );
|
||||||
|
FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||||
return call_generic<R,Args...>( this->bind_first_arg<R,Arg0,Args...>( f, a0->as< typename std::decay<Arg0>::type >( max_depth - 1 ) ), a0+1, e, max_depth - 1 );
|
return call_generic<R,Args...>( this->bind_first_arg<R,Arg0,Args...>( f, a0->as< typename std::decay<Arg0>::type >( max_depth - 1 ) ), a0+1, e, max_depth - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue