diff options
Diffstat (limited to 'forstio/codec')
-rw-r--r-- | forstio/codec/.nix/derivation.nix | 31 | ||||
-rw-r--r-- | forstio/codec/SConscript | 38 | ||||
-rw-r--r-- | forstio/codec/SConstruct | 66 | ||||
-rw-r--r-- | forstio/codec/data.h | 89 | ||||
-rw-r--r-- | forstio/codec/proto_kel.h | 41 | ||||
-rw-r--r-- | forstio/codec/schema.h | 79 |
6 files changed, 0 insertions, 344 deletions
diff --git a/forstio/codec/.nix/derivation.nix b/forstio/codec/.nix/derivation.nix deleted file mode 100644 index c9fac2e..0000000 --- a/forstio/codec/.nix/derivation.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib -, stdenvNoCC -, scons -, clang -, clang-tools -, version -, forstio -}: - -let - -in stdenvNoCC.mkDerivation { - pname = "forstio-codec"; - inherit version; - - src = ./..; - - enableParallelBuilding = true; - - buildInputs = [ - forstio.core - ]; - - nativeBuildInputs = [ - scons - clang - clang-tools - ]; - - outputs = ["out" "dev"]; -} diff --git a/forstio/codec/SConscript b/forstio/codec/SConscript deleted file mode 100644 index c038d42..0000000 --- a/forstio/codec/SConscript +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/false - -import os -import os.path -import glob - - -Import('env') - -dir_path = Dir('.').abspath - -# Environment for base library -codec_env = env.Clone(); - -codec_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) -codec_env.headers = sorted(glob.glob(dir_path + "/*.h")) - -env.sources += codec_env.sources; -env.headers += codec_env.headers; - -## Shared lib -objects_shared = [] -codec_env.add_source_files(objects_shared, codec_env.sources, shared=True); -codec_env.library_shared = codec_env.SharedLibrary('#build/forstio-codec', [objects_shared]); - -## Static lib -objects_static = [] -codec_env.add_source_files(objects_static, codec_env.sources, shared=False); -codec_env.library_static = codec_env.StaticLibrary('#build/forstio-codec', [objects_static]); - -# Set Alias -env.Alias('library_codec', [codec_env.library_shared, codec_env.library_static]); - -env.targets += ['library_codec']; - -# Install -env.Install('$prefix/lib/', [codec_env.library_shared, codec_env.library_static]); -env.Install('$prefix/include/forstio/codec/', [codec_env.headers]); diff --git a/forstio/codec/SConstruct b/forstio/codec/SConstruct deleted file mode 100644 index 0d7b7c6..0000000 --- a/forstio/codec/SConstruct +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import os.path -import glob -import re - - -if sys.version_info < (3,): - def isbasestring(s): - return isinstance(s,basestring) -else: - def isbasestring(s): - return isinstance(s, (str,bytes)) - -def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, target_post=""): - - if isbasestring(filetype): - dir_path = self.Dir('.').abspath - filetype = sorted(glob.glob(dir_path+"/"+filetype)) - - for path in filetype: - target_name = re.sub( r'(.*?)(\.cpp|\.c\+\+)', r'\1' + target_post, path ) - if shared: - target_name+='.os' - sources.append( self.SharedObject( target=target_name, source=path ) ) - else: - target_name+='.o' - sources.append( self.StaticObject( target=target_name, source=path ) ) - pass - -def isAbsolutePath(key, dirname, env): - assert os.path.isabs(dirname), "%r must have absolute path syntax" % (key,) - -env_vars = Variables( - args=ARGUMENTS -) - -env_vars.Add('prefix', - help='Installation target location of build results and headers', - default='/usr/local/', - validator=isAbsolutePath -) - -env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], - CPPDEFINES=['SAW_UNIX'], - CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], - LIBS=['forstio-core']) -env.__class__.add_source_files = add_kel_source_files -env.Tool('compilation_db'); -env.cdb = env.CompilationDatabase('compile_commands.json'); - -env.objects = []; -env.sources = []; -env.headers = []; -env.targets = []; - -Export('env') -SConscript('SConscript') - -env.Alias('cdb', env.cdb); -env.Alias('all', [env.targets]); -env.Default('all'); - -env.Alias('install', '$prefix') diff --git a/forstio/codec/data.h b/forstio/codec/data.h deleted file mode 100644 index 1682ae7..0000000 --- a/forstio/codec/data.h +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -#include <forstio/core/common.h> -#include "schema.h" - -namespace saw { -namespace encode { -struct Native {}; -} -/* - * Helper for the basic message container, so the class doesn't have to be - * specialized 10 times. - */ -template <class T> struct native_data_type; - -template <> -struct native_data_type<schema::Primitive<schema::SignedInteger, 1>> { - using type = int8_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::SignedInteger, 2>> { - using type = int16_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::SignedInteger, 4>> { - using type = int32_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::SignedInteger, 8>> { - using type = int64_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::UnsignedInteger, 1>> { - using type = uint8_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::UnsignedInteger, 2>> { - using type = uint16_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::UnsignedInteger, 4>> { - using type = uint32_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::UnsignedInteger, 8>> { - using type = uint64_t; -}; - -template <> -struct native_data_type<schema::Primitive<schema::FloatingPoint, 4>> { - using type = float; -}; - -template<typename T, typename Encoding = encode::Native> -class data { -private: - static_assert(always_false<T>, "Type not supported"); -}; - -template<> -class data<schema::String, encode::Native> { -private: - std::string value_; -public: - SAW_FORBID_COPY(data); - - data(std::string&& value__):value_{std::move(value__)}{} - - std::size_t size() const { - return value_.size(); - } - - bool operator==(const data<schema::String, encode::Native>& data){ - return value_ == data.value_; - } -}; - -template<typename T, size_t N> -class data<schema::Primitive<T,N>, encode::Native> { -private: -}; -} diff --git a/forstio/codec/proto_kel.h b/forstio/codec/proto_kel.h deleted file mode 100644 index 3b4ebac..0000000 --- a/forstio/codec/proto_kel.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "data.h" - -#include <forstio/core/error.h> - -namespace saw { -namespace encode { -struct ProtoKel {}; -} - -template<typename Schema> -class data<Schema, encode::ProtoKel> { -private: - own<buffer> buffer_; -public: - data(own<buffer>&& buffer__):buffer_{std::move(buffer__)}{} - - buffer& get_buffer(){ - return *buffer_; - } - - const buffer& get_buffer() const { - return *buffer_; - } -}; - -template<typename Schema> -class codec<Schema, encode::ProtoKel> { -private: -public: - error_or<data<Schema, encode::Native>> decode(const data<Schema, encode::ProtoKel>& encoded){ - return make_error<err::not_implemented>(); - } - - error_or<data<Schema, encode::ProtoKel>> encode(const data<Schema, encode::Native>& native){ - return make_error<err::not_implemented>(); - } -}; -} -} diff --git a/forstio/codec/schema.h b/forstio/codec/schema.h deleted file mode 100644 index b23aaa1..0000000 --- a/forstio/codec/schema.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include <forstio/common.h> -#include <forstio/string_literal.h> - -namespace saw { -namespace schema { -// NOLINTBEGIN -template <typename T, string_literal Literal> struct NamedMember {}; - -template <typename... T> struct Struct { - static_assert( - always_false<T...>, - "This schema template doesn't support this type of template argument"); -}; - -template <typename... V, string_literal... K> -struct Struct<NamedMember<V, K>...> {}; - -template <typename... T> struct Union { - static_assert( - always_false<T...>, - "This schema template doesn't support this type of template argument"); -}; - -template <typename... V, string_literal... K> -struct Union<NamedMember<V, K>...> {}; - -template <typename T> struct Array {}; - -template<typename T, size_t S> FixedArray {}; - -template <typename... T> struct Tuple {}; - -struct String {}; - -struct SignedInteger {}; -struct UnsignedInteger {}; -struct FloatingPoint {}; - -template <class T, size_t N> struct Primitive { - static_assert(((std::is_same_v<T, SignedInteger> || - std::is_same_v<T, UnsignedInteger>)&&(N == 1 || N == 2 || - N == 4 || N == 8)) || - (std::is_same_v<T, FloatingPoint> && (N == 4 || N == 8)), - "Primitive Type is not supported"); -}; - -using Int8 = Primitive<SignedInteger, 1>; -using Int16 = Primitive<SignedInteger, 2>; -using Int32 = Primitive<SignedInteger, 4>; -using Int64 = Primitive<SignedInteger, 8>; - -using UInt8 = Primitive<UnsignedInteger, 1>; -using UInt16 = Primitive<UnsignedInteger, 2>; -using UInt32 = Primitive<UnsignedInteger, 4>; -using UInt64 = Primitive<UnsignedInteger, 8>; - -using Float32 = Primitive<FloatingPoint, 4>; -using Float64 = Primitive<FloatingPoint, 8>; - -/** - * Classes enabling Rpc calls - */ -template <class Request, class Response, string_literal Literal> -struct Function {}; - -template <class... T> struct Interface { - static_assert( - always_false<T...>, - "This schema template doesn't support this type of template argument"); -}; - -template <class... Request, class... Response, string_literal... Literal> -struct Interface<Function<Request, Response, Literal>...> {}; - -// NOLINTEND -} // namespace schema -} // namespace saw |