From 5e16fe4579e10cf21af9fada603d8d585f683caf Mon Sep 17 00:00:00 2001 From: german77 Date: Tue, 25 Apr 2023 23:33:05 -0600 Subject: core: service: Add FunctionInfoTyped to allow expanding existing interfaces --- src/core/hle/service/service.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 0f79a1b7e..45b2c43b7 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -142,7 +142,8 @@ template class ServiceFramework : public ServiceFrameworkBase { protected: /// Contains information about a request type which is handled by the service. - struct FunctionInfo : FunctionInfoBase { + template + struct FunctionInfoTyped : FunctionInfoBase { // TODO(yuriks): This function could be constexpr, but clang is the only compiler that // doesn't emit an ICE or a wrong diagnostic because of the static_cast. @@ -155,12 +156,13 @@ protected: * the request * @param name_ human-friendly name for the request. Used mostly for logging purposes. */ - FunctionInfo(u32 expected_header_, HandlerFnP handler_callback_, const char* name_) + FunctionInfoTyped(u32 expected_header_, HandlerFnP handler_callback_, const char* name_) : FunctionInfoBase{ expected_header_, // Type-erase member function pointer by casting it down to the base class. static_cast>(handler_callback_), name_} {} }; + using FunctionInfo = FunctionInfoTyped; /** * Initializes the handler with no functions installed. @@ -175,8 +177,8 @@ protected: : ServiceFrameworkBase(system_, service_name_, max_sessions_, Invoker) {} /// Registers handlers in the service. - template - void RegisterHandlers(const FunctionInfo (&functions)[N]) { + template + void RegisterHandlers(const FunctionInfoTyped (&functions)[N]) { RegisterHandlers(functions, N); } @@ -184,13 +186,14 @@ protected: * Registers handlers in the service. Usually prefer using the other RegisterHandlers * overload in order to avoid needing to specify the array size. */ - void RegisterHandlers(const FunctionInfo* functions, std::size_t n) { + template + void RegisterHandlers(const FunctionInfoTyped* functions, std::size_t n) { RegisterHandlersBase(functions, n); } /// Registers handlers in the service. - template - void RegisterHandlersTipc(const FunctionInfo (&functions)[N]) { + template + void RegisterHandlersTipc(const FunctionInfoTyped (&functions)[N]) { RegisterHandlersTipc(functions, N); } @@ -198,7 +201,8 @@ protected: * Registers handlers in the service. Usually prefer using the other RegisterHandlers * overload in order to avoid needing to specify the array size. */ - void RegisterHandlersTipc(const FunctionInfo* functions, std::size_t n) { + template + void RegisterHandlersTipc(const FunctionInfoTyped* functions, std::size_t n) { RegisterHandlersBaseTipc(functions, n); } -- cgit v1.2.3