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/pctl/module.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/core/hle/service/pctl/module.cpp') diff --git a/src/core/hle/service/pctl/module.cpp b/src/core/hle/service/pctl/module.cpp index caf14ed61..6ab1e4124 100644 --- a/src/core/hle/service/pctl/module.cpp +++ b/src/core/hle/service/pctl/module.cpp @@ -11,7 +11,8 @@ namespace Service::PCTL { class IParentalControlService final : public ServiceFramework { public: - IParentalControlService() : ServiceFramework("IParentalControlService") { + explicit IParentalControlService(Core::System& system_) + : ServiceFramework{system_, "IParentalControlService"} { // clang-format off static const FunctionInfo functions[] = { {1, &IParentalControlService::Initialize, "Initialize"}, @@ -137,7 +138,7 @@ void Module::Interface::CreateService(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } void Module::Interface::CreateServiceWithoutInitialize(Kernel::HLERequestContext& ctx) { @@ -145,20 +146,20 @@ void Module::Interface::CreateServiceWithoutInitialize(Kernel::HLERequestContext IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } -Module::Interface::Interface(std::shared_ptr module, const char* name) - : ServiceFramework(name), module(std::move(module)) {} +Module::Interface::Interface(Core::System& system_, std::shared_ptr module_, const char* name) + : ServiceFramework{system_, name}, module{std::move(module_)} {} Module::Interface::~Interface() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { auto module = std::make_shared(); - std::make_shared(module, "pctl")->InstallAsService(service_manager); - std::make_shared(module, "pctl:a")->InstallAsService(service_manager); - std::make_shared(module, "pctl:r")->InstallAsService(service_manager); - std::make_shared(module, "pctl:s")->InstallAsService(service_manager); + std::make_shared(system, module, "pctl")->InstallAsService(service_manager); + std::make_shared(system, module, "pctl:a")->InstallAsService(service_manager); + std::make_shared(system, module, "pctl:r")->InstallAsService(service_manager); + std::make_shared(system, module, "pctl:s")->InstallAsService(service_manager); } } // namespace Service::PCTL -- cgit v1.2.3