Updates from BitShares FC #22

Closed
nathanielhourt wants to merge 693 commits from dapp-support into latest-fc
3 changed files with 11 additions and 4 deletions
Showing only changes of commit 1eb7b9d5c6 - Show all commits

View file

@ -12,6 +12,7 @@
#include <fc/exception/exception.hpp>
#include <fc/safe.hpp>
#include <fc/io/raw_fwd.hpp>
#include <algorithm>
#include <map>
#include <deque>
@ -58,7 +59,7 @@ namespace fc {
{
FC_ASSERT( _max_depth > 0 );
--_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>
inline void unpack( Stream& s, fc::log_message& msg, uint32_t _max_depth )
@ -67,7 +68,7 @@ namespace fc {
fc::variant 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>

View file

@ -65,7 +65,7 @@ namespace fc
template<typename IsEnum=fc::false_type>
struct if_enum
{
{
template<typename T>
static inline void to_variant( const T& v, fc::variant& vo, uint32_t max_depth )
{

View file

@ -45,13 +45,15 @@ namespace fc {
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 );
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 );
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 );
}
template<typename R, typename ... Args>
std::function<variant(const fc::variants&, uint32_t)> to_generic( const std::function<R(Args...)>& f )
{
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 );
};
}
@ -60,6 +62,7 @@ namespace fc {
std::function<variant(const fc::variants&, uint32_t)> to_generic( const std::function<void(Args...)>& f )
{
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 );
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 )
{
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) );
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 )
{
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) );
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 )
{
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 );
}