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 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'src/core/hle/service/ns/ns.cpp') 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); } -- cgit v1.2.3