mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-30 04:08:43 +00:00
@@ -47,9 +47,9 @@ ServiceFrameworkBase::~ServiceFrameworkBase() {
|
|||||||
const auto guard = ServiceFrameworkBase::LockService();
|
const auto guard = ServiceFrameworkBase::LockService();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info) {
|
void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, std::optional<FunctionInfoBase> info) {
|
||||||
auto cmd_buf = ctx.CommandBuffer();
|
auto cmd_buf = ctx.CommandBuffer();
|
||||||
std::string function_name = info == nullptr ? "<unknown>" : info->name;
|
std::string function_name = info.has_value() ? info->name : "<unknown>";
|
||||||
|
|
||||||
fmt::memory_buffer buf;
|
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]);
|
fmt::format_to(std::back_inserter(buf), "function '{}({})': port='{}' cmd_buf={{[0]={:#x}", ctx.GetCommand(), function_name, service_name, cmd_buf[0]);
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct FunctionInfoBase {
|
struct FunctionInfoBase {
|
||||||
u32 expected_header;
|
|
||||||
HandlerFnP<ServiceFrameworkBase> handler_callback;
|
HandlerFnP<ServiceFrameworkBase> handler_callback;
|
||||||
const char* name;
|
const char* name;
|
||||||
u32 version_gating;
|
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 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.
|
/// @param name_ human-friendly name for the request. Used mostly for logging purposes.
|
||||||
constexpr FunctionInfoTyped(u32 expected_header_, HandlerFnP<T> handler_callback_, const char* name_, u32 version_gating_ = 0)
|
constexpr FunctionInfoTyped(u32 expected_header_, HandlerFnP<T> handler_callback_, const char* name_, u32 version_gating_ = 0)
|
||||||
: FunctionInfoBase{
|
: FunctionInfoBase{HandlerFnP<ServiceFrameworkBase>(handler_callback_), name_, version_gating_}
|
||||||
expected_header_,
|
, expected_header{expected_header_}
|
||||||
HandlerFnP<ServiceFrameworkBase>(handler_callback_),
|
|
||||||
name_,
|
|
||||||
version_gating_
|
|
||||||
}
|
|
||||||
{}
|
{}
|
||||||
|
u32 expected_header;
|
||||||
};
|
};
|
||||||
using FunctionInfo = FunctionInfoTyped<Self>;
|
using FunctionInfo = FunctionInfoTyped<Self>;
|
||||||
|
|
||||||
template<typename ...Ts>
|
template<typename ...Ts>
|
||||||
requires (std::same_as<Ts, FunctionInfo> && ...)
|
requires (std::same_as<Ts, FunctionInfo> && ...)
|
||||||
[[nodiscard]] static consteval frozen::map<u32, FunctionInfo, sizeof...(Ts)> CreateStaticMap(Ts... args) {
|
[[nodiscard]] static consteval frozen::map<u32, HandlerFnP<ServiceFrameworkBase>, sizeof...(Ts)> CreateStaticMap(Ts... args) {
|
||||||
return frozen::map<u32, FunctionInfo, sizeof...(args)>{
|
return frozen::map<u32, HandlerFnP<ServiceFrameworkBase>, sizeof...(args)>{
|
||||||
{args.expected_header, FunctionInfo(args)}...
|
{args.expected_header, HandlerFnP<ServiceFrameworkBase>(args.handler_callback)}...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used exclusively by NFC
|
// Used exclusively by NFC
|
||||||
template<typename T, typename ...Ts>
|
template<typename T, typename ...Ts>
|
||||||
requires (std::same_as<Ts, FunctionInfoTyped<T>> && ...)
|
requires (std::same_as<Ts, FunctionInfoTyped<T>> && ...)
|
||||||
[[nodiscard]] static consteval frozen::map<u32, FunctionInfoTyped<T>, sizeof...(Ts)> CreateStaticMapWithClass(Ts... args) {
|
[[nodiscard]] static consteval frozen::map<u32, HandlerFnP<ServiceFrameworkBase>, sizeof...(Ts)> CreateStaticMapWithClass(Ts... args) {
|
||||||
return frozen::map<u32, FunctionInfoTyped<T>, sizeof...(args)>{
|
return frozen::map<u32, HandlerFnP<ServiceFrameworkBase>, sizeof...(args)>{
|
||||||
{args.expected_header, FunctionInfoTyped<T>(args)}...
|
{args.expected_header, HandlerFnP<ServiceFrameworkBase>(args.handler_callback)}...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
[[nodiscard]] static constexpr std::optional<FunctionInfoBase> HandlerTableGenerateWithFind(u32 key, T const& map) {
|
[[nodiscard]] static constexpr std::optional<FunctionInfoBase> HandlerTableGenerateWithFind(u32 key, T const& map) {
|
||||||
auto const it = map.find(key);
|
auto const it = map.find(key);
|
||||||
return it != map.end() ? std::optional<FunctionInfoBase>{it->second} : std::nullopt;
|
if (it != map.end()) {
|
||||||
|
auto fake = FunctionInfoBase{};
|
||||||
|
fake.handler_callback = it->second;
|
||||||
|
return std::optional<FunctionInfoBase>{fake};
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Initializes the handler with no functions installed.
|
/// @brief Initializes the handler with no functions installed.
|
||||||
|
|||||||
Reference in New Issue
Block a user