From 85ed42a1d28daf30d8115e5e9bd1b5230ec25e00 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 25 Jul 2018 17:07:32 -0400 Subject: service/nifm: Deduplicate interface code Rather than having the same code for each nifm service variant, we can centralize it on one class and get rid of a bit of extra code. --- src/core/hle/service/nifm/nifm.cpp | 47 ++++++++++++++++++++---------------- src/core/hle/service/nifm/nifm.h | 19 +++------------ src/core/hle/service/nifm/nifm_a.cpp | 17 ------------- src/core/hle/service/nifm/nifm_a.h | 16 ------------ src/core/hle/service/nifm/nifm_s.cpp | 17 ------------- src/core/hle/service/nifm/nifm_s.h | 16 ------------ src/core/hle/service/nifm/nifm_u.cpp | 17 ------------- src/core/hle/service/nifm/nifm_u.h | 16 ------------ 8 files changed, 30 insertions(+), 135 deletions(-) delete mode 100644 src/core/hle/service/nifm/nifm_a.cpp delete mode 100644 src/core/hle/service/nifm/nifm_a.h delete mode 100644 src/core/hle/service/nifm/nifm_s.cpp delete mode 100644 src/core/hle/service/nifm/nifm_s.h delete mode 100644 src/core/hle/service/nifm/nifm_u.cpp delete mode 100644 src/core/hle/service/nifm/nifm_u.h (limited to 'src/core/hle') diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 0d951084b..cfe8d9178 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -5,9 +5,7 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/service/nifm/nifm.h" -#include "core/hle/service/nifm/nifm_a.h" -#include "core/hle/service/nifm/nifm_s.h" -#include "core/hle/service/nifm/nifm_u.h" +#include "core/hle/service/service.h" namespace Service::NIFM { @@ -210,28 +208,35 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { RegisterHandlers(functions); } -void Module::Interface::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} +class NetworkInterface final : public ServiceFramework { +public: + explicit NetworkInterface(const char* name) : ServiceFramework{name} { + static const FunctionInfo functions[] = { + {4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, + {5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"}, + }; + RegisterHandlers(functions); + } -void Module::Interface::CreateGeneralService(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); - LOG_DEBUG(Service_NIFM, "called"); -} + void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(); + LOG_DEBUG(Service_NIFM, "called"); + } -Module::Interface::Interface(std::shared_ptr module, const char* name) - : ServiceFramework(name), module(std::move(module)) {} + void CreateGeneralService(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(); + LOG_DEBUG(Service_NIFM, "called"); + } +}; void InstallInterfaces(SM::ServiceManager& service_manager) { - auto module = std::make_shared(); - std::make_shared(module)->InstallAsService(service_manager); - std::make_shared(module)->InstallAsService(service_manager); - std::make_shared(module)->InstallAsService(service_manager); + std::make_shared("nifm:a")->InstallAsService(service_manager); + std::make_shared("nifm:s")->InstallAsService(service_manager); + std::make_shared("nifm:u")->InstallAsService(service_manager); } } // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h index 11f1b5831..4616b3b48 100644 --- a/src/core/hle/service/nifm/nifm.h +++ b/src/core/hle/service/nifm/nifm.h @@ -4,24 +4,13 @@ #pragma once -#include "core/hle/service/service.h" +namespace Service::SM { +class ServiceManager; +} namespace Service::NIFM { -class Module final { -public: - class Interface : public ServiceFramework { - public: - explicit Interface(std::shared_ptr module, const char* name); - - void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx); - void CreateGeneralService(Kernel::HLERequestContext& ctx); - - protected: - std::shared_ptr module; - }; -}; - +/// Registers all NIFM services with the specified service manager. void InstallInterfaces(SM::ServiceManager& service_manager); } // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_a.cpp b/src/core/hle/service/nifm/nifm_a.cpp deleted file mode 100644 index b7f296a20..000000000 --- a/src/core/hle/service/nifm/nifm_a.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/nifm/nifm_a.h" - -namespace Service::NIFM { - -NIFM_A::NIFM_A(std::shared_ptr module) : Module::Interface(std::move(module), "nifm:a") { - static const FunctionInfo functions[] = { - {4, &NIFM_A::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, - {5, &NIFM_A::CreateGeneralService, "CreateGeneralService"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_a.h b/src/core/hle/service/nifm/nifm_a.h deleted file mode 100644 index c3ba33110..000000000 --- a/src/core/hle/service/nifm/nifm_a.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/nifm/nifm.h" - -namespace Service::NIFM { - -class NIFM_A final : public Module::Interface { -public: - explicit NIFM_A(std::shared_ptr module); -}; - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_s.cpp b/src/core/hle/service/nifm/nifm_s.cpp deleted file mode 100644 index 96e3c0cee..000000000 --- a/src/core/hle/service/nifm/nifm_s.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/nifm/nifm_s.h" - -namespace Service::NIFM { - -NIFM_S::NIFM_S(std::shared_ptr module) : Module::Interface(std::move(module), "nifm:s") { - static const FunctionInfo functions[] = { - {4, &NIFM_S::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, - {5, &NIFM_S::CreateGeneralService, "CreateGeneralService"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_s.h b/src/core/hle/service/nifm/nifm_s.h deleted file mode 100644 index 8d1635a5d..000000000 --- a/src/core/hle/service/nifm/nifm_s.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/nifm/nifm.h" - -namespace Service::NIFM { - -class NIFM_S final : public Module::Interface { -public: - explicit NIFM_S(std::shared_ptr module); -}; - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_u.cpp b/src/core/hle/service/nifm/nifm_u.cpp deleted file mode 100644 index 8cb75b903..000000000 --- a/src/core/hle/service/nifm/nifm_u.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/nifm/nifm_u.h" - -namespace Service::NIFM { - -NIFM_U::NIFM_U(std::shared_ptr module) : Module::Interface(std::move(module), "nifm:u") { - static const FunctionInfo functions[] = { - {4, &NIFM_U::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, - {5, &NIFM_U::CreateGeneralService, "CreateGeneralService"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_u.h b/src/core/hle/service/nifm/nifm_u.h deleted file mode 100644 index def9726b1..000000000 --- a/src/core/hle/service/nifm/nifm_u.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/nifm/nifm.h" - -namespace Service::NIFM { - -class NIFM_U final : public Module::Interface { -public: - explicit NIFM_U(std::shared_ptr module); -}; - -} // namespace Service::NIFM -- cgit v1.2.3