diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index e55e58456f..5d3965ebc6 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -47,9 +47,9 @@ ServiceFrameworkBase::~ServiceFrameworkBase() { const auto guard = ServiceFrameworkBase::LockService(); } -void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info) { +void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, std::optional info) { auto cmd_buf = ctx.CommandBuffer(); - std::string function_name = info == nullptr ? "" : info->name; + std::string function_name = info.has_value() ? info->name : ""; fmt::memory_buffer buf; fmt::format_to(std::back_inserter(buf), "function '{}({})': port='{}' cmd_buf={{[0]={:#x}", ctx.GetCommand(), function_name, service_name, cmd_buf[0]); diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index be7082fc96..9a2ee549cb 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -90,7 +90,6 @@ protected: } struct FunctionInfoBase { - u32 expected_header; HandlerFnP handler_callback; const char* name; u32 version_gating; @@ -153,37 +152,39 @@ protected: /// @param handler_callback_ member function in this service which will be called to handle the request /// @param name_ human-friendly name for the request. Used mostly for logging purposes. constexpr FunctionInfoTyped(u32 expected_header_, HandlerFnP handler_callback_, const char* name_, u32 version_gating_ = 0) - : FunctionInfoBase{ - expected_header_, - HandlerFnP(handler_callback_), - name_, - version_gating_ - } + : FunctionInfoBase{HandlerFnP(handler_callback_), name_, version_gating_} + , expected_header{expected_header_} {} + u32 expected_header; }; using FunctionInfo = FunctionInfoTyped; template requires (std::same_as && ...) - [[nodiscard]] static consteval frozen::map CreateStaticMap(Ts... args) { - return frozen::map{ - {args.expected_header, FunctionInfo(args)}... + [[nodiscard]] static consteval frozen::map, sizeof...(Ts)> CreateStaticMap(Ts... args) { + return frozen::map, sizeof...(args)>{ + {args.expected_header, HandlerFnP(args.handler_callback)}... }; } // Used exclusively by NFC template requires (std::same_as> && ...) - [[nodiscard]] static consteval frozen::map, sizeof...(Ts)> CreateStaticMapWithClass(Ts... args) { - return frozen::map, sizeof...(args)>{ - {args.expected_header, FunctionInfoTyped(args)}... + [[nodiscard]] static consteval frozen::map, sizeof...(Ts)> CreateStaticMapWithClass(Ts... args) { + return frozen::map, sizeof...(args)>{ + {args.expected_header, HandlerFnP(args.handler_callback)}... }; } template [[nodiscard]] static constexpr std::optional HandlerTableGenerateWithFind(u32 key, T const& map) { auto const it = map.find(key); - return it != map.end() ? std::optional{it->second} : std::nullopt; + if (it != map.end()) { + auto fake = FunctionInfoBase{}; + fake.handler_callback = it->second; + return std::optional{fake}; + } + return std::nullopt; } /// @brief Initializes the handler with no functions installed.