summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/core/c++/reduce_templates.hpp11
-rw-r--r--modules/core/tests/templates.cpp20
-rw-r--r--modules/lang/c++/c_helper.hpp19
-rw-r--r--modules/lang/c++/c_language.hpp20
-rw-r--r--modules/lang/c++/c_rpc.hpp3
-rw-r--r--modules/lang/c++/c_transfer.hpp5
-rw-r--r--modules/lang/c++/c_types.hpp85
-rw-r--r--modules/lang/c++/language.hpp6
-rw-r--r--modules/remote/c++/remote_loopback_base.hpp2
9 files changed, 161 insertions, 10 deletions
diff --git a/modules/core/c++/reduce_templates.hpp b/modules/core/c++/reduce_templates.hpp
index ef5fa4c..fb643df 100644
--- a/modules/core/c++/reduce_templates.hpp
+++ b/modules/core/c++/reduce_templates.hpp
@@ -13,23 +13,28 @@ struct tmpl_group_reduce_match {
template<typename T0, typename TL0, typename... TL>
struct tmpl_group_reduce_match<T0, tmpl_group<TL0,TL...>> {
+ /**
+ * Check if type already exists in list
+ */
static constexpr bool has_type = std::is_same_v<T0,TL0> or tmpl_group_reduce_match<T0, tmpl_group<TL...>>::has_type;
using type = typename std::conditional<has_type, tmpl_group<TL0,TL...>, tmpl_group<T0, TL0, TL...>>::type;
};
+/**
+ * Reducing in outer loop
+ */
template<typename T>
struct tmpl_group_reduce {
using reduced_type = T;
};
-/**
- * Reducing in outer loop
- */
template<typename... TL, typename T0>
struct tmpl_group_reduce<tmpl_group<T0,TL...>> {
+ // Compile Time outer iteration
using reduced_inner_list = typename tmpl_group_reduce<tmpl_group<TL...>>::reduced_type;
+ // Actual reduction. Basically an inner loop call
using reduced_type = typename tmpl_group_reduce_match<T0,reduced_inner_list>::type;
};
}
diff --git a/modules/core/tests/templates.cpp b/modules/core/tests/templates.cpp
new file mode 100644
index 0000000..2a069a6
--- /dev/null
+++ b/modules/core/tests/templates.cpp
@@ -0,0 +1,20 @@
+#include "../c++/reduce_templates.hpp"
+
+#include "../c++/test/suite.hpp"
+
+namespace {
+struct Foo{};
+
+struct Bar{};
+struct Baz{};
+
+SAW_TEST("Templates/Reduce tmpl_group<T...>"){
+ using namespace saw;
+
+ using DuplGrp = tmpl_group<Bar,Baz,Baz,Bar,Foo,Bar,Baz,Bar,Bar>;
+
+ using UniqGrp = tmpl_group<Foo,Baz,Bar>;
+
+ SAW_EXPECT((std::is_same_v<DuplGrp,UniqGrp>), "Expected Uniquess Reduction");
+}
+}
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 {};
+}
diff --git a/modules/remote/c++/remote_loopback_base.hpp b/modules/remote/c++/remote_loopback_base.hpp
index b53ae49..6ca244f 100644
--- a/modules/remote/c++/remote_loopback_base.hpp
+++ b/modules/remote/c++/remote_loopback_base.hpp
@@ -68,7 +68,7 @@ public:
* Start listening
*/
template<typename Iface, typename Encode>
- rpc_server<Iface, Encode, rmt::Loopback> listen(const remote_address<rmt::Loopback>& addr, typename rpc_server<Iface,Encode,rmt::Loopback>::InterfaceT iface){
+ rpc_server<Iface, Encode, rmt::Loopback> rpc_listen(const remote_address<rmt::Loopback>& addr, typename rpc_server<Iface,Encode,rmt::Loopback>::InterfaceT iface){
return {addr, std::move(iface)};
}