This argument serves as an opaque id (outside the ControllerAccess
object) for a call to a wrapper function. I expect that most
ControllerAccess implementations will want to use this argument as a
sequence number (plain integer), for which uint64_t will be a better fit
than void*. For ControllerAccess implementations that want to use a
pointer, uint64_t should be sufficiently large.
This replaces SPS transparent conversion for pointers. Transparent
conversion only applies to argument/return types, not nested types. We
want to be able to serialize / deserialize structs containing pointers.
We may need to replace this in the near future with a new SPSPointer tag
type, since SPSExecutorAddr is meant to be serialization for pure
addresses, and pointers may carry other information (e.g. tag bits), but
we can do that in a follow-up commit.
SPS deserialization for span<const char> produces a value that points
directly into the argument buffer for efficiency. This was broken by an
unnecessary std::move of the buffer inside WrapperFunction, which this
commit removes.
The DirectCaller utility allows "direct" calls (with arguments
serialized into, and then immediately back out of a
WrapperFunctionBuffer) to wrapper functions. It was introduced for the
SPSWrapperFunction tests, but will be useful for testing WrapperFunction
interfaces for various orc-rt APIs too, so this commit hoists it
somewhere where it can be reused.
WrapperFunction::handleWithAsyncMethod can be used to wrap asynchronous
methods (void methods whose first arguments are Return callbacks) for
use with WrapperFunction::handle.
WrapperFunction::handleWithSyncMethod can be used to wrap regular
(non-asynchronous) methods for use with WrapperFunction::handle.
Both variants return function objects that take a Return callback as
their first argument, and an ExecutorAddr representing the address of
the instance to call the object on. For asynchronous methods the
resulting function object (AsyncMethod<method-ptr>) forwards the Return
callback through to the method. For synchronous methods the method is
called and the result passed to the Return callback.
This adds support for WrapperFunction::handle handlers that take their
arguments by reference, rather than by value.
This commit also reduces the number of temporary objects created to
support SPS-transparent conversion in SPSWrapperFunction.
This commit aims to reduce boilerplate by adding transparent conversion
between Error/Expected types and their SPS-serializable counterparts
(SPSSerializableError/SPSSerializableExpected). This allows
SPSWrapperFunction calls and handles to be written in terms of
Error/Expected directly.
This functionality can also be extended to transparently convert between
other types. This may be used in the future to provide conversion
between ExecutorAddr and native pointer types.
Introduces the following key APIs:
`orc_rt_WrapperFunction` defines the signature of an ORC asynchronous
wrapper function:
```
typedef void (*orc_rt_WrapperFunctionReturn)(
orc_rt_SessionRef Session, void *CallCtx,
orc_rt_WrapperFunctionBuffer ResultBytes);
typedef void (*orc_rt_WrapperFunction)(orc_rt_SessionRef Session, void *CallCtx,
orc_rt_WrapperFunctionReturn Return,
orc_rt_WrapperFunctionBuffer ArgBytes);
```
A wrapper function takes a reference to the session object, a context
pointer for the call being made, and a pointer to an
orc_rt_WrapperFunctionReturn function that can be used to send the
result bytes.
The `orc_rt::WrapperFunction` utility simplifies the writing of wrapper
functions whose arguments and return values are serialized/deserialized
using an abstract serialization utility.
The `orc_rt::SPSWrapperFunction` utility provides a specialized version
of `orc_rt::WrapperFunction` that uses SPS serialization.