From c174d12216cc5cb569e368cddbb8f510d9a0980e Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 4 Jul 2020 18:44:14 -0700 Subject: [PATCH] sf: Begin experimenting with new interface declaration format --- .../erpt/sf/erpt_sf_i_attachment.hpp | 37 +-- .../erpt/sf/erpt_sf_i_context.hpp | 58 ++--- .../erpt/sf/erpt_sf_i_manager.hpp | 38 +-- .../stratosphere/erpt/sf/erpt_sf_i_report.hpp | 38 +-- .../erpt/sf/erpt_sf_i_session.hpp | 25 +- .../include/stratosphere/hos/hos_types.hpp | 2 - .../lr_i_add_on_content_location_resolver.hpp | 36 +-- .../lr/lr_i_location_resolver.hpp | 122 +++------ .../lr/lr_i_location_resolver_manager.hpp | 22 +- .../lr/lr_i_registered_location_resolver.hpp | 69 ++--- .../lr/lr_location_resolver_manager_impl.hpp | 18 +- .../ncm/ncm_content_manager_impl.hpp | 33 +-- .../ncm/ncm_i_content_manager.hpp | 72 ++---- .../ncm/ncm_i_content_meta_database.hpp | 105 ++------ .../ncm/ncm_i_content_storage.hpp | 137 +++------- .../pgl/sf/pgl_sf_i_event_observer.hpp | 21 +- .../pgl/sf/pgl_sf_i_shell_interface.hpp | 62 ++--- .../pgl/srv/pgl_srv_shell_interface.hpp | 27 +- .../psc/sf/psc_sf_i_pm_module.hpp | 33 +-- .../psc/sf/psc_sf_i_pm_service.hpp | 17 +- .../include/stratosphere/sf.hpp | 1 + .../sf/cmif/sf_cmif_service_dispatch.hpp | 2 +- .../sf/impl/sf_impl_command_serialization.hpp | 14 +- .../sf/impl/sf_impl_service_object_macros.hpp | 237 ++++++++++++++++++ .../stratosphere/sf/sf_service_object.hpp | 2 +- 25 files changed, 505 insertions(+), 723 deletions(-) create mode 100644 libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_service_object_macros.hpp diff --git a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_attachment.hpp b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_attachment.hpp index cf403c4b6..0d44e8929 100644 --- a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_attachment.hpp +++ b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_attachment.hpp @@ -19,33 +19,14 @@ namespace ams::erpt::sf { - class IAttachment : public ams::sf::IServiceObject { - protected: - enum class CommandId { - Open = 0, - Read = 1, - SetFlags = 2, - GetFlags = 3, - Close = 4, - GetSize = 5, - }; - public: - /* Actual commands. */ - virtual Result Open(const AttachmentId &attachment_id) = 0; - virtual Result Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) = 0; - virtual Result SetFlags(AttachmentFlagSet flags) = 0; - virtual Result GetFlags(ams::sf::Out out) = 0; - virtual Result Close() = 0; - virtual Result GetSize(ams::sf::Out out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(Open), - MAKE_SERVICE_COMMAND_META(Read), - MAKE_SERVICE_COMMAND_META(SetFlags), - MAKE_SERVICE_COMMAND_META(GetFlags), - MAKE_SERVICE_COMMAND_META(Close), - MAKE_SERVICE_COMMAND_META(GetSize), - }; - }; + #define AMS_ERPT_I_ATTACHMENT_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Open, (const AttachmentId &attachment_id)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, Read, (ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, SetFlags, (AttachmentFlagSet flags)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, GetFlags, (ams::sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, Close, ()) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, GetSize, (ams::sf::Out out)) + + AMS_SF_DEFINE_INTERFACE(IAttachment, AMS_ERPT_I_ATTACHMENT_INTERFACE_INFO) } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_context.hpp b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_context.hpp index 85d18ef44..47cc54018 100644 --- a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_context.hpp +++ b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_context.hpp @@ -22,48 +22,20 @@ namespace ams::erpt::sf { - class IContext : public ams::sf::IServiceObject { - protected: - enum class CommandId { - SubmitContext = 0, - CreateReport = 1, - SetInitialLaunchSettingsCompletionTime = 2, - ClearInitialLaunchSettingsCompletionTime = 3, - UpdatePowerOnTime = 4, - UpdateAwakeTime = 5, - SubmitMultipleCategoryContext = 6, - UpdateApplicationLaunchTime = 7, - ClearApplicationLaunchTime = 8, - SubmitAttachment = 9, - CreateReportWithAttachments = 10, - }; - public: - /* Actual commands. */ - virtual Result SubmitContext(const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer) = 0; - virtual Result CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &meta_buffer) = 0; - virtual Result SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point) = 0; - virtual Result ClearInitialLaunchSettingsCompletionTime() = 0; - virtual Result UpdatePowerOnTime() = 0; - virtual Result UpdateAwakeTime() = 0; - virtual Result SubmitMultipleCategoryContext(const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer) = 0; - virtual Result UpdateApplicationLaunchTime() = 0; - virtual Result ClearApplicationLaunchTime() = 0; - virtual Result SubmitAttachment(ams::sf::Out out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data) = 0; - virtual Result CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &attachment_ids_buffer) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(SubmitContext), - MAKE_SERVICE_COMMAND_META(CreateReport), - MAKE_SERVICE_COMMAND_META(SetInitialLaunchSettingsCompletionTime, hos::Version_3_0_0), - MAKE_SERVICE_COMMAND_META(ClearInitialLaunchSettingsCompletionTime, hos::Version_3_0_0), - MAKE_SERVICE_COMMAND_META(UpdatePowerOnTime, hos::Version_3_0_0), - MAKE_SERVICE_COMMAND_META(UpdateAwakeTime, hos::Version_3_0_0), - MAKE_SERVICE_COMMAND_META(SubmitMultipleCategoryContext, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(UpdateApplicationLaunchTime, hos::Version_6_0_0), - MAKE_SERVICE_COMMAND_META(ClearApplicationLaunchTime, hos::Version_6_0_0), - MAKE_SERVICE_COMMAND_META(SubmitAttachment, hos::Version_8_0_0), - MAKE_SERVICE_COMMAND_META(CreateReportWithAttachments, hos::Version_8_0_0), - }; - }; + #define AMS_ERPT_I_CONTEXT_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, SubmitContext, (const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, CreateReport, (ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &meta_buffer)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, SetInitialLaunchSettingsCompletionTime, (const time::SteadyClockTimePoint &time_point), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, ClearInitialLaunchSettingsCompletionTime, (), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, UpdatePowerOnTime, (), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, UpdateAwakeTime, (), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, SubmitMultipleCategoryContext, (const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, UpdateApplicationLaunchTime, (), hos::Version_6_0_0) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, ClearApplicationLaunchTime, (), hos::Version_6_0_0) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, SubmitAttachment, (ams::sf::Out out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data), hos::Version_8_0_0) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, CreateReportWithAttachments, (ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &str_buffer, const ams::sf::InBuffer &attachment_ids_buffer), hos::Version_8_0_0) + + + AMS_SF_DEFINE_INTERFACE(IContext, AMS_ERPT_I_CONTEXT_INTERFACE_INFO) } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp index 43329a6f5..01fe43534 100644 --- a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_manager.hpp @@ -19,33 +19,15 @@ namespace ams::erpt::sf { - class IManager : public ams::sf::IServiceObject { - protected: - enum class CommandId { - GetReportList = 0, - GetEvent = 1, - CleanupReports = 2, - DeleteReport = 3, - GetStorageUsageStatistics = 4, - GetAttachmentList = 5, - }; - public: - /* Actual commands. */ - virtual Result GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter) = 0; - virtual Result GetEvent(ams::sf::OutCopyHandle out) = 0; - virtual Result CleanupReports() = 0; - virtual Result DeleteReport(const ReportId &report_id) = 0; - virtual Result GetStorageUsageStatistics(ams::sf::Out out) = 0; - virtual Result GetAttachmentList(const ams::sf::OutBuffer &out_buf, const ReportId &report_id) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(GetReportList), - MAKE_SERVICE_COMMAND_META(GetEvent), - MAKE_SERVICE_COMMAND_META(CleanupReports, hos::Version_4_0_0), - MAKE_SERVICE_COMMAND_META(DeleteReport, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(GetStorageUsageStatistics, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(GetAttachmentList, hos::Version_8_0_0), - }; - }; + #define AMS_ERPT_I_MANAGER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetReportList, (const ams::sf::OutBuffer &out_list, ReportType type_filter)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, GetEvent, (ams::sf::OutCopyHandle out)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, CleanupReports, (), hos::Version_4_0_0) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, DeleteReport, (const ReportId &report_id), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, GetStorageUsageStatistics, (ams::sf::Out out), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, GetAttachmentList, (const ams::sf::OutBuffer &out_buf, const ReportId &report_id), hos::Version_8_0_0) + + + AMS_SF_DEFINE_INTERFACE(IManager, AMS_ERPT_I_MANAGER_INTERFACE_INFO) } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_report.hpp b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_report.hpp index cc053ad84..2d8171c97 100644 --- a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_report.hpp +++ b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_report.hpp @@ -19,33 +19,15 @@ namespace ams::erpt::sf { - class IReport : public ams::sf::IServiceObject { - protected: - enum class CommandId { - Open = 0, - Read = 1, - SetFlags = 2, - GetFlags = 3, - Close = 4, - GetSize = 5, - }; - public: - /* Actual commands. */ - virtual Result Open(const ReportId &report_id) = 0; - virtual Result Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) = 0; - virtual Result SetFlags(ReportFlagSet flags) = 0; - virtual Result GetFlags(ams::sf::Out out) = 0; - virtual Result Close() = 0; - virtual Result GetSize(ams::sf::Out out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(Open), - MAKE_SERVICE_COMMAND_META(Read), - MAKE_SERVICE_COMMAND_META(SetFlags), - MAKE_SERVICE_COMMAND_META(GetFlags), - MAKE_SERVICE_COMMAND_META(Close), - MAKE_SERVICE_COMMAND_META(GetSize), - }; - }; + #define AMS_ERPT_I_REPORT_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Open, (const ReportId &report_id)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, Read, (ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, SetFlags, (ReportFlagSet flags)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, GetFlags, (ams::sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, Close, ()) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, GetSize, (ams::sf::Out out)) + + + AMS_SF_DEFINE_INTERFACE(IReport, AMS_ERPT_I_REPORT_INTERFACE_INFO) } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_session.hpp b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_session.hpp index 739d0bde2..c61e22229 100644 --- a/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_session.hpp +++ b/libraries/libstratosphere/include/stratosphere/erpt/sf/erpt_sf_i_session.hpp @@ -22,24 +22,11 @@ namespace ams::erpt::sf { - class ISession : public ams::sf::IServiceObject { - protected: - enum class CommandId { - OpenReport = 0, - OpenManager = 1, - OpenAttachment = 2, - }; - public: - /* Actual commands. */ - virtual Result OpenReport(ams::sf::Out> out) = 0; - virtual Result OpenManager(ams::sf::Out> out) = 0; - virtual Result OpenAttachment(ams::sf::Out> out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(OpenReport), - MAKE_SERVICE_COMMAND_META(OpenManager), - MAKE_SERVICE_COMMAND_META(OpenAttachment, hos::Version_8_0_0), - }; - }; + #define AMS_ERPT_I_SESSION_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, OpenReport, (ams::sf::Out> out)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, OpenManager, (ams::sf::Out> out)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, OpenAttachment, (ams::sf::Out> out), hos::Version_8_0_0) + + AMS_SF_DEFINE_INTERFACE(ISession, AMS_ERPT_I_SESSION_INTERFACE_INFO) } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/hos/hos_types.hpp b/libraries/libstratosphere/include/stratosphere/hos/hos_types.hpp index b93c6e738..8a31591ae 100644 --- a/libraries/libstratosphere/include/stratosphere/hos/hos_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/hos/hos_types.hpp @@ -60,6 +60,4 @@ namespace ams::hos { Version_Max = ::ams::TargetFirmware_Max, }; - - } diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp index 70a8a58b8..64495307a 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp @@ -19,34 +19,14 @@ namespace ams::lr { - class IAddOnContentLocationResolver : public sf::IServiceObject { - protected: - enum class CommandId { - ResolveAddOnContentPath = 0, - RegisterAddOnContentStorageDeprecated = 1, - RegisterAddOnContentStorage = 1, - UnregisterAllAddOnContentPath = 2, - RefreshApplicationAddOnContent = 3, - UnregisterApplicationAddOnContent = 4, - }; - public: - /* Actual commands. */ - virtual Result ResolveAddOnContentPath(sf::Out out, ncm::DataId id) = 0; - virtual Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) = 0; - virtual Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) = 0; - virtual Result UnregisterAllAddOnContentPath() = 0; - virtual Result RefreshApplicationAddOnContent(const sf::InArray &ids) = 0; - virtual Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ResolveAddOnContentPath, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(RegisterAddOnContentStorageDeprecated, hos::Version_2_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RegisterAddOnContentStorage, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(UnregisterAllAddOnContentPath, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(RefreshApplicationAddOnContent, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(UnregisterApplicationAddOnContent, hos::Version_9_0_0), - }; - }; + #define AMS_LR_I_ADD_ON_CONTENT_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveAddOnContentPath, (sf::Out out, ncm::DataId id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterAddOnContentStorageDeprecated, (ncm::DataId id, ncm::StorageId storage_id), hos::Version_2_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterAddOnContentStorage, (ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, UnregisterAllAddOnContentPath, (), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, RefreshApplicationAddOnContent, (const sf::InArray &ids), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, UnregisterApplicationAddOnContent, (ncm::ApplicationId id), hos::Version_9_0_0) + AMS_SF_DEFINE_INTERFACE(IAddOnContentLocationResolver, AMS_LR_I_ADD_ON_CONTENT_LOCATION_RESOLVER_INTERFACE_INFO) } diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp index d9d8d9daf..29dec9f59 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp @@ -19,97 +19,35 @@ namespace ams::lr { - class ILocationResolver : public sf::IServiceObject { - NON_COPYABLE(ILocationResolver); - NON_MOVEABLE(ILocationResolver); - protected: - enum class CommandId { - ResolveProgramPath = 0, - RedirectProgramPath = 1, - ResolveApplicationControlPath = 2, - ResolveApplicationHtmlDocumentPath = 3, - ResolveDataPath = 4, - RedirectApplicationControlPathDeprecated = 5, - RedirectApplicationControlPath = 5, - RedirectApplicationHtmlDocumentPathDeprecated = 6, - RedirectApplicationHtmlDocumentPath = 6, - ResolveApplicationLegalInformationPath = 7, - RedirectApplicationLegalInformationPathDeprecated = 8, - RedirectApplicationLegalInformationPath = 8, - Refresh = 9, - RedirectApplicationProgramPathDeprecated = 10, - RedirectApplicationProgramPath = 10, - ClearApplicationRedirectionDeprecated = 11, - ClearApplicationRedirection = 11, - EraseProgramRedirection = 12, - EraseApplicationControlRedirection = 13, - EraseApplicationHtmlDocumentRedirection = 14, - EraseApplicationLegalInformationRedirection = 15, - ResolveProgramPathForDebug = 16, - RedirectProgramPathForDebug = 17, - RedirectApplicationProgramPathForDebugDeprecated = 18, - RedirectApplicationProgramPathForDebug = 18, - EraseProgramRedirectionForDebug = 19, - }; - public: - ILocationResolver() { /* ... */ } - public: - /* Actual commands. */ - virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) = 0; - virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) = 0; - virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result Refresh() = 0; - virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result ClearApplicationRedirectionDeprecated() = 0; - virtual Result ClearApplicationRedirection(const sf::InArray &excluding_ids) = 0; - virtual Result EraseProgramRedirection(ncm::ProgramId id) = 0; - virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) = 0; - virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) = 0; - virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) = 0; - virtual Result ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) = 0; - virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ResolveProgramPath), - MAKE_SERVICE_COMMAND_META(RedirectProgramPath), - MAKE_SERVICE_COMMAND_META(ResolveApplicationControlPath), - MAKE_SERVICE_COMMAND_META(ResolveApplicationHtmlDocumentPath), - MAKE_SERVICE_COMMAND_META(ResolveDataPath), - MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPathDeprecated, hos::Version_1_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RedirectApplicationControlPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPathDeprecated, hos::Version_1_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RedirectApplicationHtmlDocumentPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(ResolveApplicationLegalInformationPath), - MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPathDeprecated, hos::Version_1_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RedirectApplicationLegalInformationPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(Refresh), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathDeprecated, hos::Version_5_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(ClearApplicationRedirectionDeprecated, hos::Version_5_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(ClearApplicationRedirection, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(EraseProgramRedirection, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(EraseApplicationControlRedirection, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(EraseApplicationHtmlDocumentRedirection, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(EraseApplicationLegalInformationRedirection, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(ResolveProgramPathForDebug, hos::Version_7_0_0), - MAKE_SERVICE_COMMAND_META(RedirectProgramPathForDebug, hos::Version_7_0_0), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebugDeprecated, hos::Version_7_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RedirectApplicationProgramPathForDebug, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(EraseProgramRedirectionForDebug, hos::Version_7_0_0), - }; - }; + #define AMS_LR_I_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveProgramPath, (sf::Out out, ncm::ProgramId id)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, RedirectProgramPath, (const Path &path, ncm::ProgramId id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, ResolveApplicationControlPath, (sf::Out out, ncm::ProgramId id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, ResolveApplicationHtmlDocumentPath, (sf::Out out, ncm::ProgramId id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, ResolveDataPath, (sf::Out out, ncm::DataId id)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, RedirectApplicationControlPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, RedirectApplicationControlPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, RedirectApplicationHtmlDocumentPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, RedirectApplicationHtmlDocumentPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, ResolveApplicationLegalInformationPath, (sf::Out out, ncm::ProgramId id)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, RedirectApplicationLegalInformationPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, RedirectApplicationLegalInformationPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, Refresh, ()) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, RedirectApplicationProgramPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_5_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, RedirectApplicationProgramPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, ClearApplicationRedirectionDeprecated, (), hos::Version_5_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, ClearApplicationRedirection, (const sf::InArray &excluding_ids), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, EraseProgramRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 13, Result, EraseApplicationControlRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 14, Result, EraseApplicationHtmlDocumentRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 15, Result, EraseApplicationLegalInformationRedirection, (ncm::ProgramId id), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 16, Result, ResolveProgramPathForDebug, (sf::Out out, ncm::ProgramId id), hos::Version_7_0_0) \ + AMS_SF_METHOD_INFO(C, H, 17, Result, RedirectProgramPathForDebug, (const Path &path, ncm::ProgramId id), hos::Version_7_0_0) \ + AMS_SF_METHOD_INFO(C, H, 18, Result, RedirectApplicationProgramPathForDebugDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_7_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 18, Result, RedirectApplicationProgramPathForDebug, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, EraseProgramRedirectionForDebug, (ncm::ProgramId id), hos::Version_7_0_0) + + + AMS_SF_DEFINE_INTERFACE(ILocationResolver, AMS_LR_I_LOCATION_RESOLVER_INTERFACE_INFO) } diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver_manager.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver_manager.hpp index 5d9c55184..79cac08eb 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver_manager.hpp @@ -22,20 +22,12 @@ namespace ams::lr { - class ILocationResolverManager : public sf::IServiceObject { - protected: - enum class CommandId { - OpenLocationResolver = 0, - OpenRegisteredLocationResolver = 1, - RefreshLocationResolver = 2, - OpenAddOnContentLocationResolver = 3, - }; - public: - /* Actual commands. */ - virtual Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) = 0; - virtual Result OpenRegisteredLocationResolver(sf::Out> out) = 0; - virtual Result RefreshLocationResolver(ncm::StorageId storage_id) = 0; - virtual Result OpenAddOnContentLocationResolver(sf::Out> out) = 0; - }; + #define AMS_LR_I_LOCATION_RESOLVER_MANAGER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, OpenLocationResolver, (sf::Out> out, ncm::StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, OpenRegisteredLocationResolver, (sf::Out> out)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, RefreshLocationResolver, (ncm::StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, OpenAddOnContentLocationResolver, (sf::Out> out), hos::Version_2_0_0) + + AMS_SF_DEFINE_INTERFACE(ILocationResolverManager, AMS_LR_I_LOCATION_RESOLVER_MANAGER_INTERFACE_INFO) } diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_i_registered_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_i_registered_location_resolver.hpp index 837dfbc8b..d628c5a51 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_i_registered_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_i_registered_location_resolver.hpp @@ -19,57 +19,22 @@ namespace ams::lr { - class IRegisteredLocationResolver : public sf::IServiceObject { - protected: - enum class CommandId { - ResolveProgramPath = 0, - RegisterProgramPathDeprecated = 1, - RegisterProgramPath = 1, - UnregisterProgramPath = 2, - RedirectProgramPathDeprecated = 3, - RedirectProgramPath = 3, - ResolveHtmlDocumentPath = 4, - RegisterHtmlDocumentPathDeprecated = 5, - RegisterHtmlDocumentPath = 5, - UnregisterHtmlDocumentPath = 6, - RedirectHtmlDocumentPathDeprecated = 7, - RedirectHtmlDocumentPath = 7, - Refresh = 8, - RefreshExcluding = 9, - }; - public: - /* Actual commands. */ - virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result UnregisterProgramPath(ncm::ProgramId id) = 0; - virtual Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result ResolveHtmlDocumentPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result UnregisterHtmlDocumentPath(ncm::ProgramId id) = 0; - virtual Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) = 0; - virtual Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; - virtual Result Refresh() = 0; - virtual Result RefreshExcluding(const sf::InArray &ids) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ResolveProgramPath), - MAKE_SERVICE_COMMAND_META(RegisterProgramPathDeprecated, hos::Version_1_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RegisterProgramPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(UnregisterProgramPath), - MAKE_SERVICE_COMMAND_META(RedirectProgramPathDeprecated, hos::Version_1_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RedirectProgramPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(ResolveHtmlDocumentPath, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(RegisterHtmlDocumentPathDeprecated, hos::Version_2_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RegisterHtmlDocumentPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(UnregisterHtmlDocumentPath, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(RedirectHtmlDocumentPathDeprecated, hos::Version_2_0_0, hos::Version_8_1_0), - MAKE_SERVICE_COMMAND_META(RedirectHtmlDocumentPath, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(Refresh, hos::Version_7_0_0), - MAKE_SERVICE_COMMAND_META(RefreshExcluding, hos::Version_9_0_0), - }; - }; + #define AMS_LR_I_REGISTERED_LOCATION_RESOLVER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, ResolveProgramPath, (sf::Out out, ncm::ProgramId id)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterProgramPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterProgramPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, UnregisterProgramPath, (ncm::ProgramId id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, RedirectProgramPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_1_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, RedirectProgramPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, ResolveHtmlDocumentPath, (sf::Out out, ncm::ProgramId id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, RegisterHtmlDocumentPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_2_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, RegisterHtmlDocumentPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, UnregisterHtmlDocumentPath, (ncm::ProgramId id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, RedirectHtmlDocumentPathDeprecated, (const Path &path, ncm::ProgramId id), hos::Version_2_0_0, hos::Version_8_1_1) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, RedirectHtmlDocumentPath, (const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, Refresh, (), hos::Version_7_0_0) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, RefreshExcluding, (const sf::InArray &ids), hos::Version_9_0_0) + + AMS_SF_DEFINE_INTERFACE(IRegisteredLocationResolver, AMS_LR_I_REGISTERED_LOCATION_RESOLVER_INTERFACE_INFO) } diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp index 6711cab75..25e571883 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp @@ -21,7 +21,7 @@ namespace ams::lr { - class LocationResolverManagerImpl final : public ILocationResolverManager { + class LocationResolverManagerImpl final { private: /* Resolver storage. */ ncm::BoundedMap, 5> location_resolvers; @@ -31,17 +31,11 @@ namespace ams::lr { os::Mutex mutex{false}; public: /* Actual commands. */ - virtual Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) override; - virtual Result OpenRegisteredLocationResolver(sf::Out> out) override; - virtual Result RefreshLocationResolver(ncm::StorageId storage_id) override; - virtual Result OpenAddOnContentLocationResolver(sf::Out> out) override; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(OpenLocationResolver), - MAKE_SERVICE_COMMAND_META(OpenRegisteredLocationResolver), - MAKE_SERVICE_COMMAND_META(RefreshLocationResolver), - MAKE_SERVICE_COMMAND_META(OpenAddOnContentLocationResolver, hos::Version_2_0_0), - }; + Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id); + Result OpenRegisteredLocationResolver(sf::Out> out); + Result RefreshLocationResolver(ncm::StorageId storage_id); + Result OpenAddOnContentLocationResolver(sf::Out> out); }; + static_assert(IsILocationResolverManager); } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp index 244aa3ffb..ecff33061 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -67,7 +67,7 @@ namespace ams::ncm { }; static_assert(util::is_pod::value); - class ContentManagerImpl final : public IContentManager { + class ContentManagerImpl final { private: constexpr static size_t MaxContentStorageRoots = 8; constexpr static size_t MaxContentMetaDatabaseRoots = 8; @@ -131,21 +131,22 @@ namespace ams::ncm { Result EnsureAndMountSystemSaveData(const char *mount, const SystemSaveDataInfo &info) const; public: /* Actual commands. */ - virtual Result CreateContentStorage(StorageId storage_id) override; - virtual Result CreateContentMetaDatabase(StorageId storage_id) override; - virtual Result VerifyContentStorage(StorageId storage_id) override; - virtual Result VerifyContentMetaDatabase(StorageId storage_id) override; - virtual Result OpenContentStorage(sf::Out> out, StorageId storage_id) override; - virtual Result OpenContentMetaDatabase(sf::Out> out, StorageId storage_id) override; - virtual Result CloseContentStorageForcibly(StorageId storage_id) override; - virtual Result CloseContentMetaDatabaseForcibly(StorageId storage_id) override; - virtual Result CleanupContentMetaDatabase(StorageId storage_id) override; - virtual Result ActivateContentStorage(StorageId storage_id) override; - virtual Result InactivateContentStorage(StorageId storage_id) override; - virtual Result ActivateContentMetaDatabase(StorageId storage_id) override; - virtual Result InactivateContentMetaDatabase(StorageId storage_id) override; - virtual Result InvalidateRightsIdCache() override; - virtual Result GetMemoryReport(sf::Out out) override; + Result CreateContentStorage(StorageId storage_id); + Result CreateContentMetaDatabase(StorageId storage_id); + Result VerifyContentStorage(StorageId storage_id); + Result VerifyContentMetaDatabase(StorageId storage_id); + Result OpenContentStorage(sf::Out> out, StorageId storage_id); + Result OpenContentMetaDatabase(sf::Out> out, StorageId storage_id); + Result CloseContentStorageForcibly(StorageId storage_id); + Result CloseContentMetaDatabaseForcibly(StorageId storage_id); + Result CleanupContentMetaDatabase(StorageId storage_id); + Result ActivateContentStorage(StorageId storage_id); + Result InactivateContentStorage(StorageId storage_id); + Result ActivateContentMetaDatabase(StorageId storage_id); + Result InactivateContentMetaDatabase(StorageId storage_id); + Result InvalidateRightsIdCache(); + Result GetMemoryReport(sf::Out out); }; + static_assert(IsIContentManager); } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp index 1ddfd6aa3..c65867ab4 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp @@ -20,59 +20,23 @@ namespace ams::ncm { - class IContentManager : public sf::IServiceObject { - protected: - enum class CommandId { - CreateContentStorage = 0, - CreateContentMetaDatabase = 1, - VerifyContentStorage = 2, - VerifyContentMetaDatabase = 3, - OpenContentStorage = 4, - OpenContentMetaDatabase = 5, - CloseContentStorageForcibly = 6, - CloseContentMetaDatabaseForcibly = 7, - CleanupContentMetaDatabase = 8, - ActivateContentStorage = 9, - InactivateContentStorage = 10, - ActivateContentMetaDatabase = 11, - InactivateContentMetaDatabase = 12, - InvalidateRightsIdCache = 13, - GetMemoryReport = 14, - }; - public: - virtual Result CreateContentStorage(StorageId storage_id) = 0; - virtual Result CreateContentMetaDatabase(StorageId storage_id) = 0; - virtual Result VerifyContentStorage(StorageId storage_id) = 0; - virtual Result VerifyContentMetaDatabase(StorageId storage_id) = 0; - virtual Result OpenContentStorage(sf::Out> out, StorageId storage_id) = 0; - virtual Result OpenContentMetaDatabase(sf::Out> out, StorageId storage_id) = 0; - virtual Result CloseContentStorageForcibly(StorageId storage_id) = 0; - virtual Result CloseContentMetaDatabaseForcibly(StorageId storage_id) = 0; - virtual Result CleanupContentMetaDatabase(StorageId storage_id) = 0; - virtual Result ActivateContentStorage(StorageId storage_id) = 0; - virtual Result InactivateContentStorage(StorageId storage_id) = 0; - virtual Result ActivateContentMetaDatabase(StorageId storage_id) = 0; - virtual Result InactivateContentMetaDatabase(StorageId storage_id) = 0; - virtual Result InvalidateRightsIdCache() = 0; - virtual Result GetMemoryReport(sf::Out out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(CreateContentStorage), - MAKE_SERVICE_COMMAND_META(CreateContentMetaDatabase), - MAKE_SERVICE_COMMAND_META(VerifyContentStorage), - MAKE_SERVICE_COMMAND_META(VerifyContentMetaDatabase), - MAKE_SERVICE_COMMAND_META(OpenContentStorage), - MAKE_SERVICE_COMMAND_META(OpenContentMetaDatabase), - MAKE_SERVICE_COMMAND_META(CloseContentStorageForcibly, hos::Version_1_0_0, hos::Version_1_0_0), - MAKE_SERVICE_COMMAND_META(CloseContentMetaDatabaseForcibly, hos::Version_1_0_0, hos::Version_1_0_0), - MAKE_SERVICE_COMMAND_META(CleanupContentMetaDatabase), - MAKE_SERVICE_COMMAND_META(ActivateContentStorage, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(InactivateContentStorage, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(ActivateContentMetaDatabase, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(InactivateContentMetaDatabase, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(InvalidateRightsIdCache, hos::Version_9_0_0), - MAKE_SERVICE_COMMAND_META(GetMemoryReport, hos::Version_10_0_0), - }; - }; + #define AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, CreateContentStorage, (StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, CreateContentMetaDatabase, (StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, VerifyContentStorage, (StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, VerifyContentMetaDatabase, (StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, OpenContentStorage, (sf::Out> out, StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, OpenContentMetaDatabase, (sf::Out> out, StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, CloseContentStorageForcibly, (StorageId storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, CloseContentMetaDatabaseForcibly, (StorageId storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, CleanupContentMetaDatabase, (StorageId storage_id)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, ActivateContentStorage, (StorageId storage_id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, InactivateContentStorage, (StorageId storage_id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, ActivateContentMetaDatabase, (StorageId storage_id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, InactivateContentMetaDatabase, (StorageId storage_id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 13, Result, InvalidateRightsIdCache, (), hos::Version_9_0_0) \ + AMS_SF_METHOD_INFO(C, H, 14, Result, GetMemoryReport, (sf::Out out), hos::Version_10_0_0) + + AMS_SF_DEFINE_INTERFACE(IContentManager, AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO); } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp index 98b001c21..b7d81067b 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp @@ -19,84 +19,31 @@ namespace ams::ncm { - class IContentMetaDatabase : public sf::IServiceObject { - protected: - enum class CommandId { - Set = 0, - Get = 1, - Remove = 2, - GetContentIdByType = 3, - ListContentInfo = 4, - List = 5, - GetLatestContentMetaKey = 6, - ListApplication = 7, - Has = 8, - HasAll = 9, - GetSize = 10, - GetRequiredSystemVersion = 11, - GetPatchId = 12, - DisableForcibly = 13, - LookupOrphanContent = 14, - Commit = 15, - HasContent = 16, - ListContentMetaInfo = 17, - GetAttributes = 18, - GetRequiredApplicationVersion = 19, - GetContentIdByTypeAndIdOffset = 20, - GetCount = 21, - GetOwnerApplicationId = 22, - }; - 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; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(Set), - MAKE_SERVICE_COMMAND_META(Get), - MAKE_SERVICE_COMMAND_META(Remove), - MAKE_SERVICE_COMMAND_META(GetContentIdByType), - MAKE_SERVICE_COMMAND_META(ListContentInfo), - MAKE_SERVICE_COMMAND_META(List), - MAKE_SERVICE_COMMAND_META(GetLatestContentMetaKey), - MAKE_SERVICE_COMMAND_META(ListApplication), - MAKE_SERVICE_COMMAND_META(Has), - MAKE_SERVICE_COMMAND_META(HasAll), - MAKE_SERVICE_COMMAND_META(GetSize), - MAKE_SERVICE_COMMAND_META(GetRequiredSystemVersion), - MAKE_SERVICE_COMMAND_META(GetPatchId), - MAKE_SERVICE_COMMAND_META(DisableForcibly), - MAKE_SERVICE_COMMAND_META(LookupOrphanContent), - MAKE_SERVICE_COMMAND_META(Commit), - MAKE_SERVICE_COMMAND_META(HasContent), - MAKE_SERVICE_COMMAND_META(ListContentMetaInfo), - MAKE_SERVICE_COMMAND_META(GetAttributes), - MAKE_SERVICE_COMMAND_META(GetRequiredApplicationVersion, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(GetContentIdByTypeAndIdOffset, hos::Version_5_0_0), - MAKE_SERVICE_COMMAND_META(GetCount, hos::Version_10_0_0), - MAKE_SERVICE_COMMAND_META(GetOwnerApplicationId, hos::Version_10_0_0), - }; - }; + #define AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Set, (const ContentMetaKey &key, sf::InBuffer value)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, Get, (sf::Out out_size, const ContentMetaKey &key, sf::OutBuffer out_value)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, Remove, (const ContentMetaKey &key)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, GetContentIdByType, (sf::Out out_content_id, const ContentMetaKey &key, ContentType type)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, ListContentInfo, (sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset)) \ + AMS_SF_METHOD_INFO(C, H, 5, 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)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, GetLatestContentMetaKey, (sf::Out out_key, u64 id)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, ListApplication, (sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, Has, (sf::Out out, const ContentMetaKey &key)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, HasAll, (sf::Out out, const sf::InArray &keys)) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, GetSize, (sf::Out out_size, const ContentMetaKey &key)) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, GetRequiredSystemVersion, (sf::Out out_version, const ContentMetaKey &key)) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, GetPatchId, (sf::Out out_patch_id, const ContentMetaKey &key)) \ + AMS_SF_METHOD_INFO(C, H, 13, Result, DisableForcibly, ()) \ + AMS_SF_METHOD_INFO(C, H, 14, Result, LookupOrphanContent, (const sf::OutArray &out_orphaned, const sf::InArray &content_ids)) \ + AMS_SF_METHOD_INFO(C, H, 15, Result, Commit, ()) \ + AMS_SF_METHOD_INFO(C, H, 16, Result, HasContent, (sf::Out out, const ContentMetaKey &key, const ContentId &content_id)) \ + AMS_SF_METHOD_INFO(C, H, 17, Result, ListContentMetaInfo, (sf::Out out_entries_written, const sf::OutArray &out_meta_info, const ContentMetaKey &key, s32 offset)) \ + AMS_SF_METHOD_INFO(C, H, 18, Result, GetAttributes, (sf::Out out_attributes, const ContentMetaKey &key)) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, GetRequiredApplicationVersion, (sf::Out out_version, const ContentMetaKey &key), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, GetContentIdByTypeAndIdOffset, (sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset), hos::Version_5_0_0) \ + AMS_SF_METHOD_INFO(C, H, 21, Result, GetCount, (sf::Out out_count), hos::Version_10_0_0) \ + AMS_SF_METHOD_INFO(C, H, 22, Result, GetOwnerApplicationId, (sf::Out out_id, const ContentMetaKey &key), hos::Version_10_0_0) + + AMS_SF_DEFINE_INTERFACE(IContentMetaDatabase, AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO) } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp index abe070674..6ab43bb9e 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp @@ -22,109 +22,38 @@ namespace ams::ncm { - class IContentStorage : public sf::IServiceObject { - NON_COPYABLE(IContentStorage); - NON_MOVEABLE(IContentStorage); - protected: - enum class CommandId { - GeneratePlaceHolderId = 0, - CreatePlaceHolder = 1, - DeletePlaceHolder = 2, - HasPlaceHolder = 3, - WritePlaceHolder = 4, - Register = 5, - Delete = 6, - Has = 7, - GetPath = 8, - GetPlaceHolderPath = 9, - CleanupAllPlaceHolder = 10, - ListPlaceHolder = 11, - GetContentCount = 12, - ListContentId = 13, - GetSizeFromContentId = 14, - DisableForcibly = 15, - RevertToPlaceHolder = 16, - SetPlaceHolderSize = 17, - ReadContentIdFile = 18, - GetRightsIdFromPlaceHolderIdDeprecated = 19, - GetRightsIdFromPlaceHolderId = 19, - GetRightsIdFromContentIdDeprecated = 20, - GetRightsIdFromContentId = 20, - WriteContentForDebug = 21, - GetFreeSpaceSize = 22, - GetTotalSpaceSize = 23, - FlushPlaceHolder = 24, - GetSizeFromPlaceHolderId = 25, - RepairInvalidFileAttribute = 26, - GetRightsIdFromPlaceHolderIdWithCache = 27, - }; - public: - IContentStorage() { /* ... */ } - public: - 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; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(GeneratePlaceHolderId), - MAKE_SERVICE_COMMAND_META(CreatePlaceHolder), - MAKE_SERVICE_COMMAND_META(DeletePlaceHolder), - MAKE_SERVICE_COMMAND_META(HasPlaceHolder), - MAKE_SERVICE_COMMAND_META(WritePlaceHolder), - MAKE_SERVICE_COMMAND_META(Register), - MAKE_SERVICE_COMMAND_META(Delete), - MAKE_SERVICE_COMMAND_META(Has), - MAKE_SERVICE_COMMAND_META(GetPath), - MAKE_SERVICE_COMMAND_META(GetPlaceHolderPath), - MAKE_SERVICE_COMMAND_META(CleanupAllPlaceHolder), - MAKE_SERVICE_COMMAND_META(ListPlaceHolder), - MAKE_SERVICE_COMMAND_META(GeneratePlaceHolderId), - MAKE_SERVICE_COMMAND_META(GetContentCount), - MAKE_SERVICE_COMMAND_META(ListContentId), - MAKE_SERVICE_COMMAND_META(GetSizeFromContentId), - MAKE_SERVICE_COMMAND_META(DisableForcibly), - MAKE_SERVICE_COMMAND_META(RevertToPlaceHolder, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(SetPlaceHolderSize, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(ReadContentIdFile, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(GetRightsIdFromPlaceHolderIdDeprecated, hos::Version_2_0_0, hos::Version_2_3_0), - MAKE_SERVICE_COMMAND_META(GetRightsIdFromPlaceHolderId, hos::Version_3_0_0), - MAKE_SERVICE_COMMAND_META(GetRightsIdFromContentIdDeprecated, hos::Version_2_0_0, hos::Version_2_3_0), - MAKE_SERVICE_COMMAND_META(GetRightsIdFromContentId, hos::Version_3_0_0), - MAKE_SERVICE_COMMAND_META(WriteContentForDebug, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(GetFreeSpaceSize, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(GetTotalSpaceSize, hos::Version_2_0_0), - MAKE_SERVICE_COMMAND_META(FlushPlaceHolder, hos::Version_3_0_0), - MAKE_SERVICE_COMMAND_META(GetSizeFromPlaceHolderId, hos::Version_4_0_0), - MAKE_SERVICE_COMMAND_META(RepairInvalidFileAttribute, hos::Version_4_0_0), - MAKE_SERVICE_COMMAND_META(GetRightsIdFromPlaceHolderIdWithCache, hos::Version_8_0_0), - }; - }; + #define AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GeneratePlaceHolderId, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, CreatePlaceHolder, (PlaceHolderId placeholder_id, ContentId content_id, s64 size)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, DeletePlaceHolder, (PlaceHolderId placeholder_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, HasPlaceHolder, (sf::Out out, PlaceHolderId placeholder_id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, WritePlaceHolder, (PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, Register, (PlaceHolderId placeholder_id, ContentId content_id)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, Delete, (ContentId content_id)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, Has, (sf::Out out, ContentId content_id)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, GetPath, (sf::Out out, ContentId content_id)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, GetPlaceHolderPath, (sf::Out out, PlaceHolderId placeholder_id)) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, CleanupAllPlaceHolder, ()) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, ListPlaceHolder, (sf::Out out_count, const sf::OutArray &out_buf)) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, GetContentCount, (sf::Out out_count)) \ + AMS_SF_METHOD_INFO(C, H, 13, Result, ListContentId, (sf::Out out_count, const sf::OutArray &out_buf, s32 start_offset)) \ + AMS_SF_METHOD_INFO(C, H, 14, Result, GetSizeFromContentId, (sf::Out out_size, ContentId content_id)) \ + AMS_SF_METHOD_INFO(C, H, 15, Result, DisableForcibly, ()) \ + AMS_SF_METHOD_INFO(C, H, 16, Result, RevertToPlaceHolder, (PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 17, Result, SetPlaceHolderSize, (PlaceHolderId placeholder_id, s64 size), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 18, Result, ReadContentIdFile, (sf::OutBuffer buf, ContentId content_id, s64 offset), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated, (sf::Out out_rights_id, PlaceHolderId placeholder_id), hos::Version_2_0_0, hos::Version_2_3_0) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderId, (sf::Out out_rights_id, PlaceHolderId placeholder_id), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated, (sf::Out out_rights_id, ContentId content_id), hos::Version_2_0_0, hos::Version_2_3_0) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentId, (sf::Out out_rights_id, ContentId content_id), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 21, Result, WriteContentForDebug, (ContentId content_id, s64 offset, sf::InBuffer data), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 22, Result, GetFreeSpaceSize, (sf::Out out_size), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 23, Result, GetTotalSpaceSize, (sf::Out out_size), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 24, Result, FlushPlaceHolder, (), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 25, Result, GetSizeFromPlaceHolderId, (sf::Out out, PlaceHolderId placeholder_id), hos::Version_4_0_0) \ + AMS_SF_METHOD_INFO(C, H, 26, Result, RepairInvalidFileAttribute, (), hos::Version_4_0_0) \ + AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCache, (sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id), hos::Version_8_0_0) + + AMS_SF_DEFINE_INTERFACE(IContentStorage, AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO) } diff --git a/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp b/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp index d3e147e9c..d212ab30f 100644 --- a/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp +++ b/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp @@ -22,21 +22,10 @@ namespace ams::pgl::sf { - class IEventObserver : public ams::sf::IServiceObject { - protected: - enum class CommandId { - GetProcessEventHandle = 0, - GetProcessEventInfo = 1, - }; - public: - /* Actual commands. */ - virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) = 0; - virtual Result GetProcessEventInfo(ams::sf::Out out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(GetProcessEventHandle), - MAKE_SERVICE_COMMAND_META(GetProcessEventInfo), - }; - }; + #define AMS_PGL_I_EVENT_OBSERVER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessEventHandle, (ams::sf::OutCopyHandle out)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, GetProcessEventInfo, (ams::sf::Out out)) + + AMS_SF_DEFINE_INTERFACE(IEventObserver, AMS_PGL_I_EVENT_OBSERVER_INTERFACE_INFO); } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_shell_interface.hpp b/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_shell_interface.hpp index c44d72924..9046b2ef2 100644 --- a/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_shell_interface.hpp +++ b/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_shell_interface.hpp @@ -23,52 +23,22 @@ namespace ams::pgl::sf { - class IShellInterface : public ams::sf::IServiceObject { - protected: - enum class CommandId { - LaunchProgram = 0, - TerminateProcess = 1, - LaunchProgramFromHost = 2, - GetHostContentMetaInfo = 4, - GetApplicationProcessId = 5, - BoostSystemMemoryResourceLimit = 6, - IsProcessTracked = 7, - EnableApplicationCrashReport = 8, - IsApplicationCrashReportEnabled = 9, - EnableApplicationAllThreadDumpOnCrash = 10, - TriggerApplicationSnapShotDumper = 12, - GetShellEventObserver = 20, - }; - public: - /* Actual commands. */ - virtual Result LaunchProgram(ams::sf::Out out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags) = 0; - virtual Result TerminateProcess(os::ProcessId process_id) = 0; - virtual Result LaunchProgramFromHost(ams::sf::Out out, const ams::sf::InBuffer &content_path, u32 pm_flags) = 0; - virtual Result GetHostContentMetaInfo(ams::sf::Out out, const ams::sf::InBuffer &content_path) = 0; - virtual Result GetApplicationProcessId(ams::sf::Out out) = 0; - virtual Result BoostSystemMemoryResourceLimit(u64 size) = 0; - virtual Result IsProcessTracked(ams::sf::Out out, os::ProcessId process_id) = 0; - virtual Result EnableApplicationCrashReport(bool enabled) = 0; - virtual Result IsApplicationCrashReportEnabled(ams::sf::Out out) = 0; - virtual Result EnableApplicationAllThreadDumpOnCrash(bool enabled) = 0; - virtual Result TriggerApplicationSnapShotDumper(SnapShotDumpType dump_type, const ams::sf::InBuffer &arg) = 0; + #define AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (ams::sf::Out out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, LaunchProgramFromHost, (ams::sf::Out out, const ams::sf::InBuffer &content_path, u32 pm_flags)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, GetHostContentMetaInfo, (ams::sf::Out out, const ams::sf::InBuffer &content_path)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (ams::sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, BoostSystemMemoryResourceLimit, (u64 size)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, IsProcessTracked, (ams::sf::Out out, os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, EnableApplicationCrashReport, (bool enabled)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, IsApplicationCrashReportEnabled, (ams::sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, EnableApplicationAllThreadDumpOnCrash, (bool enabled)) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, TriggerApplicationSnapShotDumper, (SnapShotDumpType dump_type, const ams::sf::InBuffer &arg)) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, GetShellEventObserver, (ams::sf::Out> out)) + + AMS_SF_DEFINE_INTERFACE(IShellInterface, AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO); + - virtual Result GetShellEventObserver(ams::sf::Out> out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(LaunchProgram), - MAKE_SERVICE_COMMAND_META(TerminateProcess), - MAKE_SERVICE_COMMAND_META(LaunchProgramFromHost), - MAKE_SERVICE_COMMAND_META(GetHostContentMetaInfo), - MAKE_SERVICE_COMMAND_META(GetApplicationProcessId), - MAKE_SERVICE_COMMAND_META(BoostSystemMemoryResourceLimit), - MAKE_SERVICE_COMMAND_META(IsProcessTracked), - MAKE_SERVICE_COMMAND_META(EnableApplicationCrashReport), - MAKE_SERVICE_COMMAND_META(IsApplicationCrashReportEnabled), - MAKE_SERVICE_COMMAND_META(EnableApplicationAllThreadDumpOnCrash), - MAKE_SERVICE_COMMAND_META(TriggerApplicationSnapShotDumper), - MAKE_SERVICE_COMMAND_META(GetShellEventObserver), - }; - }; } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/pgl/srv/pgl_srv_shell_interface.hpp b/libraries/libstratosphere/include/stratosphere/pgl/srv/pgl_srv_shell_interface.hpp index 40f74f3ba..3487c550b 100644 --- a/libraries/libstratosphere/include/stratosphere/pgl/srv/pgl_srv_shell_interface.hpp +++ b/libraries/libstratosphere/include/stratosphere/pgl/srv/pgl_srv_shell_interface.hpp @@ -20,7 +20,7 @@ namespace ams::pgl::srv { - class ShellInterface final : public pgl::sf::IShellInterface { + class ShellInterface final { NON_COPYABLE(ShellInterface); NON_MOVEABLE(ShellInterface); private: @@ -34,19 +34,20 @@ namespace ams::pgl::srv { } public: /* Interface commands. */ - virtual Result LaunchProgram(ams::sf::Out out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags) override final; - virtual Result TerminateProcess(os::ProcessId process_id) override final; - virtual Result LaunchProgramFromHost(ams::sf::Out out, const ams::sf::InBuffer &content_path, u32 pm_flags) override final; - virtual Result GetHostContentMetaInfo(ams::sf::Out out, const ams::sf::InBuffer &content_path) override final; - virtual Result GetApplicationProcessId(ams::sf::Out out) override final; - virtual Result BoostSystemMemoryResourceLimit(u64 size) override final; - virtual Result IsProcessTracked(ams::sf::Out out, os::ProcessId process_id) override final; - virtual Result EnableApplicationCrashReport(bool enabled) override final; - virtual Result IsApplicationCrashReportEnabled(ams::sf::Out out) override final; - virtual Result EnableApplicationAllThreadDumpOnCrash(bool enabled) override final; - virtual Result TriggerApplicationSnapShotDumper(SnapShotDumpType dump_type, const ams::sf::InBuffer &arg) override final; + Result LaunchProgram(ams::sf::Out out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags); + Result TerminateProcess(os::ProcessId process_id); + Result LaunchProgramFromHost(ams::sf::Out out, const ams::sf::InBuffer &content_path, u32 pm_flags); + Result GetHostContentMetaInfo(ams::sf::Out out, const ams::sf::InBuffer &content_path); + Result GetApplicationProcessId(ams::sf::Out out); + Result BoostSystemMemoryResourceLimit(u64 size); + Result IsProcessTracked(ams::sf::Out out, os::ProcessId process_id); + Result EnableApplicationCrashReport(bool enabled); + Result IsApplicationCrashReportEnabled(ams::sf::Out out); + Result EnableApplicationAllThreadDumpOnCrash(bool enabled); + Result TriggerApplicationSnapShotDumper(SnapShotDumpType dump_type, const ams::sf::InBuffer &arg); - virtual Result GetShellEventObserver(ams::sf::Out> out) override final; + Result GetShellEventObserver(ams::sf::Out> out); }; + static_assert(pgl::sf::IsIShellInterface); } diff --git a/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_module.hpp b/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_module.hpp index 5673bd4ab..42fd75d3d 100644 --- a/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_module.hpp +++ b/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_module.hpp @@ -21,30 +21,13 @@ namespace ams::psc::sf { - class IPmModule : public ams::sf::IServiceObject { - protected: - enum class CommandId { - Initialize = 0, - GetRequest = 1, - Acknowledge = 2, - Finalize = 3, - AcknowledgeEx = 4, - }; - public: - /* Actual commands. */ - virtual Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) = 0; - virtual Result GetRequest(ams::sf::Out out_state, ams::sf::Out out_flags) = 0; - virtual Result Acknowledge() = 0; - virtual Result Finalize() = 0; - virtual Result AcknowledgeEx(PmState state) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(Initialize), - MAKE_SERVICE_COMMAND_META(GetRequest), - MAKE_SERVICE_COMMAND_META(Acknowledge), - MAKE_SERVICE_COMMAND_META(Finalize), - MAKE_SERVICE_COMMAND_META(AcknowledgeEx, hos::Version_5_1_0), - }; - }; + #define AMS_PSC_I_PM_MODULE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, GetRequest, (ams::sf::Out out_state, ams::sf::Out out_flags)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, Acknowledge, ()) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, Finalize, ()) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, AcknowledgeEx, (PmState state), hos::Version_5_1_0) + + AMS_SF_DEFINE_INTERFACE(IPmModule, AMS_PSC_I_PM_MODULE_INTERFACE_INFO) } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_service.hpp b/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_service.hpp index f4bf8cc8b..f4dffbeb0 100644 --- a/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_service.hpp +++ b/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_service.hpp @@ -20,18 +20,9 @@ namespace ams::psc::sf { - class IPmService : public ams::sf::IServiceObject { - protected: - enum class CommandId { - Initialize = 0, - }; - public: - /* Actual commands. */ - virtual Result Initialize(ams::sf::Out> out) = 0; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(Initialize), - }; - }; + #define AMS_PSC_I_PM_SERVICE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::Out> out)) + + AMS_SF_DEFINE_INTERFACE(IPmService, AMS_PSC_I_PM_SERVICE_INTERFACE_INFO) } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/sf.hpp b/libraries/libstratosphere/include/stratosphere/sf.hpp index 333391f71..77568edf1 100644 --- a/libraries/libstratosphere/include/stratosphere/sf.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include 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 cca03664c..067dd03a4 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 @@ -114,7 +114,7 @@ namespace ams::sf::cmif { explicit constexpr ServiceDispatchTable(Entries... entries) : impl::ServiceDispatchTableImpl(entries...) { /* ... */ } }; - #define DEFINE_SERVICE_DISPATCH_TABLE \ + #define AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE \ template \ static constexpr inline ::ams::sf::cmif::ServiceDispatchTable s_CmifServiceDispatchTable diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index 2247d6de5..f68bd05e7 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -1148,18 +1148,16 @@ namespace ams::sf::impl { } -namespace ams::sf { +namespace ams::sf::impl { - template - inline static constexpr cmif::ServiceCommandMeta MakeServiceCommandMeta() { + template + consteval inline cmif::ServiceCommandMeta MakeServiceCommandMeta() { return { - .hosver_low = Low, + .hosver_low = Low, .hosver_high = High, - .cmd_id = static_cast(CommandId), - .handler = ::ams::sf::impl::InvokeServiceCommandImpl, + .cmd_id = static_cast(CommandId), + .handler = ::ams::sf::impl::InvokeServiceCommandImpl, }; } } - -#define MAKE_SERVICE_COMMAND_META(Name, ...) ::ams::sf::MakeServiceCommandMeta() 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 new file mode 100644 index 000000000..1193062f1 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_service_object_macros.hpp @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include + +namespace ams::sf::impl { + + template + concept ServiceCommandResult = std::same_as<::ams::Result, T> || std::same_as; + + template + concept Invokable = requires (Arguments &&... args) { + { F(std::forward(args)...) }; + }; + + struct FunctionTraits { + public: + template + static std::tuple GetArgsImpl(R(A...)); + }; + + template + using FunctionArgsType = decltype(FunctionTraits::GetArgsImpl(F)); + + template + struct ClassFunctionPointerHelper; + + template + struct ClassFunctionPointerHelper> { + using Type = Return (*)(Class *, Arguments &&...); + }; + + template + using ClassFunctionPointer = typename ClassFunctionPointerHelper::Type; + + template + struct TypeTag{}; + + #define AMS_SF_IMPL_HELPER_FUNCTION_NAME_IMPL(CLASSNAME, FUNCNAME, SUFFIX) \ + __ams_sf_impl_helper_##CLASSNAME##_##FUNCNAME##_##SUFFIX + + #define AMS_SF_IMPL_HELPER_FUNCTION_NAME(CLASSNAME, FUNCNAME) \ + AMS_SF_IMPL_HELPER_FUNCTION_NAME_IMPL(CLASSNAME, FUNCNAME, intf) + + #define AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, FUNCNAME) \ + ::ams::sf::impl::FunctionArgsType + + #define AMS_SF_IMPL_CONCEPT_HELPER_FUNCTION_NAME(CLASSNAME, FUNCNAME) \ + AMS_SF_IMPL_HELPER_FUNCTION_NAME_IMPL(CLASSNAME, FUNCNAME, intf_for_concept) + + #define AMS_SF_IMPL_DECLARE_HELPER_FUNCTIONS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + static void AMS_SF_IMPL_HELPER_FUNCTION_NAME(CLASSNAME, NAME) ARGS { __builtin_unreachable(); } \ + template \ + requires std::same_as, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \ + static auto AMS_SF_IMPL_CONCEPT_HELPER_FUNCTION_NAME(CLASSNAME, NAME) (T &t, std::tuple a) { \ + return [&](std::index_sequence) { \ + return t.NAME(std::forward::type>(std::get(a))...); \ + }(std::make_index_sequence()); \ + } + + #define AMS_SF_IMPL_DECLARE_HELPERS(CLASSNAME, CMD_MACRO) \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_HELPER_FUNCTIONS) + + #define AMS_SF_IMPL_DECLARE_CONCEPT_REQUIREMENT(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + { AMS_SF_IMPL_CONCEPT_HELPER_FUNCTION_NAME(CLASSNAME, NAME) (impl, std::declval()) } -> ::ams::sf::impl::ServiceCommandResult; + + #define AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \ + template \ + concept Is##CLASSNAME = requires (Impl &impl) { \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_CONCEPT_REQUIREMENT) \ + }; + + #define AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + ::ams::sf::impl::ClassFunctionPointer + + #define AMS_SF_IMPL_DECLARE_FUNCTION_POINTER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) NAME; + + #define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + template \ + requires (::ams::sf::impl::Invokable && \ + std::same_as, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>) \ + RETURN NAME (Arguments &&... args) { \ + return this->cmd_table->NAME(this, std::forward(args)...); \ + } \ + template \ + requires (::ams::sf::impl::Invokable && \ + !std::same_as, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)>) \ + ALWAYS_INLINE RETURN NAME (Arguments &&... args) { \ + return [this] ALWAYS_INLINE_LAMBDA (::ams::sf::impl::TypeTag>, PassedArguments &&...args_) -> RETURN { \ + return this->template NAME(std::forward(args_)...); \ + }(::ams::sf::impl::TypeTag{}, std::forward(args)...); \ + } + + #define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + template \ + requires std::same_as, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \ + static RETURN NAME##Invoker (CLASSNAME *_this, Arguments &&... args) { \ + return static_cast(_this)->NAME(std::forward(args)...); \ + } + + #define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL(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_as()...))>) \ + 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); \ + }; + + #define AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + template struct NAME##ServiceCommandMetaHolder; \ + \ + template \ + requires std::same_as, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \ + struct NAME##ServiceCommandMetaHolder> { \ + static constexpr auto Value = ::ams::sf::impl::MakeServiceCommandMeta>(); \ + }; + + #define AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + .NAME = NAME##FunctionPointerHolder::Value, + + #define AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + NAME##ServiceCommandMetaHolder::Value, + + #define AMS_SF_IMPL_DEFINE_CLASS(BASECLASS, CLASSNAME, CMD_MACRO) \ + class CLASSNAME : public BASECLASS { \ + NON_COPYABLE(CLASSNAME); \ + NON_MOVEABLE(CLASSNAME); \ + private: \ + struct CommandPointerTable { \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_FUNCTION_POINTER) \ + }; \ + private: \ + const CommandPointerTable * const cmd_table; \ + private: \ + CLASSNAME() = delete; \ + protected: \ + constexpr CLASSNAME(const CommandPointerTable *ct) \ + : cmd_table(ct) { /* ... */ } \ + virtual ~CLASSNAME() { /* ... */ } \ + public: \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION) \ + private: \ + template requires (std::same_as && !std::same_as&& Is##CLASSNAME) \ + struct ImplGenerator { \ + public: \ + class ImplHolder : public S { \ + private: \ + T impl; \ + public: \ + template requires std::constructible_from \ + constexpr ImplHolder(Args &&... args) \ + : S(std::addressof(CommandPointerTableImpl)), impl(std::forward(args)...) \ + { \ + /* ... */ \ + } \ + private: \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \ + public: \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL) \ + 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) \ + public: \ + template requires (!std::same_as&& Is##CLASSNAME) \ + using Impl = typename ImplGenerator::ImplHolder; \ + \ + AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE { \ + CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY) \ + }; \ + }; + + #define AMS_SF_METHOD_INFO_6(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS) \ + HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, hos::Version_Min, hos::Version_Max) + + #define AMS_SF_METHOD_INFO_7(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN) \ + HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, hos::Version_Max) + + #define AMS_SF_METHOD_INFO_8(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) + + #define AMS_SF_METHOD_INFO_X(_, _0, _1, _2, _3, _4, _5, _6, _7, FUNC, ...) FUNC + + #define AMS_SF_METHOD_INFO(...) \ + AMS_SF_METHOD_INFO_X(, ## __VA_ARGS__, AMS_SF_METHOD_INFO_8(__VA_ARGS__), AMS_SF_METHOD_INFO_7(__VA_ARGS__), AMS_SF_METHOD_INFO_6(__VA_ARGS__)) + + #define AMS_SF_DEFINE_INTERFACE(CLASSNAME, CMD_MACRO) \ + AMS_SF_IMPL_DECLARE_HELPERS(CLASSNAME,CMD_MACRO) \ + AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \ + AMS_SF_IMPL_DEFINE_CLASS( ::ams::sf::IServiceObject, CLASSNAME, CMD_MACRO) \ + static_assert(Is##CLASSNAME); + + #define AMS_SF_DEFINE_MITM_INTERFACE(CLASSNAME, CMD_MACRO) \ + AMS_SF_IMPL_DECLARE_HELPERS(CLASSNAME,CMD_MACRO) \ + AMS_SF_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \ + AMS_SF_IMPL_DEFINE_CLASS(::ams::sf::IMitmServiceObject, CLASSNAME, CMD_MACRO) \ + static_assert(Is##CLASSNAME); + + #define AMS_SF_IMPL_DECLARE_INTERFACE_METHODS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \ + RETURN NAME ARGS; + + #define AMS_SF_DECLARE_INTERFACE_METHODS(CMD_MACRO) \ + CMD_MACRO(_, AMS_SF_IMPL_DECLARE_INTERFACE_METHODS) + +} \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp index 70b93ec6f..866375684 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp @@ -38,7 +38,7 @@ namespace ams::sf { }; /* Utility. */ - #define SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : ::ams::sf::IMitmServiceObject(std::forward>(s), c) + #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 {