From ea78d2e75d3c74cc65e98ff5959627350a982b0f Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Fri, 23 Sep 2016 12:19:47 -0400 Subject: [PATCH] reflect.hpp: Improve reflection of enum types - Fix implementation of FC_REFLECT_VISIT_ENUM() - Re-enable visit() for enum - Add typename information for enum --- include/fc/reflect/reflect.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/fc/reflect/reflect.hpp b/include/fc/reflect/reflect.hpp index c9f5405..45efbe0 100644 --- a/include/fc/reflect/reflect.hpp +++ b/include/fc/reflect/reflect.hpp @@ -112,7 +112,7 @@ void fc::reflector::visit( const Visitor& v ) { \ #define FC_REFLECT_VISIT_ENUM( r, enum_type, elem ) \ - v.TEMPLATE operator()(BOOST_PP_STRINGIZE(elem)); + v.operator()(BOOST_PP_STRINGIZE(elem), int64_t(enum_type::elem) ); #define FC_REFLECT_ENUM_TO_STRING( r, enum_type, elem ) \ case enum_type::elem: return BOOST_PP_STRINGIZE(elem); #define FC_REFLECT_ENUM_TO_FC_STRING( r, enum_type, elem ) \ @@ -172,7 +172,13 @@ template<> struct reflector { \ } \ return from_int(i); \ } \ + template< typename Visitor > \ + static void visit( Visitor& v ) \ + { \ + BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_VISIT_ENUM, ENUM, FIELDS ) \ + } \ }; \ +template<> struct get_typename { static const char* name() { return BOOST_PP_STRINGIZE(ENUM); } }; \ } /* Note: FC_REFLECT_ENUM previously defined this function, but I don't think it ever