Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Server/mods/deathmatch/logic/luadefs/CLuaDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CLuaDefs
template <auto ReturnOnError, auto T>
static inline int ArgumentParserWarn(lua_State* L)
{
return CLuaFunctionParser<false, ReturnOnError, T>()(L, m_pScriptDebugging);
return CLuaFunctionParser<false, ReturnOnError, remove_noexcept_fn_v<T>>()(L, m_pScriptDebugging);
}

// Special case for overloads
Expand All @@ -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<FunctionA, FunctionB>;
using PaddedFunctionB = pad_func_with_func<FunctionB, FunctionA>;
using PaddedFunctionA = pad_func_with_func<remove_noexcept_fn_v<FunctionA>, remove_noexcept_fn_v<FunctionB>>;
using PaddedFunctionB = pad_func_with_func<remove_noexcept_fn_v<FunctionB>, remove_noexcept_fn_v<FunctionA>>;
// Combine functions
using Overload = CLuaOverloadParser<PaddedFunctionA::Call, PaddedFunctionB::Call>;

Expand All @@ -118,7 +118,7 @@ class CLuaDefs
template <auto T>
static inline int ArgumentParser(lua_State* L)
{
return CLuaFunctionParser<true, nullptr, T>()(L, m_pScriptDebugging);
return CLuaFunctionParser<true, nullptr, remove_noexcept_fn_v<T>>()(L, m_pScriptDebugging);
}

// Special case for overloads
Expand All @@ -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<FunctionA, FunctionB>;
using PaddedFunctionB = pad_func_with_func<FunctionB, FunctionA>;
using PaddedFunctionA = pad_func_with_func<remove_noexcept_fn_v<FunctionA>, remove_noexcept_fn_v<FunctionB>>;
using PaddedFunctionB = pad_func_with_func<remove_noexcept_fn_v<FunctionB>, remove_noexcept_fn_v<FunctionA>>;
// Combine functions
using Overload = CLuaOverloadParser<PaddedFunctionA::Call, PaddedFunctionB::Call>;

Expand Down
30 changes: 30 additions & 0 deletions Shared/sdk/SharedUtil.Template.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,33 @@ struct pad_func_with_func<Func, FuncB>
std::max(sizeof...(Args), sizeof...(ArgsB)) - sizeof...(Args) == 0>::type>
{
};


// Removes noexcept(true) from a function type
template <typename T>
struct remove_noexcept
{
using type = T;
};
template <typename R, typename... P>
struct remove_noexcept<R(P...) noexcept>
{
using type = R(P...);
};
template <typename T>
using remove_noexcept_t = typename remove_noexcept<T>::type;

// Removes noexcept(true) from a function
template <auto T>
struct remove_noexcept_fn
{
constexpr static auto func = T;
};
template <typename Ret, typename... Args, Ret(Func)(Args...) noexcept>
struct remove_noexcept_fn<Func>
{
using func_t = Ret (*)(Args...);
constexpr static func_t func = Func;
};
template <auto Func>
constexpr auto remove_noexcept_fn_v = remove_noexcept_fn<Func>::func;
Loading