From 1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 26 Nov 2020 15:19:08 -0500 Subject: service: Eliminate usages of the global system instance Completely removes all usages of the global system instance within the services code by passing in the using system instance to the services. --- src/core/hle/service/ns/ns.cpp | 45 ++++++++++++++++++++++------------------ src/core/hle/service/ns/ns.h | 20 +++++++----------- src/core/hle/service/ns/pl_u.cpp | 4 ++-- src/core/hle/service/ns/pl_u.h | 3 +-- 4 files changed, 36 insertions(+), 36 deletions(-) (limited to 'src/core/hle/service/ns') diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 2594e6839..ef7584641 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp @@ -18,7 +18,8 @@ namespace Service::NS { -IAccountProxyInterface::IAccountProxyInterface() : ServiceFramework{"IAccountProxyInterface"} { +IAccountProxyInterface::IAccountProxyInterface(Core::System& system_) + : ServiceFramework{system_, "IAccountProxyInterface"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "CreateUserAccount"}, @@ -31,7 +32,7 @@ IAccountProxyInterface::IAccountProxyInterface() : ServiceFramework{"IAccountPro IAccountProxyInterface::~IAccountProxyInterface() = default; IApplicationManagerInterface::IApplicationManagerInterface(Core::System& system_) - : ServiceFramework{"IApplicationManagerInterface"}, system{system_} { + : ServiceFramework{system_, "IApplicationManagerInterface"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "ListApplicationRecord"}, @@ -428,8 +429,8 @@ ResultVal IApplicationManagerInterface::ConvertApplicationLanguageToLanguag return MakeResult(static_cast(*language_code)); } -IApplicationVersionInterface::IApplicationVersionInterface() - : ServiceFramework{"IApplicationVersionInterface"} { +IApplicationVersionInterface::IApplicationVersionInterface(Core::System& system_) + : ServiceFramework{system_, "IApplicationVersionInterface"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetLaunchRequiredVersion"}, @@ -449,8 +450,8 @@ IApplicationVersionInterface::IApplicationVersionInterface() IApplicationVersionInterface::~IApplicationVersionInterface() = default; -IContentManagementInterface::IContentManagementInterface() - : ServiceFramework{"IContentManagementInterface"} { +IContentManagementInterface::IContentManagementInterface(Core::System& system_) + : ServiceFramework{system_, "IContentManagementInterface"} { // clang-format off static const FunctionInfo functions[] = { {11, nullptr, "CalculateApplicationOccupiedSize"}, @@ -469,7 +470,8 @@ IContentManagementInterface::IContentManagementInterface() IContentManagementInterface::~IContentManagementInterface() = default; -IDocumentInterface::IDocumentInterface() : ServiceFramework{"IDocumentInterface"} { +IDocumentInterface::IDocumentInterface(Core::System& system_) + : ServiceFramework{system_, "IDocumentInterface"} { // clang-format off static const FunctionInfo functions[] = { {21, nullptr, "GetApplicationContentPath"}, @@ -483,7 +485,8 @@ IDocumentInterface::IDocumentInterface() : ServiceFramework{"IDocumentInterface" IDocumentInterface::~IDocumentInterface() = default; -IDownloadTaskInterface::IDownloadTaskInterface() : ServiceFramework{"IDownloadTaskInterface"} { +IDownloadTaskInterface::IDownloadTaskInterface(Core::System& system_) + : ServiceFramework{system_, "IDownloadTaskInterface"} { // clang-format off static const FunctionInfo functions[] = { {701, nullptr, "ClearTaskStatusList"}, @@ -503,7 +506,8 @@ IDownloadTaskInterface::IDownloadTaskInterface() : ServiceFramework{"IDownloadTa IDownloadTaskInterface::~IDownloadTaskInterface() = default; -IECommerceInterface::IECommerceInterface() : ServiceFramework{"IECommerceInterface"} { +IECommerceInterface::IECommerceInterface(Core::System& system_) + : ServiceFramework{system_, "IECommerceInterface"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestLinkDevice"}, @@ -521,8 +525,8 @@ IECommerceInterface::IECommerceInterface() : ServiceFramework{"IECommerceInterfa IECommerceInterface::~IECommerceInterface() = default; -IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface() - : ServiceFramework{"IFactoryResetInterface"} { +IFactoryResetInterface::IFactoryResetInterface(Core::System& system_) + : ServiceFramework{system_, "IFactoryResetInterface"} { // clang-format off static const FunctionInfo functions[] = { {100, nullptr, "ResetToFactorySettings"}, @@ -540,7 +544,7 @@ IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface() IFactoryResetInterface::~IFactoryResetInterface() = default; -NS::NS(const char* name, Core::System& system_) : ServiceFramework{name}, system{system_} { +NS::NS(const char* name, Core::System& system_) : ServiceFramework{system_, name} { // clang-format off static const FunctionInfo functions[] = { {7992, &NS::PushInterface, "GetECommerceInterface"}, @@ -565,7 +569,7 @@ std::shared_ptr NS::GetApplicationManagerInterface class NS_DEV final : public ServiceFramework { public: - explicit NS_DEV() : ServiceFramework{"ns:dev"} { + explicit NS_DEV(Core::System& system_) : ServiceFramework{system_, "ns:dev"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "LaunchProgram"}, @@ -592,7 +596,8 @@ public: class ISystemUpdateControl final : public ServiceFramework { public: - explicit ISystemUpdateControl() : ServiceFramework{"ISystemUpdateControl"} { + explicit ISystemUpdateControl(Core::System& system_) + : ServiceFramework{system_, "ISystemUpdateControl"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "HasDownloaded"}, @@ -627,7 +632,7 @@ public: class NS_SU final : public ServiceFramework { public: - explicit NS_SU() : ServiceFramework{"ns:su"} { + explicit NS_SU(Core::System& system_) : ServiceFramework{system_, "ns:su"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetBackgroundNetworkUpdateState"}, @@ -659,13 +664,13 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } }; class NS_VM final : public ServiceFramework { public: - explicit NS_VM() : ServiceFramework{"ns:vm"} { + explicit NS_VM(Core::System& system_) : ServiceFramework{system_, "ns:vm"} { // clang-format off static const FunctionInfo functions[] = { {1200, nullptr, "NeedsUpdateVulnerability"}, @@ -686,9 +691,9 @@ void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system std::make_shared("ns:rt", system)->InstallAsService(service_manager); std::make_shared("ns:web", system)->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); std::make_shared(system)->InstallAsService(service_manager); } diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h index c90ccd755..991271f3e 100644 --- a/src/core/hle/service/ns/ns.h +++ b/src/core/hle/service/ns/ns.h @@ -20,7 +20,7 @@ namespace NS { class IAccountProxyInterface final : public ServiceFramework { public: - explicit IAccountProxyInterface(); + explicit IAccountProxyInterface(Core::System& system_); ~IAccountProxyInterface() override; }; @@ -36,43 +36,41 @@ private: void GetApplicationControlData(Kernel::HLERequestContext& ctx); void GetApplicationDesiredLanguage(Kernel::HLERequestContext& ctx); void ConvertApplicationLanguageToLanguageCode(Kernel::HLERequestContext& ctx); - - Core::System& system; }; class IApplicationVersionInterface final : public ServiceFramework { public: - explicit IApplicationVersionInterface(); + explicit IApplicationVersionInterface(Core::System& system_); ~IApplicationVersionInterface() override; }; class IContentManagementInterface final : public ServiceFramework { public: - explicit IContentManagementInterface(); + explicit IContentManagementInterface(Core::System& system_); ~IContentManagementInterface() override; }; class IDocumentInterface final : public ServiceFramework { public: - explicit IDocumentInterface(); + explicit IDocumentInterface(Core::System& system_); ~IDocumentInterface() override; }; class IDownloadTaskInterface final : public ServiceFramework { public: - explicit IDownloadTaskInterface(); + explicit IDownloadTaskInterface(Core::System& system_); ~IDownloadTaskInterface() override; }; class IECommerceInterface final : public ServiceFramework { public: - explicit IECommerceInterface(); + explicit IECommerceInterface(Core::System& system_); ~IECommerceInterface() override; }; class IFactoryResetInterface final : public ServiceFramework { public: - explicit IFactoryResetInterface(); + explicit IFactoryResetInterface(Core::System& system_); ~IFactoryResetInterface() override; }; @@ -90,7 +88,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } void PushIApplicationManagerInterface(Kernel::HLERequestContext& ctx) { @@ -108,8 +106,6 @@ private: return std::make_shared(std::forward(args)...); } - - Core::System& system; }; /// Registers all NS services with the specified service manager. diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 5ccec2637..ccc137e40 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp @@ -141,8 +141,8 @@ struct PL_U::Impl { std::vector shared_font_regions; }; -PL_U::PL_U(Core::System& system) - : ServiceFramework("pl:u"), impl{std::make_unique()}, system(system) { +PL_U::PL_U(Core::System& system_) + : ServiceFramework{system_, "pl:u"}, impl{std::make_unique()} { // clang-format off static const FunctionInfo functions[] = { {0, &PL_U::RequestLoad, "RequestLoad"}, diff --git a/src/core/hle/service/ns/pl_u.h b/src/core/hle/service/ns/pl_u.h index 27161bd7a..224dcb997 100644 --- a/src/core/hle/service/ns/pl_u.h +++ b/src/core/hle/service/ns/pl_u.h @@ -20,7 +20,7 @@ void EncryptSharedFont(const std::vector& input, std::vector& output, s class PL_U final : public ServiceFramework { public: - explicit PL_U(Core::System& system); + explicit PL_U(Core::System& system_); ~PL_U() override; private: @@ -33,7 +33,6 @@ private: struct Impl; std::unique_ptr impl; - Core::System& system; }; } // namespace NS -- cgit v1.2.3