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:
Lioncash 2020-11-26 15:19:08 -05:00
parent 322349e8cc
commit 1a954b2a59
222 changed files with 1221 additions and 907 deletions

View file

@ -4,6 +4,7 @@
#include <memory>
#include "common/string_util.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h"
@ -15,10 +16,10 @@ constexpr u64 SERVICE_VERSION = 0x00000002;
class YuzuTest final : public ServiceFramework<YuzuTest> {
public:
explicit YuzuTest(std::string data,
std::function<void(std::vector<TestResult>)> finish_callback)
: ServiceFramework{"yuzutest"}, data(std::move(data)),
finish_callback(std::move(finish_callback)) {
explicit YuzuTest(Core::System& system_, std::string data_,
std::function<void(std::vector<TestResult>)> finish_callback_)
: ServiceFramework{system_, "yuzutest"}, data{std::move(data_)}, finish_callback{std::move(
finish_callback_)} {
static const FunctionInfo functions[] = {
{0, &YuzuTest::Initialize, "Initialize"},
{1, &YuzuTest::GetServiceVersion, "GetServiceVersion"},
@ -104,9 +105,11 @@ private:
std::function<void(std::vector<TestResult>)> finish_callback;
};
void InstallInterfaces(SM::ServiceManager& sm, std::string data,
void InstallInterfaces(Core::System& system, std::string data,
std::function<void(std::vector<TestResult>)> finish_callback) {
std::make_shared<YuzuTest>(data, finish_callback)->InstallAsService(sm);
auto& sm = system.ServiceManager();
std::make_shared<YuzuTest>(system, std::move(data), std::move(finish_callback))
->InstallAsService(sm);
}
} // namespace Service::Yuzu

View file

@ -7,8 +7,8 @@
#include <functional>
#include <string>
namespace Service::SM {
class ServiceManager;
namespace Core {
class System;
}
namespace Service::Yuzu {
@ -19,7 +19,7 @@ struct TestResult {
std::string name;
};
void InstallInterfaces(SM::ServiceManager& sm, std::string data,
void InstallInterfaces(Core::System& system, std::string data,
std::function<void(std::vector<TestResult>)> finish_callback);
} // namespace Service::Yuzu

View file

@ -247,9 +247,10 @@ int main(int argc, char** argv) {
"additional help.\n\nError Code: {:04X}-{:04X}\nError Description: {}",
loader_id, error_id, static_cast<Loader::ResultStatus>(error_id));
}
break;
}
Service::Yuzu::InstallInterfaces(system.ServiceManager(), datastring, callback);
Service::Yuzu::InstallInterfaces(system, datastring, callback);
system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend",
"SDLHideTester");