Skip to content

Commit

Permalink
Use new reflect_init tag to indicate reflector_init() should be called
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Feb 20, 2019
1 parent c34ffb8 commit 10f08f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with amount = 10 and symbol(4,"CUR")
*/

struct asset
struct asset : fc::reflect_init
{
static constexpr int64_t max_amount = (1LL << 62) - 1;

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/symbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace eosio {
operator uint64_t()const { return value; }
};

class symbol {
class symbol : fc::reflect_init {
public:

static constexpr uint8_t max_precision = 18;
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/eosio/chain/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace eosio { namespace chain {
bool allow_duplicate_keys = false )const;
};

struct packed_transaction {
struct packed_transaction : fc::reflect_init {
enum compression_type {
none = 0,
zlib = 1,
Expand Down Expand Up @@ -158,6 +158,7 @@ namespace eosio { namespace chain {

friend struct fc::reflector<packed_transaction>;
friend struct fc::reflector_init_visitor<packed_transaction>;
friend struct fc::has_reflector_init<packed_transaction>;
void reflector_init();
private:
vector<signature_type> signatures;
Expand Down
5 changes: 4 additions & 1 deletion unittests/misc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ using namespace eosio::testing;
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>

struct base_reflect {
struct base_reflect : fc::reflect_init {
int bv = 0;
bool base_reflect_initialized = false;
int base_reflect_called = 0;
protected:
friend struct fc::reflector<base_reflect>;
friend struct fc::reflector_init_visitor<base_reflect>;
friend struct fc::has_reflector_init<base_reflect>;
void reflector_init() {
BOOST_CHECK_EQUAL( bv, 42 ); // should be deserialized before called, set by test
++base_reflect_called;
Expand All @@ -47,6 +48,7 @@ struct derived_reflect : public base_reflect {
protected:
friend struct fc::reflector<derived_reflect>;
friend struct fc::reflector_init_visitor<derived_reflect>;
friend struct fc::has_reflector_init<derived_reflect>;
void reflector_init() {
BOOST_CHECK_EQUAL( bv, 42 ); // should be deserialized before called, set by test
BOOST_CHECK_EQUAL( dv, 52 ); // should be deserialized before called, set by test
Expand All @@ -63,6 +65,7 @@ struct final_reflect : public derived_reflect {
private:
friend struct fc::reflector<final_reflect>;
friend struct fc::reflector_init_visitor<final_reflect>;
friend struct fc::has_reflector_init<derived_reflect>;
void reflector_init() {
BOOST_CHECK_EQUAL( bv, 42 ); // should be deserialized before called, set by test
BOOST_CHECK_EQUAL( dv, 52 ); // should be deserialized before called, set by test
Expand Down

0 comments on commit 10f08f7

Please sign in to comment.