Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variant fix #21

Merged
merged 6 commits into from
Mar 19, 2018
Merged

Variant fix #21

merged 6 commits into from
Mar 19, 2018

Conversation

pmconrad
Copy link

@pmconrad pmconrad commented Mar 13, 2018

Work in progress
Limit recursion in variant conversions

@abitmore abitmore self-assigned this Mar 18, 2018
@@ -57,15 +57,17 @@ namespace fc {
inline void pack( Stream& s, const fc::log_message& msg, uint32_t _max_depth )
{
FC_ASSERT( _max_depth > 0 );
fc::raw::pack( s, variant(msg), _max_depth - 1 ); // TODO check variant depth?
--_max_depth;
fc::raw::pack( s, variant( msg, _max_depth ), _max_depth );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have different definitions on depth. I suggest we change the variant to:
variant( msg, min( _max_depth, FC_MAX_LOG_OBJECT_DEPTH ) ).

msg = vmsg.as<log_message>(); // TODO check depth?
--_max_depth;
fc::raw::unpack( s, vmsg, _max_depth );
msg = vmsg.as<log_message>( _max_depth );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

{
template<typename IsEnum=fc::false_type>
struct if_enum
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation.

{
FC_ASSERT( a0 != e );
return call_generic<R,Args...>( bind_first_arg<R,Arg0,Args...>( f, a0->as< typename std::decay<Arg0>::type >() ), a0+1, 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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check max_depth > 0?

return [=]( const variants& args ) {
return variant( call_generic( f, args.begin(), args.end() ) );
return [=]( const variants& args, uint32_t max_depth ) {
return variant( call_generic( f, args.begin(), args.end(), max_depth - 1 ), max_depth - 1 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check max_depth > 0?

return [=]( const variants& args ) {
call_generic( f, args.begin(), args.end() );
return [=]( const variants& args, uint32_t max_depth ) {
call_generic( f, args.begin(), args.end(), max_depth - 1 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check max_depth > 0?

detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>() );
return call_generic<R,Args...>( this->bind_first_arg<R,std::function<Signature>,Args...>( f, std::function<Signature>(arg0) ), a0+1, e );
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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check max_depth > 0?

detail::callback_functor<Signature> arg0( get_connection(), a0->as<uint64_t>() );
return call_generic<R,Args...>( this->bind_first_arg<R,const std::function<Signature>&,Args...>( f, arg0 ), a0+1, e );
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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check max_depth > 0?

{
FC_ASSERT( a0 != e, "too few arguments passed to method" );
return call_generic<R,Args...>( this->bind_first_arg<R,Arg0,Args...>( f, a0->as< typename std::decay<Arg0>::type >() ), a0+1, e );
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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check max_depth > 0?

@abitmore abitmore assigned pmconrad and unassigned abitmore Mar 18, 2018
@pmconrad pmconrad assigned abitmore and unassigned pmconrad Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants