1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-22 10:22:08 +00:00

Stratosphere: Add IPC templating for non-member functions.

This commit is contained in:
Michael Scire 2018-05-03 03:14:48 -06:00
parent 593efedb2c
commit b5412df53b
2 changed files with 24 additions and 0 deletions

2
.gitignore vendored
View file

@ -75,6 +75,8 @@ stratosphere/loader/out/**
stratosphere/loader/build/**
stratosphere/sm/out/**
stratosphere/sm/build/**
stratosphere/pm/out/**
stratosphere/pm/build/**
stratosphere/boot/out/**
stratosphere/boot/build/**
stratosphere/boot2/out/**

View file

@ -428,5 +428,27 @@ Result WrapIpcCommandImpl(Class *this_ptr, IpcParsedCommand& r, IpcCommand &out_
auto args = Decoder<OutArgs, InArgsWithoutThis>::Decode(r, out_command, pointer_buffer);
auto result = std::apply( [=](auto&&... args) { return (this_ptr->*IpcCommandImpl)(args...); }, args);
return std::apply(Encoder<OutArgs>{out_command}, result);
}
template<auto IpcCommandImpl>
Result WrapStaticIpcCommandImpl(IpcParsedCommand& r, IpcCommand &out_command, u8 *pointer_buffer, size_t pointer_buffer_size) {
using InArgs = typename boost::callable_traits::args_t<decltype(IpcCommandImpl)>;
using OutArgs = typename boost::callable_traits::return_type_t<decltype(IpcCommandImpl)>;
static_assert(is_specialization_of<OutArgs, std::tuple>::value, "IpcCommandImpls must return std::tuple<Result, ...>");
static_assert(std::is_same_v<std::tuple_element_t<0, OutArgs>, Result>, "IpcCommandImpls must return std::tuple<Result, ...>");
ipcInitialize(&out_command);
Result rc = Validator<InArgs>{r, pointer_buffer_size}();
if (R_FAILED(rc)) {
return 0xF601;
}
auto args = Decoder<OutArgs, InArgs>::Decode(r, out_command, pointer_buffer);
auto result = std::apply(IpcCommandImpl, args);
return std::apply(Encoder<OutArgs>{out_command}, result);
}