Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/mp/type-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <concepts>
#include <span>
#include <ranges>

namespace mp {
template <typename T, typename U>
Expand All @@ -33,7 +34,7 @@ requires (std::is_same_v<decltype(output.get()), ::capnp::Data::Builder> && IsBy
{
auto data = std::span{value};
auto result = output.init(data.size());
memcpy(result.begin(), data.data(), data.size());
std::ranges::copy(data, result.begin());
}

template <typename LocalType, typename Input, typename ReadDest>
Expand Down
1 change: 1 addition & 0 deletions test/mp/test/foo.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface FooInterface $Proxy.wrap("mp::test::FooImplementation") {
callbackExtended @10 (context :Proxy.Context, callback :ExtendedCallback, arg: Int32) -> (result :Int32);
passCustom @11 (arg :FooCustom) -> (result :FooCustom);
passEmpty @12 (arg :FooEmpty) -> (result :FooEmpty);
passData @24 (arg :Data) -> (result :Data);
passMessage @13 (arg :FooMessage) -> (result :FooMessage);
passMutable @14 (arg :FooMutable) -> (arg :FooMutable);
passEnum @15 (arg :Int32) -> (result :Int32);
Expand Down
1 change: 1 addition & 0 deletions test/mp/test/foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class FooImplementation
int callbackExtended(ExtendedCallback& callback, int arg) { return callback.callExtended(arg); }
FooCustom passCustom(FooCustom foo) { return foo; }
FooEmpty passEmpty(FooEmpty foo) { return foo; }
FooData passData(FooData foo) { return foo; }
FooMessage passMessage(FooMessage foo) { foo.message += " call"; return foo; }
void passMutable(FooMutable& foo) { foo.message += " call"; }
FooEnum passEnum(FooEnum foo) { return foo; }
Expand Down
3 changes: 3 additions & 0 deletions test/mp/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ KJ_TEST("Call FooInterface methods")

foo->passEmpty(FooEmpty{});

FooData empty_data_out = foo->passData(FooData{});
KJ_EXPECT(empty_data_out.empty());

FooMessage message1;
message1.message = "init";
FooMessage message2{foo->passMessage(message1)};
Expand Down
Loading