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/yuzu_tester/service/yuzutest.cpp | 15 +++++++++------ src/yuzu_tester/service/yuzutest.h | 6 +++--- src/yuzu_tester/yuzu.cpp | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/yuzu_tester') diff --git a/src/yuzu_tester/service/yuzutest.cpp b/src/yuzu_tester/service/yuzutest.cpp index 2d3f6e3a7..e257fae25 100644 --- a/src/yuzu_tester/service/yuzutest.cpp +++ b/src/yuzu_tester/service/yuzutest.cpp @@ -4,6 +4,7 @@ #include #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 { public: - explicit YuzuTest(std::string data, - std::function)> finish_callback) - : ServiceFramework{"yuzutest"}, data(std::move(data)), - finish_callback(std::move(finish_callback)) { + explicit YuzuTest(Core::System& system_, std::string data_, + std::function)> 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)> finish_callback; }; -void InstallInterfaces(SM::ServiceManager& sm, std::string data, +void InstallInterfaces(Core::System& system, std::string data, std::function)> finish_callback) { - std::make_shared(data, finish_callback)->InstallAsService(sm); + auto& sm = system.ServiceManager(); + std::make_shared(system, std::move(data), std::move(finish_callback)) + ->InstallAsService(sm); } } // namespace Service::Yuzu diff --git a/src/yuzu_tester/service/yuzutest.h b/src/yuzu_tester/service/yuzutest.h index eca129c8c..7794814fa 100644 --- a/src/yuzu_tester/service/yuzutest.h +++ b/src/yuzu_tester/service/yuzutest.h @@ -7,8 +7,8 @@ #include #include -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)> finish_callback); } // namespace Service::Yuzu diff --git a/src/yuzu_tester/yuzu.cpp b/src/yuzu_tester/yuzu.cpp index 88e4bd1f7..ea94a6537 100644 --- a/src/yuzu_tester/yuzu.cpp +++ b/src/yuzu_tester/yuzu.cpp @@ -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(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"); -- cgit v1.2.3