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.
This commit is contained in:
parent
322349e8cc
commit
1a954b2a59
222 changed files with 1221 additions and 907 deletions
|
@ -11,7 +11,8 @@ namespace Service::PCTL {
|
|||
|
||||
class IParentalControlService final : public ServiceFramework<IParentalControlService> {
|
||||
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<IParentalControlService>();
|
||||
rb.PushIpcInterface<IParentalControlService>(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<IParentalControlService>();
|
||||
rb.PushIpcInterface<IParentalControlService>(system);
|
||||
}
|
||||
|
||||
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
||||
: ServiceFramework(name), module(std::move(module)) {}
|
||||
Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> 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<Module>();
|
||||
std::make_shared<PCTL>(module, "pctl")->InstallAsService(service_manager);
|
||||
std::make_shared<PCTL>(module, "pctl:a")->InstallAsService(service_manager);
|
||||
std::make_shared<PCTL>(module, "pctl:r")->InstallAsService(service_manager);
|
||||
std::make_shared<PCTL>(module, "pctl:s")->InstallAsService(service_manager);
|
||||
std::make_shared<PCTL>(system, module, "pctl")->InstallAsService(service_manager);
|
||||
std::make_shared<PCTL>(system, module, "pctl:a")->InstallAsService(service_manager);
|
||||
std::make_shared<PCTL>(system, module, "pctl:r")->InstallAsService(service_manager);
|
||||
std::make_shared<PCTL>(system, module, "pctl:s")->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
} // namespace Service::PCTL
|
||||
|
|
|
@ -6,13 +6,18 @@
|
|||
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::PCTL {
|
||||
|
||||
class Module final {
|
||||
public:
|
||||
class Interface : public ServiceFramework<Interface> {
|
||||
public:
|
||||
explicit Interface(std::shared_ptr<Module> module, const char* name);
|
||||
explicit Interface(Core::System& system_, std::shared_ptr<Module> module_,
|
||||
const char* name);
|
||||
~Interface() override;
|
||||
|
||||
void CreateService(Kernel::HLERequestContext& ctx);
|
||||
|
@ -24,6 +29,6 @@ public:
|
|||
};
|
||||
|
||||
/// Registers all PCTL services with the specified service manager.
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
|
||||
|
||||
} // namespace Service::PCTL
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
namespace Service::PCTL {
|
||||
|
||||
PCTL::PCTL(std::shared_ptr<Module> module, const char* name)
|
||||
: Module::Interface(std::move(module), name) {
|
||||
PCTL::PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name)
|
||||
: Interface{system_, std::move(module_), name} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &PCTL::CreateService, "CreateService"},
|
||||
{1, &PCTL::CreateServiceWithoutInitialize, "CreateServiceWithoutInitialize"},
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
|
||||
#include "core/hle/service/pctl/module.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::PCTL {
|
||||
|
||||
class PCTL final : public Module::Interface {
|
||||
public:
|
||||
explicit PCTL(std::shared_ptr<Module> module, const char* name);
|
||||
explicit PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name);
|
||||
~PCTL() override;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue