diff options
| -rw-r--r-- | default.nix | 2 | ||||
| -rw-r--r-- | modules/codec-json/c++/json.hpp | 1 | ||||
| -rw-r--r-- | modules/codec-unit/c++/unit_schema.hpp | 12 | ||||
| -rw-r--r-- | modules/codec-unit/c++/unit_transform.hpp | 27 | ||||
| -rw-r--r-- | modules/codec/.nix/derivation.nix | 2 | ||||
| -rw-r--r-- | modules/codec/c++/data.hpp | 2 | ||||
| -rw-r--r-- | modules/codec/tests/forst.cpp | 4 | ||||
| -rw-r--r-- | modules/io/c++/log.hpp | 30 | ||||
| -rw-r--r-- | modules/remote-io/c++/remote.hpp | 3 | ||||
| -rw-r--r-- | modules/remote-io/c++/transfer.tmpl.hpp | 3 |
10 files changed, 66 insertions, 20 deletions
diff --git a/default.nix b/default.nix index 4532dbf..cf7dd97 100644 --- a/default.nix +++ b/default.nix @@ -184,7 +184,6 @@ in rec { forstio.io_codec forstio.remote forstio.remote-filesystem - forstio.remote-sycl forstio.crypto ]; }; @@ -193,6 +192,7 @@ in rec { name = "forstio-unstable-${version}"; paths = [ forstio.remote-thread + forstio.remote-sycl # forstio.codec-minecraft ]; }; diff --git a/modules/codec-json/c++/json.hpp b/modules/codec-json/c++/json.hpp index 9a785b4..1da74b1 100644 --- a/modules/codec-json/c++/json.hpp +++ b/modules/codec-json/c++/json.hpp @@ -66,6 +66,7 @@ struct codec_config<encode::Json> { uint64_t depth = 16u; uint64_t length = 4096u; bool pretty = false; + bool strict = false; bool is_within(uint64_t bytes, uint64_t d){ return bytes <= length && d <= depth; diff --git a/modules/codec-unit/c++/unit_schema.hpp b/modules/codec-unit/c++/unit_schema.hpp index 5de8770..a675e23 100644 --- a/modules/codec-unit/c++/unit_schema.hpp +++ b/modules/codec-unit/c++/unit_schema.hpp @@ -4,11 +4,17 @@ namespace saw { namespace schema { -template<typename Unit, int64_t Exponent> -struct UnitElement {}; +template<typename Un, int64_t Expo = 0, int64_t Scal = 0> +struct UnitElement { + using Schema = Un; + static constexpr int64_t Exponent = Expo; + static constexpr int64_t Scaling = Scal; +}; template<typename BaseSchema, typename ... Components> -struct Unit {}; +struct Unit { + using Schema = BaseSchema; +}; template<typename BaseSchema> using Pure = Unit<BaseSchema>; diff --git a/modules/codec-unit/c++/unit_transform.hpp b/modules/codec-unit/c++/unit_transform.hpp index 5e90878..40a85a1 100644 --- a/modules/codec-unit/c++/unit_transform.hpp +++ b/modules/codec-unit/c++/unit_transform.hpp @@ -18,9 +18,9 @@ class unit_redux_list { using Type = unit_redux_list<>; }; -template<typename T0, int64_t E0, typename... TL, int64_t... EL> -struct unit_redux_list<schema::UnitElement<T0,E0>, schema::UnitElement<TL,EL>...> { - using Type = typename unit_matching<unit_redux_list<schema::UnitElement<T0,E0>, schema::UnitElement<TL,EL>...>, unit_redux_list<>>::TypeList; +template<typename T0, int64_t E0, int64_t S0, typename... TL, int64_t... EL, int64_t... SL> +struct unit_redux_list<schema::UnitElement<T0,E0,S0>, schema::UnitElement<TL,EL,SL>...> { + using Type = typename unit_matching<unit_redux_list<schema::UnitElement<T0,E0,S0>, schema::UnitElement<TL,EL,SL>...>, unit_redux_list<>>::TypeList; }; template<typename T, typename U, typename V> @@ -32,16 +32,16 @@ public: /** * Iterate over the left list to check against the left element. */ -template<typename T, int64_t E, typename T0, int64_t E0, typename... TL, int64_t... EL, typename... TR, int64_t... ER> -class unit_matching_reduce<schema::UnitElement<T,E>, unit_redux_list<schema::UnitElement<T0,E0>,schema::UnitElement<TL,EL>...>, unit_redux_list<schema::UnitElement<TR,ER>...>> { +template<typename T, int64_t E, int64_t S, typename T0, int64_t E0, int64_t S0, typename... TL, int64_t... EL, int64_t... SL, typename... TR, int64_t... ER, int64_t... SR> +class unit_matching_reduce<schema::UnitElement<T,E,S>, unit_redux_list<schema::UnitElement<T0,E0,S0>,schema::UnitElement<TL,EL,SL>...>, unit_redux_list<schema::UnitElement<TR,ER,SR>...>> { public: - static constexpr bool is_same = std::is_same_v<T,T0>; + static constexpr bool is_same = std::is_same_v<T,T0> and std::is_same_v<S,S0>; // Match T,E against T0,E0 - using ReducedType = typename std::conditional<is_same, schema::UnitElement<T,E+E0>, schema::UnitElement<T,E>>::type; - using ReducedTypeList = typename std::conditional<is_same, unit_redux_list<schema::UnitElement<TR,ER>...>, unit_redux_list<schema::UnitElement<TR,ER>..., schema::UnitElement<T0,E0>>>::type; + using ReducedType = typename std::conditional<is_same, schema::UnitElement<T,E+E0,S>, schema::UnitElement<T,E,S>>::type; + using ReducedTypeList = typename std::conditional<is_same, unit_redux_list<schema::UnitElement<TR,ER,SR>...>, unit_redux_list<schema::UnitElement<TR,ER,SR>..., schema::UnitElement<T0,E0,S0>>>::type; - using NextMatcher = unit_matching_reduce<ReducedType, unit_redux_list<schema::UnitElement<TL,EL>...>, ReducedTypeList>; + using NextMatcher = unit_matching_reduce<ReducedType, unit_redux_list<schema::UnitElement<TL,EL,SL>...>, ReducedTypeList>; using Type = typename NextMatcher::Type; using TypeList = typename NextMatcher::TypeList; static constexpr int64_t Num = NextMatcher::Num; @@ -51,12 +51,13 @@ public: * Final step after going through the list. This contains the final match result. * On the left is the accumulated type and on the right its's a list of non matching types */ -template<typename T, int64_t E, typename... TR, int64_t... ER> -class unit_matching_reduce<schema::UnitElement<T,E>, unit_redux_list<>, unit_redux_list<schema::UnitElement<TR,ER>...>> { +template<typename T, int64_t E, int64_t S, typename... TR, int64_t... ER, int64_t... SR> +class unit_matching_reduce<schema::UnitElement<T,E,S>, unit_redux_list<>, unit_redux_list<schema::UnitElement<TR,ER,SR>...>> { public: - using Type = schema::UnitElement<T,E>; - using TypeList = unit_redux_list<schema::UnitElement<TR,ER>...>; + using Type = schema::UnitElement<T,E,S>; + using TypeList = unit_redux_list<schema::UnitElement<TR,ER,SR>...>; static constexpr int64_t Num = E; + static constexpr int64_t Scale = S; }; template<typename LR, typename RR> diff --git a/modules/codec/.nix/derivation.nix b/modules/codec/.nix/derivation.nix index c17d575..a8c39b1 100644 --- a/modules/codec/.nix/derivation.nix +++ b/modules/codec/.nix/derivation.nix @@ -1,6 +1,7 @@ { lib , stdenv , scons +, bear , clang-tools , version , forstio @@ -23,6 +24,7 @@ in stdenv.mkDerivation { nativeBuildInputs = [ scons + bear clang-tools ]; diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index 4dd1fd3..afcf382 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -590,7 +590,7 @@ private: }; public: data() = default; - data(data<MetaSchema, encode::Native> init){ + data(const data<MetaSchema, encode::Native>& init){ if constexpr ( 0u < sizeof...(T) ){ init_helper<0u>::apply(value_, std::move(init)); } diff --git a/modules/codec/tests/forst.cpp b/modules/codec/tests/forst.cpp index 2bf6442..e68c539 100644 --- a/modules/codec/tests/forst.cpp +++ b/modules/codec/tests/forst.cpp @@ -18,7 +18,7 @@ using TestStruct = Struct< using TestArray = Array< TestStruct >; -/* + SAW_TEST("Codec Forst Layer Info"){ using namespace saw; @@ -39,7 +39,7 @@ SAW_TEST("Codec Forst Layer Info"){ SAW_EXPECT(depth == 2, "Layer info is wrong"); } } - +/* SAW_TEST("Codec Forst Static Size Info"){ using namespace saw; diff --git a/modules/io/c++/log.hpp b/modules/io/c++/log.hpp new file mode 100644 index 0000000..b4e0663 --- /dev/null +++ b/modules/io/c++/log.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include <forstio/codec/data.hpp> + +#include <source_location> + +namespace saw { +namespace schema { +using LogMessage = Struct< + Member<UInt64, "level">, + Member<String, "message">, + Member<String, "file">, + Member<UInt64, "line"> +>; +} + +class local_log final { +public: + void send(uint64_t kind, const std::string_view& msg, const std::source_location& loc); +}; + +logger& get_local_logger(); + +template<typename Kind> +void log(const std::string_view& msg, const std::source_location& loc = std::source_location::current()){ + auto& lg = get_local_logger(); + + lg.send(kind, msg, file, line); +} +} diff --git a/modules/remote-io/c++/remote.hpp b/modules/remote-io/c++/remote.hpp index fe2804d..2337019 100644 --- a/modules/remote-io/c++/remote.hpp +++ b/modules/remote-io/c++/remote.hpp @@ -49,3 +49,6 @@ public: } }; } + +#include "transfer.tmpl.hpp" +#include "remote.tmpl.hpp" diff --git a/modules/remote-io/c++/transfer.tmpl.hpp b/modules/remote-io/c++/transfer.tmpl.hpp new file mode 100644 index 0000000..45dcbb0 --- /dev/null +++ b/modules/remote-io/c++/transfer.tmpl.hpp @@ -0,0 +1,3 @@ +#pragma once + + |
