Merge branch 'phoenix' of https://github.com/InvictusInnovations/fc into phoenix

This commit is contained in:
Daniel Larimer 2014-04-27 21:20:54 -04:00
commit 1d8f80c8f7
2 changed files with 27 additions and 19 deletions

View file

@ -17,7 +17,7 @@
#include <fc/reflect/typename.hpp>
namespace fc {
namespace fc {
/**
* @brief defines visit functions for T
@ -32,13 +32,13 @@ template<typename T>
struct reflector{
typedef T type;
typedef fc::false_type is_defined;
typedef fc::false_type is_enum;
typedef fc::false_type is_enum;
/**
* @tparam Visitor a function object of the form:
*
*
* @code
* struct functor {
* struct functor {
* template<typename Member, class Class, Member (Class::*member)>
* void operator()( const char* name )const;
* };
@ -46,19 +46,19 @@ struct reflector{
*
* If T is an enum then the functor has the following form:
* @code
* struct functor {
* struct functor {
* template<int Value>
* void operator()( const char* name )const;
* };
* @endcode
*
*
* @param v a functor that will be called for each member on T
*
* @note - this method is not defined for non-reflected types.
*/
#ifdef DOXYGEN
template<typename Visitor>
static inline void visit( const Visitor& v );
static inline void visit( const Visitor& v );
#endif // DOXYGEN
};
@ -77,7 +77,7 @@ void throw_bad_enum_cast( const char* k, const char* e );
#define TEMPLATE template
#else
// Disable warning C4482: nonstandard extention used: enum 'enum_type::enum_value' used in qualified name
#pragma warning( disable: 4482 )
#pragma warning( disable: 4482 )
#define TEMPLATE
#endif
@ -98,14 +98,14 @@ template<typename Visitor>\
static inline void visit( const Visitor& v ) { \
BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_VISIT_BASE, v, INHERITS ) \
BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_VISIT_MEMBER, v, MEMBERS ) \
}
}
#define FC_REFLECT_DERIVED_IMPL_EXT( TYPE, INHERITS, MEMBERS ) \
template<typename Visitor>\
void fc::reflector<TYPE>::visit( const Visitor& v ) { \
BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_VISIT_BASE, v, INHERITS ) \
BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_VISIT_MEMBER, v, MEMBERS ) \
}
}
#endif // DOXYGEN
@ -132,15 +132,23 @@ template<> struct reflector<ENUM> { \
}\
return nullptr; \
} \
static const char* to_string(ENUM elem) { \
switch( elem ) { \
BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_ENUM_TO_STRING, ENUM, FIELDS ) \
default: \
fc::throw_bad_enum_cast( BOOST_PP_STRINGIZE(elem), BOOST_PP_STRINGIZE(ENUM) ); \
}\
return nullptr; \
} \
static ENUM from_string( const char* s ) { \
BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_ENUM_FROM_STRING, ENUM, FIELDS ) \
fc::throw_bad_enum_cast( s, BOOST_PP_STRINGIZE(ENUM) ); \
return ENUM();\
} \
}; \
}
}
/* Note: FC_REFLECT_ENUM previously defined this function, but I don't think it ever
/* Note: FC_REFLECT_ENUM previously defined this function, but I don't think it ever
* did what we expected it to do. I've disabled it for now.
*
* template<typename Visitor> \
@ -152,7 +160,7 @@ template<> struct reflector<ENUM> { \
/**
* @def FC_REFLECT_DERIVED(TYPE,INHERITS,MEMBERS)
*
* @brief Specializes fc::reflector for TYPE where
* @brief Specializes fc::reflector for TYPE where
* type inherits other reflected classes
*
* @param INHERITS - a sequence of base class names (basea)(baseb)(basec)
@ -170,7 +178,7 @@ template<> struct reflector<TYPE> {\
total_member_count = local_member_count BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_BASE_MEMBER_COUNT, +, INHERITS )\
}; \
FC_REFLECT_DERIVED_IMPL_INLINE( TYPE, INHERITS, MEMBERS ) \
}; }
}; }
#define FC_REFLECT_DERIVED_TEMPLATE( TEMPLATE_ARGS, TYPE, INHERITS, MEMBERS ) \
namespace fc { \
template<BOOST_PP_SEQ_ENUM(TEMPLATE_ARGS)> struct get_typename<TYPE> { static const char* name() { return BOOST_PP_STRINGIZE(TYPE); } }; \
@ -183,9 +191,9 @@ template<BOOST_PP_SEQ_ENUM(TEMPLATE_ARGS)> struct reflector<TYPE> {\
total_member_count = local_member_count BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_BASE_MEMBER_COUNT, +, INHERITS )\
}; \
FC_REFLECT_DERIVED_IMPL_INLINE( TYPE, INHERITS, MEMBERS ) \
}; }
}; }
//BOOST_PP_SEQ_SIZE(MEMBERS),
//BOOST_PP_SEQ_SIZE(MEMBERS),
/**
* @def FC_REFLECT(TYPE,MEMBERS)

View file

@ -141,7 +141,7 @@ namespace fc { namespace rpc {
}
}
}
else if( i != obj.end() )
else if( i != obj.end() ) //handle any received JSON response
{
uint64_t id = i->value().as_int64();
auto await = _awaiting.find(id);
@ -149,11 +149,11 @@ namespace fc { namespace rpc {
{
auto r = obj.find("result");
auto e = obj.find("error");
if( r != obj.end() )
if( r != obj.end() ) //if regular result response
{
await->second->set_value( r->value() );
}
else if( e != obj.end() )
else if( e != obj.end() ) //if error response
{
try
{