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/nfc/nfc.cpp | 34 +++++++++++++++++----------------- src/core/hle/service/nfc/nfc.h | 6 +++++- 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'src/core/hle/service/nfc') diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index 780ea30fe..6ab35de47 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -16,7 +16,7 @@ namespace Service::NFC { class IAm final : public ServiceFramework { public: - explicit IAm() : ServiceFramework{"NFC::IAm"} { + explicit IAm(Core::System& system_) : ServiceFramework{system_, "NFC::IAm"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "Initialize"}, @@ -31,7 +31,7 @@ public: class NFC_AM final : public ServiceFramework { public: - explicit NFC_AM() : ServiceFramework{"nfc:am"} { + explicit NFC_AM(Core::System& system_) : ServiceFramework{system_, "nfc:am"} { // clang-format off static const FunctionInfo functions[] = { {0, &NFC_AM::CreateAmInterface, "CreateAmInterface"}, @@ -47,13 +47,13 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } }; class MFIUser final : public ServiceFramework { public: - explicit MFIUser() : ServiceFramework{"NFC::MFIUser"} { + explicit MFIUser(Core::System& system_) : ServiceFramework{system_, "NFC::MFIUser"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "Initialize"}, @@ -79,7 +79,7 @@ public: class NFC_MF_U final : public ServiceFramework { public: - explicit NFC_MF_U() : ServiceFramework{"nfc:mf:u"} { + explicit NFC_MF_U(Core::System& system_) : ServiceFramework{system_, "nfc:mf:u"} { // clang-format off static const FunctionInfo functions[] = { {0, &NFC_MF_U::CreateUserInterface, "CreateUserInterface"}, @@ -95,13 +95,13 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } }; class IUser final : public ServiceFramework { public: - explicit IUser() : ServiceFramework{"NFC::IUser"} { + explicit IUser(Core::System& system_) : ServiceFramework{system_, "NFC::IUser"} { // clang-format off static const FunctionInfo functions[] = { {0, &IUser::InitializeOld, "InitializeOld"}, @@ -171,7 +171,7 @@ private: class NFC_U final : public ServiceFramework { public: - explicit NFC_U() : ServiceFramework{"nfc:user"} { + explicit NFC_U(Core::System& system_) : ServiceFramework{system_, "nfc:user"} { // clang-format off static const FunctionInfo functions[] = { {0, &NFC_U::CreateUserInterface, "CreateUserInterface"}, @@ -187,13 +187,13 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } }; class ISystem final : public ServiceFramework { public: - explicit ISystem() : ServiceFramework{"ISystem"} { + explicit ISystem(Core::System& system_) : ServiceFramework{system_, "ISystem"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "Initialize"}, @@ -230,7 +230,7 @@ public: class NFC_SYS final : public ServiceFramework { public: - explicit NFC_SYS() : ServiceFramework{"nfc:sys"} { + explicit NFC_SYS(Core::System& system_) : ServiceFramework{system_, "nfc:sys"} { // clang-format off static const FunctionInfo functions[] = { {0, &NFC_SYS::CreateSystemInterface, "CreateSystemInterface"}, @@ -246,15 +246,15 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } }; -void InstallInterfaces(SM::ServiceManager& sm) { - std::make_shared()->InstallAsService(sm); - std::make_shared()->InstallAsService(sm); - std::make_shared()->InstallAsService(sm); - std::make_shared()->InstallAsService(sm); +void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { + std::make_shared(system)->InstallAsService(sm); + std::make_shared(system)->InstallAsService(sm); + std::make_shared(system)->InstallAsService(sm); + std::make_shared(system)->InstallAsService(sm); } } // namespace Service::NFC diff --git a/src/core/hle/service/nfc/nfc.h b/src/core/hle/service/nfc/nfc.h index 4d2d815f9..5a94b076d 100644 --- a/src/core/hle/service/nfc/nfc.h +++ b/src/core/hle/service/nfc/nfc.h @@ -4,12 +4,16 @@ #pragma once +namespace Core { +class System; +} + namespace Service::SM { class ServiceManager; } namespace Service::NFC { -void InstallInterfaces(SM::ServiceManager& sm); +void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); } // namespace Service::NFC -- cgit v1.2.3