sf: Change interface definition methodology (#1074)

* sf: Begin experimenting with new interface declaration format

* sf: convert fs interfaces to new format

* sf: finish conversion of libstrat to new definitions

* sf: convert loader to new format

* sf: convert spl to new format

* sf: update ncm for new format

* sf: convert pm to new format

* sf: convert ro/sm to new format

* sf: update fatal for new format

* sf: support building dmnt under new scheme

* sf: update ams.mitm for new format

* sf: correct invocation def for pointer holder

* fs: correct 10.x+ user bindings for Get*SpaceSize
This commit is contained in:
SciresM
2020-07-07 17:07:23 -07:00
committed by GitHub
parent 94eb2195d3
commit 9fde97cfdd
190 changed files with 3220 additions and 3172 deletions

View File

@@ -18,28 +18,29 @@
namespace ams::pgl {
class RemoteEventObserver final : public pgl::sf::IEventObserver {
class RemoteEventObserver final {
NON_COPYABLE(RemoteEventObserver);
NON_MOVEABLE(RemoteEventObserver);
private:
::PglEventObserver observer;
public:
constexpr RemoteEventObserver(const ::PglEventObserver &o) : observer(o) { /* ... */ }
virtual ~RemoteEventObserver() override {
~RemoteEventObserver() {
::pglEventObserverClose(std::addressof(this->observer));
}
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) override {
Result GetProcessEventHandle(ams::sf::OutCopyHandle out) {
::Event ev;
R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev)));
out.SetValue(ev.revent);
return ResultSuccess();
}
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) override {
Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo));
return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()));
}
};
static_assert(pgl::sf::IsIEventObserver<RemoteEventObserver>);
}

View File

@@ -79,7 +79,7 @@ namespace ams::pgl {
::PglEventObserver obs;
R_TRY(::pglGetEventObserver(std::addressof(obs)));
auto remote_observer = std::make_shared<RemoteEventObserver>(obs);
auto remote_observer = ams::sf::MakeShared<pgl::sf::IEventObserver, RemoteEventObserver>(obs);
AMS_ABORT_UNLESS(remote_observer != nullptr);
*out = pgl::EventObserver(remote_observer);

View File

@@ -66,13 +66,13 @@ namespace ams::pgl::srv {
this->event.Signal();
}
Result EventObserverInterface::GetProcessEventHandle(ams::sf::OutCopyHandle out) {
out.SetValue(GetReference(this->observer).GetEvent().GetReadableHandle());
Result ShellEventObserver::GetProcessEventHandle(ams::sf::OutCopyHandle out) {
out.SetValue(this->GetEvent().GetReadableHandle());
return ResultSuccess();
}
Result EventObserverInterface::GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
return GetReference(this->observer).PopEventInfo(out.GetPointer());
Result ShellEventObserver::GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
return this->PopEventInfo(out.GetPointer());
}
}
}

View File

@@ -56,23 +56,10 @@ namespace ams::pgl::srv {
Result PopEventInfo(pm::ProcessEventInfo *out);
virtual void Notify(const pm::ProcessEventInfo &info) override final;
};
class EventObserverInterface final : public pgl::sf::IEventObserver {
private:
TYPED_STORAGE(ShellEventObserver) observer;
public:
EventObserverInterface() {
std::memset(std::addressof(this->observer), 0, sizeof(this->observer));
new (GetPointer(this->observer)) ShellEventObserver;
}
~EventObserverInterface() {
GetReference(this->observer).~ShellEventObserver();
}
public:
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) override final;
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) override final;
Result GetProcessEventHandle(ams::sf::OutCopyHandle out);
Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out);
};
static_assert(pgl::sf::IsIEventObserver<ShellEventObserver>);
}

View File

@@ -69,20 +69,22 @@ namespace ams::pgl::srv {
}
Result ShellInterface::GetShellEventObserver(ams::sf::Out<std::shared_ptr<pgl::sf::IEventObserver>> out) {
using Interface = typename pgl::sf::IEventObserver::ImplHolder<ShellEventObserver>;
/* Allocate a new interface. */
auto *observer_memory = this->memory_resource->Allocate(sizeof(EventObserverInterface), alignof(EventObserverInterface));
auto *observer_memory = this->memory_resource->Allocate(sizeof(Interface), alignof(Interface));
AMS_ABORT_UNLESS(observer_memory != nullptr);
/* Create the interface object. */
new (observer_memory) EventObserverInterface;
new (observer_memory) Interface;
/* Set the output. */
out.SetValue(std::shared_ptr<EventObserverInterface>(reinterpret_cast<EventObserverInterface *>(observer_memory), [&](EventObserverInterface *obj) {
out.SetValue(std::shared_ptr<pgl::sf::IEventObserver>(reinterpret_cast<Interface *>(observer_memory), [&](Interface *obj) {
/* Destroy the object. */
obj->~EventObserverInterface();
obj->~Interface();
/* Custom deleter: use the memory resource to free. */
this->memory_resource->Deallocate(obj, sizeof(EventObserverInterface), alignof(EventObserverInterface));
this->memory_resource->Deallocate(obj, sizeof(Interface), alignof(Interface));
}));
return ResultSuccess();
}