From dd432f33e881ddf6a3d3af52defa275675de7938 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 6 Jul 2020 19:41:04 -0700 Subject: [PATCH] sf: finish conversion of libstrat to new definitions --- .../sf/cmif/sf_cmif_service_dispatch.hpp | 10 +-- .../sf/hipc/sf_hipc_server_manager.hpp | 37 ++++----- .../sf/impl/sf_impl_service_object_macros.hpp | 38 ++++++++- .../stratosphere/sf/sf_service_object.hpp | 34 ++++---- ...odersrv_decoder_control_server_manager.cpp | 2 +- ...odersrv_decoder_control_server_manager.hpp | 1 + .../decodersrv_decoder_control_service.hpp | 20 ++--- .../erpt/srv/erpt_srv_attachment_impl.hpp | 15 ++-- .../source/erpt/srv/erpt_srv_context_impl.hpp | 25 +++--- .../source/erpt/srv/erpt_srv_manager_impl.hpp | 15 ++-- .../source/erpt/srv/erpt_srv_report_impl.hpp | 15 ++-- .../source/erpt/srv/erpt_srv_service.cpp | 10 +-- .../source/erpt/srv/erpt_srv_session_impl.cpp | 42 +++++----- .../source/erpt/srv/erpt_srv_session_impl.hpp | 9 +- .../fssrv_filesystem_interface_adapter.cpp | 4 +- ..._add_on_content_location_resolver_impl.hpp | 15 ++-- .../libstratosphere/source/lr/lr_api.cpp | 4 +- .../lr/lr_content_location_resolver_impl.hpp | 53 ++++++------ .../lr/lr_location_resolver_impl_base.hpp | 2 +- .../lr/lr_location_resolver_manager_impl.cpp | 10 +-- ...r_redirect_only_location_resolver_impl.hpp | 53 ++++++------ .../lr_registered_location_resolver_impl.hpp | 31 +++---- .../lr/lr_remote_location_resolver_impl.hpp | 83 ++++++++++--------- ...mote_registered_location_resolver_impl.hpp | 33 ++++---- .../libstratosphere/source/ncm/ncm_api.cpp | 2 +- .../source/ncm/ncm_content_manager_impl.cpp | 16 ++-- .../ncm_content_meta_database_impl_base.hpp | 28 ++++++- .../ncm/ncm_content_storage_impl_base.hpp | 35 +++++++- .../ncm/ncm_remote_content_manager_impl.hpp | 37 +++++---- .../ncm_remote_content_meta_database_impl.hpp | 50 +++++------ .../ncm/ncm_remote_content_storage_impl.hpp | 63 +++++++------- .../source/pgl/pgl_remote_event_observer.hpp | 9 +- .../source/pgl/pgl_shell_api.cpp | 2 +- .../pgl/srv/pgl_srv_shell_event_observer.cpp | 10 +-- .../pgl/srv/pgl_srv_shell_event_observer.hpp | 19 +---- .../pgl/srv/pgl_srv_shell_interface.cpp | 12 +-- .../source/psc/psc_pm_module.os.horizon.cpp | 2 +- .../source/psc/psc_remote_pm_module.hpp | 15 ++-- .../source/sf/hipc/sf_hipc_mitm_query_api.cpp | 19 ++--- .../sf_hipc_server_domain_session_manager.cpp | 31 +++---- 40 files changed, 498 insertions(+), 413 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp index 067dd03a4..4ee1c3f65 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp @@ -127,23 +127,21 @@ namespace ams::sf::cmif { } }; - template + template requires sf::IsServiceObject struct ServiceDispatchTraits { - static_assert(std::is_base_of::value, "ServiceObjects must derive from sf::IServiceObject"); - using ProcessHandlerType = decltype(ServiceDispatchMeta::ProcessHandler); static constexpr inline auto DispatchTable = T::template s_CmifServiceDispatchTable; using DispatchTableType = decltype(DispatchTable); - static constexpr ProcessHandlerType ProcessHandlerImpl = ServiceObjectTraits::IsMitmServiceObject ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm) - : (&impl::ServiceDispatchTableBase::ProcessMessage); + static constexpr ProcessHandlerType ProcessHandlerImpl = sf::IsMitmServiceObject ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm) + : (&impl::ServiceDispatchTableBase::ProcessMessage); static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl}; }; template - NX_CONSTEXPR const ServiceDispatchMeta *GetServiceDispatchMeta() { + constexpr ALWAYS_INLINE const ServiceDispatchMeta *GetServiceDispatchMeta() { return &ServiceDispatchTraits::Meta; } diff --git a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp index fabff0f93..66ecde8ea 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp @@ -69,12 +69,12 @@ namespace ams::sf::hipc { virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const = 0; }; - template> + template class Server : public ServerBase { NON_COPYABLE(Server); NON_MOVEABLE(Server); private: - static constexpr bool IsMitmServer = ServiceObjectTraits::IsMitmServiceObject; + static constexpr bool IsMitmServer = sf::IsMitmServiceObject; public: Server(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) : ServerBase(ph, sn, m, std::forward(sh)) { /* ... */ @@ -145,14 +145,14 @@ namespace ams::sf::hipc { void ProcessDeferredSessions(); - template> + template void RegisterServerImpl(Handle port_handle, sm::ServiceName service_name, bool managed, cmif::ServiceObjectHolder &&static_holder) { /* Allocate server memory. */ auto *server = this->AllocateServer(); AMS_ABORT_UNLESS(server != nullptr); - new (server) Server(port_handle, service_name, managed, std::forward(static_holder)); + new (server) Server(port_handle, service_name, managed, std::forward(static_holder)); - if constexpr (!ServiceObjectTraits::IsMitmServiceObject) { + if constexpr (!sf::IsMitmServiceObject) { /* Non-mitm server. */ os::SetWaitableHolderUserData(server, static_cast(UserDataTag::Server)); } else { @@ -163,9 +163,9 @@ namespace ams::sf::hipc { os::LinkWaitableHolder(std::addressof(this->waitable_manager), server); } - template - static constexpr inline std::shared_ptr MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) { - return std::make_shared(std::forward>(s), client_info); + template + static constexpr inline std::shared_ptr MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) { + return sf::MakeShared(std::forward>(s), client_info); } Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func); @@ -187,21 +187,18 @@ namespace ams::sf::hipc { os::InitializeWaitableManager(std::addressof(this->waitlist)); } - template> - void RegisterServer(Handle port_handle, std::shared_ptr static_object = nullptr) { - static_assert(!ServiceObjectTraits::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead."); + template> requires (sf::IsServiceObject && !sf::IsMitmServiceObject) + void RegisterServer(Handle port_handle, std::shared_ptr static_object = nullptr) { /* Register server. */ cmif::ServiceObjectHolder static_holder; if (static_object != nullptr) { static_holder = cmif::ServiceObjectHolder(std::move(static_object)); } - this->RegisterServerImpl(port_handle, sm::InvalidServiceName, false, std::move(static_holder)); + this->RegisterServerImpl(port_handle, sm::InvalidServiceName, false, std::move(static_holder)); } - template> - Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr static_object = nullptr) { - static_assert(!ServiceObjectTraits::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead."); - + template> requires (sf::IsServiceObject && !sf::IsMitmServiceObject) + Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr static_object = nullptr) { /* Register service. */ Handle port_handle; R_TRY(sm::RegisterService(&port_handle, service_name, max_sessions, false)); @@ -211,19 +208,17 @@ namespace ams::sf::hipc { if (static_object != nullptr) { static_holder = cmif::ServiceObjectHolder(std::move(static_object)); } - this->RegisterServerImpl(port_handle, service_name, true, std::move(static_holder)); + this->RegisterServerImpl(port_handle, service_name, true, std::move(static_holder)); return ResultSuccess(); } - template> + template> requires (sf::IsMitmServiceObject) Result RegisterMitmServer(sm::ServiceName service_name) { - static_assert(ServiceObjectTraits::IsMitmServiceObject, "RegisterMitmServer requires mitm object. Use RegisterServer instead."); - /* Install mitm service. */ Handle port_handle; R_TRY(this->InstallMitmServerImpl(&port_handle, service_name, &ServiceImpl::ShouldMitm)); - this->RegisterServerImpl(port_handle, service_name, true, cmif::ServiceObjectHolder()); + this->RegisterServerImpl(port_handle, service_name, true, cmif::ServiceObjectHolder()); return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_service_object_macros.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_service_object_macros.hpp index d5a1a438e..f71594bc9 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_service_object_macros.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_service_object_macros.hpp @@ -126,13 +126,21 @@ namespace ams::sf::impl { return this->impl.NAME(std::forward(args)...); \ } + #define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + template \ + requires (std::same_as, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> && \ + std::same_asNAME(std::declval()...))>) \ + RETURN NAME (Arguments &&... args) { \ + return this->impl->NAME(std::forward(args)...); \ + } + #define AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ template struct NAME##FunctionPointerHolder; \ \ template \ requires std::same_as, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \ struct NAME##FunctionPointerHolder> { \ - static constexpr auto Value = static_cast(&ImplHolder::NAME##Invoker); \ + static constexpr auto Value = static_cast(&NAME##Invoker); \ }; #define AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ @@ -185,6 +193,8 @@ namespace ams::sf::impl { { \ /* ... */ \ } \ + ALWAYS_INLINE T &GetImpl() { return this->impl; } \ + ALWAYS_INLINE const T &GetImpl() const { return this->impl; } \ private: \ CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \ public: \ @@ -198,6 +208,29 @@ namespace ams::sf::impl { }; \ static_assert(Is##CLASSNAME); \ \ + class ImplPointer : public S { \ + private: \ + T *impl; \ + public: \ + constexpr ImplPointer(T *t) \ + : S(std::addressof(CommandPointerTableImpl)), impl(t) \ + { \ + /* ... */ \ + } \ + ALWAYS_INLINE T &GetImpl() { return *this->impl; } \ + ALWAYS_INLINE const T &GetImpl() const { return *this->impl; } \ + private: \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \ + public: \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR) \ + private: \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER) \ + public: \ + static constexpr CommandPointerTable CommandPointerTableImpl = { \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER) \ + }; \ + }; \ + static_assert(Is##CLASSNAME); \ }; \ private: \ CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER) \ @@ -205,6 +238,9 @@ namespace ams::sf::impl { template requires (!std::same_as&& Is##CLASSNAME) \ using ImplHolder = typename ImplGenerator::ImplHolder; \ \ + template requires (!std::same_as&& Is##CLASSNAME) \ + using ImplPointer = typename ImplGenerator::ImplPointer; \ + \ AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE { \ CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY) \ }; \ diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp index 866375684..7226c81da 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp @@ -25,6 +25,9 @@ namespace ams::sf { virtual ~IServiceObject() { /* ... */ } }; + template + concept IsServiceObject = std::derived_from; + class IMitmServiceObject : public IServiceObject { protected: std::shared_ptr<::Service> forward_service; @@ -37,26 +40,25 @@ namespace ams::sf { static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id); }; + template + concept IsMitmServiceObject = IsServiceObject && std::derived_from; + /* Utility. */ #define AMS_SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : ::ams::sf::IMitmServiceObject(std::forward>(s), c) - template - struct ServiceObjectTraits { - static_assert(std::is_base_of::value, "ServiceObjectTraits requires ServiceObject"); - - static constexpr bool IsMitmServiceObject = std::is_base_of::value; - - struct SharedPointerHelper { - - static constexpr void EmptyDelete(T *) { /* Empty deleter, for fake shared pointer. */ } - - static constexpr std::shared_ptr GetEmptyDeleteSharedPointer(T *srv_obj) { - return std::shared_ptr(srv_obj, EmptyDelete); - } - - }; - }; + template requires std::constructible_from + constexpr ALWAYS_INLINE std::shared_ptr> MakeShared(Arguments &&... args) { + return std::make_shared>(std::forward(args)...); + } + template + constexpr ALWAYS_INLINE std::shared_ptr> GetSharedPointerTo(Impl *impl) { + return std::make_shared>(impl); + } + template + constexpr ALWAYS_INLINE std::shared_ptr> GetSharedPointerTo(Impl &impl) { + return GetSharedPointerTo(std::addressof(impl)); + } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp index 42553cfcb..b5e9a6232 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp @@ -24,7 +24,7 @@ namespace ams::capsrv::server { this->server_manager_holder.emplace(); /* Register the service. */ - R_ABORT_UNLESS(this->server_manager_holder->RegisterServer(ServiceName, MaxSessions, sf::ServiceObjectTraits::SharedPointerHelper::GetEmptyDeleteSharedPointer(std::addressof(*this->service_holder)))); + R_ABORT_UNLESS((this->server_manager_holder->RegisterServer(ServiceName, MaxSessions, sf::GetSharedPointerTo(*this->service_holder)))); /* Initialize the idle event, we're idle initially. */ os::InitializeEvent(std::addressof(this->idle_event), true, os::EventClearMode_ManualClear); diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp index d8db8697f..3d7fdbf17 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp @@ -26,6 +26,7 @@ namespace ams::capsrv::server { static constexpr inline size_t MaxSessions = 2; static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("caps:dc"); + using Interface = IDecoderControlService; using Service = DecoderControlService; using ServerOptions = sf::hipc::DefaultServerManagerOptions; using ServerManager = sf::hipc::ServerManager; diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.hpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.hpp index 0a095883b..961018cc1 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.hpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_service.hpp @@ -18,17 +18,15 @@ namespace ams::capsrv::server { - class DecoderControlService final : public sf::IServiceObject { - protected: - enum class CommandId { - DecodeJpeg = 3001, - }; + #define AMS_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 3001, Result, DecodeJpeg, (const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option)) + + AMS_SF_DEFINE_INTERFACE(IDecoderControlService, AMS_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO) + + class DecoderControlService final { public: - /* Actual commands. */ - virtual Result DecodeJpeg(const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(DecodeJpeg) - }; + Result DecodeJpeg(const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option); }; + static_assert(IsIDecoderControlService); + } \ No newline at end of file diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp index 8d0e65670..05aebe943 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp @@ -20,19 +20,20 @@ namespace ams::erpt::srv { class Attachment; - class AttachmentImpl final : public erpt::sf::IAttachment { + class AttachmentImpl final { private: Attachment *attachment; public: AttachmentImpl(); ~AttachmentImpl(); public: - virtual Result Open(const AttachmentId &attachment_id) override final; - virtual Result Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) override final; - virtual Result SetFlags(AttachmentFlagSet flags) override final; - virtual Result GetFlags(ams::sf::Out out) override final; - virtual Result Close() override final; - virtual Result GetSize(ams::sf::Out out) override final; + Result Open(const AttachmentId &attachment_id); + Result Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer); + Result SetFlags(AttachmentFlagSet flags); + Result GetFlags(ams::sf::Out out); + Result Close(); + Result GetSize(ams::sf::Out out); }; + static_assert(erpt::sf::IsIAttachment); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.hpp index 662f02022..f2660638a 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_impl.hpp @@ -18,19 +18,20 @@ namespace ams::erpt::srv { - class ContextImpl final : public erpt::sf::IContext { + class ContextImpl final { public: - virtual Result SubmitContext(const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer) override final; - virtual Result CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer) override final; - virtual Result SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point) override final; - virtual Result ClearInitialLaunchSettingsCompletionTime() override final; - virtual Result UpdatePowerOnTime() override final; - virtual Result UpdateAwakeTime() override final; - virtual Result SubmitMultipleCategoryContext(const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer) override final; - virtual Result UpdateApplicationLaunchTime() override final; - virtual Result ClearApplicationLaunchTime() override final; - virtual Result SubmitAttachment(ams::sf::Out out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data) override final; - virtual Result CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer) override final; + Result SubmitContext(const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer); + Result CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer); + Result SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point); + Result ClearInitialLaunchSettingsCompletionTime(); + Result UpdatePowerOnTime(); + Result UpdateAwakeTime(); + Result SubmitMultipleCategoryContext(const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer); + Result UpdateApplicationLaunchTime(); + Result ClearApplicationLaunchTime(); + Result SubmitAttachment(ams::sf::Out out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data); + Result CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer); }; + static_assert(erpt::sf::IsIContext); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp index b75d01955..e59dddb51 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp @@ -18,7 +18,7 @@ namespace ams::erpt::srv { - class ManagerImpl final : public erpt::sf::IManager, public util::IntrusiveListBaseNode { + class ManagerImpl final : public util::IntrusiveListBaseNode { private: os::SystemEvent system_event; public: @@ -29,12 +29,13 @@ namespace ams::erpt::srv { public: static Result NotifyAll(); public: - virtual Result GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter) override final; - virtual Result GetEvent(ams::sf::OutCopyHandle out) override final; - virtual Result CleanupReports() override final; - virtual Result DeleteReport(const ReportId &report_id) override final; - virtual Result GetStorageUsageStatistics(ams::sf::Out out) override final; - virtual Result GetAttachmentList(const ams::sf::OutBuffer &out_buf, const ReportId &report_id) override final; + Result GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter); + Result GetEvent(ams::sf::OutCopyHandle out); + Result CleanupReports(); + Result DeleteReport(const ReportId &report_id); + Result GetStorageUsageStatistics(ams::sf::Out out); + Result GetAttachmentList(const ams::sf::OutBuffer &out_buf, const ReportId &report_id); }; + static_assert(erpt::sf::IsIManager); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp index 8b60e536a..c1adc2529 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp @@ -20,19 +20,20 @@ namespace ams::erpt::srv { class Report; - class ReportImpl final : public erpt::sf::IReport { + class ReportImpl final { private: Report *report; public: ReportImpl(); ~ReportImpl(); public: - virtual Result Open(const ReportId &report_id) override final; - virtual Result Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) override final; - virtual Result SetFlags(ReportFlagSet flags) override final; - virtual Result GetFlags(ams::sf::Out out) override final; - virtual Result Close() override final; - virtual Result GetSize(ams::sf::Out out) override final; + Result Open(const ReportId &report_id); + Result Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer); + Result SetFlags(ReportFlagSet flags); + Result GetFlags(ams::sf::Out out); + Result Close(); + Result GetSize(ams::sf::Out out); }; + static_assert(erpt::sf::IsIReport); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp index b6fd8725e..293a5358e 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp @@ -42,7 +42,7 @@ namespace ams::erpt::srv { class ErrorReportServiceManager : public ams::sf::hipc::ServerManager { private: os::ThreadType thread; - std::shared_ptr context_session_object; + std::shared_ptr context_session_object; private: static void ThreadFunction(void *_this) { reinterpret_cast(_this)->SetupAndLoopProcess(); @@ -51,14 +51,14 @@ namespace ams::erpt::srv { void SetupAndLoopProcess(); public: ErrorReportServiceManager(erpt::srv::ContextImpl *c) - : context_session_object(ams::sf::ServiceObjectTraits::SharedPointerHelper::GetEmptyDeleteSharedPointer(c)) + : context_session_object(ams::sf::GetSharedPointerTo(c)) { /* ... */ } Result Initialize() { - R_ABORT_UNLESS(this->RegisterServer(ErrorReportContextServiceName, ErrorReportContextSessions, this->context_session_object)); - R_ABORT_UNLESS(this->RegisterServer(ErrorReportReportServiceName, ErrorReportReportSessions)); + R_ABORT_UNLESS((this->RegisterServer(ErrorReportContextServiceName, ErrorReportContextSessions, this->context_session_object))); + R_ABORT_UNLESS((this->RegisterServer(ErrorReportReportServiceName, ErrorReportReportSessions))); this->ResumeProcessing(); @@ -117,7 +117,7 @@ namespace ams::erpt::srv { } } - erpt::srv::ContextImpl g_context_object; + constinit erpt::srv::ContextImpl g_context_object; ErrorReportServiceManager g_erpt_server_manager(std::addressof(g_context_object)); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp index 3a0eda8b0..4aec973b6 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.cpp @@ -21,34 +21,34 @@ namespace ams::erpt::srv { - Result SessionImpl::OpenReport(ams::sf::Out> out) { - /* Create an interface. */ - auto intf = std::shared_ptr(new (std::nothrow) ReportImpl); - R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory()); + namespace { - /* Return it. */ - out.SetValue(std::move(intf)); - return ResultSuccess(); + template + ALWAYS_INLINE Result OpenInterface(ams::sf::Out> &out) { + /* Define holder type. */ + using Holder = typename Interface::ImplHolder; + + /* Create an interface holder. */ + auto intf = std::shared_ptr(new (std::nothrow) Holder); + R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory()); + + /* Return it. */ + out.SetValue(std::move(intf)); + return ResultSuccess(); + } + + } + + Result SessionImpl::OpenReport(ams::sf::Out> out) { + return OpenInterface(out); } Result SessionImpl::OpenManager(ams::sf::Out> out) { - /* Create an interface. */ - auto intf = std::shared_ptr(new (std::nothrow) ManagerImpl); - R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory()); - - /* Return it. */ - out.SetValue(std::move(intf)); - return ResultSuccess(); + return OpenInterface(out); } Result SessionImpl::OpenAttachment(ams::sf::Out> out) { - /* Create an interface. */ - auto intf = std::shared_ptr(new (std::nothrow) AttachmentImpl); - R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory()); - - /* Return it. */ - out.SetValue(std::move(intf)); - return ResultSuccess(); + return OpenInterface(out); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.hpp index 4dcc165b0..8d68c701d 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_session_impl.hpp @@ -18,11 +18,12 @@ namespace ams::erpt::srv { - class SessionImpl final : public erpt::sf::ISession { + class SessionImpl final { public: - virtual Result OpenReport(ams::sf::Out> out) override final; - virtual Result OpenManager(ams::sf::Out> out) override final; - virtual Result OpenAttachment(ams::sf::Out> out) override final; + Result OpenReport(ams::sf::Out> out); + Result OpenManager(ams::sf::Out> out); + Result OpenAttachment(ams::sf::Out> out); }; + static_assert(erpt::sf::IsISession); } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp index 3aaa84de5..23040e25c 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp @@ -254,7 +254,7 @@ namespace ams::fssrv::impl { /* TODO: N creates an nn::fssystem::AsynchronousAccessFile here. */ std::shared_ptr shared_this = this->shared_from_this(); - std::shared_ptr file_intf = std::make_shared>(std::move(file), std::move(shared_this), std::move(open_count_semaphore)); + auto file_intf = ams::sf::MakeShared(std::move(file), std::move(shared_this), std::move(open_count_semaphore)); R_UNLESS(file_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter()); out.SetValue(std::move(file_intf), target_object_id); @@ -281,7 +281,7 @@ namespace ams::fssrv::impl { const auto target_object_id = dir->GetDomainObjectId(); std::shared_ptr shared_this = this->shared_from_this(); - std::shared_ptr dir_intf = std::make_shared>(std::move(dir), std::move(shared_this), std::move(open_count_semaphore)); + auto dir_intf = ams::sf::MakeShared(std::move(dir), std::move(shared_this), std::move(open_count_semaphore)); R_UNLESS(dir_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter()); out.SetValue(std::move(dir_intf), target_object_id); diff --git a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp index 17c7a0c1c..60e57b767 100644 --- a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp @@ -21,7 +21,7 @@ namespace ams::lr { - class AddOnContentLocationResolverImpl : public IAddOnContentLocationResolver { + class AddOnContentLocationResolverImpl { private: /* Storage for RegisteredData entries by data id. */ RegisteredStorages registered_storages; @@ -29,12 +29,13 @@ namespace ams::lr { AddOnContentLocationResolverImpl() : registered_storages(hos::GetVersion() < hos::Version_9_0_0 ? 0x800 : 0x2) { /* ... */ } /* Actual commands. */ - virtual Result ResolveAddOnContentPath(sf::Out out, ncm::DataId id) override; - virtual Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) override; - virtual Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) override; - virtual Result UnregisterAllAddOnContentPath() override; - virtual Result RefreshApplicationAddOnContent(const sf::InArray &ids) override; - virtual Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) override; + Result ResolveAddOnContentPath(sf::Out out, ncm::DataId id); + Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id); + Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id); + Result UnregisterAllAddOnContentPath(); + Result RefreshApplicationAddOnContent(const sf::InArray &ids); + Result UnregisterApplicationAddOnContent(ncm::ApplicationId id); }; + static_assert(lr::IsIAddOnContentLocationResolver); } diff --git a/libraries/libstratosphere/source/lr/lr_api.cpp b/libraries/libstratosphere/source/lr/lr_api.cpp index 36a7cb813..391285080 100644 --- a/libraries/libstratosphere/source/lr/lr_api.cpp +++ b/libraries/libstratosphere/source/lr/lr_api.cpp @@ -42,7 +42,7 @@ namespace ams::lr { LrLocationResolver lr; R_TRY(lrOpenLocationResolver(static_cast(storage_id), std::addressof(lr))); - *out = LocationResolver(std::make_shared(lr)); + *out = LocationResolver(sf::MakeShared(lr)); return ResultSuccess(); } @@ -50,7 +50,7 @@ namespace ams::lr { LrRegisteredLocationResolver lr; R_TRY(lrOpenRegisteredLocationResolver(std::addressof(lr))); - *out = RegisteredLocationResolver(std::make_shared(lr)); + *out = RegisteredLocationResolver(sf::MakeShared(lr)); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp index 5553962da..5b344bdfc 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp @@ -35,32 +35,33 @@ namespace ams::lr { void GetContentStoragePath(Path *out, ncm::ContentId content_id); public: /* Actual commands. */ - virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) override; - virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override; - virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) override; - virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) override; - virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) override; - virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) override; - virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result Refresh() override; - virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result ClearApplicationRedirectionDeprecated() override; - virtual Result ClearApplicationRedirection(const sf::InArray &excluding_ids) override; - virtual Result EraseProgramRedirection(ncm::ProgramId id) override; - virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override; - virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override; - virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override; - virtual Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) override; - virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override; + Result ResolveProgramPath(sf::Out out, ncm::ProgramId id); + Result RedirectProgramPath(const Path &path, ncm::ProgramId id); + Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id); + Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id); + Result ResolveDataPath(sf::Out out, ncm::DataId id); + Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id); + Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result Refresh(); + Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result ClearApplicationRedirectionDeprecated(); + Result ClearApplicationRedirection(const sf::InArray &excluding_ids); + Result EraseProgramRedirection(ncm::ProgramId id); + Result EraseApplicationControlRedirection(ncm::ProgramId id); + Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id); + Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id); + Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id); + Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id); + Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result EraseProgramRedirectionForDebug(ncm::ProgramId id); }; + static_assert(lr::IsILocationResolver); } diff --git a/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp b/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp index d8931d041..03f7c68ee 100644 --- a/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp +++ b/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp @@ -20,7 +20,7 @@ namespace ams::lr { - class LocationResolverImplBase : public ILocationResolver { + class LocationResolverImplBase { NON_COPYABLE(LocationResolverImplBase); NON_MOVEABLE(LocationResolverImplBase); protected: diff --git a/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp b/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp index f726cdf7e..fd5392c52 100644 --- a/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp @@ -30,10 +30,10 @@ namespace ams::lr { /* No existing resolver is present, create one. */ if (!resolver) { if (storage_id == ncm::StorageId::Host) { - AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::make_shared())); + AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, sf::MakeShared())); } else { - auto content_resolver = std::make_shared(storage_id); - R_TRY(content_resolver->Refresh()); + auto content_resolver = sf::MakeShared(storage_id); + R_TRY(content_resolver->GetImpl().Refresh()); AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::move(content_resolver))); } @@ -51,7 +51,7 @@ namespace ams::lr { /* No existing resolver is present, create one. */ if (!this->registered_location_resolver) { - this->registered_location_resolver = std::make_shared(); + this->registered_location_resolver = sf::MakeShared(); } /* Copy the output interface. */ @@ -79,7 +79,7 @@ namespace ams::lr { /* No existing resolver is present, create one. */ if (!this->add_on_content_location_resolver) { - this->add_on_content_location_resolver = std::make_shared(); + this->add_on_content_location_resolver = sf::MakeShared(); } /* Copy the output interface. */ diff --git a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp index a204169d1..a9aee02b4 100644 --- a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp @@ -24,32 +24,33 @@ namespace ams::lr { ~RedirectOnlyLocationResolverImpl(); public: /* Actual commands. */ - virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) override; - virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override; - virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) override; - virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) override; - virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) override; - virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) override; - virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result Refresh() override; - virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result ClearApplicationRedirectionDeprecated() override; - virtual Result ClearApplicationRedirection(const sf::InArray &excluding_ids) override; - virtual Result EraseProgramRedirection(ncm::ProgramId id) override; - virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override; - virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override; - virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override; - virtual Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) override; - virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override; + Result ResolveProgramPath(sf::Out out, ncm::ProgramId id); + Result RedirectProgramPath(const Path &path, ncm::ProgramId id); + Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id); + Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id); + Result ResolveDataPath(sf::Out out, ncm::DataId id); + Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id); + Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result Refresh(); + Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result ClearApplicationRedirectionDeprecated(); + Result ClearApplicationRedirection(const sf::InArray &excluding_ids); + Result EraseProgramRedirection(ncm::ProgramId id); + Result EraseApplicationControlRedirection(ncm::ProgramId id); + Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id); + Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id); + Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id); + Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id); + Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result EraseProgramRedirectionForDebug(ncm::ProgramId id); }; + static_assert(lr::IsILocationResolver); } diff --git a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp index 1a5ea6994..b1399336f 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp @@ -21,7 +21,7 @@ namespace ams::lr { - class RegisteredLocationResolverImpl : public IRegisteredLocationResolver { + class RegisteredLocationResolverImpl { private: static constexpr size_t MaxRegisteredLocationsDeprecated = 0x10; static constexpr size_t MaxRegisteredLocations = 0x20; @@ -49,20 +49,21 @@ namespace ams::lr { ~RegisteredLocationResolverImpl(); public: /* Actual commands. */ - virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) override; - virtual Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result UnregisterProgramPath(ncm::ProgramId id) override; - virtual Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result ResolveHtmlDocumentPath(sf::Out out, ncm::ProgramId id) override; - virtual Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result UnregisterHtmlDocumentPath(ncm::ProgramId id) override; - virtual Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; - virtual Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; - virtual Result Refresh() override; - virtual Result RefreshExcluding(const sf::InArray &ids) override; + Result ResolveProgramPath(sf::Out out, ncm::ProgramId id); + Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id); + Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result UnregisterProgramPath(ncm::ProgramId id); + Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result ResolveHtmlDocumentPath(sf::Out out, ncm::ProgramId id); + Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id); + Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result UnregisterHtmlDocumentPath(ncm::ProgramId id); + Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id); + Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id); + Result Refresh(); + Result RefreshExcluding(const sf::InArray &ids); }; + static_assert(lr::IsIRegisteredLocationResolver); } diff --git a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp index 59093e7d8..895325dcf 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp @@ -18,7 +18,7 @@ namespace ams::lr { - class RemoteLocationResolverImpl : public ILocationResolver { + class RemoteLocationResolverImpl { private: ::LrLocationResolver srv; public: @@ -27,121 +27,122 @@ namespace ams::lr { ~RemoteLocationResolverImpl() { ::serviceClose(&srv.s); } public: /* Actual commands. */ - virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) override { - return lrLrResolveProgramPath(std::addressof(this->srv), id.value, out->str); + Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) { + return ::lrLrResolveProgramPath(std::addressof(this->srv), id.value, out->str); } - virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override { - return lrLrRedirectProgramPath(std::addressof(this->srv), id.value, path.str); + Result RedirectProgramPath(const Path &path, ncm::ProgramId id) { + return ::lrLrRedirectProgramPath(std::addressof(this->srv), id.value, path.str); } - virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) override { - return lrLrResolveApplicationControlPath(std::addressof(this->srv), id.value, out->str); + Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) { + return ::lrLrResolveApplicationControlPath(std::addressof(this->srv), id.value, out->str); } - virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) override { - return lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, out->str); + Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) { + return ::lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, out->str); } - virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) override { - return lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str); + Result ResolveDataPath(sf::Out out, ncm::DataId id) { + return ::lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str); } - virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override { - return lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, 0, path.str); + Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) { + return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, 0, path.str); } - virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { - return lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, owner_id.value, path.str); + Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { + return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, owner_id.value, path.str); } - virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override { - return lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, 0, path.str); + Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { + return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, 0, path.str); } - virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { - return lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, owner_id.value, path.str); + Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { + return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, owner_id.value, path.str); } - virtual Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) override { - return lrLrResolveApplicationLegalInformationPath(std::addressof(this->srv), id.value, out->str); + Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) { + return ::lrLrResolveApplicationLegalInformationPath(std::addressof(this->srv), id.value, out->str); } - virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override { - return lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, 0, path.str); + Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) { + return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, 0, path.str); } - virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { - return lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, owner_id.value, path.str); + Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { + return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, owner_id.value, path.str); } - virtual Result Refresh() override { - return lrLrRefresh(std::addressof(this->srv)); + Result Refresh() { + return ::lrLrRefresh(std::addressof(this->srv)); } - virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override { + Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { + Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result ClearApplicationRedirectionDeprecated() override { + Result ClearApplicationRedirectionDeprecated() { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result ClearApplicationRedirection(const sf::InArray &excluding_ids) override { + Result ClearApplicationRedirection(const sf::InArray &excluding_ids) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result EraseProgramRedirection(ncm::ProgramId id) override { - return lrLrEraseProgramRedirection(std::addressof(this->srv), id.value); + Result EraseProgramRedirection(ncm::ProgramId id) { + return ::lrLrEraseProgramRedirection(std::addressof(this->srv), id.value); } - virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override { + Result EraseApplicationControlRedirection(ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override { + Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override { + Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) override { + Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override { + Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override { + Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { + Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override { + Result EraseProgramRedirectionForDebug(ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } }; + static_assert(lr::IsILocationResolver); } diff --git a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp index 3b8551756..2a3367d34 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp @@ -19,7 +19,7 @@ namespace ams::lr { - class RemoteRegisteredLocationResolverImpl : public IRegisteredLocationResolver { + class RemoteRegisteredLocationResolverImpl { private: ::LrRegisteredLocationResolver srv; public: @@ -28,74 +28,75 @@ namespace ams::lr { ~RemoteRegisteredLocationResolverImpl() { ::serviceClose(&srv.s); } public: /* Actual commands. */ - virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) override { - return lrRegLrResolveProgramPath(std::addressof(this->srv), static_cast(id), out->str); + Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) { + return ::lrRegLrResolveProgramPath(std::addressof(this->srv), static_cast(id), out->str); } - virtual Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) override { + Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { + Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result UnregisterProgramPath(ncm::ProgramId id) override { + Result UnregisterProgramPath(ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) override { + Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { + Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result ResolveHtmlDocumentPath(sf::Out out, ncm::ProgramId id) override { + Result ResolveHtmlDocumentPath(sf::Out out, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override { + Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { + Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result UnregisterHtmlDocumentPath(ncm::ProgramId id) override { + Result UnregisterHtmlDocumentPath(ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override { + Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override { + Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result Refresh() override { + Result Refresh() { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result RefreshExcluding(const sf::InArray &ids) override { + Result RefreshExcluding(const sf::InArray &ids) { /* TODO: libnx bindings */ AMS_ABORT(); } }; + static_assert(lr::IsIRegisteredLocationResolver); } diff --git a/libraries/libstratosphere/source/ncm/ncm_api.cpp b/libraries/libstratosphere/source/ncm/ncm_api.cpp index b2c3e2d9c..ca392ab6a 100644 --- a/libraries/libstratosphere/source/ncm/ncm_api.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_api.cpp @@ -27,7 +27,7 @@ namespace ams::ncm { void Initialize() { AMS_ASSERT(g_content_manager == nullptr); R_ABORT_UNLESS(ncmInitialize()); - g_content_manager = std::make_shared(); + g_content_manager = sf::MakeShared(); } void Finalize() { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index 3f4dabcb0..7302acc19 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -553,23 +553,23 @@ namespace ams::ncm { if (storage_id == StorageId::GameCard) { /* Game card content storage is read only. */ - auto content_storage = std::make_shared(); - R_TRY(content_storage->Initialize(root->path, MakeFlatContentFilePath)); + auto content_storage = sf::MakeShared(); + R_TRY(content_storage->GetImpl().Initialize(root->path, MakeFlatContentFilePath)); root->content_storage = std::move(content_storage); } else { /* Create a content storage. */ - auto content_storage = std::make_shared(); + auto content_storage = sf::MakeShared(); /* Initialize content storage with an appropriate path function. */ switch (storage_id) { case StorageId::BuiltInSystem: - R_TRY(content_storage->Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache))); + R_TRY(content_storage->GetImpl().Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache))); break; case StorageId::SdCard: - R_TRY(content_storage->Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache))); + R_TRY(content_storage->GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache))); break; default: - R_TRY(content_storage->Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache))); + R_TRY(content_storage->GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache))); break; } @@ -617,7 +617,7 @@ namespace ams::ncm { R_TRY(root->kvs->Initialize(root->max_content_metas, root->memory_resource)); /* Create an on memory content meta database for game cards. */ - root->content_meta_database = std::make_shared(std::addressof(*root->kvs)); + root->content_meta_database = sf::MakeShared(std::addressof(*root->kvs)); } else { /* Mount save data for this root. */ R_TRY(fs::MountSystemSaveData(root->mount_name, root->info.space_id, root->info.id)); @@ -630,7 +630,7 @@ namespace ams::ncm { R_TRY(root->kvs->Load()); /* Create the content meta database. */ - root->content_meta_database = std::make_shared(std::addressof(*root->kvs), root->mount_name); + root->content_meta_database = sf::MakeShared(std::addressof(*root->kvs), root->mount_name); mount_guard.Cancel(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp index 171180622..21945868c 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp @@ -18,7 +18,7 @@ namespace ams::ncm { - class ContentMetaDatabaseImplBase : public IContentMetaDatabase { + class ContentMetaDatabaseImplBase { NON_COPYABLE(ContentMetaDatabaseImplBase); NON_MOVEABLE(ContentMetaDatabaseImplBase); protected: @@ -52,6 +52,32 @@ namespace ams::ncm { R_TRY(this->GetContentMetaSize(out_size, key)); return this->kvs->GetValuePointer(reinterpret_cast(out_value_ptr), key); } + public: + /* Actual commands. */ + virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) = 0; + virtual Result Get(sf::Out out_size, const ContentMetaKey &key, sf::OutBuffer out_value) = 0; + virtual Result Remove(const ContentMetaKey &key) = 0; + virtual Result GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) = 0; + virtual Result ListContentInfo(sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) = 0; + virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) = 0; + virtual Result GetLatestContentMetaKey(sf::Out out_key, u64 id) = 0; + virtual Result ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type) = 0; + virtual Result Has(sf::Out out, const ContentMetaKey &key) = 0; + virtual Result HasAll(sf::Out out, const sf::InArray &keys) = 0; + virtual Result GetSize(sf::Out out_size, const ContentMetaKey &key) = 0; + virtual Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) = 0; + virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) = 0; + virtual Result DisableForcibly() = 0; + virtual Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) = 0; + virtual Result Commit() = 0; + virtual Result HasContent(sf::Out out, const ContentMetaKey &key, const ContentId &content_id) = 0; + virtual Result ListContentMetaInfo(sf::Out out_entries_written, const sf::OutArray &out_meta_info, const ContentMetaKey &key, s32 offset) = 0; + virtual Result GetAttributes(sf::Out out_attributes, const ContentMetaKey &key) = 0; + virtual Result GetRequiredApplicationVersion(sf::Out out_version, const ContentMetaKey &key) = 0; + virtual Result GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) = 0; + virtual Result GetCount(sf::Out out_count) = 0; + virtual Result GetOwnerApplicationId(sf::Out out_id, const ContentMetaKey &key) = 0; }; + static_assert(ncm::IsIContentMetaDatabase); } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp index 7991eeb2b..3c094dba8 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp @@ -18,7 +18,7 @@ namespace ams::ncm { - class ContentStorageImplBase : public IContentStorage { + class ContentStorageImplBase { NON_COPYABLE(ContentStorageImplBase); NON_MOVEABLE(ContentStorageImplBase); protected: @@ -43,6 +43,39 @@ namespace ams::ncm { } return ResultSuccess(); } + public: + /* Actual commands. */ + virtual Result GeneratePlaceHolderId(sf::Out out) = 0; + virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) = 0; + virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) = 0; + virtual Result HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) = 0; + virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) = 0; + virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) = 0; + virtual Result Delete(ContentId content_id) = 0; + virtual Result Has(sf::Out out, ContentId content_id) = 0; + virtual Result GetPath(sf::Out out, ContentId content_id) = 0; + virtual Result GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) = 0; + virtual Result CleanupAllPlaceHolder() = 0; + virtual Result ListPlaceHolder(sf::Out out_count, const sf::OutArray &out_buf) = 0; + virtual Result GetContentCount(sf::Out out_count) = 0; + virtual Result ListContentId(sf::Out out_count, const sf::OutArray &out_buf, s32 start_offset) = 0; + virtual Result GetSizeFromContentId(sf::Out out_size, ContentId content_id) = 0; + virtual Result DisableForcibly() = 0; + virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) = 0; + virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) = 0; + virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) = 0; + virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) = 0; + virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) = 0; + virtual Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) = 0; + virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) = 0; + virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) = 0; + virtual Result GetFreeSpaceSize(sf::Out out_size) = 0; + virtual Result GetTotalSpaceSize(sf::Out out_size) = 0; + virtual Result FlushPlaceHolder() = 0; + virtual Result GetSizeFromPlaceHolderId(sf::Out out, PlaceHolderId placeholder_id) = 0; + virtual Result RepairInvalidFileAttribute() = 0; + virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) = 0; }; + static_assert(ncm::IsIContentStorage); } diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp index 5ff6ca8d5..59577f7ae 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp @@ -20,80 +20,81 @@ namespace ams::ncm { - class RemoteContentManagerImpl final : public IContentManager { + class RemoteContentManagerImpl final { public: RemoteContentManagerImpl() { /* ... */ } ~RemoteContentManagerImpl() { /* ... */ } public: - virtual Result CreateContentStorage(StorageId storage_id) override { + Result CreateContentStorage(StorageId storage_id) { return ::ncmCreateContentStorage(static_cast(storage_id)); } - virtual Result CreateContentMetaDatabase(StorageId storage_id) override { + Result CreateContentMetaDatabase(StorageId storage_id) { return ::ncmCreateContentMetaDatabase(static_cast(storage_id)); } - virtual Result VerifyContentStorage(StorageId storage_id) override { + Result VerifyContentStorage(StorageId storage_id) { return ::ncmVerifyContentStorage(static_cast(storage_id)); } - virtual Result VerifyContentMetaDatabase(StorageId storage_id) override { + Result VerifyContentMetaDatabase(StorageId storage_id) { return ::ncmVerifyContentMetaDatabase(static_cast(storage_id)); } - virtual Result OpenContentStorage(sf::Out> out, StorageId storage_id) override { + Result OpenContentStorage(sf::Out> out, StorageId storage_id) { NcmContentStorage cs; R_TRY(::ncmOpenContentStorage(std::addressof(cs), static_cast(storage_id))); - out.SetValue(std::make_shared(cs)); + out.SetValue(sf::MakeShared(cs)); return ResultSuccess(); } - virtual Result OpenContentMetaDatabase(sf::Out> out, StorageId storage_id) override { + Result OpenContentMetaDatabase(sf::Out> out, StorageId storage_id) { NcmContentMetaDatabase db; R_TRY(::ncmOpenContentMetaDatabase(std::addressof(db), static_cast(storage_id))); - out.SetValue(std::make_shared(db)); + out.SetValue(sf::MakeShared(db)); return ResultSuccess(); } - virtual Result CloseContentStorageForcibly(StorageId storage_id) override { + Result CloseContentStorageForcibly(StorageId storage_id) { return ::ncmCloseContentStorageForcibly(static_cast(storage_id)); } - virtual Result CloseContentMetaDatabaseForcibly(StorageId storage_id) override { + Result CloseContentMetaDatabaseForcibly(StorageId storage_id) { return ::ncmCloseContentMetaDatabaseForcibly(static_cast(storage_id)); } - virtual Result CleanupContentMetaDatabase(StorageId storage_id) override { + Result CleanupContentMetaDatabase(StorageId storage_id) { return ::ncmCleanupContentMetaDatabase(static_cast(storage_id)); } - virtual Result ActivateContentStorage(StorageId storage_id) override { + Result ActivateContentStorage(StorageId storage_id) { return ::ncmActivateContentStorage(static_cast(storage_id)); } - virtual Result InactivateContentStorage(StorageId storage_id) override { + Result InactivateContentStorage(StorageId storage_id) { return ::ncmInactivateContentStorage(static_cast(storage_id)); } - virtual Result ActivateContentMetaDatabase(StorageId storage_id) override { + Result ActivateContentMetaDatabase(StorageId storage_id) { return ::ncmActivateContentMetaDatabase(static_cast(storage_id)); } - virtual Result InactivateContentMetaDatabase(StorageId storage_id) override { + Result InactivateContentMetaDatabase(StorageId storage_id) { return ::ncmInactivateContentMetaDatabase(static_cast(storage_id)); } - virtual Result InvalidateRightsIdCache() override { + Result InvalidateRightsIdCache() { return ::ncmInvalidateRightsIdCache(); } - virtual Result GetMemoryReport(sf::Out out) override { + Result GetMemoryReport(sf::Out out) { /* TODO: libnx bindings */ AMS_ABORT(); } }; + static_assert(ncm::IsIContentManager); } diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp index 98fc25068..14935f465 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp @@ -18,7 +18,7 @@ namespace ams::ncm { - class RemoteContentMetaDatabaseImpl final : public IContentMetaDatabase { + class RemoteContentMetaDatabaseImpl final { private: ::NcmContentMetaDatabase srv; public: @@ -71,101 +71,101 @@ namespace ams::ncm { return reinterpret_cast(std::addressof(c)); } public: - virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) override { + Result Set(const ContentMetaKey &key, sf::InBuffer value) { return ncmContentMetaDatabaseSet(std::addressof(this->srv), Convert(key), value.GetPointer(), value.GetSize()); } - virtual Result Get(sf::Out out_size, const ContentMetaKey &key, sf::OutBuffer out_value) override { + Result Get(sf::Out out_size, const ContentMetaKey &key, sf::OutBuffer out_value) { return ncmContentMetaDatabaseGet(std::addressof(this->srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize()); } - virtual Result Remove(const ContentMetaKey &key) override { + Result Remove(const ContentMetaKey &key) { return ncmContentMetaDatabaseRemove(std::addressof(this->srv), Convert(key)); } - virtual Result GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) override { + Result GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) { return ncmContentMetaDatabaseGetContentIdByType(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type)); } - virtual Result ListContentInfo(sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) override { + Result ListContentInfo(sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) { return ncmContentMetaDatabaseListContentInfo(std::addressof(this->srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset); } - virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) override { + Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) { return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type)); } - virtual Result GetLatestContentMetaKey(sf::Out out_key, u64 id) override { + Result GetLatestContentMetaKey(sf::Out out_key, u64 id) { return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(this->srv), Convert(out_key.GetPointer()), static_cast(id)); } - virtual Result ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type) override { + Result ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type) { return ncmContentMetaDatabaseListApplication(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type)); } - virtual Result Has(sf::Out out, const ContentMetaKey &key) override { + Result Has(sf::Out out, const ContentMetaKey &key) { return ncmContentMetaDatabaseHas(std::addressof(this->srv), out.GetPointer(), Convert(key)); } - virtual Result HasAll(sf::Out out, const sf::InArray &keys) override { + Result HasAll(sf::Out out, const sf::InArray &keys) { return ncmContentMetaDatabaseHasAll(std::addressof(this->srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize()); } - virtual Result GetSize(sf::Out out_size, const ContentMetaKey &key) override { + Result GetSize(sf::Out out_size, const ContentMetaKey &key) { return ncmContentMetaDatabaseGetSize(std::addressof(this->srv), out_size.GetPointer(), Convert(key)); } - virtual Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) override { + Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) { return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key)); } - virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) override { + Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { return ncmContentMetaDatabaseGetPatchId(std::addressof(this->srv), reinterpret_cast(out_patch_id.GetPointer()), Convert(key)); } - virtual Result DisableForcibly() override { + Result DisableForcibly() { return ncmContentMetaDatabaseDisableForcibly(std::addressof(this->srv)); } - virtual Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) override { + Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) { return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(this->srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize())); } - virtual Result Commit() override { + Result Commit() { return ncmContentMetaDatabaseCommit(std::addressof(this->srv)); } - virtual Result HasContent(sf::Out out, const ContentMetaKey &key, const ContentId &content_id) override { + Result HasContent(sf::Out out, const ContentMetaKey &key, const ContentId &content_id) { return ncmContentMetaDatabaseHasContent(std::addressof(this->srv), out.GetPointer(), Convert(key), Convert(content_id)); } - virtual Result ListContentMetaInfo(sf::Out out_entries_written, const sf::OutArray &out_meta_info, const ContentMetaKey &key, s32 offset) override { + Result ListContentMetaInfo(sf::Out out_entries_written, const sf::OutArray &out_meta_info, const ContentMetaKey &key, s32 offset) { return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(this->srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset); } - virtual Result GetAttributes(sf::Out out_attributes, const ContentMetaKey &key) override { + Result GetAttributes(sf::Out out_attributes, const ContentMetaKey &key) { static_assert(sizeof(ContentMetaAttribute) == sizeof(u8)); return ncmContentMetaDatabaseGetAttributes(std::addressof(this->srv), Convert(key), out_attributes.GetPointer()); } - virtual Result GetRequiredApplicationVersion(sf::Out out_version, const ContentMetaKey &key) override { + Result GetRequiredApplicationVersion(sf::Out out_version, const ContentMetaKey &key) { return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key)); } - virtual Result GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) override { + Result GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset); } - virtual Result GetCount(sf::Out out_count) override { + Result GetCount(sf::Out out_count) { /* TODO: libnx bindings */ AMS_ABORT(); } - virtual Result GetOwnerApplicationId(sf::Out out_id, const ContentMetaKey &key) override { + Result GetOwnerApplicationId(sf::Out out_id, const ContentMetaKey &key) { /* TODO: libnx bindings */ AMS_ABORT(); } - }; + static_assert(ncm::IsIContentMetaDatabase); } diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp index a7db1d4d9..32465f563 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp @@ -18,7 +18,7 @@ namespace ams::ncm { - class RemoteContentStorageImpl final : public IContentStorage { + class RemoteContentStorageImpl final { private: ::NcmContentStorage srv; public: @@ -46,85 +46,85 @@ namespace ams::ncm { return reinterpret_cast<::NcmContentId *>(std::addressof(c)); } public: - virtual Result GeneratePlaceHolderId(sf::Out out) override { + Result GeneratePlaceHolderId(sf::Out out) { return ncmContentStorageGeneratePlaceHolderId(std::addressof(this->srv), Convert(out.GetPointer())); } - virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) override { + Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { static_assert(alignof(ContentId) < alignof(PlaceHolderId)); return ncmContentStorageCreatePlaceHolder(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id), size); } - virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) override { + Result DeletePlaceHolder(PlaceHolderId placeholder_id) { return ncmContentStorageDeletePlaceHolder(std::addressof(this->srv), Convert(placeholder_id)); } - virtual Result HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) override { + Result HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) { return ncmContentStorageHasPlaceHolder(std::addressof(this->srv), out.GetPointer(), Convert(placeholder_id)); } - virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) override { + Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) { return ncmContentStorageWritePlaceHolder(std::addressof(this->srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize()); } - virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) override { + Result Register(PlaceHolderId placeholder_id, ContentId content_id) { static_assert(alignof(ContentId) < alignof(PlaceHolderId)); return ncmContentStorageRegister(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id)); } - virtual Result Delete(ContentId content_id) override { + Result Delete(ContentId content_id) { return ncmContentStorageDelete(std::addressof(this->srv), Convert(content_id)); } - virtual Result Has(sf::Out out, ContentId content_id) override { + Result Has(sf::Out out, ContentId content_id) { return ncmContentStorageHas(std::addressof(this->srv), out.GetPointer(), Convert(content_id)); } - virtual Result GetPath(sf::Out out, ContentId content_id) override { + Result GetPath(sf::Out out, ContentId content_id) { return ncmContentStorageGetPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id)); } - virtual Result GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) override { + Result GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) { return ncmContentStorageGetPlaceHolderPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id)); } - virtual Result CleanupAllPlaceHolder() override { + Result CleanupAllPlaceHolder() { return ncmContentStorageCleanupAllPlaceHolder(std::addressof(this->srv)); } - virtual Result ListPlaceHolder(sf::Out out_count, const sf::OutArray &out_buf) override { + Result ListPlaceHolder(sf::Out out_count, const sf::OutArray &out_buf) { return ncmContentStorageListPlaceHolder(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer()); } - virtual Result GetContentCount(sf::Out out_count) override { + Result GetContentCount(sf::Out out_count) { return ncmContentStorageGetContentCount(std::addressof(this->srv), out_count.GetPointer()); } - virtual Result ListContentId(sf::Out out_count, const sf::OutArray &out_buf, s32 offset) override { + Result ListContentId(sf::Out out_count, const sf::OutArray &out_buf, s32 offset) { return ncmContentStorageListContentId(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset); } - virtual Result GetSizeFromContentId(sf::Out out_size, ContentId content_id) override { + Result GetSizeFromContentId(sf::Out out_size, ContentId content_id) { return ncmContentStorageGetSizeFromContentId(std::addressof(this->srv), out_size.GetPointer(), Convert(content_id)); } - virtual Result DisableForcibly() override { + Result DisableForcibly() { return ncmContentStorageDisableForcibly(std::addressof(this->srv)); } - virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) override { + Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) { return ncmContentStorageRevertToPlaceHolder(std::addressof(this->srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id)); } - virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) override { + Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { return ncmContentStorageSetPlaceHolderSize(std::addressof(this->srv), Convert(placeholder_id), size); } - virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) override { + Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) { return ncmContentStorageReadContentIdFile(std::addressof(this->srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset); } - virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) override { + Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { ::NcmRightsId rights_id; R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id))); @@ -133,7 +133,7 @@ namespace ams::ncm { return ResultSuccess(); } - virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) override { + Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) { ::NcmRightsId rights_id; R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id))); @@ -142,7 +142,7 @@ namespace ams::ncm { return ResultSuccess(); } - virtual Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) override { + Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { ::NcmRightsId rights_id; R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id))); @@ -151,7 +151,7 @@ namespace ams::ncm { return ResultSuccess(); } - virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) override { + Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) { ::NcmRightsId rights_id; R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id))); @@ -160,35 +160,36 @@ namespace ams::ncm { return ResultSuccess(); } - virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) override { + Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) { return ncmContentStorageWriteContentForDebug(std::addressof(this->srv), Convert(content_id), offset, data.GetPointer(), data.GetSize()); } - virtual Result GetFreeSpaceSize(sf::Out out_size) override { + Result GetFreeSpaceSize(sf::Out out_size) { return ncmContentStorageGetFreeSpaceSize(std::addressof(this->srv), out_size.GetPointer()); } - virtual Result GetTotalSpaceSize(sf::Out out_size) override { + Result GetTotalSpaceSize(sf::Out out_size) { return ncmContentStorageGetTotalSpaceSize(std::addressof(this->srv), out_size.GetPointer()); } - virtual Result FlushPlaceHolder() override { + Result FlushPlaceHolder() { return ncmContentStorageFlushPlaceHolder(std::addressof(this->srv)); } - virtual Result GetSizeFromPlaceHolderId(sf::Out out_size, PlaceHolderId placeholder_id) override { + Result GetSizeFromPlaceHolderId(sf::Out out_size, PlaceHolderId placeholder_id) { return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(this->srv), out_size.GetPointer(), Convert(placeholder_id)); } - virtual Result RepairInvalidFileAttribute() override { + Result RepairInvalidFileAttribute() { return ncmContentStorageRepairInvalidFileAttribute(std::addressof(this->srv)); } - virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) override { + Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId)); ::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer()); return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(this->srv), out, Convert(placeholder_id), Convert(cache_content_id)); } }; + static_assert(ncm::IsIContentStorage); } diff --git a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp index c7cf0d844..418ec6e99 100644 --- a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp +++ b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp @@ -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 out) override { + Result GetProcessEventInfo(ams::sf::Out out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); } }; + static_assert(pgl::sf::IsIEventObserver); } \ No newline at end of file diff --git a/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp b/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp index 66c2bc2d0..742292091 100644 --- a/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp +++ b/libraries/libstratosphere/source/pgl/pgl_shell_api.cpp @@ -79,7 +79,7 @@ namespace ams::pgl { ::PglEventObserver obs; R_TRY(::pglGetEventObserver(std::addressof(obs))); - auto remote_observer = std::make_shared(obs); + auto remote_observer = ams::sf::MakeShared(obs); AMS_ABORT_UNLESS(remote_observer != nullptr); *out = pgl::EventObserver(remote_observer); diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp index daaa1e0f5..5b7bacec9 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp @@ -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 out) { - return GetReference(this->observer).PopEventInfo(out.GetPointer()); + Result ShellEventObserver::GetProcessEventInfo(ams::sf::Out out) { + return this->PopEventInfo(out.GetPointer()); } -} \ No newline at end of file +} diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp index 29918a8c3..30387526b 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp @@ -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 out) override final; + Result GetProcessEventHandle(ams::sf::OutCopyHandle out); + Result GetProcessEventInfo(ams::sf::Out out); }; + static_assert(pgl::sf::IsIEventObserver); } diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp index 614488e25..81b2641d5 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_interface.cpp @@ -69,20 +69,22 @@ namespace ams::pgl::srv { } Result ShellInterface::GetShellEventObserver(ams::sf::Out> out) { + using Interface = typename pgl::sf::IEventObserver::ImplHolder; + /* 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(reinterpret_cast(observer_memory), [&](EventObserverInterface *obj) { + out.SetValue(std::shared_ptr(reinterpret_cast(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(); } diff --git a/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp b/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp index 146e5e47a..f9c10cc06 100644 --- a/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp +++ b/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp @@ -34,7 +34,7 @@ namespace ams::psc { ::PscPmModule module; R_TRY(::pscmGetPmModule(std::addressof(module), static_cast<::PscPmModuleId>(mid), reinterpret_cast(dependencies), dependency_count, clear_mode == os::EventClearMode_AutoClear)); - this->intf = std::make_shared(module); + this->intf = ams::sf::MakeShared(module); this->system_event.AttachReadableHandle(module.event.revent, false, clear_mode); this->initialized = true; return ResultSuccess(); diff --git a/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp b/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp index ff6451a62..6afc613fc 100644 --- a/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp +++ b/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp @@ -18,41 +18,42 @@ namespace ams::psc { - class RemotePmModule final : public psc::sf::IPmModule { + class RemotePmModule final { NON_COPYABLE(RemotePmModule); NON_MOVEABLE(RemotePmModule); private: ::PscPmModule module; public: constexpr RemotePmModule(const ::PscPmModule &m) : module(m) { /* ... */ } - virtual ~RemotePmModule() override { + ~RemotePmModule() { ::pscPmModuleClose(std::addressof(this->module)); } - virtual Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) override final { + Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) { /* NOTE: This functionality is already implemented by the libnx command we use to instantiate the PscPmModule. */ AMS_ABORT(); } - virtual Result GetRequest(ams::sf::Out out_state, ams::sf::Out out_flags) override final { + Result GetRequest(ams::sf::Out out_state, ams::sf::Out out_flags) { static_assert(sizeof(PmState) == sizeof(::PscPmState)); static_assert(sizeof(PmFlagSet) == sizeof(u32)); return ::pscPmModuleGetRequest(std::addressof(this->module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast(out_flags.GetPointer())); } - virtual Result Acknowledge() override final { + Result Acknowledge() { /* NOTE: libnx does not separate acknowledge/acknowledgeEx. */ return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(0)); } - virtual Result Finalize() override final { + Result Finalize() { return ::pscPmModuleFinalize(std::addressof(this->module)); } - virtual Result AcknowledgeEx(PmState state) override final { + Result AcknowledgeEx(PmState state) { static_assert(sizeof(state) == sizeof(::PscPmState)); return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(state)); } }; + static_assert(psc::sf::IsIPmModule); } \ No newline at end of file diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp index 29b3e5c56..ee6f9c18a 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp @@ -20,11 +20,13 @@ namespace ams::sf::hipc::impl { namespace { - class MitmQueryService : public IServiceObject { - private: - enum class CommandId { - ShouldMitm = 65000, - }; + #define AMS_SF_HIPC_IMPL_I_MITM_QUERY_SERVICE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 65000, void, ShouldMitm, (sf::Out out, const sm::MitmProcessInfo &client_info)) + + AMS_SF_DEFINE_INTERFACE(IMitmQueryService, AMS_SF_HIPC_IMPL_I_MITM_QUERY_SERVICE_INTERFACE_INFO) + + + class MitmQueryService { private: ServerManagerBase::MitmQueryFunction query_function; public: @@ -33,11 +35,8 @@ namespace ams::sf::hipc::impl { void ShouldMitm(sf::Out out, const sm::MitmProcessInfo &client_info) { out.SetValue(this->query_function(client_info)); } - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ShouldMitm), - }; }; + static_assert(IsIMitmQueryService); /* Globals. */ os::Mutex g_query_server_lock(false); @@ -66,7 +65,7 @@ namespace ams::sf::hipc::impl { g_constructed_server = true; } - R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(std::make_shared(query_func)))); + R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(sf::MakeShared(query_func)))); if (AMS_UNLIKELY(!g_registered_any)) { R_ABORT_UNLESS(os::CreateThread(std::addressof(g_query_server_process_thread), &QueryServerProcessThreadMain, GetPointer(g_query_server_storage), g_server_process_thread_stack, sizeof(g_server_process_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm_sf, QueryServerProcessThread))); diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp index 2177bd237..20578d12d 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp @@ -19,15 +19,16 @@ namespace ams::sf::hipc { namespace impl { - class HipcManager : public IServiceObject { - private: - enum class CommandId { - ConvertCurrentObjectToDomain = 0, - CopyFromCurrentDomain = 1, - CloneCurrentObject = 2, - QueryPointerBufferSize = 3, - CloneCurrentObjectEx = 4, - }; + #define AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, ConvertCurrentObjectToDomain, (ams::sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, CopyFromCurrentDomain, (ams::sf::OutMoveHandle out, ams::sf::cmif::DomainObjectId object_id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, CloneCurrentObject, (ams::sf::OutMoveHandle out)) \ + AMS_SF_METHOD_INFO(C, H, 3, void, QueryPointerBufferSize, (ams::sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, CloneCurrentObjectEx, (ams::sf::OutMoveHandle out, u32 tag)) + + AMS_SF_DEFINE_INTERFACE(IHipcManager, AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO) + + class HipcManager final { private: ServerDomainSessionManager *manager; ServerSession *session; @@ -150,16 +151,8 @@ namespace ams::sf::hipc { Result CloneCurrentObjectEx(sf::OutMoveHandle out, u32 tag) { return this->CloneCurrentObjectImpl(out.GetHandlePointer(), this->manager->GetSessionManagerByTag(tag)); } - - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ConvertCurrentObjectToDomain), - MAKE_SERVICE_COMMAND_META(CopyFromCurrentDomain), - MAKE_SERVICE_COMMAND_META(CloneCurrentObject), - MAKE_SERVICE_COMMAND_META(QueryPointerBufferSize), - MAKE_SERVICE_COMMAND_META(CloneCurrentObjectEx), - }; }; + static_assert(IsIHipcManager); } @@ -168,7 +161,7 @@ namespace ams::sf::hipc { /* Note: This is safe, as no additional references to the hipc manager can ever be stored. */ /* The shared pointer to stack object is definitely gross, though. */ impl::HipcManager hipc_manager(this, session); - return this->DispatchRequest(cmif::ServiceObjectHolder(std::move(ServiceObjectTraits::SharedPointerHelper::GetEmptyDeleteSharedPointer(&hipc_manager))), session, in_message, out_message); + return this->DispatchRequest(cmif::ServiceObjectHolder(sf::GetSharedPointerTo(hipc_manager)), session, in_message, out_message); } }