From a61124a9e7f2a6eab7f51c2b4dd30574e62ba25a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 24 Jul 2018 02:45:23 -0400 Subject: [PATCH 1/2] time: Simplify interface creation We can use one instance of the interface instead of duplicating code. --- src/core/CMakeLists.txt | 6 ++-- .../time/{time_s.cpp => interface.cpp} | 15 ++++----- .../service/time/{time_s.h => interface.h} | 4 +-- src/core/hle/service/time/time.cpp | 7 ++--- src/core/hle/service/time/time_u.cpp | 31 ------------------- src/core/hle/service/time/time_u.h | 16 ---------- 6 files changed, 15 insertions(+), 64 deletions(-) rename src/core/hle/service/time/{time_s.cpp => interface.cpp} (65%) rename src/core/hle/service/time/{time_s.h => interface.h} (68%) delete mode 100644 src/core/hle/service/time/time_u.cpp delete mode 100644 src/core/hle/service/time/time_u.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6b6efbc00f..028095ff98 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -235,12 +235,10 @@ add_library(core STATIC hle/service/spl/spl.h hle/service/ssl/ssl.cpp hle/service/ssl/ssl.h + hle/service/time/interface.cpp + hle/service/time/interface.h hle/service/time/time.cpp hle/service/time/time.h - hle/service/time/time_s.cpp - hle/service/time/time_s.h - hle/service/time/time_u.cpp - hle/service/time/time_u.h hle/service/vi/vi.cpp hle/service/vi/vi.h hle/service/vi/vi_m.cpp diff --git a/src/core/hle/service/time/time_s.cpp b/src/core/hle/service/time/interface.cpp similarity index 65% rename from src/core/hle/service/time/time_s.cpp rename to src/core/hle/service/time/interface.cpp index 0b599ea001..e61788db80 100644 --- a/src/core/hle/service/time/time_s.cpp +++ b/src/core/hle/service/time/interface.cpp @@ -2,17 +2,18 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/hle/service/time/time_s.h" +#include "core/hle/service/time/interface.h" namespace Service::Time { -TIME_S::TIME_S(std::shared_ptr time) : Module::Interface(std::move(time), "time:s") { +TIME::TIME(std::shared_ptr time, const char* name) + : Module::Interface(std::move(time), name) { static const FunctionInfo functions[] = { - {0, &TIME_S::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, - {1, &TIME_S::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"}, - {2, &TIME_S::GetStandardSteadyClock, "GetStandardSteadyClock"}, - {3, &TIME_S::GetTimeZoneService, "GetTimeZoneService"}, - {4, &TIME_S::GetStandardLocalSystemClock, "GetStandardLocalSystemClock"}, + {0, &TIME::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, + {1, &TIME::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"}, + {2, &TIME::GetStandardSteadyClock, "GetStandardSteadyClock"}, + {3, &TIME::GetTimeZoneService, "GetTimeZoneService"}, + {4, &TIME::GetStandardLocalSystemClock, "GetStandardLocalSystemClock"}, {5, nullptr, "GetEphemeralNetworkSystemClock"}, {50, nullptr, "SetStandardSteadyClockInternalOffset"}, {100, nullptr, "IsStandardUserSystemClockAutomaticCorrectionEnabled"}, diff --git a/src/core/hle/service/time/time_s.h b/src/core/hle/service/time/interface.h similarity index 68% rename from src/core/hle/service/time/time_s.h rename to src/core/hle/service/time/interface.h index 4a2daa513a..0f97cec350 100644 --- a/src/core/hle/service/time/time_s.h +++ b/src/core/hle/service/time/interface.h @@ -8,9 +8,9 @@ namespace Service::Time { -class TIME_S final : public Module::Interface { +class TIME final : public Module::Interface { public: - explicit TIME_S(std::shared_ptr time); + explicit TIME(std::shared_ptr time, const char* name); }; } // namespace Service::Time diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 507ae95f4e..dbaa661bbe 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -9,9 +9,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" +#include "core/hle/service/time/interface.h" #include "core/hle/service/time/time.h" -#include "core/hle/service/time/time_s.h" -#include "core/hle/service/time/time_u.h" namespace Service::Time { @@ -212,8 +211,8 @@ Module::Interface::Interface(std::shared_ptr time, const char* name) void InstallInterfaces(SM::ServiceManager& service_manager) { auto time = std::make_shared(); - std::make_shared(time)->InstallAsService(service_manager); - std::make_shared(time)->InstallAsService(service_manager); + std::make_shared