diff options
Diffstat (limited to 'modules/lang')
-rw-r--r-- | modules/lang/c++/c_helper.hpp | 19 | ||||
-rw-r--r-- | modules/lang/c++/c_language.hpp | 20 | ||||
-rw-r--r-- | modules/lang/c++/c_rpc.hpp | 3 | ||||
-rw-r--r-- | modules/lang/c++/c_transfer.hpp | 5 | ||||
-rw-r--r-- | modules/lang/c++/c_types.hpp | 85 | ||||
-rw-r--r-- | modules/lang/c++/language.hpp | 6 |
6 files changed, 132 insertions, 6 deletions
diff --git a/modules/lang/c++/c_helper.hpp b/modules/lang/c++/c_helper.hpp new file mode 100644 index 0000000..550e55c --- /dev/null +++ b/modules/lang/c++/c_helper.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "c_common.hpp" + +namespace saw { +namespace impl { +struct lang_helper { + static error_or<void> append_string(std::string& buff, const std::string_view& str){ + try{ + buff += str; + }catch(const std::exception&){ + return make_error<err::out_of_memory>(); + } + + return make_void(); + } +}; +} +} diff --git a/modules/lang/c++/c_language.hpp b/modules/lang/c++/c_language.hpp new file mode 100644 index 0000000..c4b1d48 --- /dev/null +++ b/modules/lang/c++/c_language.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "c_transfer.hpp" +#include "c_helper.hpp" +#include "c_rpc.hpp" + +namespace saw { +template<typename Iface, typename Encoding> +class language<Iface, Encoding, lang::RemoteC> { +public: + struct config { + std::string prefix; + }; +public: + error_or<void> generate_rpc(const config& cfg){ + return make_error<err::not_implemented>(); + } +}; + +} diff --git a/modules/lang/c++/c_rpc.hpp b/modules/lang/c++/c_rpc.hpp index 75c2f7c..7a1c6ab 100644 --- a/modules/lang/c++/c_rpc.hpp +++ b/modules/lang/c++/c_rpc.hpp @@ -1,7 +1,4 @@ #pragma once -#include "c_rpc_types.hpp" - namespace saw { - } diff --git a/modules/lang/c++/c_transfer.hpp b/modules/lang/c++/c_transfer.hpp index 6c2061b..5de204c 100644 --- a/modules/lang/c++/c_transfer.hpp +++ b/modules/lang/c++/c_transfer.hpp @@ -1,8 +1,7 @@ #pragma once -#include "c_common.hpp" +#include "language.hpp" +#include "c_types.hpp" namespace saw { -template<typename Interface, typename T> -struct language {}; } diff --git a/modules/lang/c++/c_types.hpp b/modules/lang/c++/c_types.hpp new file mode 100644 index 0000000..ff3f5a8 --- /dev/null +++ b/modules/lang/c++/c_types.hpp @@ -0,0 +1,85 @@ +#pragma once + +#include <forstio/codec/schema.hpp> + +#include "c_common.hpp" + +namespace saw { +/** + * Helper to determine if we are dealing with primitive types + */ +template<typename Schema> +struct c_is_primitive { + static constexpr bool value = false; +}; + +template<typename T, size_t N> +struct c_is_primitive<schema::Primitive<T,N>> { + static constexpr bool value = true; +}; + +template<typename Schema> +struct c_primitive_string { + static_assert(always_false<Schema>, "Not supported"); +}; + +template<> +struct c_primitive_string<schema::Int8> { + static constexpr string_literal name = "int8"; + static constexpr string_literal value = "int8_t"; +}; + +template<> +struct c_primitive_string<schema::Int16> { + static constexpr string_literal name = "int16"; + static constexpr string_literal value = "int16_t"; +}; + +template<> +struct c_primitive_string<schema::Int32> { + static constexpr string_literal name = "int32"; + static constexpr string_literal value = "int32_t"; +}; + +template<> +struct c_primitive_string<schema::Int64> { + static constexpr string_literal name = "int64"; + static constexpr string_literal value = "int64_t"; +}; + +template<> +struct c_primitive_string<schema::UInt8> { + static constexpr string_literal name = "uint8"; + static constexpr string_literal value = "uint8_t"; +}; + +template<> +struct c_primitive_string<schema::UInt16> { + static constexpr string_literal name = "uint16"; + static constexpr string_literal value = "uint16_t"; +}; + +template<> +struct c_primitive_string<schema::UInt32> { + static constexpr string_literal name = "uint32"; + static constexpr string_literal value = "uint32_t"; +}; + +template<> +struct c_primitive_string<schema::UInt64> { + static constexpr string_literal name = "uint64"; + static constexpr string_literal value = "uint64_t"; +}; + +template<> +struct c_primitive_string<schema::Float32> { + static constexpr string_literal name = "float32"; + static constexpr string_literal value = "float"; +}; + +template<> +struct c_primitive_string<schema::Float64> { + static constexpr string_literal name = "float64"; + static constexpr string_literal value = "double"; +}; +} diff --git a/modules/lang/c++/language.hpp b/modules/lang/c++/language.hpp new file mode 100644 index 0000000..1c05f81 --- /dev/null +++ b/modules/lang/c++/language.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace saw { +template<typename Interface,typename Encoding, typename Language> +struct language {}; +} |