Skip to content

Commit

Permalink
Appendum - CLuaFunctionParser refactor (multitheftauto#3494) (multith…
Browse files Browse the repository at this point in the history
  • Loading branch information
TracerDS authored Jul 19, 2024
1 parent 934c1d6 commit 8c2f95a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class LuaFunctionError
constexpr bool IsWarning() const noexcept { return m_bWarning; }
};

using LuaVarArgs = std::optional<CLuaArguments>;

struct CLuaFunctionParserBase
{
// iIndex is passed around by reference
Expand Down Expand Up @@ -74,6 +76,8 @@ struct CLuaFunctionParserBase
}
else if constexpr (std::is_same_v<T, CLuaArgument>)
return "value";
else if constexpr (std::is_same_v<T, CLuaArguments>)
return "values";
else if constexpr (is_2specialization<T, std::vector>::value)
return "table";
else if constexpr (is_5specialization<T, std::unordered_map>::value)
Expand Down Expand Up @@ -219,6 +223,9 @@ struct CLuaFunctionParserBase
else if constexpr (std::is_same_v<T, CLuaArgument>)
return iArgument != LUA_TNONE;

else if constexpr (std::is_same_v<T, CLuaArguments>)
return iArgument != LUA_TNONE;

// All color classes are read as a single tocolor number
// Do not be tempted to change this to is_base_of<SColor, T>
// SColorARGB etc are only **constructors** for SColor!
Expand Down Expand Up @@ -651,6 +658,12 @@ struct CLuaFunctionParserBase
argument.Read(L, index++);
return argument;
}
else if constexpr (std::is_same_v<T, CLuaArguments>)
{
CLuaArguments argument;
argument.ReadArguments(L, index);
return argument;
}
else if constexpr (std::is_same_v<T, std::monostate>)
{
return T{};
Expand Down

0 comments on commit 8c2f95a

Please sign in to comment.