summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/codec/c++/data.hpp3
-rw-r--r--modules/remote/c++/remote.hpp2
-rw-r--r--modules/remote/c++/remote_loopback.hpp15
-rw-r--r--modules/remote/c++/transfer.hpp6
-rw-r--r--modules/remote/c++/transfer_loopback.hpp4
-rw-r--r--modules/remote/tests/remote_loopback.cpp39
-rw-r--r--modules/tools/c++/c_gen_iface.hpp7
7 files changed, 61 insertions, 15 deletions
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp
index b1e9401..734a56e 100644
--- a/modules/codec/c++/data.hpp
+++ b/modules/codec/c++/data.hpp
@@ -622,6 +622,9 @@ private:
public:
data() = default;
data(data<MetaSchema, encode::Native>){}
+ data(const std::array<data<T, encode::Native>, ct_multiply<uint64_t,D...>::value>& value__):
+ value_{value__}
+ {}
data<T, encode::Native, storage::Default>& at(const std::array<uint64_t, sizeof...(D)>& ind){
return value_.at(this->get_flat_index(ind));
diff --git a/modules/remote/c++/remote.hpp b/modules/remote/c++/remote.hpp
index fd6f4e6..72c9cce 100644
--- a/modules/remote/c++/remote.hpp
+++ b/modules/remote/c++/remote.hpp
@@ -8,6 +8,8 @@
#include <variant>
+#include "transfer.hpp"
+
namespace saw {
/**
* This class acts as a helper for rpc calls and representing data on the remote.
diff --git a/modules/remote/c++/remote_loopback.hpp b/modules/remote/c++/remote_loopback.hpp
index 76aab69..10ac79c 100644
--- a/modules/remote/c++/remote_loopback.hpp
+++ b/modules/remote/c++/remote_loopback.hpp
@@ -55,6 +55,16 @@ class rpc_client<Iface, Encoding, Storage, rmt::Loopback> {
template<>
class remote_address<rmt::Loopback> {
+private:
+ data<schema::UInt64> addr_id_;
+public:
+ remote_address(data<schema::UInt64> addr_id__):
+ addr_id_{addr_id__}
+ {}
+
+ const data<schema::UInt64>& get_address_id() const {
+ return addr_id_;
+ }
};
template<typename Iface, typename Encode, typename Storage>
@@ -75,12 +85,13 @@ public:
template<>
class remote<rmt::Loopback> {
+private:
public:
/**
* Resolves an address for the remote
*/
- error_or<own<remote_address<rmt::Loopback>>> parse_address(){
- return heap<remote_address<rmt::Loopback>>();
+ error_or<own<remote_address<rmt::Loopback>>> parse_address(data<schema::UInt64> id){
+ return heap<remote_address<rmt::Loopback>>(id);
}
/**
diff --git a/modules/remote/c++/transfer.hpp b/modules/remote/c++/transfer.hpp
index 2fdd0b9..ea61d56 100644
--- a/modules/remote/c++/transfer.hpp
+++ b/modules/remote/c++/transfer.hpp
@@ -1,6 +1,12 @@
#pragma once
namespace saw {
+template<typename Remote>
+class i_data_server {
+protected:
+ virtual ~i_data_server() = default;
+};
+
template<typename Schema, typename Encoding, typename Remote>
class data_server;
diff --git a/modules/remote/c++/transfer_loopback.hpp b/modules/remote/c++/transfer_loopback.hpp
index abea83f..9d026f2 100644
--- a/modules/remote/c++/transfer_loopback.hpp
+++ b/modules/remote/c++/transfer_loopback.hpp
@@ -13,7 +13,11 @@ template<typename... Schema, typename Encoding>
class data_server<tmpl_group<Schema...>, Encoding, rmt::Loopback> {
private:
typename impl::data_server_redux<Encoding, storage::Default, typename tmpl_reduce<tmpl_group<Schema...>>::type>::type values_;
+
+ ptr<remote<rmt::Loopback>> remote_;
public:
+ data_server(remote_address<rmt::Loopback>& addr)
+
/**
* Get data from client
*/
diff --git a/modules/remote/tests/remote_loopback.cpp b/modules/remote/tests/remote_loopback.cpp
index e78f646..2430029 100644
--- a/modules/remote/tests/remote_loopback.cpp
+++ b/modules/remote/tests/remote_loopback.cpp
@@ -21,20 +21,17 @@ using GroupedSchemas = saw::tmpl_group<
SAW_TEST("Remote Loopback Data"){
using namespace saw;
+ event_loop loop;
+ wait_scope wait{loop};
+
remote<rmt::Loopback> rmt;
- auto eov = rmt.parse_address();
+ auto eov = rmt.parse_address(0u);
SAW_EXPECT(eov.is_value(), "Didn't parse correctly");
auto& val = eov.get_value();
- interface<sch::TestInterface, encode::Native, storage::Default> iface{
- [](data<sch::UInt32>& foo){
- return foo.template cast_to<sch::Int64>();
- }
- };
-
- auto srv = data_server<sch::GroupedSchemas, encode::Native, rmt::Loopback>{};
- auto client = data_client<sch::GroupedSchemas, encode::Native, rmt::Loopback>{srv};
+ auto srv = data_server<sch::GroupedSchemas, encode::Native, rmt::Loopback>{val};
+ auto client = data_client<sch::GroupedSchemas, encode::Native, rmt::Loopback>{val};
data<sch::UInt64> foo{421};
id<sch::UInt64> sent_id = [&](){
@@ -43,9 +40,6 @@ SAW_TEST("Remote Loopback Data"){
return eov.get_value();
}();
- event_loop loop;
- wait_scope wait{loop};
-
{
auto conv = client.receive(sent_id);
auto eov = conv.take();
@@ -82,5 +76,26 @@ SAW_TEST("Remote Loopback Data"){
SAW_EXPECT(f_val, "Nullptr in find.");
f_val->set(5u);
}
+ {
+ auto conv = client.receive(alloc_id);
+ auto eov = conv.take();
+ SAW_EXPECT(eov.is_value(), "Failed receive.");
+ SAW_EXPECT(eov.get_value().get() == 5u, "Wrong received value.");
+ }
+
+ data<sch::FixedArray<sch::UInt64,1>> arr_meta{{128u}};
+
+ id<sch::Array<sch::Int32>> arr_alloc_id = [&](){
+ auto eov = client.allocate<sch::Array<sch::Int32>>(arr_meta);
+ SAW_EXPECT(eov.is_value(), "Failed send.");
+ return eov.get_value();
+ }();
+ {
+ auto eov = client.find(arr_alloc_id);
+ SAW_EXPECT(eov.is_value(), "Failed find.");
+ auto& f_val = eov.get_value();
+ SAW_EXPECT(f_val, "Nullptr in find.");
+ SAW_EXPECT(f_val->size() == arr_meta.at(0).get(), "Wrong initialized size.");
+ }
}
}
diff --git a/modules/tools/c++/c_gen_iface.hpp b/modules/tools/c++/c_gen_iface.hpp
index 63cd3a7..3a648a1 100644
--- a/modules/tools/c++/c_gen_iface.hpp
+++ b/modules/tools/c++/c_gen_iface.hpp
@@ -488,7 +488,12 @@ struct lang_bind<schema::Struct<schema::Member<V,K>...>, binding::SyncC> {
using Schema = schema::Struct<schema::Member<V,K>...>;
template<uint64_t i>
- static error_or<void> generate_translation_func(std::string& buff, const std::string_view& prefix, bool c_to_cpp){
+ static error_or<void> generate_translation_func(const language_binding_config& cfg, language_binding_state& state, std::string& buff, bool c_to_cpp){
+ using MT = typename parameter_pack_type<i,V...>::type;
+ static constexpr string_literal Lit = parameter_key_pack_type<i,K...>::literal;
+
+ constexpr uint32_t hash = schema_hash<MT>::apply();
+
auto& tpe = state.tp_elements;
uint64_t id;
{