Skip to content

Commit

Permalink
Beginning changes to code to allow serialization/deserialization to w…
Browse files Browse the repository at this point in the history
…ork in restricted C++ environment (for EOSIO/eos#354)
  • Loading branch information
arhag committed Sep 28, 2017
1 parent 69a38f4 commit 1ec04ec
Show file tree
Hide file tree
Showing 34 changed files with 998 additions and 884 deletions.
2 changes: 1 addition & 1 deletion libraries/table/include/eos/table/dynamic_object.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <eos/types/raw_region.hpp>
#include <eos/eoslib/raw_region.hpp>
#include <eos/types/types_manager.hpp>

namespace eos { namespace table {
Expand Down
2 changes: 1 addition & 1 deletion libraries/table/include/eos/table/dynamic_table.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <eos/table/dynamic_object.hpp>
#include <eos/types/type_id.hpp>
#include <eos/eoslib/type_id.hpp>
#include <eos/types/types_manager.hpp>

#include <type_traits>
Expand Down
4 changes: 2 additions & 2 deletions libraries/types/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/eos/types/*.hpp")
file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/eos/types/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/eos/eoslib/*.hpp")

add_definitions(-DBOOST_PP_VARIADICS)
add_definitions(-DBOOST_PP_VARIADICS -DEOS_TYPES_FULL_CAPABILITY)

add_library( eos_types
reflect.cpp
Expand Down
18 changes: 11 additions & 7 deletions libraries/types/field_metadata.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <eos/types/field_metadata.hpp>
#include <eos/eoslib/field_metadata.hpp>
#include <eos/eoslib/exceptions.hpp>

#ifdef EOS_TYPES_FULL_CAPABILITY
#include <ostream>
#include <iomanip>
#include <stdexcept>
#include <boost/io/ios_state.hpp>
#endif

namespace eos { namespace types {

Expand All @@ -28,12 +30,12 @@ namespace eos { namespace types {
if( is_offset_in_bits() )
{
if( offset_window::get(_extra) >= offset_limit_in_bits )
throw std::invalid_argument("Offset (specified in bits) is too large.");
EOS_ERROR(std::invalid_argument, "Offset (specified in bits) is too large.");
}
else
{
if( offset_window::get(_extra) >= offset_limit )
throw std::invalid_argument("Offset is too large.");
EOS_ERROR(std::invalid_argument, "Offset is too large.");
}
}

Expand All @@ -46,7 +48,7 @@ namespace eos { namespace types {
: _tid(tid), _extra(0)
{
if( offset >= offset_limit )
throw std::domain_error("Offset is too large");
EOS_ERROR(std::domain_error, "Offset is too large");

offset_window::set(_extra, offset);

Expand All @@ -60,7 +62,7 @@ namespace eos { namespace types {
void field_metadata::set_offset(uint32_t offset)
{
if( offset >= offset_limit )
throw std::domain_error("Offset is too large.");
EOS_ERROR(std::domain_error, "Offset is too large.");

if( is_offset_in_bits() )
offset <<= 3;
Expand All @@ -71,14 +73,15 @@ namespace eos { namespace types {
void field_metadata::set_offset_in_bits(uint32_t offset)
{
if( offset >= offset_limit_in_bits )
throw std::domain_error("Offset is too large.");
EOS_ERROR(std::domain_error, "Offset is too large.");

if( !is_offset_in_bits() )
offset >>= 3;

offset_window::set(_extra, offset);
}

#ifdef EOS_TYPES_FULL_CAPABILITY
std::ostream& operator<<(std::ostream& os, const field_metadata& f)
{
boost::io::ios_flags_saver ifs( os );
Expand All @@ -104,6 +107,7 @@ namespace eos { namespace types {

return os;
}
#endif

} }

Loading

0 comments on commit 1ec04ec

Please sign in to comment.