From c1572ff1c275145208333e3e69c29c569689e51b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 17 Apr 2024 15:03:09 +0200 Subject: Moved to platform description in structs --- modules/codec-json/SConstruct | 1 + modules/codec-json/c++/json.tmpl.hpp | 6 +++--- modules/codec-json/tests/codec-json.cpp | 32 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 19 deletions(-) (limited to 'modules/codec-json') diff --git a/modules/codec-json/SConstruct b/modules/codec-json/SConstruct index 20dd972..ff2b31d 100644 --- a/modules/codec-json/SConstruct +++ b/modules/codec-json/SConstruct @@ -44,6 +44,7 @@ env_vars.Add('prefix', ) env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], + CXX=['c++'], CPPDEFINES=['SAW_UNIX'], CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], LIBS=[ diff --git a/modules/codec-json/c++/json.tmpl.hpp b/modules/codec-json/c++/json.tmpl.hpp index e8226f9..0a9f53d 100644 --- a/modules/codec-json/c++/json.tmpl.hpp +++ b/modules/codec-json/c++/json.tmpl.hpp @@ -773,7 +773,7 @@ struct json_decode, ToDecode> { using Schema = schema::Array; template - static error_or decode_flat_level(buffer_view& buff, std::vector>& to, std::array& index, std::array& dims, bool log_dim){ + static error_or decode_flat_level(buffer_view& buff, std::vector>>& to, std::array& index, std::array& dims, bool log_dim){ if constexpr (Level == D) { json_helper::skip_whitespace(buff); try { @@ -830,7 +830,7 @@ struct json_decode, ToDecode> { } template - static error_or decode_unflat_level(std::vector>& flat, data, ToDecode>& to, std::array& index, std::size_t& flat_index) { + static error_or decode_unflat_level(std::vector>>& flat, data, ToDecode>& to, std::array& index, std::size_t& flat_index) { if constexpr ( Level == D ){ auto& flat_data = flat.at(flat_index); to.at(index) = std::move(flat_data); @@ -852,7 +852,7 @@ struct json_decode, ToDecode> { std::array index; std::array dims; std::fill(dims.begin(), dims.end(), 0); - std::vector> flat_array; + std::vector>> flat_array; auto eov = decode_flat_level<0>(buff, flat_array, index, dims, true); if(eov.is_error()){ return eov; diff --git a/modules/codec-json/tests/codec-json.cpp b/modules/codec-json/tests/codec-json.cpp index 723e78c..aca4e21 100644 --- a/modules/codec-json/tests/codec-json.cpp +++ b/modules/codec-json/tests/codec-json.cpp @@ -28,7 +28,7 @@ using TestStruct = Struct< SAW_TEST("UInt8 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(121); @@ -48,7 +48,7 @@ SAW_TEST("UInt8 write"){ SAW_TEST("UInt16 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(24413); @@ -68,7 +68,7 @@ SAW_TEST("UInt16 write"){ SAW_TEST("UInt32 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(44123); @@ -88,7 +88,7 @@ SAW_TEST("UInt32 write"){ SAW_TEST("UInt64 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(243345543); @@ -108,7 +108,7 @@ SAW_TEST("UInt64 write"){ SAW_TEST("Int8 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(-121); @@ -128,7 +128,7 @@ SAW_TEST("Int8 write"){ SAW_TEST("Int16 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(-24413); @@ -148,7 +148,7 @@ SAW_TEST("Int16 write"){ SAW_TEST("Int32 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(44123); @@ -168,7 +168,7 @@ SAW_TEST("Int32 write"){ SAW_TEST("Int64 write"){ using namespace saw; - data native_int; + data> native_int; data json_int; native_int.set(243345543); @@ -188,7 +188,7 @@ SAW_TEST("Int64 write"){ SAW_TEST("String write and read"){ using namespace saw; - data nat_str; + data> nat_str; data json_str; nat_str.set("foo"); @@ -215,7 +215,7 @@ SAW_TEST("String write and read"){ SAW_TEST("Tuple read and write"){ using namespace saw; - data native_tup; + data> native_tup; data json_tup; auto& nat_zero = native_tup.template get<0>(); @@ -244,7 +244,7 @@ SAW_TEST("Tuple read and write"){ SAW_TEST("Array write"){ using namespace saw; - data native{3u}; + data> native{3u}; data json; native.at(0).set("foo"); @@ -264,7 +264,7 @@ SAW_TEST("Array write"){ SAW_TEST("Three Dim Array write and read"){ using namespace saw; - data native{2,1,2}; + data> native{2,1,2}; data json; native.at(0,0,0).set("multi"); @@ -294,7 +294,7 @@ SAW_TEST("Three Dim Array write and read"){ SAW_TEST("Struct read and write"){ using namespace saw; - data native; + data> native; data json; native.get<"foo">().set(5); @@ -319,7 +319,7 @@ SAW_TEST("Struct read and write"){ SAW_TEST("Int8 read"){ using namespace saw; - data native_int; + data> native_int; data json_int{"43"}; codec json_codec; @@ -337,7 +337,7 @@ SAW_TEST("Int8 read"){ SAW_TEST("Int64 read"){ using namespace saw; - data native_int; + data> native_int; data json_int{"-453"}; codec json_codec; @@ -355,7 +355,7 @@ SAW_TEST("Int64 read"){ SAW_TEST("Tuple Pretty Encode and Decode"){ using namespace saw; - data native_tup; + data> native_tup; data json_tup; auto& nat_zero = native_tup.template get<0>(); -- cgit v1.2.3