From af9d24d5097f0a94ed8e9eaf14633d6255e98de6 Mon Sep 17 00:00:00 2001 From: FileEX Date: Sat, 30 Aug 2025 16:29:38 +0200 Subject: [PATCH] Fix noexcept functions in argument parser (MSVC-friendly) --- .../mods/deathmatch/logic/luadefs/CLuaDefs.h | 12 +++---- .../mods/deathmatch/logic/luadefs/CLuaDefs.h | 12 +++---- Shared/sdk/SharedUtil.Template.h | 35 +++++++++++++++++++ 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaDefs.h index dd31b93f19f..9318f9a8062 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaDefs.h @@ -77,7 +77,7 @@ class CLuaDefs template static inline int ArgumentParserWarn(lua_State* L) { - return CLuaFunctionParser()(L, m_pScriptDebugging); + return CLuaFunctionParser>()(L, m_pScriptDebugging); } // Special case for overloads @@ -87,8 +87,8 @@ class CLuaDefs { // Pad functions to have the same number of parameters by // filling both up to the larger number of parameters with dummy_type arguments - using PaddedFunctionA = pad_func_with_func; - using PaddedFunctionB = pad_func_with_func; + using PaddedFunctionA = pad_func_with_func, remove_noexcept_fn_v>; + using PaddedFunctionB = pad_func_with_func, remove_noexcept_fn_v>; // Combine functions using Overload = CLuaOverloadParser; @@ -99,7 +99,7 @@ class CLuaDefs template static inline int ArgumentParser(lua_State* L) { - return CLuaFunctionParser()(L, m_pScriptDebugging); + return CLuaFunctionParser>()(L, m_pScriptDebugging); } // Special case for overloads @@ -109,8 +109,8 @@ class CLuaDefs { // Pad functions to have the same number of parameters by // filling both up to the larger number of parameters with dummy_type arguments - using PaddedFunctionA = pad_func_with_func; - using PaddedFunctionB = pad_func_with_func; + using PaddedFunctionA = pad_func_with_func, remove_noexcept_fn_v>; + using PaddedFunctionB = pad_func_with_func, remove_noexcept_fn_v>; // Combine functions using Overload = CLuaOverloadParser; diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h index 412ad98ea7a..9949cccb314 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h @@ -96,7 +96,7 @@ class CLuaDefs template static inline int ArgumentParserWarn(lua_State* L) { - return CLuaFunctionParser()(L, m_pScriptDebugging); + return CLuaFunctionParser>()(L, m_pScriptDebugging); } // Special case for overloads @@ -106,8 +106,8 @@ class CLuaDefs { // Pad functions to have the same number of parameters by // filling both up to the larger number of parameters with dummy_type arguments - using PaddedFunctionA = pad_func_with_func; - using PaddedFunctionB = pad_func_with_func; + using PaddedFunctionA = pad_func_with_func, remove_noexcept_fn_v>; + using PaddedFunctionB = pad_func_with_func, remove_noexcept_fn_v>; // Combine functions using Overload = CLuaOverloadParser; @@ -118,7 +118,7 @@ class CLuaDefs template static inline int ArgumentParser(lua_State* L) { - return CLuaFunctionParser()(L, m_pScriptDebugging); + return CLuaFunctionParser>()(L, m_pScriptDebugging); } // Special case for overloads @@ -128,8 +128,8 @@ class CLuaDefs { // Pad functions to have the same number of parameters by // filling both up to the larger number of parameters with dummy_type arguments - using PaddedFunctionA = pad_func_with_func; - using PaddedFunctionB = pad_func_with_func; + using PaddedFunctionA = pad_func_with_func, remove_noexcept_fn_v>; + using PaddedFunctionB = pad_func_with_func, remove_noexcept_fn_v>; // Combine functions using Overload = CLuaOverloadParser; diff --git a/Shared/sdk/SharedUtil.Template.h b/Shared/sdk/SharedUtil.Template.h index e423610cd7f..9a84a5bd176 100644 --- a/Shared/sdk/SharedUtil.Template.h +++ b/Shared/sdk/SharedUtil.Template.h @@ -250,3 +250,38 @@ struct pad_func_with_func std::max(sizeof...(Args), sizeof...(ArgsB)) - sizeof...(Args) == 0>::type> { }; + +// Removes noexcept(true) from a function type +template +struct remove_noexcept +{ + using type = T; +}; + +template +struct remove_noexcept +{ + using type = R(Args...); +}; + +template +using remove_noexcept_t = typename remove_noexcept::type; + +// Removes noexcept(true) from a function +template +struct remove_noexcept_fn; + +template +struct remove_noexcept_fn +{ + using type = R (*)(Args...); +}; + +template +struct remove_noexcept_fn +{ + using type = R (*)(Args...); +}; + +template +constexpr auto remove_noexcept_fn_v = static_cast::type>(Func);