Skip to content

Commit

Permalink
C++17 constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
edo9300 committed Nov 26, 2023
1 parent 24e0004 commit cde7b35
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion duel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ duel::~duel() {
delete game_field;
delete lua;
}
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang_analyzer__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
Expand Down
6 changes: 3 additions & 3 deletions function_array_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ template<std::size_t N>
struct LuaFunction;

template<std::size_t... I>
constexpr auto make_lua_functions_array(std::index_sequence<I...> seq) {
return std::array<luaL_Reg, seq.size() + 1>{Detail::LuaFunction<I>::elem..., luaL_Reg{ nullptr, nullptr }};
constexpr auto make_lua_functions_array(std::index_sequence<I...>) {
return std::array{Detail::LuaFunction<I>::elem..., luaL_Reg{ nullptr, nullptr }};
}

} // namespace Detail
Expand Down Expand Up @@ -72,6 +72,6 @@ struct Detail::LuaFunction<COUNTER> { \
#define LUA_STATIC_FUNCTION(name) static int32_t MAKE_LUA_NAME(LUA_MODULE,name)([[maybe_unused]] lua_State* L, [[maybe_unused]] duel* pduel)
#define LUA_FUNCTION_EXISTING(name,...) struct MAKE_LUA_NAME(LUA_MODULE,name) {}
#define LUA_FUNCTION_ALIAS(name) struct MAKE_LUA_NAME(LUA_MODULE,name) {}
#define GET_LUA_FUNCTIONS_ARRAY() std::array<luaL_Reg,1>{{{nullptr,nullptr}}}
#define GET_LUA_FUNCTIONS_ARRAY() std::array{luaL_Reg{nullptr,nullptr}}
#endif // __INTELLISENSE__
#endif // FUNCTION_ARRAY_HELPER_H
2 changes: 1 addition & 1 deletion libcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,7 +2371,7 @@ LUA_FUNCTION_EXISTING(IsDeleted, is_deleted_object);

void scriptlib::push_card_lib(lua_State* L) {
static constexpr auto cardlib = GET_LUA_FUNCTIONS_ARRAY();
static_assert(cardlib.back().name == nullptr, "");
static_assert(cardlib.back().name == nullptr);
lua_createtable(L, 0, static_cast<int>(cardlib.size() - 1));
luaL_setfuncs(L, cardlib.data(), 0);
lua_pushstring(L, "__index");
Expand Down
2 changes: 1 addition & 1 deletion libdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ LUA_STATIC_FUNCTION(CardToStringWrapper) {

void scriptlib::push_debug_lib(lua_State* L) {
static constexpr auto debuglib = GET_LUA_FUNCTIONS_ARRAY();
static_assert(debuglib.back().name == nullptr, "");
static_assert(debuglib.back().name == nullptr);
lua_createtable(L, 0, static_cast<int>(debuglib.size() - 1));
luaL_setfuncs(L, debuglib.data(), 0);
lua_setglobal(L, "Debug");
Expand Down
2 changes: 1 addition & 1 deletion libduel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4203,7 +4203,7 @@ LUA_STATIC_FUNCTION(GetCardSetcodeFromCode) {

void scriptlib::push_duel_lib(lua_State* L) {
static constexpr auto duellib = GET_LUA_FUNCTIONS_ARRAY();
static_assert(duellib.back().name == nullptr, "");
static_assert(duellib.back().name == nullptr);
lua_createtable(L, 0, static_cast<int>(duellib.size() - 1));
luaL_setfuncs(L, duellib.data(), 0);
lua_setglobal(L, "Duel");
Expand Down
2 changes: 1 addition & 1 deletion libeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ LUA_FUNCTION_EXISTING(IsDeleted, is_deleted_object);

void scriptlib::push_effect_lib(lua_State* L) {
static constexpr auto effectlib = GET_LUA_FUNCTIONS_ARRAY();
static_assert(effectlib.back().name == nullptr, "");
static_assert(effectlib.back().name == nullptr);
lua_createtable(L, 0, static_cast<int>(effectlib.size() - 1));
luaL_setfuncs(L, effectlib.data(), 0);
lua_pushstring(L, "__index");
Expand Down
2 changes: 1 addition & 1 deletion libgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ LUA_FUNCTION_EXISTING(IsDeleted, is_deleted_object);

void scriptlib::push_group_lib(lua_State* L) {
static constexpr auto grouplib = GET_LUA_FUNCTIONS_ARRAY();
static_assert(grouplib.back().name == nullptr, "");
static_assert(grouplib.back().name == nullptr);
lua_createtable(L, 0, static_cast<int>(grouplib.size() - 1));
luaL_setfuncs(L, grouplib.data(), 0);
lua_pushstring(L, "__index");
Expand Down

0 comments on commit cde7b35

Please sign in to comment.