Skip to content
Merged
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
2 changes: 1 addition & 1 deletion orc-rt/include/orc-rt/SPSWrapperFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ template <typename... SPSArgTs> struct WFSPSHelper {
}

template <typename ArgTuple>
std::optional<ArgTuple> deserialize(WrapperFunctionBuffer ArgBytes) {
std::optional<ArgTuple> deserialize(const WrapperFunctionBuffer &ArgBytes) {
assert(!ArgBytes.getOutOfBandError() &&
"Should not attempt to deserialize out-of-band error");
SPSInputBuffer IB(ArgBytes.data(), ArgBytes.size());
Expand Down
3 changes: 1 addition & 2 deletions orc-rt/include/orc-rt/WrapperFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ struct WrapperFunction {
if (ArgBytes.getOutOfBandError())
return Return(Session, CallCtx, ArgBytes.release());

if (auto Args =
S.arguments().template deserialize<ArgTuple>(std::move(ArgBytes)))
if (auto Args = S.arguments().template deserialize<ArgTuple>(ArgBytes))
std::apply(HandlerTraits::forwardArgsAsRequested(bind_front(
std::forward<Handler>(H),
detail::StructuredYield<RetTupleType, Serializer>(
Expand Down
23 changes: 23 additions & 0 deletions orc-rt/unittests/SPSWrapperFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,29 @@ TEST(SPSWrapperFunctionUtilsTest, BinaryOpViaFunctionPointer) {
EXPECT_EQ(Result, 42);
}

static void
round_trip_string_via_span_sps_wrapper(orc_rt_SessionRef Session, void *CallCtx,
orc_rt_WrapperFunctionReturn Return,
orc_rt_WrapperFunctionBuffer ArgBytes) {
SPSWrapperFunction<SPSString(SPSString)>::handle(
Session, CallCtx, Return, ArgBytes,
[](move_only_function<void(std::string)> Return, span<const char> S) {
Return({S.data(), S.size()});
});
}

TEST(SPSWrapperFunctionUtilsTest, RoundTripStringViaSpan) {
/// Test that the SPSWrapperFunction<...>::handle call in
/// round_trip_string_via_span_sps_wrapper can deserialize into a usable
/// span<const char>.
std::string Result;
SPSWrapperFunction<SPSString(SPSString)>::call(
DirectCaller(nullptr, round_trip_string_via_span_sps_wrapper),
[&](Expected<std::string> R) { Result = cantFail(std::move(R)); },
std::string_view("hello, world!"));
EXPECT_EQ(Result, "hello, world!");
}

static void improbable_feat_sps_wrapper(orc_rt_SessionRef Session,
void *CallCtx,
orc_rt_WrapperFunctionReturn Return,
Expand Down
Loading