Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Introduce built_in type 'any'
Browse files Browse the repository at this point in the history
  • Loading branch information
conr2d committed Mar 8, 2021
1 parent 37d9df6 commit a932ffb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions libraries/chain/abi_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ namespace eosio { namespace chain {
built_in_types.emplace("symbol_code", pack_unpack<symbol_code>());
built_in_types.emplace("asset", pack_unpack<asset>());
built_in_types.emplace("extended_asset", pack_unpack<extended_asset>());
built_in_types.emplace("any", pack_unpack<any>());
}

void abi_serializer::set_abi(const abi_def& abi, const yield_function_t& yield) {
Expand Down
13 changes: 13 additions & 0 deletions libraries/chain/include/eosio/chain/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <fc/interprocess/container.hpp>
#include <fc/io/varint.hpp>
#include <fc/io/enum_type.hpp>
#include <fc/io/json.hpp>
#include <fc/crypto/sha224.hpp>
#include <fc/optional.hpp>
#include <fc/safe.hpp>
Expand Down Expand Up @@ -393,6 +394,18 @@ namespace eosio { namespace chain {
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;

struct any {
fc::variant data;
};

} } // eosio::chain

namespace fc {
inline void to_variant(const eosio::chain::any& var, fc::variant& vo) { vo = var.data; }
inline void from_variant(const fc::variant& var, eosio::chain::any& vo) {
vo.data = fc::json::from_string(var.get_string());
}
}

FC_REFLECT_EMPTY( eosio::chain::void_t )
FC_REFLECT( eosio::chain::any, (data) )

0 comments on commit a932ffb

Please sign in to comment.