VERY experimental Nintendo Switch 2 emulator
C++
Service: Clean-up Interface
Yuri Kunde Schlesnera79d21c83e3f
diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cppindex 20a3fa2e51..53d920de13 100644--- a/src/core/hle/service/ac_u.cpp+++ b/src/core/hle/service/ac_u.cpp@@ -53,7 +53,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/act_u.cpp b/src/core/hle/service/act_u.cppindex 10870f14b5..4ea7a9fb29 100644--- a/src/core/hle/service/act_u.cpp+++ b/src/core/hle/service/act_u.cpp@@ -18,7 +18,7 @@ namespace ACT_U {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/am_app.cpp b/src/core/hle/service/am_app.cppindex 0b396b6d3a..df10db87fa 100644--- a/src/core/hle/service/am_app.cpp+++ b/src/core/hle/service/am_app.cpp@@ -18,7 +18,7 @@ namespace AM_APP {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/am_net.cpp b/src/core/hle/service/am_net.cppindex 112844e5bf..c74012d9d8 100644--- a/src/core/hle/service/am_net.cpp+++ b/src/core/hle/service/am_net.cpp@@ -38,7 +38,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/am_sys.cpp b/src/core/hle/service/am_sys.cppindex b63c8c0879..c5df8abdaa 100644--- a/src/core/hle/service/am_sys.cpp+++ b/src/core/hle/service/am_sys.cpp@@ -18,7 +18,7 @@ namespace AM_SYS {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/apt_a.cpp b/src/core/hle/service/apt_a.cppindex 42f2879c1c..e1dd2a5fb3 100644--- a/src/core/hle/service/apt_a.cpp+++ b/src/core/hle/service/apt_a.cpp@@ -39,7 +39,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/apt_s.cpp b/src/core/hle/service/apt_s.cppindex 7ad428ee7e..6863354287 100644--- a/src/core/hle/service/apt_s.cpp+++ b/src/core/hle/service/apt_s.cpp@@ -117,7 +117,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/apt_u.cpp b/src/core/hle/service/apt_u.cppindex 4c3f621d05..1e6f1f78c6 100644--- a/src/core/hle/service/apt_u.cpp+++ b/src/core/hle/service/apt_u.cpp@@ -520,7 +520,7 @@ Interface::Interface() {lock = Kernel::Mutex::Create(false, "APT_U:Lock").MoveFrom();- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/boss_p.cpp b/src/core/hle/service/boss_p.cppindex f245a38e99..b3aa6acee0 100644--- a/src/core/hle/service/boss_p.cpp+++ b/src/core/hle/service/boss_p.cpp@@ -18,7 +18,7 @@ namespace BOSS_P {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/boss_u.cpp b/src/core/hle/service/boss_u.cppindex 1820ea7ad9..50bb5d426f 100644--- a/src/core/hle/service/boss_u.cpp+++ b/src/core/hle/service/boss_u.cpp@@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/cam_u.cpp b/src/core/hle/service/cam_u.cppindex 5490953397..cf3b276649 100644--- a/src/core/hle/service/cam_u.cpp+++ b/src/core/hle/service/cam_u.cpp@@ -18,7 +18,7 @@ namespace CAM_U {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/cecd_s.cpp b/src/core/hle/service/cecd_s.cppindex 9c4992f134..2c707baff3 100644--- a/src/core/hle/service/cecd_s.cpp+++ b/src/core/hle/service/cecd_s.cpp@@ -18,7 +18,7 @@ namespace CECD_S {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/cecd_u.cpp b/src/core/hle/service/cecd_u.cppindex b7655ef0b5..b7ea3a1861 100644--- a/src/core/hle/service/cecd_u.cpp+++ b/src/core/hle/service/cecd_u.cpp@@ -18,7 +18,7 @@ namespace CECD_U {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/cfg/cfg_i.cpp b/src/core/hle/service/cfg/cfg_i.cppindex 7c1ee8ac37..555b7884a5 100644--- a/src/core/hle/service/cfg/cfg_i.cpp+++ b/src/core/hle/service/cfg/cfg_i.cpp@@ -104,7 +104,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/cfg/cfg_s.cpp b/src/core/hle/service/cfg/cfg_s.cppindex cf4e821521..2170894d6b 100644--- a/src/core/hle/service/cfg/cfg_s.cpp+++ b/src/core/hle/service/cfg/cfg_s.cpp@@ -92,7 +92,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/cfg/cfg_u.cpp b/src/core/hle/service/cfg/cfg_u.cppindex 835620909b..1da9f59f6c 100644--- a/src/core/hle/service/cfg/cfg_u.cpp+++ b/src/core/hle/service/cfg/cfg_u.cpp@@ -186,7 +186,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/csnd_snd.cpp b/src/core/hle/service/csnd_snd.cppindex 3a557efe1c..39b00982cc 100644--- a/src/core/hle/service/csnd_snd.cpp+++ b/src/core/hle/service/csnd_snd.cpp@@ -29,7 +29,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cppindex 9a38be3938..7a18c17477 100644--- a/src/core/hle/service/dsp_dsp.cpp+++ b/src/core/hle/service/dsp_dsp.cpp@@ -206,7 +206,7 @@ Interface::Interface() {interrupt_event = nullptr;read_pipe_count = 0;- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cppindex 8c900eabcd..962de21704 100644--- a/src/core/hle/service/err_f.cpp+++ b/src/core/hle/service/err_f.cpp@@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/frd_a.cpp b/src/core/hle/service/frd_a.cppindex 53edc2cd8e..79140a756d 100644--- a/src/core/hle/service/frd_a.cpp+++ b/src/core/hle/service/frd_a.cpp@@ -18,7 +18,7 @@ namespace FRD_A {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/frd_u.cpp b/src/core/hle/service/frd_u.cppindex 021186e573..59faca77ae 100644--- a/src/core/hle/service/frd_u.cpp+++ b/src/core/hle/service/frd_u.cpp@@ -27,7 +27,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cppindex 9cb7d809ab..94a3a31c87 100644--- a/src/core/hle/service/fs/fs_user.cpp+++ b/src/core/hle/service/fs/fs_user.cpp@@ -591,7 +591,7 @@ const FSUserInterface::FunctionInfo FunctionTable[] = {// Interface classFSUserInterface::FSUserInterface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespace FSdiff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cppindex 5b91f17d27..9362033186 100644--- a/src/core/hle/service/gsp_gpu.cpp+++ b/src/core/hle/service/gsp_gpu.cpp@@ -389,7 +389,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);g_interrupt_event = 0;g_shared_memory = 0;diff --git a/src/core/hle/service/gsp_lcd.cpp b/src/core/hle/service/gsp_lcd.cppindex 6213472ffd..d63fa1ee2f 100644--- a/src/core/hle/service/gsp_lcd.cpp+++ b/src/core/hle/service/gsp_lcd.cpp@@ -20,7 +20,7 @@ namespace GSP_LCD {// Interface classInterface::Interface() {- //Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ //Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/hid/hid_spvr.cpp b/src/core/hle/service/hid/hid_spvr.cppindex 76c40b6599..054aa8b59f 100644--- a/src/core/hle/service/hid/hid_spvr.cpp+++ b/src/core/hle/service/hid/hid_spvr.cpp@@ -32,7 +32,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cppindex 5444aa5ee7..68edafebbd 100644--- a/src/core/hle/service/hid/hid_user.cpp+++ b/src/core/hle/service/hid/hid_user.cpp@@ -72,7 +72,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cppindex d0bff552f0..6595ca5728 100644--- a/src/core/hle/service/http_c.cpp+++ b/src/core/hle/service/http_c.cpp@@ -58,7 +58,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ir_rst.cpp b/src/core/hle/service/ir_rst.cppindex d49bd53355..31da8e1608 100644--- a/src/core/hle/service/ir_rst.cpp+++ b/src/core/hle/service/ir_rst.cpp@@ -22,7 +22,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ir_u.cpp b/src/core/hle/service/ir_u.cppindex da6f38e411..7fa233048b 100644--- a/src/core/hle/service/ir_u.cpp+++ b/src/core/hle/service/ir_u.cpp@@ -36,7 +36,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ldr_ro.cpp b/src/core/hle/service/ldr_ro.cppindex 7d6e2e8e8e..459717fff0 100644--- a/src/core/hle/service/ldr_ro.cpp+++ b/src/core/hle/service/ldr_ro.cpp@@ -27,7 +27,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cppindex 82bce91807..af967b5b65 100644--- a/src/core/hle/service/mic_u.cpp+++ b/src/core/hle/service/mic_u.cpp@@ -34,7 +34,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ndm_u.cpp b/src/core/hle/service/ndm_u.cppindex 0f03de6ae7..df3c97193d 100644--- a/src/core/hle/service/ndm_u.cpp+++ b/src/core/hle/service/ndm_u.cpp@@ -24,7 +24,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/news_s.cpp b/src/core/hle/service/news_s.cppindex 1850f59bdd..d7537875b8 100644--- a/src/core/hle/service/news_s.cpp+++ b/src/core/hle/service/news_s.cpp@@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/news_u.cpp b/src/core/hle/service/news_u.cppindex b5adad4c6f..a9e161c234 100644--- a/src/core/hle/service/news_u.cpp+++ b/src/core/hle/service/news_u.cpp@@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/nim_aoc.cpp b/src/core/hle/service/nim_aoc.cppindex 17d1c4ff51..ab2ef44294 100644--- a/src/core/hle/service/nim_aoc.cpp+++ b/src/core/hle/service/nim_aoc.cpp@@ -25,7 +25,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ns_s.cpp b/src/core/hle/service/ns_s.cppindex b9aca42578..5cf3e20395 100644--- a/src/core/hle/service/ns_s.cpp+++ b/src/core/hle/service/ns_s.cpp@@ -21,7 +21,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/nwm_uds.cpp b/src/core/hle/service/nwm_uds.cppindex ce456a966c..61fcb54cee 100644--- a/src/core/hle/service/nwm_uds.cpp+++ b/src/core/hle/service/nwm_uds.cpp@@ -26,7 +26,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/pm_app.cpp b/src/core/hle/service/pm_app.cppindex 529dccafbb..d61eaf80fa 100644--- a/src/core/hle/service/pm_app.cpp+++ b/src/core/hle/service/pm_app.cpp@@ -26,7 +26,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ptm_play.cpp b/src/core/hle/service/ptm_play.cppindex ae9e2925cc..b357057fdb 100644--- a/src/core/hle/service/ptm_play.cpp+++ b/src/core/hle/service/ptm_play.cpp@@ -22,7 +22,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ptm_sysm.cpp b/src/core/hle/service/ptm_sysm.cppindex 4b5f86a479..b6f688de37 100644--- a/src/core/hle/service/ptm_sysm.cpp+++ b/src/core/hle/service/ptm_sysm.cpp@@ -50,7 +50,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ptm_u.cpp b/src/core/hle/service/ptm_u.cppindex 753180add1..7b465a348b 100644--- a/src/core/hle/service/ptm_u.cpp+++ b/src/core/hle/service/ptm_u.cpp@@ -137,7 +137,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);// Create the SharedExtSaveData archive 0xF000000B and the gamecoin.dat file// TODO(Subv): In the future we should use the FS service to query this archivestd::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.hindex 533d3565b5..121e69932a 100644--- a/src/core/hle/service/service.h+++ b/src/core/hle/service/service.h@@ -5,11 +5,12 @@#pragma once#include <algorithm>-#include <map>#include <string>#include <unordered_map>#include <vector>+#include <boost/container/flat_map.hpp>+#include "common/common.h"#include "common/string_util.h"#include "core/mem_map.h"@@ -69,21 +70,6 @@ public:return "[UNKNOWN SERVICE PORT]";}- /// Allocates a new handle for the service- Handle CreateHandle(Kernel::Object *obj) {- // TODO(yuriks): Fix error reporting- Handle handle = Kernel::g_handle_table.Create(obj).ValueOr(INVALID_HANDLE);- m_handles.push_back(handle);- return handle;- }-- /// Frees a handle from the service- template <class T>- void DeleteHandle(const Handle handle) {- Kernel::g_handle_table.Close(handle);- m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end());- }-ResultVal<bool> SyncRequest() override {u32* cmd_buff = Kernel::GetCommandBuffer();auto itr = m_functions.find(cmd_buff[0]);@@ -109,16 +95,17 @@ protected:/*** Registers the functions in the service*/- void Register(const FunctionInfo* functions, int len) {- for (int i = 0; i < len; i++) {- m_functions[functions[i].id] = functions[i];+ template <size_t N>+ void Register(const FunctionInfo (&functions)[N]) {+ m_functions.reserve(N);+ for (auto& fn : functions) {+ // Usually this array is sorted by id already, so hint to instead at the end+ m_functions.emplace_hint(m_functions.cend(), fn.id, fn);}}private:-- std::vector<Handle> m_handles;- std::map<u32, FunctionInfo> m_functions;+ boost::container::flat_map<u32, FunctionInfo> m_functions;};diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cppindex bb8ee86be6..414c53c548 100644--- a/src/core/hle/service/soc_u.cpp+++ b/src/core/hle/service/soc_u.cpp@@ -734,7 +734,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}Interface::~Interface() {diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cppindex c50aebf151..b140e9fe31 100644--- a/src/core/hle/service/srv.cpp+++ b/src/core/hle/service/srv.cpp@@ -63,7 +63,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/ssl_c.cpp b/src/core/hle/service/ssl_c.cppindex 360516cdf7..3f49c1c973 100644--- a/src/core/hle/service/ssl_c.cpp+++ b/src/core/hle/service/ssl_c.cpp@@ -22,7 +22,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespacediff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cppindex b3d873ef0a..fc76d27219 100644--- a/src/core/hle/service/y2r_u.cpp+++ b/src/core/hle/service/y2r_u.cpp@@ -54,7 +54,7 @@ const Interface::FunctionInfo FunctionTable[] = {// Interface classInterface::Interface() {- Register(FunctionTable, ARRAY_SIZE(FunctionTable));+ Register(FunctionTable);}} // namespace