diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eb418f2..287c7937 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,6 +255,11 @@ set(INCLUDED_DIRECTORIES "tests/dGameTests/dComponentsTests" ) +if(__include_lua__) + set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "dLua") + set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "dLua/sol") +endif() + # Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux) if (APPLE) include_directories("/usr/local/include/") diff --git a/dGame/CMakeLists.txt b/dGame/CMakeLists.txt index 1dbb2f07..70aca7c1 100644 --- a/dGame/CMakeLists.txt +++ b/dGame/CMakeLists.txt @@ -60,20 +60,25 @@ foreach(file ${DSCRIPTS_SOURCES}) set(DGAME_SOURCES ${DGAME_SOURCES} "${PROJECT_SOURCE_DIR}/dScripts/${file}") endforeach() -set(DGAME_LIBRARIES dDatabase) - # If we are including LUA, include the dLua files in dGame if(__include_lua__) # Append the dLua files to the dGame files - set(DGAME_SOURCES ${DGAME_SOURCES} ${DGAME_DLUA}) + foreach(file ${DGAME_DLUA_SOURCES}) + set(DGAME_SOURCES ${DGAME_SOURCES} "${PROJECT_SOURCE_DIR}/dLua/${file}") + endforeach() find_package(Lua REQUIRED) - set(DGAME_LIBRARIES ${DGAME_LIBRARIES} ${LUA_LIBRARIES}) + add_library(dGame STATIC ${DGAME_SOURCES}) + + target_link_libraries(dGame dDatabase Recast Detour ${LUA_LIBRARIES}) + + include_directories("${PROJECT_SOURCE_DIR}/dLua/") message(STATUS "Linking dGame to LUA " ${LUA_LIBRARIES}) +else() + add_library(dGame STATIC ${DGAME_SOURCES}) + + target_link_libraries(dGame dDatabase Recast Detour) endif() -add_library(dGame STATIC ${DGAME_SOURCES}) - -target_link_libraries(dGame dDatabase Recast Detour) diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index fcf2738c..26abd769 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -262,6 +262,8 @@ void RebuildComponent::SpawnActivator() { info.spawnerID = m_Parent->GetObjectID(); info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_Parent->GetPosition() : m_ActivatorPosition; + Game::logger->Log("RebuildComponent", "Spawning activator at <%f, %f, %f>", info.pos.x, info.pos.y, info.pos.z); + m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent); if (m_Activator) { m_ActivatorId = m_Activator->GetObjectID(); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 1b244fdf..4778f908 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -632,7 +632,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } #if __include_lua__ == 1 - if (chatCommand == "lua" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) { + if (chatCommand == "lua" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) { std::string input = ""; // If the first argument is "load", load the file diff --git a/dLua/CMakeLists.txt b/dLua/CMakeLists.txt index e9fed3af..edb2e4e9 100644 --- a/dLua/CMakeLists.txt +++ b/dLua/CMakeLists.txt @@ -1,4 +1,4 @@ -set(DGAME_DLUA "dLua.cpp" +set(DGAME_DLUA_SOURCES "dLua.cpp" "lCommonTypes.cpp" "lEntity.cpp" "LuaScript.cpp" diff --git a/dLua/LuaScript.h b/dLua/LuaScript.h index c2191430..210258b5 100644 --- a/dLua/LuaScript.h +++ b/dLua/LuaScript.h @@ -81,7 +81,7 @@ public: * * Equivalent to 'function onMissionDialogueOK(self, msg)' */ - void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override { + void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override { Invoke("onMissionDialogueOK", lEntity(target), missionID, (int32_t) missionState); } @@ -345,7 +345,7 @@ public: * * Equivalent to 'function onNotifyPetTamingMinigame(self, msg)' */ - void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override { + void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override { Invoke("onNotifyPetTamingMinigame", lEntity(tamer), (int32_t) type); } diff --git a/dLua/lEntity.cpp b/dLua/lEntity.cpp index 943da3a1..c021da1a 100644 --- a/dLua/lEntity.cpp +++ b/dLua/lEntity.cpp @@ -8,6 +8,7 @@ #include "BaseCombatAIComponent.h" #include "MovementAIComponent.h" #include "GameMessages.h" +#include "EntityInfo.h" void lEntity::RegisterClass(LuaScript* script) { @@ -140,12 +141,6 @@ void lEntity::RegisterClass(LuaScript* script) "SetLootMatrixID", [](lEntity& entity, int32_t lootMatrixID) { GetComponent(entity)->SetLootMatrixID(lootMatrixID); }, - "PushImmunity", [](lEntity& entity, int32_t immunity) { - GetComponent(entity)->PushImmunity(immunity); - }, - "PopImmunity", [](lEntity& entity) { - GetComponent(entity)->PopImmunity(); - }, "GetIsSmashable", [](lEntity& entity) { AssertComponent(entity); return entity->GetComponent()->GetIsSmashable(); diff --git a/dLua/lEntity.h b/dLua/lEntity.h index fe59fc30..d9bdabfb 100644 --- a/dLua/lEntity.h +++ b/dLua/lEntity.h @@ -97,7 +97,7 @@ struct lEntity { template void AssertComponent() { if (!GetEntity()->HasComponent(T::ComponentType)) { - throw std::runtime_error("Entity does not have component " + std::to_string(T::ComponentType)); + throw std::runtime_error("Entity does not have component " + std::to_string((int32_t) T::ComponentType)); } } @@ -107,7 +107,7 @@ struct lEntity { template static inline void AssertComponent(lEntity entity) { if (!entity->HasComponent(T::ComponentType)) { - throw std::runtime_error("Entity does not have component " + std::to_string(T::ComponentType)); + throw std::runtime_error("Entity does not have component " + std::to_string((int32_t) T::ComponentType)); } } diff --git a/dLua/sol/config.hpp b/dLua/sol/config.hpp index 333f4847..3b7ef023 100644 --- a/dLua/sol/config.hpp +++ b/dLua/sol/config.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2022-04-03 15:48:33.302370 UTC -// This header was generated with sol v4.0.0-alpha (revision 50b62c93) +// Generated 2022-06-25 08:14:19.336233 UTC +// This header was generated with sol v3.3.0 (revision eba86625) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_CONFIG_HPP diff --git a/dLua/sol/forward.hpp b/dLua/sol/forward.hpp index 66ba9da8..c1c6e3a8 100644 --- a/dLua/sol/forward.hpp +++ b/dLua/sol/forward.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2022-04-03 15:48:33.299725 UTC -// This header was generated with sol v4.0.0-alpha (revision 50b62c93) +// Generated 2022-06-25 08:14:19.328625 UTC +// This header was generated with sol v3.3.0 (revision eba86625) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP @@ -42,10 +42,21 @@ #define SOL_VERSION_STRING "3.2.3" #define SOL_VERSION ((SOL_VERSION_MAJOR * 100000) + (SOL_VERSION_MINOR * 100) + (SOL_VERSION_PATCH)) -#define SOL_IS_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) != 0) -#define SOL_IS_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3) == 0) -#define SOL_IS_DEFAULT_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) > 3) -#define SOL_IS_DEFAULT_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3 OP_SYMBOL 3) < 0) +#define SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN) #_TOKEN +#define SOL_TOKEN_TO_STRING_I_(_TOKEN) SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN) + +#define SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT) _LEFT##_RIGHT +#define SOL_CONCAT_TOKENS_I_(_LEFT, _RIGHT) SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT) + +#define SOL_RAW_IS_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) != 0) +#define SOL_RAW_IS_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3) == 0) +#define SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) > 3) +#define SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3 OP_SYMBOL 3) < 0) + +#define SOL_IS_ON(OP_SYMBOL) SOL_RAW_IS_ON(OP_SYMBOL ## _I_) +#define SOL_IS_OFF(OP_SYMBOL) SOL_RAW_IS_OFF(OP_SYMBOL ## _I_) +#define SOL_IS_DEFAULT_ON(OP_SYMBOL) SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL ## _I_) +#define SOL_IS_DEFAULT_OFF(OP_SYMBOL) SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL ## _I_) #define SOL_ON | #define SOL_OFF ^ @@ -76,7 +87,7 @@ #define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_OFF #endif -#if SOL_IS_ON(SOL_BUILD_C_MODE_I_) +#if SOL_IS_ON(SOL_BUILD_C_MODE) #include #include #include @@ -231,9 +242,9 @@ #define SOL_DEBUG_BUILD_I_ SOL_OFF #endif #elif !defined(NDEBUG) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) && defined(_DEBUG) + #if SOL_IS_ON(SOL_COMPILER_VCXX) && defined(_DEBUG) #define SOL_DEBUG_BUILD_I_ SOL_ON - #elif (SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_)) && !defined(__OPTIMIZE__) + #elif (SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC)) && !defined(__OPTIMIZE__) #define SOL_DEBUG_BUILD_I_ SOL_ON #else #define SOL_DEBUG_BUILD_I_ SOL_OFF @@ -248,13 +259,13 @@ #else #define SOL_EXCEPTIONS_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) #if !defined(_CPPUNWIND) #define SOL_EXCEPTIONS_I_ SOL_OFF #else #define SOL_EXCEPTIONS_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_) +#elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC) #if !defined(__EXCEPTIONS) #define SOL_EXCEPTIONS_I_ SOL_OFF #else @@ -270,13 +281,13 @@ #else #define SOL_RTTI_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) #if !defined(_CPPRTTI) #define SOL_RTTI_I_ SOL_OFF #else #define SOL_RTTI_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_) +#elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC) #if !defined(__GXX_RTTI) #define SOL_RTTI_I_ SOL_OFF #else @@ -313,9 +324,9 @@ #define SOL_SAFE_GETTER_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_GETTER_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_OFF @@ -329,9 +340,9 @@ #define SOL_SAFE_USERTYPE_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_USERTYPE_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_OFF @@ -345,9 +356,9 @@ #define SOL_SAFE_REFERENCES_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_REFERENCES_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_OFF @@ -367,9 +378,9 @@ #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_OFF @@ -383,9 +394,9 @@ #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_OFF @@ -399,9 +410,9 @@ #define SOL_SAFE_PROXIES_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_PROXIES_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_OFF @@ -415,9 +426,9 @@ #define SOL_SAFE_NUMERICS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_NUMERICS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_OFF @@ -430,7 +441,7 @@ #else #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_OFF #endif -#elif !SOL_IS_DEFAULT_OFF(SOL_SAFE_NUMERICS_I_) && SOL_IS_OFF(SOL_SAFE_NUMERICS_I_) +#elif !SOL_IS_DEFAULT_OFF(SOL_SAFE_NUMERICS) && SOL_IS_OFF(SOL_SAFE_NUMERICS) // if numerics is intentionally turned off, flip this on #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_DEFAULT_ON #else @@ -445,9 +456,9 @@ #define SOL_SAFE_STACK_CHECK_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_STACK_CHECK_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_OFF @@ -467,11 +478,11 @@ #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON - #elif SOL_IS_ON(SOL_SAFE_NUMERICS_I_) + #elif SOL_IS_ON(SOL_SAFE_NUMERICS) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON #else #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_OFF @@ -549,7 +560,7 @@ #define SOL_STD_VARIANT_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_COMPILER_CLANG_I_) && SOL_IS_ON(SOL_PLATFORM_APPLE_I_) + #if SOL_IS_ON(SOL_COMPILER_CLANG) && SOL_IS_ON(SOL_PLATFORM_APPLE) #if defined(__has_include) #if __has_include() #define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON @@ -573,7 +584,7 @@ #else #if defined(__cpp_noexcept_function_type) #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON - #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) && (defined(_MSVC_LANG) && (_MSVC_LANG < 201403L)) + #elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(_MSVC_LANG) && (_MSVC_LANG < 201403L)) // There is a bug in the VC++ compiler?? // on /std:c++latest under x86 conditions (VS 15.5.2), // compiler errors are tossed for noexcept markings being on function types @@ -612,9 +623,9 @@ #define SOL_PRINT_ERRORS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_PRINT_ERRORS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_PRINT_ERRORS_I_ SOL_DEFAULT_ON #else #define SOL_PRINT_ERRORS_I_ SOL_OFF @@ -771,7 +782,7 @@ #else #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_OFF #endif -#elif SOL_IS_ON(SOL_COMPILER_MINGW_I_) && defined(__GNUC__) && (__GNUC__ < 6) +#elif SOL_IS_ON(SOL_COMPILER_MINGW) && defined(__GNUC__) && (__GNUC__ < 6) // MinGW is off its rocker in some places... #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_ON #else @@ -792,7 +803,7 @@ #endif #endif -#if SOL_IS_ON(SOL_USE_BOOST_I_) +#if SOL_IS_ON(SOL_USE_BOOST) #include #if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr @@ -835,10 +846,10 @@ #define SOL_PROLOGUE_I_ 1 -#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) +#if SOL_IS_ON(SOL_BUILD_CXX_MODE) #define _FWD(...) static_cast( __VA_ARGS__ ) - #if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ ) #else #include @@ -857,7 +868,7 @@ #undef SOL_PROLOGUE_I_ #endif -#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) +#if SOL_IS_ON(SOL_BUILD_CXX_MODE) #undef _FWD #undef _MOVE #endif @@ -872,7 +883,7 @@ #else #define SOL_DLL_I_ SOL_OFF #endif -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) && (defined(DLL_) || defined(_DLL)) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(DLL_) || defined(_DLL)) #define SOL_DLL_I_ SOL_DEFAULT_ON #else #define SOL_DLL_I_ SOL_DEFAULT_OFF @@ -894,7 +905,7 @@ #else #define SOL_BUILD_I_ SOL_OFF #endif -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_BUILD_I_ SOL_DEFAULT_OFF #else #define SOL_BUILD_I_ SOL_DEFAULT_ON @@ -913,7 +924,7 @@ #if defined(SOL_C_FUNCTION_LINKAGE) #define SOL_C_FUNCTION_LINKAGE_I_ SOL_C_FUNCTION_LINKAGE #else - #if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) + #if SOL_IS_ON(SOL_BUILD_CXX_MODE) // C++ #define SOL_C_FUNCTION_LINKAGE_I_ extern "C" #else @@ -925,12 +936,12 @@ #if defined(SOL_API_LINKAGE) #define SOL_API_LINKAGE_I_ SOL_API_LINKAGE #else - #if SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) || SOL_IS_ON(SOL_PLATFORM_WINDOWS_I_) || SOL_IS_ON(SOL_PLATFORM_CYGWIN_I_) + #if SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) || SOL_IS_ON(SOL_PLATFORM_WINDOWS) || SOL_IS_ON(SOL_PLATFORM_CYGWIN) // MSVC Compiler; or, Windows, or Cygwin platforms - #if SOL_IS_ON(SOL_BUILD_I_) + #if SOL_IS_ON(SOL_BUILD) // Building the library - #if SOL_IS_ON(SOL_COMPILER_GCC_I_) + #if SOL_IS_ON(SOL_COMPILER_GCC) // Using GCC #define SOL_API_LINKAGE_I_ __attribute__((dllexport)) #else @@ -938,7 +949,7 @@ #define SOL_API_LINKAGE_I_ __declspec(dllexport) #endif #else - #if SOL_IS_ON(SOL_COMPILER_GCC_I_) + #if SOL_IS_ON(SOL_COMPILER_GCC) #define SOL_API_LINKAGE_I_ __attribute__((dllimport)) #else #define SOL_API_LINKAGE_I_ __declspec(dllimport) @@ -948,9 +959,9 @@ // extern if building normally on non-MSVC #define SOL_API_LINKAGE_I_ extern #endif - #elif SOL_IS_ON(SOL_UNITY_BUILD_I_) + #elif SOL_IS_ON(SOL_UNITY_BUILD) // Built-in library, like how stb typical works - #if SOL_IS_ON(SOL_HEADER_ONLY_I_) + #if SOL_IS_ON(SOL_HEADER_ONLY) // Header only, so functions are defined "inline" #define SOL_API_LINKAGE_I_ inline #else @@ -959,7 +970,7 @@ #endif #else // Normal static library - #if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) + #if SOL_IS_ON(SOL_BUILD_CXX_MODE) #define SOL_API_LINKAGE_I_ #else #define SOL_API_LINKAGE_I_ extern @@ -993,16 +1004,16 @@ #if defined(SOL_FUNC_DECL) #define SOL_FUNC_DECL_I_ SOL_FUNC_DECL -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_FUNC_DECL_I_ -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_FUNC_DECL_I_ extern __declspec(dllexport) #else #define SOL_FUNC_DECL_I_ extern __declspec(dllimport) #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_FUNC_DECL_I_ extern __attribute__((visibility("default"))) #else #define SOL_FUNC_DECL_I_ extern @@ -1011,16 +1022,16 @@ #if defined(SOL_FUNC_DEFN) #define SOL_FUNC_DEFN_I_ SOL_FUNC_DEFN -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_FUNC_DEFN_I_ inline -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_FUNC_DEFN_I_ __declspec(dllexport) #else #define SOL_FUNC_DEFN_I_ __declspec(dllimport) #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_FUNC_DEFN_I_ __attribute__((visibility("default"))) #else #define SOL_FUNC_DEFN_I_ @@ -1029,16 +1040,16 @@ #if defined(SOL_HIDDEN_FUNC_DECL) #define SOL_HIDDEN_FUNC_DECL_I_ SOL_HIDDEN_FUNC_DECL -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_HIDDEN_FUNC_DECL_I_ -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllexport) #else #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllimport) #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_HIDDEN_FUNC_DECL_I_ extern __attribute__((visibility("default"))) #else #define SOL_HIDDEN_FUNC_DECL_I_ extern @@ -1047,16 +1058,16 @@ #if defined(SOL_HIDDEN_FUNC_DEFN) #define SOL_HIDDEN_FUNC_DEFN_I_ SOL_HIDDEN_FUNC_DEFN -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_HIDDEN_FUNC_DEFN_I_ inline -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_HIDDEN_FUNC_DEFN_I_ #else #define SOL_HIDDEN_FUNC_DEFN_I_ #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_HIDDEN_FUNC_DEFN_I_ __attribute__((visibility("hidden"))) #else #define SOL_HIDDEN_FUNC_DEFN_I_ @@ -1071,7 +1082,7 @@ #include #include -#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_) +#if SOL_IS_ON(SOL_USE_CXX_LUA) || SOL_IS_ON(SOL_USE_CXX_LUAJIT) struct lua_State; #else extern "C" { @@ -1158,7 +1169,7 @@ namespace sol { using main_protected_function = main_safe_function; using stack_protected_function = stack_safe_function; using stack_aligned_protected_function = stack_aligned_safe_function; -#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) +#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS) using function = protected_function; using main_function = main_protected_function; using stack_function = stack_protected_function; @@ -1174,7 +1185,7 @@ namespace sol { struct unsafe_function_result; struct protected_function_result; using safe_function_result = protected_function_result; -#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) +#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS) using function_result = safe_function_result; #else using function_result = unsafe_function_result; @@ -1275,7 +1286,7 @@ namespace sol { struct record; } -#if SOL_IS_OFF(SOL_USE_BOOST_I_) +#if SOL_IS_OFF(SOL_USE_BOOST) template class optional; diff --git a/dLua/sol/sol.hpp b/dLua/sol/sol.hpp index 1a7a6940..938a5190 100644 --- a/dLua/sol/sol.hpp +++ b/dLua/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2022-04-03 15:48:33.238242 UTC -// This header was generated with sol v4.0.0-alpha (revision 50b62c93) +// Generated 2022-06-25 08:14:19.151876 UTC +// This header was generated with sol v3.3.0 (revision eba86625) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -42,10 +42,21 @@ #define SOL_VERSION_STRING "3.2.3" #define SOL_VERSION ((SOL_VERSION_MAJOR * 100000) + (SOL_VERSION_MINOR * 100) + (SOL_VERSION_PATCH)) -#define SOL_IS_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) != 0) -#define SOL_IS_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3) == 0) -#define SOL_IS_DEFAULT_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) > 3) -#define SOL_IS_DEFAULT_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3 OP_SYMBOL 3) < 0) +#define SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN) #_TOKEN +#define SOL_TOKEN_TO_STRING_I_(_TOKEN) SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN) + +#define SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT) _LEFT##_RIGHT +#define SOL_CONCAT_TOKENS_I_(_LEFT, _RIGHT) SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT) + +#define SOL_RAW_IS_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) != 0) +#define SOL_RAW_IS_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3) == 0) +#define SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) > 3) +#define SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3 OP_SYMBOL 3) < 0) + +#define SOL_IS_ON(OP_SYMBOL) SOL_RAW_IS_ON(OP_SYMBOL ## _I_) +#define SOL_IS_OFF(OP_SYMBOL) SOL_RAW_IS_OFF(OP_SYMBOL ## _I_) +#define SOL_IS_DEFAULT_ON(OP_SYMBOL) SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL ## _I_) +#define SOL_IS_DEFAULT_OFF(OP_SYMBOL) SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL ## _I_) #define SOL_ON | #define SOL_OFF ^ @@ -76,7 +87,7 @@ #define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_OFF #endif -#if SOL_IS_ON(SOL_BUILD_C_MODE_I_) +#if SOL_IS_ON(SOL_BUILD_C_MODE) #include #include #include @@ -231,9 +242,9 @@ #define SOL_DEBUG_BUILD_I_ SOL_OFF #endif #elif !defined(NDEBUG) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) && defined(_DEBUG) + #if SOL_IS_ON(SOL_COMPILER_VCXX) && defined(_DEBUG) #define SOL_DEBUG_BUILD_I_ SOL_ON - #elif (SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_)) && !defined(__OPTIMIZE__) + #elif (SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC)) && !defined(__OPTIMIZE__) #define SOL_DEBUG_BUILD_I_ SOL_ON #else #define SOL_DEBUG_BUILD_I_ SOL_OFF @@ -248,13 +259,13 @@ #else #define SOL_EXCEPTIONS_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) #if !defined(_CPPUNWIND) #define SOL_EXCEPTIONS_I_ SOL_OFF #else #define SOL_EXCEPTIONS_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_) +#elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC) #if !defined(__EXCEPTIONS) #define SOL_EXCEPTIONS_I_ SOL_OFF #else @@ -270,13 +281,13 @@ #else #define SOL_RTTI_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) #if !defined(_CPPRTTI) #define SOL_RTTI_I_ SOL_OFF #else #define SOL_RTTI_I_ SOL_ON #endif -#elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_) +#elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC) #if !defined(__GXX_RTTI) #define SOL_RTTI_I_ SOL_OFF #else @@ -313,9 +324,9 @@ #define SOL_SAFE_GETTER_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_GETTER_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_OFF @@ -329,9 +340,9 @@ #define SOL_SAFE_USERTYPE_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_USERTYPE_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_OFF @@ -345,9 +356,9 @@ #define SOL_SAFE_REFERENCES_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_REFERENCES_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_OFF @@ -367,9 +378,9 @@ #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_OFF @@ -383,9 +394,9 @@ #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_OFF @@ -399,9 +410,9 @@ #define SOL_SAFE_PROXIES_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_PROXIES_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_OFF @@ -415,9 +426,9 @@ #define SOL_SAFE_NUMERICS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_NUMERICS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_OFF @@ -430,7 +441,7 @@ #else #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_OFF #endif -#elif !SOL_IS_DEFAULT_OFF(SOL_SAFE_NUMERICS_I_) && SOL_IS_OFF(SOL_SAFE_NUMERICS_I_) +#elif !SOL_IS_DEFAULT_OFF(SOL_SAFE_NUMERICS) && SOL_IS_OFF(SOL_SAFE_NUMERICS) // if numerics is intentionally turned off, flip this on #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_DEFAULT_ON #else @@ -445,9 +456,9 @@ #define SOL_SAFE_STACK_CHECK_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_STACK_CHECK_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_OFF @@ -467,11 +478,11 @@ #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON - #elif SOL_IS_ON(SOL_SAFE_NUMERICS_I_) + #elif SOL_IS_ON(SOL_SAFE_NUMERICS) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON #else #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_OFF @@ -549,7 +560,7 @@ #define SOL_STD_VARIANT_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_COMPILER_CLANG_I_) && SOL_IS_ON(SOL_PLATFORM_APPLE_I_) + #if SOL_IS_ON(SOL_COMPILER_CLANG) && SOL_IS_ON(SOL_PLATFORM_APPLE) #if defined(__has_include) #if __has_include() #define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON @@ -573,7 +584,7 @@ #else #if defined(__cpp_noexcept_function_type) #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON - #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) && (defined(_MSVC_LANG) && (_MSVC_LANG < 201403L)) + #elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(_MSVC_LANG) && (_MSVC_LANG < 201403L)) // There is a bug in the VC++ compiler?? // on /std:c++latest under x86 conditions (VS 15.5.2), // compiler errors are tossed for noexcept markings being on function types @@ -612,9 +623,9 @@ #define SOL_PRINT_ERRORS_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) + #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_PRINT_ERRORS_I_ SOL_ON - #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_PRINT_ERRORS_I_ SOL_DEFAULT_ON #else #define SOL_PRINT_ERRORS_I_ SOL_OFF @@ -771,7 +782,7 @@ #else #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_OFF #endif -#elif SOL_IS_ON(SOL_COMPILER_MINGW_I_) && defined(__GNUC__) && (__GNUC__ < 6) +#elif SOL_IS_ON(SOL_COMPILER_MINGW) && defined(__GNUC__) && (__GNUC__ < 6) // MinGW is off its rocker in some places... #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_ON #else @@ -792,7 +803,7 @@ #endif #endif -#if SOL_IS_ON(SOL_USE_BOOST_I_) +#if SOL_IS_ON(SOL_USE_BOOST) #include #if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr @@ -835,10 +846,10 @@ #define SOL_PROLOGUE_I_ 1 -#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) +#if SOL_IS_ON(SOL_BUILD_CXX_MODE) #define _FWD(...) static_cast( __VA_ARGS__ ) - #if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ ) #else #include @@ -857,7 +868,7 @@ #undef SOL_PROLOGUE_I_ #endif -#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) +#if SOL_IS_ON(SOL_BUILD_CXX_MODE) #undef _FWD #undef _MOVE #endif @@ -872,7 +883,7 @@ #else #define SOL_DLL_I_ SOL_OFF #endif -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) && (defined(DLL_) || defined(_DLL)) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(DLL_) || defined(_DLL)) #define SOL_DLL_I_ SOL_DEFAULT_ON #else #define SOL_DLL_I_ SOL_DEFAULT_OFF @@ -894,7 +905,7 @@ #else #define SOL_BUILD_I_ SOL_OFF #endif -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_BUILD_I_ SOL_DEFAULT_OFF #else #define SOL_BUILD_I_ SOL_DEFAULT_ON @@ -913,7 +924,7 @@ #if defined(SOL_C_FUNCTION_LINKAGE) #define SOL_C_FUNCTION_LINKAGE_I_ SOL_C_FUNCTION_LINKAGE #else - #if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) + #if SOL_IS_ON(SOL_BUILD_CXX_MODE) // C++ #define SOL_C_FUNCTION_LINKAGE_I_ extern "C" #else @@ -925,12 +936,12 @@ #if defined(SOL_API_LINKAGE) #define SOL_API_LINKAGE_I_ SOL_API_LINKAGE #else - #if SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) || SOL_IS_ON(SOL_PLATFORM_WINDOWS_I_) || SOL_IS_ON(SOL_PLATFORM_CYGWIN_I_) + #if SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) || SOL_IS_ON(SOL_PLATFORM_WINDOWS) || SOL_IS_ON(SOL_PLATFORM_CYGWIN) // MSVC Compiler; or, Windows, or Cygwin platforms - #if SOL_IS_ON(SOL_BUILD_I_) + #if SOL_IS_ON(SOL_BUILD) // Building the library - #if SOL_IS_ON(SOL_COMPILER_GCC_I_) + #if SOL_IS_ON(SOL_COMPILER_GCC) // Using GCC #define SOL_API_LINKAGE_I_ __attribute__((dllexport)) #else @@ -938,7 +949,7 @@ #define SOL_API_LINKAGE_I_ __declspec(dllexport) #endif #else - #if SOL_IS_ON(SOL_COMPILER_GCC_I_) + #if SOL_IS_ON(SOL_COMPILER_GCC) #define SOL_API_LINKAGE_I_ __attribute__((dllimport)) #else #define SOL_API_LINKAGE_I_ __declspec(dllimport) @@ -948,9 +959,9 @@ // extern if building normally on non-MSVC #define SOL_API_LINKAGE_I_ extern #endif - #elif SOL_IS_ON(SOL_UNITY_BUILD_I_) + #elif SOL_IS_ON(SOL_UNITY_BUILD) // Built-in library, like how stb typical works - #if SOL_IS_ON(SOL_HEADER_ONLY_I_) + #if SOL_IS_ON(SOL_HEADER_ONLY) // Header only, so functions are defined "inline" #define SOL_API_LINKAGE_I_ inline #else @@ -959,7 +970,7 @@ #endif #else // Normal static library - #if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_) + #if SOL_IS_ON(SOL_BUILD_CXX_MODE) #define SOL_API_LINKAGE_I_ #else #define SOL_API_LINKAGE_I_ extern @@ -993,16 +1004,16 @@ #if defined(SOL_FUNC_DECL) #define SOL_FUNC_DECL_I_ SOL_FUNC_DECL -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_FUNC_DECL_I_ -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_FUNC_DECL_I_ extern __declspec(dllexport) #else #define SOL_FUNC_DECL_I_ extern __declspec(dllimport) #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_FUNC_DECL_I_ extern __attribute__((visibility("default"))) #else #define SOL_FUNC_DECL_I_ extern @@ -1011,16 +1022,16 @@ #if defined(SOL_FUNC_DEFN) #define SOL_FUNC_DEFN_I_ SOL_FUNC_DEFN -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_FUNC_DEFN_I_ inline -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_FUNC_DEFN_I_ __declspec(dllexport) #else #define SOL_FUNC_DEFN_I_ __declspec(dllimport) #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_FUNC_DEFN_I_ __attribute__((visibility("default"))) #else #define SOL_FUNC_DEFN_I_ @@ -1029,16 +1040,16 @@ #if defined(SOL_HIDDEN_FUNC_DECL) #define SOL_HIDDEN_FUNC_DECL_I_ SOL_HIDDEN_FUNC_DECL -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_HIDDEN_FUNC_DECL_I_ -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllexport) #else #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllimport) #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_HIDDEN_FUNC_DECL_I_ extern __attribute__((visibility("default"))) #else #define SOL_HIDDEN_FUNC_DECL_I_ extern @@ -1047,16 +1058,16 @@ #if defined(SOL_HIDDEN_FUNC_DEFN) #define SOL_HIDDEN_FUNC_DEFN_I_ SOL_HIDDEN_FUNC_DEFN -#elif SOL_IS_ON(SOL_HEADER_ONLY_I_) +#elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_HIDDEN_FUNC_DEFN_I_ inline -#elif SOL_IS_ON(SOL_DLL_I_) - #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) - #if SOL_IS_ON(SOL_BUILD_I_) +#elif SOL_IS_ON(SOL_DLL) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #if SOL_IS_ON(SOL_BUILD) #define SOL_HIDDEN_FUNC_DEFN_I_ #else #define SOL_HIDDEN_FUNC_DEFN_I_ #endif - #elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) + #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_HIDDEN_FUNC_DEFN_I_ __attribute__((visibility("hidden"))) #else #define SOL_HIDDEN_FUNC_DEFN_I_ @@ -1067,22 +1078,22 @@ // end of sol/version.hpp -#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_) +#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE) #ifdef check #pragma push_macro("check") #undef check #endif #endif // Unreal Engine 4 Bullshit -#if SOL_IS_ON(SOL_COMPILER_GCC_I_) +#if SOL_IS_ON(SOL_COMPILER_GCC) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wconversion" #if __GNUC__ > 6 #pragma GCC diagnostic ignored "-Wnoexcept-type" #endif -#elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#elif SOL_IS_ON(SOL_COMPILER_CLANG) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) #pragma warning(push) #pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS #endif // clang++ vs. g++ vs. VC++ @@ -1096,7 +1107,7 @@ #include #include -#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_) +#if SOL_IS_ON(SOL_USE_CXX_LUA) || SOL_IS_ON(SOL_USE_CXX_LUAJIT) struct lua_State; #else extern "C" { @@ -1183,7 +1194,7 @@ namespace sol { using main_protected_function = main_safe_function; using stack_protected_function = stack_safe_function; using stack_aligned_protected_function = stack_aligned_safe_function; -#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) +#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS) using function = protected_function; using main_function = main_protected_function; using stack_function = stack_protected_function; @@ -1199,7 +1210,7 @@ namespace sol { struct unsafe_function_result; struct protected_function_result; using safe_function_result = protected_function_result; -#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) +#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS) using function_result = safe_function_result; #else using function_result = unsafe_function_result; @@ -1300,7 +1311,7 @@ namespace sol { struct record; } -#if SOL_IS_OFF(SOL_USE_BOOST_I_) +#if SOL_IS_OFF(SOL_USE_BOOST) template class optional; @@ -1511,7 +1522,7 @@ namespace sol { namespace sol { namespace meta { namespace meta_detail { template - using detect_deducible_signature = decltype(&F::operator(), void()); + using detect_deducible_signature = decltype(&F::operator()); } // namespace meta_detail template @@ -1676,7 +1687,7 @@ namespace sol { namespace meta { typedef R (T::*function_pointer_type)(Args..., ...) const volatile&&; }; -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) template struct fx_traits : public basic_traits { @@ -1791,7 +1802,7 @@ namespace sol { namespace meta { #endif // noexcept is part of a function's type -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) && SOL_IS_ON(SOL_PLATFORM_X86_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) && SOL_IS_ON(SOL_PLATFORM_X86) template struct fx_traits : public basic_traits { typedef R(__stdcall* function_pointer_type)(Args...); @@ -1849,7 +1860,7 @@ namespace sol { namespace meta { typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&&; }; -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) template struct fx_traits : public basic_traits { @@ -2036,6 +2047,7 @@ namespace sol { namespace meta { #include #include +#include namespace sol { @@ -2136,7 +2148,7 @@ namespace sol { #include #include #include -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) #include #endif // variant is weird on XCode, thanks XCode @@ -2577,7 +2589,7 @@ namespace sol { namespace meta { template class supports_op_less_test() < std::declval())>> : public std::integral_constant, std::variant> && !is_specialization_of_v, std::variant> #else true @@ -2590,7 +2602,7 @@ namespace sol { namespace meta { template class supports_op_equal_test() == std::declval())>> : public std::integral_constant, std::variant> && !is_specialization_of_v, std::variant> #else true @@ -2603,7 +2615,7 @@ namespace sol { namespace meta { template class supports_op_less_equal_test() <= std::declval())>> : public std::integral_constant, std::variant> && !is_specialization_of_v, std::variant> #else true @@ -2725,7 +2737,7 @@ namespace sol { namespace meta { template using is_string_literal_array = boolean && any_same_v, char, -#if SOL_IS_ON(SOL_CHAR8_T_I_) +#if SOL_IS_ON(SOL_CHAR8_T) char8_t, #endif char16_t, char32_t, wchar_t>>; @@ -2797,7 +2809,7 @@ namespace sol { namespace meta { using is_c_str_or_string = is_c_str_or_string_of; template - constexpr inline bool is_c_str_or_string_v = is_c_str::value; + constexpr inline bool is_c_str_or_string_v = is_c_str_or_string::value; template struct is_move_only : all>, neg>>, std::is_move_constructible>> { }; @@ -2839,7 +2851,7 @@ namespace sol { namespace meta { namespace sol { namespace detail { const bool default_safe_function_calls = -#if SOL_IS_ON(SOL_SAFE_FUNCTION_CALLS_I_) +#if SOL_IS_ON(SOL_SAFE_FUNCTION_CALLS) true; #else false; @@ -2864,7 +2876,7 @@ namespace sol { // beginning of sol/assert.hpp -#if SOL_IS_ON(SOL2_CI_I_) +#if SOL_IS_ON(SOL2_CI) struct pre_main { pre_main() { @@ -2876,10 +2888,10 @@ struct pre_main { #endif // Prevent lockup when doing Continuous Integration -#if SOL_IS_ON(SOL_USER_C_ASSERT_I_) +#if SOL_IS_ON(SOL_USER_C_ASSERT) #define sol_c_assert(...) SOL_C_ASSERT(__VA_ARGS__) #else - #if SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #if SOL_IS_ON(SOL_DEBUG_BUILD) #include #include #include @@ -2901,10 +2913,10 @@ struct pre_main { #endif #endif -#if SOL_IS_ON(SOL_USER_M_ASSERT_I_) +#if SOL_IS_ON(SOL_USER_M_ASSERT) #define sol_m_assert(message, ...) SOL_M_ASSERT(message, __VA_ARGS__) #else - #if SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #if SOL_IS_ON(SOL_DEBUG_BUILD) #include #include #include @@ -2935,11 +2947,11 @@ struct pre_main { // beginning of sol/compatibility/lua_version.hpp -#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) +#if SOL_IS_ON(SOL_USE_CXX_LUA) #include #include #include -#elif SOL_IS_ON(SOL_USE_LUA_HPP_I_) +#elif SOL_IS_ON(SOL_USE_LUA_HPP) #include #else extern "C" { @@ -2961,9 +2973,9 @@ struct pre_main { #define SOL_USE_LUAJIT_I_ SOL_DEFAULT_OFF #endif // luajit -#if SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_) +#if SOL_IS_ON(SOL_USE_CXX_LUAJIT) #include -#elif SOL_IS_ON(SOL_USE_LUAJIT_I_) +#elif SOL_IS_ON(SOL_USE_LUAJIT) extern "C" { #include } @@ -2971,7 +2983,7 @@ struct pre_main { #if defined(SOL_LUAJIT_VERSION) #define SOL_LUAJIT_VERSION_I_ SOL_LUAJIT_VERSION -#elif SOL_IS_ON(SOL_USE_LUAJIT_I_) +#elif SOL_IS_ON(SOL_USE_LUAJIT) #define SOL_LUAJIT_VERSION_I_ LUAJIT_VERSION_NUM #else #define SOL_LUAJIT_VERSION_I_ 0 @@ -3028,7 +3040,7 @@ struct pre_main { #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON #elif SOL_LUAJIT_VERSION_I_ >= 20000 // LuaJIT 2.0.x have exception support only on x64 builds - #if SOL_IS_ON(SOL_PLATFORM_X64_I_) + #if SOL_IS_ON(SOL_PLATFORM_X64) #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON #else #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF @@ -3047,11 +3059,11 @@ struct pre_main { #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_OFF #endif #else - #if SOL_IS_ON(SOL_USE_LUAJIT_I_) + #if SOL_IS_ON(SOL_USE_LUAJIT) #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF - #elif SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_) + #elif SOL_IS_ON(SOL_USE_CXX_LUAJIT) #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF - #elif SOL_IS_ON(SOL_USE_CXX_LUA_I_) + #elif SOL_IS_ON(SOL_USE_CXX_LUA) #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF #else #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_ON @@ -3065,7 +3077,7 @@ struct pre_main { #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_OFF #endif #else - #if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_) && SOL_IS_ON(SOL_USE_LUAJIT_I_) + #if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS) && SOL_IS_ON(SOL_USE_LUAJIT) #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON #else #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_DEFAULT_OFF @@ -3079,7 +3091,7 @@ struct pre_main { #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_OFF #endif #else - #if SOL_IS_OFF(SOL_USE_LUAJIT_I_) && (SOL_LUA_VERSION > 501) + #if SOL_IS_OFF(SOL_USE_LUAJIT) && (SOL_LUA_VERSION > 501) #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON #else #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_DEFAULT_OFF @@ -3118,9 +3130,9 @@ struct pre_main { // end of sol/compatibility/lua_version.hpp -#if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER_I_) +#if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER) -#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_) +#if SOL_IS_ON(SOL_USE_CXX_LUA) || SOL_IS_ON(SOL_USE_CXX_LUAJIT) #ifndef COMPAT53_LUA_CPP #define COMPAT53_LUA_CPP 1 #endif // Build Lua Compat layer as C++ @@ -4496,7 +4508,7 @@ namespace sol { using storage_t = Container; const std::byte* p_code = static_cast(memory); storage_t& bc = *static_cast(userdata_pointer); -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) bc.insert(bc.cend(), p_code, p_code + memory_size); #else try { @@ -4614,7 +4626,7 @@ namespace sol { // end of sol/in_place.hpp -#if SOL_IS_ON(SOL_USE_BOOST_I_) +#if SOL_IS_ON(SOL_USE_BOOST) #include #else // beginning of sol/optional_implementation.hpp @@ -5928,7 +5940,7 @@ namespace sol { SOL_TL_OPTIONAL_11_CONSTEXPR T& value() & { if (has_value()) return this->m_value; -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) std::abort(); #else throw bad_optional_access(); @@ -5939,7 +5951,7 @@ namespace sol { SOL_TL_OPTIONAL_11_CONSTEXPR const T& value() const& { if (has_value()) return this->m_value; -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) std::abort(); #else throw bad_optional_access(); @@ -5949,7 +5961,7 @@ namespace sol { SOL_TL_OPTIONAL_11_CONSTEXPR T&& value() && { if (has_value()) return std::move(this->m_value); -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) std::abort(); #else throw bad_optional_access(); @@ -5961,7 +5973,7 @@ namespace sol { SOL_TL_OPTIONAL_11_CONSTEXPR const T&& value() const&& { if (has_value()) return std::move(this->m_value); -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) std::abort(); #else throw bad_optional_access(); @@ -6799,7 +6811,7 @@ namespace sol { SOL_TL_OPTIONAL_11_CONSTEXPR T& value() { if (has_value()) return *m_value; -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) std::abort(); #else throw bad_optional_access(); @@ -6810,7 +6822,7 @@ namespace sol { SOL_TL_OPTIONAL_11_CONSTEXPR const T& value() const { if (has_value()) return *m_value; -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) std::abort(); #else throw bad_optional_access(); @@ -6857,7 +6869,7 @@ namespace std { namespace sol { -#if SOL_IS_ON(SOL_USE_BOOST_I_) +#if SOL_IS_ON(SOL_USE_BOOST) template using optional = boost::optional; using nullopt_t = boost::none_t; @@ -6878,14 +6890,14 @@ namespace sol { inline static constexpr std::nullopt_t value = std::nullopt; }; -#if SOL_IS_ON(SOL_USE_BOOST_I_) +#if SOL_IS_ON(SOL_USE_BOOST) template struct associated_nullopt> { inline static SOL_BOOST_NONE_CONSTEXPR_I_ boost::none_t value = boost::none; }; #endif // Boost nullopt -#if SOL_IS_ON(SOL_USE_BOOST_I_) +#if SOL_IS_ON(SOL_USE_BOOST) template inline SOL_BOOST_NONE_CONSTEXPR_I_ auto associated_nullopt_v = associated_nullopt::value; #else @@ -6895,7 +6907,7 @@ namespace sol { } // namespace detail } // namespace sol -#if SOL_IS_ON(SOL_USE_BOOST_I_) +#if SOL_IS_ON(SOL_USE_BOOST) #undef SOL_BOOST_NONE_CONSTEXPR_I_ #endif @@ -7114,6 +7126,7 @@ namespace sol { #include #include +#include namespace sol { namespace detail { @@ -7252,7 +7265,8 @@ namespace sol { namespace detail { #include #include #include -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#include +#if SOL_IS_ON(SOL_STD_VARIANT) #include #endif // variant shenanigans (thanks, Mac OSX) @@ -7267,7 +7281,7 @@ namespace sol { } // namespace d namespace detail { -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) typedef int (*lua_CFunction_noexcept)(lua_State* L) noexcept; #else typedef int (*lua_CFunction_noexcept)(lua_State* L); @@ -7304,7 +7318,7 @@ namespace sol { inline bool operator!=(lua_nil_t, lua_nil_t) { return false; } -#if SOL_IS_ON(SOL_NIL_I_) +#if SOL_IS_ON(SOL_NIL) using nil_t = lua_nil_t; inline constexpr const nil_t& nil = lua_nil; #endif @@ -7500,7 +7514,7 @@ namespace sol { } template - struct metatable_regisTrykey : private detail::ebco { + struct metatable_registry_key : private detail::ebco { private: using base_t = detail::ebco; @@ -7511,9 +7525,9 @@ namespace sol { }; template - auto meta_regisTrykey(T&& key) { + auto meta_registry_key(T&& key) { typedef meta::unqualified_t K; - return metatable_regisTrykey(std::forward(key)); + return metatable_registry_key(std::forward(key)); } template @@ -7869,7 +7883,7 @@ namespace sol { enum class type : int { none = LUA_TNONE, lua_nil = LUA_TNIL, -#if SOL_IS_ON(SOL_NIL_I_) +#if SOL_IS_ON(SOL_NIL) nil = lua_nil, #endif // Objective C/C++ Keyword that's found in OSX SDK and OBJC -- check for all forms to protect string = LUA_TSTRING, @@ -8143,7 +8157,7 @@ namespace sol { template struct lua_type_of : std::integral_constant { }; -#if SOL_IS_ON(SOL_CHAR8_T_I_) +#if SOL_IS_ON(SOL_CHAR8_T) template struct lua_type_of : std::integral_constant { }; #endif @@ -8160,7 +8174,7 @@ namespace sol { template <> struct lua_type_of : std::integral_constant { }; -#if SOL_IS_ON(SOL_CHAR8_T_I_) +#if SOL_IS_ON(SOL_CHAR8_T) template <> struct lua_type_of : std::integral_constant { }; #endif @@ -8177,7 +8191,7 @@ namespace sol { template <> struct lua_type_of : std::integral_constant { }; -#if SOL_IS_ON(SOL_CHAR8_T_I_) +#if SOL_IS_ON(SOL_CHAR8_T) template <> struct lua_type_of : std::integral_constant { }; #endif @@ -8326,7 +8340,7 @@ namespace sol { template <> struct lua_type_of : std::integral_constant { }; -#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) template struct lua_type_of : std::integral_constant ? type::function : type::userdata> { }; #else @@ -8347,7 +8361,7 @@ namespace sol { template <> struct lua_type_of : std::integral_constant { }; -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) template struct lua_type_of> : std::integral_constant { }; #endif // std::variant deployment sucks on Clang @@ -8416,7 +8430,7 @@ namespace sol { template struct is_value_semantic_for_function -#if SOL_IS_ON(SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_) +#if SOL_IS_ON(SOL_FUNCTION_CALL_VALUE_SEMANTICS) : std::true_type { }; #else @@ -8570,7 +8584,7 @@ namespace sol { template struct is_automagical : std::integral_constant> || (!std::is_same_v, state> && !std::is_same_v, state_view>))> { }; @@ -8708,7 +8722,7 @@ namespace sol { #include #include -#if SOL_IS_ON(SOL_PRINT_ERRORS_I_) +#if SOL_IS_ON(SOL_PRINT_ERRORS) #include #endif @@ -8726,7 +8740,7 @@ namespace sol { // must push at least 1 object on the stack inline int default_exception_handler(lua_State* L, optional, string_view what) { -#if SOL_IS_ON(SOL_PRINT_ERRORS_I_) +#if SOL_IS_ON(SOL_PRINT_ERRORS) std::cerr << "[sol2] An exception occurred: "; std::cerr.write(what.data(), static_cast(what.size())); std::cerr << std::endl; @@ -8751,13 +8765,13 @@ namespace sol { return exfunc(L, std::move(maybe_ex), std::move(what)); } -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) template int static_trampoline(lua_State* L) noexcept { return f(L); } -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) template int static_trampoline_noexcept(lua_State* L) noexcept { return f(L); @@ -8780,7 +8794,7 @@ namespace sol { #else inline int lua_cfunction_trampoline(lua_State* L, lua_CFunction f) { -#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_) +#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS) return f(L); #else try { @@ -8795,7 +8809,7 @@ namespace sol { catch (const std::exception& e) { call_exception_handler(L, optional(e), e.what()); } -#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL_I_) +#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL) // LuaJIT cannot have the catchall when the safe propagation is on // but LuaJIT will swallow all C++ errors // if we don't at least catch std::exception ones @@ -8812,7 +8826,7 @@ namespace sol { return lua_cfunction_trampoline(L, f); } -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) template int static_trampoline_noexcept(lua_State* L) noexcept { return f(L); @@ -8830,7 +8844,7 @@ namespace sol { return f(L, std::forward(args)...); } else { -#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_) +#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS) return f(L, std::forward(args)...); #else try { @@ -8845,7 +8859,7 @@ namespace sol { catch (const std::exception& e) { call_exception_handler(L, optional(e), e.what()); } -#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL_I_) +#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL) // LuaJIT cannot have the catchall when the safe propagation is on // but LuaJIT will swallow all C++ errors // if we don't at least catch std::exception ones @@ -8903,7 +8917,7 @@ namespace sol { #include #include #include -#if SOL_IS_ON(SOL_MINGW_CCTYPE_IS_POISONED_I_) +#if SOL_IS_ON(SOL_MINGW_CCTYPE_IS_POISONED) extern "C" { #include } @@ -8921,7 +8935,7 @@ namespace sol { namespace detail { "`anonymous-namespace'", "`anonymous namespace'" } }; -#if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) +#if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) inline std::string ctti_get_type_name_from_sig(std::string name) { // cardinal sins from MINGW using namespace std; @@ -8959,7 +8973,7 @@ namespace sol { namespace detail { inline std::string ctti_get_type_name() { return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__); } -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) inline std::string ctti_get_type_name_from_sig(std::string name) { std::size_t start = name.find("get_type_name"); if (start == std::string::npos) @@ -9514,7 +9528,7 @@ namespace sol { case type::poly: return "anything"; case type::userdata: { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 2, "not enough space to push get the type name"); #endif // make sure stack doesn't overflow if (lua_getmetatable(L, index) == 0) { @@ -9648,7 +9662,7 @@ namespace sol { int m_index = 0; - int regisTryindex() const noexcept { + int registry_index() const noexcept { return LUA_NOREF; } @@ -9674,7 +9688,7 @@ namespace sol { stateless_stack_reference& operator=(const stateless_stack_reference&) noexcept = default; int push(lua_State* L_) const noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, "not enough Lua stack space to push a single reference value"); #endif // make sure stack doesn't overflow lua_pushvalue(L_, m_index); @@ -9757,7 +9771,7 @@ namespace sol { } int i = r.stack_index(); if (detail::xmovable(lua_state(), r.lua_state())) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, "not enough Lua stack space to push a single reference value"); #endif // make sure stack doesn't overflow lua_pushvalue(r.lua_state(), r.stack_index()); @@ -10179,7 +10193,7 @@ namespace sol { } stateless_reference(lua_State* L_, global_tag_t) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value"); #endif // make sure stack doesn't overflow lua_pushglobaltable(L_); @@ -10242,7 +10256,7 @@ namespace sol { } stateless_reference(lua_State* L_, int index = -1) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value"); #endif // make sure stack doesn't overflow lua_pushvalue(L_, index); @@ -10273,7 +10287,7 @@ namespace sol { } int push(lua_State* L_) const noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value"); #endif // make sure stack doesn't overflow lua_rawgeti(L_, LUA_REGISTRYINDEX, ref); @@ -10284,7 +10298,7 @@ namespace sol { lua_pop(L_, n); } - int regisTryindex() const noexcept { + int registry_index() const noexcept { return ref; } @@ -10297,7 +10311,7 @@ namespace sol { void reset(lua_State* L_, int index_) noexcept { reset(L_); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value"); #endif // make sure stack doesn't overflow lua_pushvalue(L_, index_); @@ -10506,7 +10520,7 @@ namespace sol { } basic_reference(lua_State* L_, int index = -1) noexcept : luastate(detail::pick_main_thread(L_, L_)) { // use L_ to stick with that state's execution stack -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value"); #endif // make sure stack doesn't overflow lua_pushvalue(L_, index); @@ -10583,7 +10597,7 @@ namespace sol { } int push(lua_State* L_) const noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value"); #endif // make sure stack doesn't overflow if (lua_state() == nullptr) { @@ -10605,8 +10619,8 @@ namespace sol { stateless_reference::pop(L_, n); } - int regisTryindex() const noexcept { - return stateless_reference::regisTryindex(); + int registry_index() const noexcept { + return stateless_reference::registry_index(); } bool valid() const noexcept { @@ -10689,27 +10703,27 @@ namespace sol { } inline bool operator==(const stateless_reference& l, const stateless_reference& r) noexcept { - return l.regisTryindex() == r.regisTryindex(); + return l.registry_index() == r.registry_index(); } inline bool operator!=(const stateless_reference& l, const stateless_reference& r) noexcept { - return l.regisTryindex() != r.regisTryindex(); + return l.registry_index() != r.registry_index(); } inline bool operator==(const stateless_reference& lhs, const lua_nil_t&) noexcept { - return lhs.regisTryindex() == LUA_REFNIL; + return lhs.registry_index() == LUA_REFNIL; } inline bool operator==(const lua_nil_t&, const stateless_reference& rhs) noexcept { - return rhs.regisTryindex() == LUA_REFNIL; + return rhs.registry_index() == LUA_REFNIL; } inline bool operator!=(const stateless_reference& lhs, const lua_nil_t&) noexcept { - return lhs.regisTryindex() != LUA_REFNIL; + return lhs.registry_index() != LUA_REFNIL; } inline bool operator!=(const lua_nil_t&, const stateless_reference& rhs) noexcept { - return rhs.regisTryindex() != LUA_REFNIL; + return rhs.registry_index() != LUA_REFNIL; } struct stateless_reference_equals : public stateless_stack_reference_equals { @@ -10869,7 +10883,7 @@ namespace sol { namespace sol { namespace detail { inline void stack_fail(int, int) { -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_ON(SOL_EXCEPTIONS) throw error(detail::direct_error, "imbalanced stack after operation finish"); #else // Lol, what do you want, an error printout? :3c @@ -10995,7 +11009,7 @@ namespace sol { inline void* align_usertype_pointer(void* ptr) { using use_align = std::integral_constant::value > 1) @@ -11011,7 +11025,7 @@ namespace sol { template void* align_usertype_unique_destructor(void* ptr) { using use_align = std::integral_constant::value > 1) @@ -11033,7 +11047,7 @@ namespace sol { template void* align_usertype_unique_tag(void* ptr) { using use_align = std::integral_constant::value > 1) @@ -11055,7 +11069,7 @@ namespace sol { template void* align_usertype_unique(void* ptr) { typedef std::integral_constant > 1) @@ -11078,7 +11092,7 @@ namespace sol { template void* align_user(void* ptr) { typedef std::integral_constant > 1) @@ -11095,7 +11109,7 @@ namespace sol { template T** usertype_allocate_pointer(lua_State* L) { typedef std::integral_constant::value > 1) @@ -11179,7 +11193,7 @@ namespace sol { template T* usertype_allocate(lua_State* L) { typedef std::integral_constant::value > 1 || std::alignment_of_v > 1) @@ -11220,7 +11234,7 @@ namespace sol { template Real* usertype_unique_allocate(lua_State* L, T**& pref, unique_destructor*& dx, unique_tag*& id) { typedef std::integral_constant::value > 1 || std::alignment_of::value > 1 || std::alignment_of::value > 1 @@ -11274,7 +11288,7 @@ namespace sol { template T* user_allocate(lua_State* L) { typedef std::integral_constant > 1) @@ -11576,7 +11590,6 @@ namespace sol { } else { unqualified_getter g {}; - (void)g; return g.get(L, index, tracking); } } @@ -11588,7 +11601,6 @@ namespace sol { } else { qualified_getter g {}; - (void)g; return g.get(L, index, tracking); } } @@ -11744,7 +11756,6 @@ namespace sol { } else { unqualified_pusher p {}; - (void)p; return p.push(L, std::forward(t), std::forward(args)...); } } @@ -11764,7 +11775,6 @@ namespace sol { } else { unqualified_pusher p {}; - (void)p; return p.push(L, std::forward(arg), std::forward(args)...); } } @@ -11795,7 +11805,7 @@ namespace sol { using use_reference_tag = meta::all< meta::neg> -#if SOL_IS_OFF(SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_) +#if SOL_IS_OFF(SOL_FUNCTION_CALL_VALUE_SEMANTICS) , std::is_lvalue_reference, meta::neg>>, meta::neg>>, @@ -11850,9 +11860,7 @@ namespace sol { return sol_lua_check(types(), L, index, std::forward(handler), tracking); } else { - unqualified_checker> c; - // VC++ has a bad warning here: shut it up - (void)c; + unqualified_checker> c{}; return c.check(L, index, std::forward(handler), tracking); } } @@ -11876,9 +11884,7 @@ namespace sol { } else { using Tu = meta::unqualified_t; - qualified_checker> c; - // VC++ has a bad warning here: shut it up - (void)c; + qualified_checker> c{}; return c.check(L, index, std::forward(handler), tracking); } } @@ -11932,7 +11938,6 @@ namespace sol { } else { unqualified_check_getter cg {}; - (void)cg; return cg.get(L, index, std::forward(handler), tracking); } } @@ -11956,7 +11961,6 @@ namespace sol { } else { qualified_check_getter cg {}; - (void)cg; return cg.get(L, index, std::forward(handler), tracking); } } @@ -12012,7 +12016,7 @@ namespace sol { template auto unqualified_get(lua_State* L, int index, record& tracking) -> decltype(stack_detail::unchecked_unqualified_get(L, index, tracking)) { -#if SOL_IS_ON(SOL_SAFE_GETTER_I_) +#if SOL_IS_ON(SOL_SAFE_GETTER) static constexpr bool is_op = meta::is_optional_v; if constexpr (is_op) { return stack_detail::unchecked_unqualified_get(L, index, tracking); @@ -12037,7 +12041,7 @@ namespace sol { template auto get(lua_State* L, int index, record& tracking) -> decltype(stack_detail::unchecked_get(L, index, tracking)) { -#if SOL_IS_ON(SOL_SAFE_GETTER_I_) +#if SOL_IS_ON(SOL_SAFE_GETTER) static constexpr bool is_op = meta::is_optional_v; if constexpr (is_op) { return stack_detail::unchecked_get(L, index, tracking); @@ -12331,7 +12335,7 @@ namespace sol { #include #include #include -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) #include #endif // variant shenanigans @@ -12415,7 +12419,7 @@ namespace sol { namespace stack { } else if constexpr (meta::any_same_v= 503 // Lua 5.3 and greater checks for numeric precision -#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_) +#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS) // imprecise, sloppy conversions int isnum = 0; lua_tointegerx(L_, index, &isnum); @@ -12437,7 +12441,7 @@ namespace sol { namespace stack { // expected type, actual type handler(L_, index, type::number, type_of(L_, index), detail::not_a_number_or_number_string_integral); } -#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) +#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS) // this check is precise, do not convert if (lua_isinteger(L_, index) == 1) { return true; @@ -12459,7 +12463,7 @@ namespace sol { namespace stack { return success; #else // Lua 5.2 and below checks -#if SOL_IS_OFF(SOL_STRINGS_ARE_NUMBERS_I_) +#if SOL_IS_OFF(SOL_STRINGS_ARE_NUMBERS) // must pre-check, because it will convert type t = type_of(L_, index); if (t != type::number) { @@ -12469,7 +12473,7 @@ namespace sol { namespace stack { } #endif // Do not allow strings to be numbers -#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) +#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS) int isnum = 0; const lua_Number v = lua_tonumberx(L_, index, &isnum); const bool success = isnum != 0 && static_cast(llround(v)) == v; @@ -12478,9 +12482,9 @@ namespace sol { namespace stack { #endif // Safe numerics and number precision checking if (!success) { // Use defines to provide a better error message! -#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_) +#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS) handler(L_, index, type::number, type_of(L_, index), detail::not_a_number_or_number_string); -#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) +#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS) handler(L_, index, type::number, t, detail::not_a_number_or_number_string); #else handler(L_, index, type::number, t, detail::not_a_number); @@ -12491,7 +12495,7 @@ namespace sol { namespace stack { } else if constexpr (std::is_floating_point_v || std::is_same_v) { tracking.use(1); -#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_) +#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS) bool success = lua_isnumber(L_, index) == 1; if (!success) { // expected type, actual type @@ -12670,7 +12674,7 @@ namespace sol { namespace stack { } return stack::unqualified_check(L_, index, &no_panic, tracking); } -#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) else if constexpr (std::is_function_v || (std::is_pointer_v && std::is_function_v>)) { return stack_detail::check_function_pointer>(L_, index, std::forward(handler), tracking); } @@ -12807,13 +12811,13 @@ namespace sol { namespace stack { return true; } else { -#if SOL_IS_ON(SOL_USE_INTEROP_I_) +#if SOL_IS_ON(SOL_USE_INTEROP) if (stack_detail::interop_check(L_, index, indextype, handler, tracking)) { return true; } #endif // interop extensibility tracking.use(1); -#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) if (lua_iscfunction(L_, index) != 0) { // a potential match... return true; @@ -12838,7 +12842,7 @@ namespace sol { namespace stack { bool success = false; bool has_derived = derive::value || weak_derive::value; if (has_derived) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L_, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow auto pn = stack::pop_n(L_, 1); @@ -12894,7 +12898,7 @@ namespace sol { namespace stack { } }; -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) template struct unqualified_checker, type::poly> { @@ -13347,7 +13351,7 @@ namespace sol { #include #include #include -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) #include #endif // Apple clang screwed up @@ -13479,7 +13483,7 @@ namespace sol { namespace stack { luaL_Stream* pstream = static_cast(lua_touserdata(L, index)); return *pstream; } -#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) else if constexpr (std::is_function_v || (std::is_pointer_v && std::is_function_v>)) { return stack_detail::get_function_pointer>(L, index, tracking); } @@ -13520,7 +13524,7 @@ namespace sol { namespace stack { } actual r {}; if constexpr (!derive::value) { -#if SOL_IS_ON(SOL_DEBUG_BUILD_I_) +#if SOL_IS_ON(SOL_DEBUG_BUILD) // In debug mode we would rather abort you for this grave failure rather // than let you deref a null pointer and fuck everything over std::abort(); @@ -13557,7 +13561,7 @@ namespace sol { namespace stack { // uh oh.. break; } -#if SOL_IS_ON(SOL_DEBUG_BUILD_I_) +#if SOL_IS_ON(SOL_DEBUG_BUILD) // In debug mode we would rather abort you for this grave failure rather // than let you deref a null pointer and fuck everything over std::abort(); @@ -13665,8 +13669,8 @@ namespace sol { namespace stack { } bool isnil = false; for (int vi = 0; vi < lua_size::value; ++vi) { -#if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES_I_) && SOL_LUA_VERSION_I_ >= 600 -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES) && SOL_LUA_VERSION_I_ >= 600 +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushinteger(L, static_cast(i + vi)); @@ -13686,7 +13690,7 @@ namespace sol { namespace stack { if (i == 0) { break; } -#if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES_I_) && SOL_LUA_VERSION_I_ >= 600 +#if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES) && SOL_LUA_VERSION_I_ >= 600 lua_pop(L, vi); #else lua_pop(L, (vi + 1)); @@ -13696,7 +13700,7 @@ namespace sol { namespace stack { } } if (isnil) { -#if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES_I_) && SOL_LUA_VERSION_I_ >= 600 +#if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES) && SOL_LUA_VERSION_I_ >= 600 #else lua_pop(L, lua_size::value); #endif @@ -13714,7 +13718,7 @@ namespace sol { namespace stack { // see above comment goto done; } -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 2, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow bool isnil = false; @@ -13753,7 +13757,7 @@ namespace sol { namespace stack { static T get(types, lua_State* L, int relindex, record& tracking) { tracking.use(1); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 3, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow @@ -13796,7 +13800,7 @@ namespace sol { namespace stack { template static C get(types, lua_State* L, int relindex, record& tracking) { tracking.use(1); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 3, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow @@ -13861,7 +13865,7 @@ namespace sol { namespace stack { static C get(types, lua_State* L, int relindex, record& tracking) { tracking.use(1); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 3, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow @@ -13891,23 +13895,17 @@ namespace sol { namespace stack { typedef typename T::value_type P; typedef typename P::first_type K; typedef typename P::second_type V; - unqualified_getter> g; - // VC++ has a bad warning here: shut it up - (void)g; + unqualified_getter> g{}; return g.get(types>(), L, index, tracking); } else { typedef typename T::value_type V; - unqualified_getter> g; - // VC++ has a bad warning here: shut it up - (void)g; + unqualified_getter> g{}; return g.get(types>(), L, index, tracking); } } else { - unqualified_getter g; - // VC++ has a bad warning here: shut it up - (void)g; + unqualified_getter g{}; return g.get(L, index, tracking); } } @@ -14193,7 +14191,7 @@ namespace sol { namespace stack { struct unqualified_getter> { static T* get_no_lua_nil(lua_State* L, int index, record& tracking) { void* memory = lua_touserdata(L, index); -#if SOL_IS_ON(SOL_USE_INTEROP_I_) +#if SOL_IS_ON(SOL_USE_INTEROP) auto ugr = stack_detail::interop_get(L, index, memory, tracking); if (ugr.first) { return ugr.second; @@ -14243,9 +14241,7 @@ namespace sol { namespace stack { tracking.use(1); return nullptr; } - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get_no_lua_nil(L, index, tracking); } }; @@ -14253,9 +14249,7 @@ namespace sol { namespace stack { template struct unqualified_getter> { static T* get(lua_State* L, int index, record& tracking) { - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get_no_lua_nil(L, index, tracking); } }; @@ -14263,9 +14257,7 @@ namespace sol { namespace stack { template struct unqualified_getter { static T& get(lua_State* L, int index, record& tracking) { - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get(L, index, tracking); } }; @@ -14273,9 +14265,7 @@ namespace sol { namespace stack { template struct unqualified_getter> { static T& get(lua_State* L, int index, record& tracking) { - unqualified_getter g; - // Avoid VC++ warning - (void)g; + unqualified_getter g{}; return g.get(L, index, tracking); } }; @@ -14283,20 +14273,16 @@ namespace sol { namespace stack { template struct unqualified_getter { static T* get(lua_State* L, int index, record& tracking) { -#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) if constexpr (std::is_function_v) { return stack_detail::get_function_pointer(L, index, tracking); } else { - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get(L, index, tracking); } #else - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get(L, index, tracking); #endif } @@ -14332,7 +14318,7 @@ namespace sol { namespace stack { } }; -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) template struct unqualified_getter> { @@ -14394,7 +14380,7 @@ namespace sol { namespace stack { #include #include #include -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) #include #endif // variant shenanigans (thanks, Mac OSX) @@ -14437,7 +14423,7 @@ namespace sol { namespace stack { int isnum = 0; const lua_Number value = lua_tonumberx(L, index, &isnum); if (isnum != 0) { -#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) +#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS) const auto integer_value = llround(value); if (static_cast(integer_value) == value) { tracking.use(1); @@ -14500,7 +14486,7 @@ namespace sol { namespace stack { } }; -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) template struct unqualified_check_getter, C> { typedef std::variant V; @@ -14550,6 +14536,11 @@ namespace sol { namespace stack { namespace sol { namespace stack { +#if SOL_IS_ON(SOL_COMPILER_GCC) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + namespace stack_detail { template OptionalType get_optional(lua_State* L, int index, Handler&& handler, record& tracking) { @@ -14590,9 +14581,8 @@ namespace sol { namespace stack { actual* mem = static_cast(memory); return static_cast(*mem); } - actual r {}; if constexpr (!derive::value) { - return {}; + return OptionalType(); } else { memory = detail::align_usertype_unique_tag(memory); @@ -14600,6 +14590,7 @@ namespace sol { namespace stack { memory = detail::align_usertype_unique(memory); string_view ti = usertype_traits::qualified_name(); int cast_operation; + actual r {}; if constexpr (is_actual_type_rebindable_for_v) { using rebound_actual_type = unique_usertype_rebind_actual_t; string_view rebind_ti = usertype_traits::qualified_name(); @@ -14623,19 +14614,23 @@ namespace sol { namespace stack { default: break; } - return {}; + return OptionalType(); } } else { if (!check(L, index, std::forward(handler))) { tracking.use(static_cast(!lua_isnone(L, index))); - return {}; + return OptionalType(); } return OptionalType(stack_detail::unchecked_get(L, index, tracking)); } } } // namespace stack_detail +#if SOL_IS_ON(SOL_COMPILER_GCC) +#pragma GCC diagnostic pop +#endif + template struct qualified_check_getter { typedef decltype(stack_detail::unchecked_get(nullptr, -1, std::declval())) R; @@ -14668,10 +14663,38 @@ namespace sol { namespace stack { #include #include #include -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) #include #endif // Can use variant +// beginning of sol/debug.hpp + +#include + +namespace sol { namespace detail { namespace debug { + inline std::string dump_types(lua_State* L) { + std::string visual; + std::size_t size = lua_gettop(L) + 1; + for (std::size_t i = 1; i < size; ++i) { + if (i != 1) { + visual += " | "; + } + visual += type_name(L, stack::get(L, static_cast(i))); + } + return visual; + } + + inline void print_stack(lua_State* L) { + std::cout << dump_types(L) << std::endl; + } + + inline void print_section(const std::string& message, lua_State* L) { + std::cout << "-- " << message << " -- [ " << dump_types(L) << " ]" << std::endl; + } +}}} // namespace sol::detail::debug + +// end of sol/debug.hpp + namespace sol { namespace stack { namespace stack_detail { template @@ -14683,7 +14706,7 @@ namespace sol { namespace stack { constexpr bool is_same_signedness = (std::is_signed_v && std::is_signed_v) || (std::is_unsigned_v && std::is_unsigned_v); constexpr bool probaby_fits_within_lua_Integer = sizeof(T) == sizeof(lua_Integer) -#if SOL_IS_ON(SOL_ALL_INTEGER_VALUES_FIT_I_) +#if SOL_IS_ON(SOL_ALL_INTEGER_VALUES_FIT) && ((std::has_unique_object_representations_v && std::has_unique_object_representations_v) ? true : is_same_signedness) #else && is_same_signedness @@ -14706,7 +14729,7 @@ namespace sol { namespace stack { int msvc_is_ass_with_if_constexpr_push_enum(std::true_type, lua_State* L, const T& value) { if constexpr (meta::any_same_v, char -#if SOL_IS_ON(SOL_CHAR8_T_I_) +#if SOL_IS_ON(SOL_CHAR8_T) , char8_t #endif @@ -14732,7 +14755,7 @@ namespace sol { namespace stack { } // namespace stack_detail inline int push_environment_of(lua_State* L, int target_index = -1) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_environment); #endif // make sure stack doesn't overflow #if SOL_LUA_VERSION_I_ < 502 @@ -14772,14 +14795,18 @@ namespace sol { namespace stack { int push_environment_of(const T& target) { lua_State* target_L = target.lua_state(); int target_index = absolute_index(target_L, -target.push()); - return push_environment_of(target_L, target_index); + int env_count = push_environment_of(target_L, target_index); + sol_c_assert(env_count == 1); + lua_rotate(target_L, target_index, 1); + lua_pop(target_L, 1); + return env_count; } template struct unqualified_pusher> { template static int push_fx(lua_State* L, F&& f, Args&&... args) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_userdata); #endif // make sure stack doesn't overflow // Basically, we store all user-data like this: @@ -14824,7 +14851,7 @@ namespace sol { namespace stack { static int push_fx(lua_State* L, F&& f, T* obj) { if (obj == nullptr) return stack::push(L, lua_nil); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_userdata); #endif // make sure stack doesn't overflow T** pref = detail::usertype_allocate_pointer(L); @@ -14880,7 +14907,7 @@ namespace sol { namespace stack { template static int push_deep(lua_State* L, Args&&... args) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_userdata); #endif // make sure stack doesn't overflow element** pointer_to_memory = nullptr; @@ -14926,7 +14953,7 @@ namespace sol { namespace stack { return p[0]; } else if constexpr (std::is_same_v) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushboolean(L, std::forward(args)...); @@ -14934,7 +14961,7 @@ namespace sol { namespace stack { } else if constexpr (std::is_integral_v || std::is_same_v) { const Tu& value(std::forward(args)...); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_integral); #endif // make sure stack doesn't overflow #if SOL_LUA_VERSION_I_ >= 503 @@ -14943,11 +14970,11 @@ namespace sol { namespace stack { return 1; } #endif // Lua 5.3 and above -#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) +#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS) if (static_cast(llround(static_cast(value))) != value) { -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) // Is this really worth it? - assert(false && "integer value will be misrepresented in lua"); + sol_m_assert(false, "integer value will be misrepresented in lua"); lua_pushinteger(L, static_cast(value)); return 1; #else @@ -14959,7 +14986,7 @@ namespace sol { namespace stack { return 1; } else if constexpr (std::is_floating_point_v || std::is_same_v) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_floating); #endif // make sure stack doesn't overflow lua_pushnumber(L, std::forward(args)...); @@ -14969,7 +14996,7 @@ namespace sol { namespace stack { luaL_Stream* source { std::forward(args)... }; luaL_Stream* stream = static_cast(detail::alloc_newuserdata(L, sizeof(luaL_Stream))); stream->f = source->f; -#if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_) +#if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION) stream->closef = source->closef; #endif // LuaJIT and Lua 5.1 and below do not have return 1; @@ -14978,7 +15005,7 @@ namespace sol { namespace stack { luaL_Stream& source(std::forward(args)...); luaL_Stream* stream = static_cast(detail::alloc_newuserdata(L, sizeof(luaL_Stream))); stream->f = source.f; -#if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_) +#if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION) stream->closef = source.closef; #endif // LuaJIT and Lua 5.1 and below do not have return 1; @@ -15054,7 +15081,7 @@ namespace sol { namespace stack { lua_seti(L, tableindex, static_cast(index++)); } #else -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushinteger(L, static_cast(index)); @@ -15067,7 +15094,7 @@ namespace sol { namespace stack { int firstindex = tableindex + 1 + 1; for (int pi = 0; pi < p; ++pi) { stack::push(L, index); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushvalue(L, firstindex); @@ -15137,8 +15164,6 @@ namespace sol { namespace stack { struct unqualified_pusher> { static int push(lua_State* L, const std::initializer_list& il) noexcept { unqualified_pusher>> p {}; - // silence annoying VC++ warning - (void)p; return p.push(L, il); } }; @@ -15146,7 +15171,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, lua_nil_t) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushnil(L); @@ -15164,7 +15189,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, metatable_key_t) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushlstring(L, to_string(meta_function::metatable).c_str(), 4); @@ -15175,7 +15200,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher> { static int push(lua_State* L, lua_CFunction func, int n = 0) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushcclosure(L, func, n); @@ -15186,7 +15211,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, lua_CFunction func, int n = 0) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushcclosure(L, func, n); @@ -15194,11 +15219,11 @@ namespace sol { namespace stack { } }; -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) template <> struct unqualified_pusher> { static int push(lua_State* L, detail::lua_CFunction_noexcept func, int n = 0) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushcclosure(L, func, n); @@ -15209,7 +15234,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, detail::lua_CFunction_noexcept func, int n = 0) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushcclosure(L, func, n); @@ -15221,7 +15246,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, c_closure cc) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushcclosure(L, cc.c_function, cc.upvalues); @@ -15247,7 +15272,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, void* userdata) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushlightuserdata(L, userdata); @@ -15258,7 +15283,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, const void* userdata) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushlightuserdata(L, const_cast(userdata)); @@ -15269,7 +15294,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, lightuserdata_value userdata) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushlightuserdata(L, userdata); @@ -15280,10 +15305,10 @@ namespace sol { namespace stack { template struct unqualified_pusher> { static int push(lua_State* L, light l) noexcept { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow - lua_pushlightuserdata(L, static_cast(l.value)); + lua_pushlightuserdata(L, static_cast(l.value())); return 1; } }; @@ -15292,14 +15317,14 @@ namespace sol { namespace stack { struct unqualified_pusher> { template static int push_with(lua_State* L, Key&& name, Args&&... args) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_userdata); #endif // make sure stack doesn't overflow // A dumb pusher T* data = detail::user_allocate(L); if (with_meta) { // Make sure we have a plain GC set for this data -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow if (luaL_newmetatable(L, name) != 0) { @@ -15355,7 +15380,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, userdata_value data) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_userdata); #endif // make sure stack doesn't overflow void** ud = detail::usertype_allocate_pointer(L); @@ -15367,7 +15392,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push_sized(lua_State* L, const char* str, std::size_t len) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow lua_pushlstring(L, str, len); @@ -15419,7 +15444,7 @@ namespace sol { namespace stack { template struct unqualified_pusher { static int push(lua_State* L, const char (&str)[N]) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow lua_pushlstring(L, str, std::char_traits::length(str)); @@ -15427,7 +15452,7 @@ namespace sol { namespace stack { } static int push(lua_State* L, const char (&str)[N], std::size_t sz) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow lua_pushlstring(L, str, sz); @@ -15443,11 +15468,11 @@ namespace sol { namespace stack { } }; -#if SOL_IS_ON(SOL_CHAR8_T_I_) +#if SOL_IS_ON(SOL_CHAR8_T) template <> struct unqualified_pusher { static int push_sized(lua_State* L, const char8_t* str, std::size_t len) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow lua_pushlstring(L, reinterpret_cast(str), len); @@ -15499,7 +15524,7 @@ namespace sol { namespace stack { template struct unqualified_pusher { static int push(lua_State* L, const char8_t (&str)[N]) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow const char* str_as_char = reinterpret_cast(static_cast(str)); @@ -15508,7 +15533,7 @@ namespace sol { namespace stack { } static int push(lua_State* L, const char8_t (&str)[N], std::size_t sz) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow lua_pushlstring(L, str, sz); @@ -15532,7 +15557,7 @@ namespace sol { namespace stack { return stack::push(L, str.data(), str.size()); } else { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow lua_pushlstring(L, str.c_str(), str.size()); @@ -15545,7 +15570,7 @@ namespace sol { namespace stack { return stack::push(L, str.data(), sz); } else { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_string); #endif // make sure stack doesn't overflow lua_pushlstring(L, str.c_str(), sz); @@ -15568,7 +15593,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, meta_function m) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_meta_function_name); #endif // make sure stack doesn't overflow const std::string& str = to_string(m); @@ -15580,7 +15605,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, absolute_index ai) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushvalue(L, ai); @@ -15591,7 +15616,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, raw_index ri) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushvalue(L, ri); @@ -15602,7 +15627,7 @@ namespace sol { namespace stack { template <> struct unqualified_pusher { static int push(lua_State* L, ref_index ri) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_rawgeti(L, LUA_REGISTRYINDEX, ri); @@ -15874,7 +15899,7 @@ namespace sol { namespace stack { struct unqualified_pusher> { template static int push(std::index_sequence, lua_State* L, T&& t) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, static_cast(sizeof...(I)), detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow int pushcount = 0; @@ -15978,7 +16003,7 @@ namespace sol { namespace stack { } }; -#if SOL_IS_ON(SOL_STD_VARIANT_I_) +#if SOL_IS_ON(SOL_STD_VARIANT) namespace stack_detail { struct push_function { @@ -16222,7 +16247,7 @@ namespace sol { namespace stack { } } else { - if constexpr (meta::is_c_str_v) { + if constexpr (meta::is_c_str_or_string_v) { if constexpr (global) { push(L, std::forward(value)); lua_setglobal(L, &key[0]); @@ -16400,9 +16425,9 @@ namespace sol { } } - inline void clear_entries(const reference& regisTryreference) { - auto pp = stack::push_pop(regisTryreference); - stack_reference ref(regisTryreference.lua_state(), -1); + inline void clear_entries(const reference& registry_reference) { + auto pp = stack::push_pop(registry_reference); + stack_reference ref(registry_reference.lua_state(), -1); clear_entries(ref); } } // namespace detail @@ -16469,7 +16494,7 @@ namespace sol { template static decltype(auto) eval(types, std::index_sequence, lua_State* L_, int start_index_, Handler&& handler_, record& tracking_, Fx&& fx_, FxArgs&&... fxargs_) { -#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_) +#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS) // We can save performance/time by letting errors unwind produced arguments // rather than checking everything once, and then potentially re-doing work if constexpr (checked) { @@ -16506,7 +16531,7 @@ namespace sol { "a reference and std::move it manually if this was your intention."); argument_handler> handler {}; record tracking {}; -#if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS) if constexpr (checkargs) { multi_check(L_, start_index_, handler); } @@ -16520,11 +16545,21 @@ namespace sol { argument_types_, argument_indices_, L_, start_index_, handler, tracking, std::forward(fx_), std::forward(args_)...); } } + + template + void raw_table_set(lua_State* L, T&& arg, int tableindex = -2) { + int push_count = push(L, std::forward(arg)); + sol_c_assert(push_count == 1); + std::size_t unique_index = static_cast(luaL_len(L, tableindex) + 1u); + lua_rawseti(L, tableindex, unique_index); + } + } // namespace stack_detail template int set_ref(lua_State* L, T&& arg, int tableindex = -2) { - push(L, std::forward(arg)); + int push_count = push(L, std::forward(arg)); + sol_c_assert(push_count == 1); return luaL_ref(L, tableindex); } @@ -16639,11 +16674,11 @@ namespace sol { } inline void luajit_exception_handler(lua_State* L, int (*handler)(lua_State*, lua_CFunction) = detail::c_trampoline) { -#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_) +#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE) if (L == nullptr) { return; } -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushlightuserdata(L, (void*)handler); @@ -16656,7 +16691,7 @@ namespace sol { } inline void luajit_exception_off(lua_State* L) { -#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_) +#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE) if (L == nullptr) { return; } @@ -16747,7 +16782,7 @@ namespace sol { template bool is_stack(std::false_type) const { - int r = base_t::regisTryindex(); + int r = base_t::registry_index(); if (r == LUA_REFNIL) return meta::any_same, lua_nil_t, nullopt_t, std::nullptr_t>::value ? true : false; if (r == LUA_NOREF) @@ -17209,7 +17244,7 @@ namespace sol { typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; - protected_function_result() noexcept = default; + protected_function_result() noexcept : protected_function_result(nullptr) {} protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept : L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) { } @@ -17254,6 +17289,11 @@ namespace sol { return status() == call_status::ok || status() == call_status::yielded; } +#if SOL_IS_ON(SOL_COMPILER_GCC) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + template decltype(auto) get(int index_offset = 0) const { using UT = meta::unqualified_t; @@ -17275,7 +17315,7 @@ namespace sol { } else { if constexpr (std::is_same_v) { -#if SOL_IS_ON(SOL_SAFE_PROXIES_I_) +#if SOL_IS_ON(SOL_SAFE_PROXIES) if (valid()) { type t = type_of(L, target); type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is an error)"); @@ -17284,7 +17324,7 @@ namespace sol { return error(detail::direct_error, stack::get(L, target)); } else { -#if SOL_IS_ON(SOL_SAFE_PROXIES_I_) +#if SOL_IS_ON(SOL_SAFE_PROXIES) if (!valid()) { type t = type_of(L, target); type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is not an error)"); @@ -17295,6 +17335,10 @@ namespace sol { } } +#if SOL_IS_ON(SOL_COMPILER_GCC) +#pragma GCC diagnostic pop +#endif + type get_type(int index_offset = 0) const noexcept { return type_of(L, index + static_cast(index_offset)); } @@ -17371,7 +17415,7 @@ namespace sol { template <> struct unqualified_pusher { static int push(lua_State* L, const protected_function_result& pfr) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, static_cast(pfr.pop_count()), detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow int p = 0; @@ -17409,7 +17453,7 @@ namespace sol { typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; - unsafe_function_result() noexcept = default; + unsafe_function_result() noexcept : unsafe_function_result(nullptr) {} unsafe_function_result(lua_State* Ls, int idx = -1, int retnum = 0) noexcept : L(Ls), index(idx), returncount(retnum) { } @@ -17516,7 +17560,9 @@ namespace sol { returncount = 0; } ~unsafe_function_result() { - lua_pop(L, returncount); + if (L != nullptr) { + lua_pop(L, returncount); + } } }; @@ -17789,7 +17835,7 @@ namespace sol { template struct wrapper : public member_function_wrapper { }; -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) // noexcept has become a part of a function's type template @@ -18043,7 +18089,7 @@ namespace sol { lua_createtable(L, static_cast(sizeof...(In)), 0); stack_reference deps(L, -1); auto per_dep = [&L, &deps](int i) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushvalue(L, i); @@ -18068,7 +18114,7 @@ namespace sol { } lua_createtable(L, static_cast(sdeps.size()), 0); stack_reference deps(L, -1); -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, static_cast(sdeps.size()), detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow for (std::size_t i = 0; i < sdeps.size(); ++i) { @@ -18418,7 +18464,7 @@ namespace sol { } }; -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) template struct agnostic_lua_call_wrapper { static int call(lua_State* L, detail::lua_CFunction_noexcept f) { @@ -18471,7 +18517,7 @@ namespace sol { "It seems like you might have accidentally bound a class type with a member function method that does not correspond to the " "class. For example, there could be a small type in your new_usertype(...) binding, where you specify one class \"T\" " "but then bind member methods from a complete unrelated class. Check things over!"); -#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) +#if SOL_IS_ON(SOL_SAFE_USERTYPE) auto maybeo = stack::check_get(L, 1); if (!maybeo || maybeo.value() == nullptr) { return luaL_error(L, @@ -18504,7 +18550,7 @@ namespace sol { "It seems like you might have accidentally bound a class type with a member function method that does not correspond " "to the class. For example, there could be a small type in your new_usertype(...) binding, where you specify one " "class \"T\" but then bind member methods from a complete unrelated class. Check things over!"); -#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) +#if SOL_IS_ON(SOL_SAFE_USERTYPE) auto maybeo = stack::check_get(L, 1); if (!maybeo || maybeo.value() == nullptr) { if (is_variable) { @@ -18562,7 +18608,7 @@ namespace sol { } else { using Ta = meta::conditional_t, object_type, T>; -#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) +#if SOL_IS_ON(SOL_SAFE_USERTYPE) auto maybeo = stack::check_get(L, 1); if (!maybeo || maybeo.value() == nullptr) { if (is_variable) { @@ -18800,7 +18846,7 @@ namespace sol { using args_list = meta::pop_front_type_t; using Ta = T; using Oa = std::remove_pointer_t; -#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) +#if SOL_IS_ON(SOL_SAFE_USERTYPE) auto maybeo = stack::check_get(L, 1); if (!maybeo || maybeo.value() == nullptr) { if (is_variable) { @@ -19044,7 +19090,7 @@ namespace sol { typedef meta::unqualified_t Fu; typedef std::integral_constant::value -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) || std::is_same::value #endif > @@ -19085,7 +19131,7 @@ namespace sol { namespace function_detail { using traits_type = meta::bind_traits; static int real_call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19120,7 +19166,7 @@ namespace sol { namespace function_detail { typedef lua_bind_traits traits_type; static int real_call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19138,7 +19184,7 @@ namespace sol { namespace function_detail { template static int call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19160,7 +19206,7 @@ namespace sol { namespace function_detail { } int operator()(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19176,7 +19222,7 @@ namespace sol { namespace function_detail { typedef lua_bind_traits traits_type; static int real_call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19203,7 +19249,7 @@ namespace sol { namespace function_detail { template static int call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19225,7 +19271,7 @@ namespace sol { namespace function_detail { } int operator()(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19241,7 +19287,7 @@ namespace sol { namespace function_detail { typedef lua_bind_traits traits_type; static int real_call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19266,7 +19312,7 @@ namespace sol { namespace function_detail { template static int call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19288,7 +19334,7 @@ namespace sol { namespace function_detail { } int operator()(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19304,7 +19350,7 @@ namespace sol { namespace function_detail { typedef lua_bind_traits traits_type; static int real_call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19318,7 +19364,7 @@ namespace sol { namespace function_detail { template static int call(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19340,7 +19386,7 @@ namespace sol { namespace function_detail { } int operator()(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19483,7 +19529,7 @@ namespace sol { namespace function_detail { } static int call(lua_State* L, member_function& self) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19499,7 +19545,7 @@ namespace sol { namespace function_detail { } int operator()(lua_State* L) -#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#if SOL_IS_ON(SOL_COMPILER_VCXX) // MSVC is broken, what a surprise... #else noexcept(traits_type::is_noexcept) @@ -19936,7 +19982,7 @@ namespace sol { int upvalues = 0; upvalues += stack::push(L, nullptr); upvalues += stack::push(L, std::forward(fx)); -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) if constexpr (std::is_nothrow_invocable_r_v) { detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper; lua_pushcclosure(L, reinterpret_cast(cf), upvalues); @@ -19956,7 +20002,7 @@ namespace sol { int upvalues = 0; upvalues += stack::push(L, nullptr); upvalues += stack::push(L, std::forward(fx)); -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) if constexpr (std::is_nothrow_invocable_r_v) { detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper; lua_pushcclosure(L, reinterpret_cast(cf), upvalues); @@ -20117,7 +20163,7 @@ namespace sol { struct unqualified_pusher>, meta::neg>, meta::neg>> -#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) +#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) , meta::neg>, meta::neg>> @@ -20430,7 +20476,7 @@ namespace sol { namespace stack_detail { template bool check_function_pointer(lua_State* L, int index, Handler&& handler, record& tracking) noexcept { -#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) tracking.use(1); bool success = lua_iscfunction(L, index) == 1; if (success) { @@ -20456,7 +20502,7 @@ namespace sol { template Function* get_function_pointer(lua_State* L, int index, record& tracking) noexcept { -#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) tracking.use(1); auto udata = stack::stack_detail::get_as_upvalues_using_function(L, index); Function* fx = udata.first; @@ -20466,7 +20512,7 @@ namespace sol { (void)index; (void)tracking; static_assert(meta::meta_detail::always_true::value, -#if SOL_IS_DEFAULT_OFF(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) +#if SOL_IS_DEFAULT_OFF(SOL_GET_FUNCTION_POINTER_UNSAFE) "You are attempting to retrieve a function pointer type. " "This is inherently unsafe in sol2. In order to do this, you must turn on the " "SOL_GET_FUNCTION_POINTER_UNSAFE configuration macro, as detailed in the documentation. " @@ -20524,7 +20570,7 @@ namespace sol { } inline int dump_throw_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) { -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) return dump_panic_on_error(L_, result_code, writer_function, userdata_pointer_, strip); #else (void)L_; @@ -20585,7 +20631,7 @@ namespace sol { meta::enable, basic_function>>, meta::neg>, meta::neg>>, is_lua_reference>> = meta::enabler> basic_function(T&& r) noexcept : base_t(std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_function>::value) { auto pp = stack::push_pop(*this); constructor_handler handler {}; @@ -20605,20 +20651,20 @@ namespace sol { } template >> = meta::enabler> basic_function(lua_State* L, T&& r) : base_t(L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); #endif // Safety } basic_function(lua_State* L, int index = -1) : base_t(L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_function(lua_State* L, ref_index index) : base_t(L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -20745,7 +20791,7 @@ namespace sol { namespace detail { return; } if (!ref.valid()) { -#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) +#if SOL_IS_ON(SOL_SAFE_STACK_CHECK) luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); #endif // make sure stack doesn't overflow lua_pushnil(L); @@ -20802,7 +20848,7 @@ namespace sol { meta::neg>>, meta::neg>, meta::neg>>, is_lua_reference>> = meta::enabler> basic_protected_function(T&& r) noexcept : base_t(std::forward(r)), m_error_handler(get_default_handler(r.lua_state())) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_function>::value) { auto pp = stack::push_pop(*this); constructor_handler handler {}; @@ -20860,7 +20906,7 @@ namespace sol { } template >> = meta::enabler> basic_protected_function(lua_State* L_, T&& r, handler_t eh) : base_t(L_, std::forward(r)), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -20873,7 +20919,7 @@ namespace sol { basic_protected_function(lua_State* L_, int index_ = -1) : basic_protected_function(L_, index_, get_default_handler(L_)) { } basic_protected_function(lua_State* L_, int index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L_, index_, handler); #endif // Safety @@ -20881,7 +20927,7 @@ namespace sol { basic_protected_function(lua_State* L_, absolute_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) { } basic_protected_function(lua_State* L_, absolute_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L_, index_, handler); #endif // Safety @@ -20889,7 +20935,7 @@ namespace sol { basic_protected_function(lua_State* L_, raw_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) { } basic_protected_function(lua_State* L_, raw_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L_, index_, handler); #endif // Safety @@ -20897,7 +20943,7 @@ namespace sol { basic_protected_function(lua_State* L_, ref_index index_) : basic_protected_function(L_, index_, get_default_handler(L_)) { } basic_protected_function(lua_State* L_, ref_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -21009,7 +21055,7 @@ namespace sol { return stack_reference(lua_state(), m_error_handler.stack_index()); } else { - return basic_reference>(lua_state(), ref_index(m_error_handler.regisTryindex())); + return basic_reference>(lua_state(), ref_index(m_error_handler.registry_index())); } } else { @@ -21066,14 +21112,14 @@ namespace sol { int firstreturn = 1; int returncount = 0; call_status code = call_status::ok; -#if SOL_IS_ON(SOL_EXCEPTIONS_I_) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_) +#if SOL_IS_ON(SOL_EXCEPTIONS) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS) try { #endif // No Exceptions firstreturn = (std::max)(1, static_cast(stacksize - n - static_cast(h.valid() && !is_stack_handler_v))); code = luacall(n, LUA_MULTRET, h); poststacksize = lua_gettop(lua_state()) - static_cast(h.valid() && !is_stack_handler_v); returncount = poststacksize - (firstreturn - 1); -#if SOL_IS_ON(SOL_EXCEPTIONS_I_) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_) +#if SOL_IS_ON(SOL_EXCEPTIONS) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS) } // Handle C++ errors thrown from C++ functions bound inside of lua catch (const char* error) { @@ -21091,7 +21137,7 @@ namespace sol { firstreturn = lua_gettop(lua_state()); return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime); } -#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL_I_) +#if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL) // LuaJIT cannot have the catchall when the safe propagation is on // but LuaJIT will swallow all C++ errors // if we don't at least catch std::exception ones @@ -21742,7 +21788,7 @@ namespace sol { iterator it; std::size_t index; - iter(lua_State* L_, int stack_index, T& source_, iterator it_) : keep_alive(L_, stack_index), source(source_), it(std::move(it_)), index(0) { + iter(lua_State* L_, int stack_index, T& source_, iterator it_) : keep_alive(sol::main_thread(L_, L_), stack_index), source(source_), it(std::move(it_)), index(0) { } ~iter() { @@ -21750,7 +21796,7 @@ namespace sol { }; static auto& get_src(lua_State* L_) { -#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) +#if SOL_IS_ON(SOL_SAFE_USERTYPE) auto p = stack::unqualified_check_get(L_, 1); if (!p) { luaL_error(L_, @@ -22619,17 +22665,18 @@ namespace sol { T& source; iterator it; - iter(lua_State* L_, int stack_index, T& source, iterator it) noexcept : keep_alive(L_, stack_index), source(source), it(std::move(it)) { + iter(lua_State* L_, int stack_index, T& source, iterator it) noexcept + : keep_alive(sol::main_thread(L_, L_), stack_index), source(source), it(std::move(it)) { } - ~iter () { + ~iter() { } }; static auto& get_src(lua_State* L_) { auto p = stack::unqualified_check_get(L_, 1); -#if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) +#if SOL_IS_ON(SOL_SAFE_USERTYPE) if (!p) { luaL_error(L_, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", @@ -23225,7 +23272,7 @@ namespace sol { return s; } -#if SOL_IS_ON(SOL_CHAR8_T_I_) +#if SOL_IS_ON(SOL_CHAR8_T) inline auto make_string_view(const char8_t* s) { return string_view(reinterpret_cast(s)); } @@ -23371,6 +23418,7 @@ namespace sol { #include #include +#include namespace sol { namespace u_detail { @@ -23408,11 +23456,11 @@ namespace sol { namespace u_detail { template struct binding : binding_base { using uF = meta::unqualified_t; - using F = meta::conditional_t -#if SOL_IS_ON(SOL_CHAR8_T_I_) - || meta::is_c_str_or_string_of_v + using F = meta::conditional_t +#if SOL_IS_ON(SOL_CHAR8_T) + || meta::is_c_str_of_v #endif - || meta::is_c_str_or_string_of_v || meta::is_c_str_or_string_of_v || meta::is_c_str_or_string_of_v, + || meta::is_c_str_of_v || meta::is_c_str_of_v || meta::is_c_str_of_v, std::add_pointer_t>>, std::decay_t>; F data_; @@ -23649,12 +23697,15 @@ namespace sol { namespace u_detail { usertype_storage_base(lua_State* L_) : m_L(L_) , storage() + , string_keys_storage() , string_keys() , auxiliary_keys(0, stateless_reference_hash(L_), stateless_reference_equals(L_)) , value_index_table() , reference_index_table() , unique_index_table() , const_reference_index_table() + , const_value_index_table() + , named_index_table() , type_table(make_reference(L_, create)) , gc_names_table(make_reference(L_, create)) , named_metatable(make_reference(L_, create)) @@ -23801,7 +23852,7 @@ namespace sol { namespace u_detail { } (void)L_; (void)self; -#if SOL_IS_ON(SOL_USE_UNSAFE_BASE_LOOKUP_I_) +#if SOL_IS_ON(SOL_USE_UNSAFE_BASE_LOOKUP) usertype_storage_base& base_storage = get_usertype_storage(L_); base_result = self_index_call(bases(), L_, base_storage); #else @@ -24143,7 +24194,7 @@ namespace sol { namespace u_detail { } template - inline void clear_usertype_regisTrynames(lua_State* L) { + inline void clear_usertype_registry_names(lua_State* L) { using u_traits = usertype_traits; using u_const_traits = usertype_traits; using u_unique_traits = usertype_traits>; @@ -24166,7 +24217,7 @@ namespace sol { namespace u_detail { template inline int destroy_usertype_storage(lua_State* L) noexcept { - clear_usertype_regisTrynames(L); + clear_usertype_registry_names(L); return detail::user_alloc_destroy>(L); } @@ -24278,7 +24329,7 @@ namespace sol { namespace u_detail { usertype_storage& target_umt = stack::pop>>(L); target_umt.clear(); - clear_usertype_regisTrynames(L); + clear_usertype_registry_names(L); stack::set_field(L, gcmetakey, lua_nil); } @@ -24768,6 +24819,13 @@ namespace sol { return std::move(*this).set(std::move(other)); } + template + bool is() const { + typedef decltype(get()) U; + optional option = this->get>(); + return option.has_value(); + } + template decltype(auto) get() const& { using idx_seq = std::make_index_sequence>>; @@ -25667,7 +25725,7 @@ namespace sol { template >> = meta::enabler> basic_table_core(lua_State* L, T&& r) : base_t(L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); int table_index = pp.index_of(*this); constructor_handler handler {}; @@ -25682,14 +25740,14 @@ namespace sol { } basic_table_core(lua_State* L, int index = -1) : basic_table_core(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_table_core(lua_State* L, ref_index index) : basic_table_core(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); int table_index = pp.index_of(*this); constructor_handler handler {}; @@ -25701,7 +25759,7 @@ namespace sol { meta::enable, basic_table_core>>, meta::neg>, meta::neg>>, is_lua_reference>> = meta::enabler> basic_table_core(T&& r) noexcept : basic_table_core(detail::no_safety, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_table>::value) { auto pp = stack::push_pop(*this); int table_index = pp.index_of(*this); @@ -25981,7 +26039,7 @@ namespace sol { auto pp = stack::push_pop(*this); int table_index = pp.index_of(*this); lua_State* L = base_t::lua_state(); - (void)detail::swallow { 0, (stack::set_ref(L, std::forward(args), table_index), 0)... }; + (void)detail::swallow { 0, (stack::stack_detail::raw_table_set(L, std::forward(args), table_index), 0)... }; return *this; } @@ -26128,20 +26186,20 @@ namespace sol { } template >> = meta::enabler> basic_metatable(lua_State* L, T&& r) : base_t(L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); #endif // Safety } basic_metatable(lua_State* L, int index = -1) : basic_metatable(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_metatable(lua_State* L, ref_index index) : basic_metatable(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -26151,7 +26209,7 @@ namespace sol { meta::enable, basic_metatable>>, meta::neg>, meta::neg>>, is_lua_reference>> = meta::enabler> basic_metatable(T&& r) noexcept : basic_metatable(detail::no_safety, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_table>::value) { auto pp = stack::push_pop(*this); constructor_handler handler {}; @@ -26198,11 +26256,11 @@ namespace sol { return; } ustorage_base& base_storage = *static_cast(stack::get(L, -1)); - std::array regisTrytraits; - for (std::size_t i = 0; i < regisTrytraits.size(); ++i) { + std::array registry_traits; + for (std::size_t i = 0; i < registry_traits.size(); ++i) { u_detail::submetatable_type smt = static_cast(i); stack::get_field(L, smt, gc_names_table.stack_index()); - regisTrytraits[i] = stack::get(L, -1); + registry_traits[i] = stack::get(L, -1); } // get the registry @@ -26212,9 +26270,9 @@ namespace sol { // in the registry (luaL_newmetatable does // [name] = new table // in registry upon creation) - for (std::size_t i = 0; i < regisTrytraits.size(); ++i) { + for (std::size_t i = 0; i < registry_traits.size(); ++i) { u_detail::submetatable_type smt = static_cast(i); - const string_view& gcmetakey = regisTrytraits[i]; + const string_view& gcmetakey = registry_traits[i]; if (smt == u_detail::submetatable_type::named) { // use .data() to make it treat it like a c string, // which it is... @@ -26372,7 +26430,7 @@ namespace sol { } template >> = meta::enabler> basic_lua_table(lua_State* L, T&& r) : base_t(L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -26384,13 +26442,13 @@ namespace sol { } } basic_lua_table(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_lua_table(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -26400,7 +26458,7 @@ namespace sol { meta::enable, basic_lua_table>>, meta::neg>, meta::neg>>, is_lua_reference>> = meta::enabler> basic_lua_table(T&& r) noexcept : basic_lua_table(detail::no_safety, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_table>::value) { auto pp = stack::push_pop(*this); constructor_handler handler {}; @@ -26541,29 +26599,29 @@ namespace sol { basic_environment(env_key_t, const stack_reference& extraction_target) : base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(this->lua_state(), -1, handler); #endif // Safety - lua_pop(this->lua_state(), 2); + lua_pop(this->lua_state(), 1); } template basic_environment(env_key_t, const basic_reference& extraction_target) : base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(this->lua_state(), -1, handler); #endif // Safety - lua_pop(this->lua_state(), 2); + lua_pop(this->lua_state(), 1); } basic_environment(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_environment(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(L, -1, handler); @@ -26573,7 +26631,7 @@ namespace sol { meta::enable, basic_environment>>, meta::neg>, meta::neg>>, is_lua_reference>> = meta::enabler> basic_environment(T&& r) noexcept : base_t(detail::no_safety, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_environment>::value) { auto pp = stack::push_pop(*this); constructor_handler handler {}; @@ -26586,7 +26644,7 @@ namespace sol { template >> = meta::enabler> basic_environment(lua_State* L, T&& r) noexcept : base_t(detail::no_safety, L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_environment>::value) { auto pp = stack::push_pop(*this); constructor_handler handler {}; @@ -26619,11 +26677,13 @@ namespace sol { const char* success = lua_setupvalue(L, target_index, 1); if (success == nullptr) { // left things alone on the stack, pop them off - lua_pop(L, 1); + lua_pop(L, 2); return false; } + lua_pop(L, 1); return true; } + lua_pop(L, 1); return false; } else { @@ -26635,6 +26695,7 @@ namespace sol { } string_view upvalue_name(maybe_upvalue_name); if (upvalue_name == "_ENV") { + lua_pop(L, 1); this->push(); const char* success = lua_setupvalue(L, target_index, upvalue_index); if (success == nullptr) { @@ -26757,7 +26818,7 @@ namespace sol { load_status err; public: - load_result() noexcept = default; + load_result() noexcept : load_result(nullptr) {} load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept : L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) { } @@ -26824,7 +26885,7 @@ namespace sol { } else { if constexpr (std::is_same_v) { -#if SOL_IS_ON(SOL_SAFE_PROXIES_I_) +#if SOL_IS_ON(SOL_SAFE_PROXIES) if (valid()) { type_panic_c_str(L, index, type_of(L, index), type::none, "expecting an error type (a string, from Lua)"); } @@ -26832,7 +26893,7 @@ namespace sol { return error(detail::direct_error, stack::get(L, index)); } else { -#if SOL_IS_ON(SOL_SAFE_PROXIES_I_) +#if SOL_IS_ON(SOL_SAFE_PROXIES) if (!valid()) { type_panic_c_str(L, index, type_of(L, index), type::none); } @@ -26860,7 +26921,9 @@ namespace sol { }; ~load_result() { - stack::remove(L, index, popcount); + if (L != nullptr) { + stack::remove(L, index, popcount); + } } }; } // namespace sol @@ -26891,7 +26954,7 @@ namespace sol { using is_lua_value_single_constructible = meta::any, is_reference_or_lua_value_init_list>; static lua_State*& thread_local_lua_state() { -#if SOL_IS_ON(SOL_USE_THREAD_LOCAL_I_) +#if SOL_IS_ON(SOL_USE_THREAD_LOCAL) static thread_local lua_State* L = nullptr; #else static lua_State* L = nullptr; @@ -26969,7 +27032,7 @@ namespace sol { template bool is() const { - int r = ref_value.regisTryindex(); + int r = ref_value.registry_index(); if (r == LUA_REFNIL) return meta::any_same, lua_nil_t, nullopt_t, std::nullptr_t>::value ? true : false; if (r == LUA_NOREF) @@ -27004,7 +27067,7 @@ namespace sol { // end of sol/lua_value.hpp -#if SOL_IS_ON(SOL_PRINT_ERRORS_I_) +#if SOL_IS_ON(SOL_PRINT_ERRORS) #include #endif @@ -27024,7 +27087,7 @@ namespace sol { } inline int default_at_panic(lua_State* L) { -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) (void)L; return -1; #else @@ -27033,7 +27096,7 @@ namespace sol { if (message) { std::string err(message, messagesize); lua_settop(L, 0); -#if SOL_IS_ON(SOL_PRINT_ERRORS_I_) +#if SOL_IS_ON(SOL_PRINT_ERRORS) std::cerr << "[sol2] An error occurred and panic has been invoked: "; std::cerr << err; std::cerr << std::endl; @@ -27058,7 +27121,7 @@ namespace sol { const string_view& traceback = maybetraceback.value(); msg.assign(traceback.data(), traceback.size()); } -#if SOL_IS_ON(SOL_PRINT_ERRORS_I_) +#if SOL_IS_ON(SOL_PRINT_ERRORS) // std::cerr << "[sol2] An error occurred and was caught in traceback: "; // std::cerr << msg; // std::cerr << std::endl; @@ -27093,7 +27156,7 @@ namespace sol { std::string err = "sol: "; err += to_string(result.status()); err += " error"; -#if SOL_IS_ON(SOL_EXCEPTIONS_I_) +#if SOL_IS_ON(SOL_EXCEPTIONS) std::exception_ptr eptr = std::current_exception(); if (eptr) { err += " with a "; @@ -27122,7 +27185,7 @@ namespace sol { string_view serr = stack::unqualified_get(L, result.stack_index()); err.append(serr.data(), serr.size()); } -#if SOL_IS_ON(SOL_PRINT_ERRORS_I_) +#if SOL_IS_ON(SOL_PRINT_ERRORS) std::cerr << "[sol2] An error occurred and has been passed to an error handler: "; std::cerr << err; std::cerr << std::endl; @@ -27138,7 +27201,7 @@ namespace sol { if (towards != 0) { lua_rotate(L, top, towards); } -#if SOL_IS_OFF(SOL_EXCEPTIONS_I_) +#if SOL_IS_OFF(SOL_EXCEPTIONS) return result; #else // just throw our error @@ -27147,7 +27210,7 @@ namespace sol { } inline protected_function_result script_default_on_error(lua_State* L, protected_function_result pfr) { -#if SOL_IS_ON(SOL_DEFAULT_PASS_ON_ERROR_I_) +#if SOL_IS_ON(SOL_DEFAULT_PASS_ON_ERROR) return script_pass_on_error(L, std::move(pfr)); #else return script_throw_on_error(L, std::move(pfr)); @@ -27265,7 +27328,7 @@ namespace sol { for (auto&& library : libraries) { switch (library) { -#if SOL_LUA_VERSION_I_ <= 501 && SOL_IS_ON(SOL_USE_LUAJIT_I_) +#if SOL_LUA_VERSION_I_ <= 501 && SOL_IS_ON(SOL_USE_LUAJIT) case lib::coroutine: #endif // luajit opens coroutine base stuff case lib::base: @@ -27276,7 +27339,7 @@ namespace sol { luaL_requiref(L, "package", luaopen_package, 1); lua_pop(L, 1); break; -#if SOL_IS_OFF(SOL_USE_LUAJIT_I_) +#if SOL_IS_OFF(SOL_USE_LUAJIT) case lib::coroutine: #if SOL_LUA_VERSION_I_ > 501 luaL_requiref(L, "coroutine", luaopen_coroutine, 1); @@ -27297,10 +27360,10 @@ namespace sol { lua_pop(L, 1); break; case lib::bit32: -#if SOL_IS_ON(SOL_USE_LUAJIT_I_) +#if SOL_IS_ON(SOL_USE_LUAJIT) luaL_requiref(L, "bit32", luaopen_bit, 1); lua_pop(L, 1); -#elif SOL_IS_ON(SOL_LUA_BIT32_LIB_I_) +#elif SOL_IS_ON(SOL_LUA_BIT32_LIB) luaL_requiref(L, "bit32", luaopen_bit32, 1); lua_pop(L, 1); #else @@ -27319,19 +27382,19 @@ namespace sol { lua_pop(L, 1); break; case lib::utf8: -#if SOL_LUA_VERSION_I_ > 502 && SOL_IS_OFF(SOL_USE_LUAJIT_I_) +#if SOL_LUA_VERSION_I_ > 502 && SOL_IS_OFF(SOL_USE_LUAJIT) luaL_requiref(L, "utf8", luaopen_utf8, 1); lua_pop(L, 1); #endif // Lua 5.3+ only break; case lib::ffi: -#if SOL_IS_ON(SOL_USE_LUAJIT_I_) && SOL_IS_OFF(SOL_LUAJIT_FFI_DISABLED_I_) +#if SOL_IS_ON(SOL_USE_LUAJIT) && SOL_IS_OFF(SOL_LUAJIT_FFI_DISABLED) luaL_requiref(L, "ffi", luaopen_ffi, 1); lua_pop(L, 1); #endif // LuaJIT only break; case lib::jit: -#if SOL_IS_ON(SOL_USE_LUAJIT_I_) +#if SOL_IS_ON(SOL_USE_LUAJIT) luaL_requiref(L, "jit", luaopen_jit, 0); lua_pop(L, 1); #endif // LuaJIT Only @@ -27687,7 +27750,7 @@ namespace sol { return safe_script_file(filename, env, script_default_on_error, mode); } -#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) +#if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS) protected_function_result script( lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) { return safe_script(reader, data, chunkname, mode); @@ -28076,7 +28139,7 @@ namespace sol { template , basic_thread>>, is_lua_reference>> = meta::enabler> basic_thread(T&& r) : base_t(std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -28088,20 +28151,20 @@ namespace sol { basic_thread& operator=(basic_thread&&) = default; template >> = meta::enabler> basic_thread(lua_State* L, T&& r) : base_t(L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); #endif // Safety } basic_thread(lua_State* L, int index = -1) : base_t(L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_thread(lua_State* L, ref_index index) : base_t(L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -28112,7 +28175,7 @@ namespace sol { basic_thread(lua_State* L, this_state actualthread) : basic_thread(L, lua_thread_state { actualthread.L }) { } basic_thread(lua_State* L, lua_thread_state actualthread) : base_t(L, -stack::push(L, actualthread)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(lua_state(), -1, handler); #endif // Safety @@ -28269,7 +28332,7 @@ namespace sol { meta::neg>>, is_lua_reference>> = meta::enabler> basic_coroutine(T&& r) noexcept : base_t(std::forward(r)), m_error_handler(detail::get_default_handler::value>(r.lua_state())) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_function>::value) { auto pp = stack::push_pop(*this); constructor_handler handler {}; @@ -28332,7 +28395,7 @@ namespace sol { } template >> = meta::enabler> basic_coroutine(lua_State* L, T&& r, handler_t eh) : base_t(L, std::forward(r)), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -28355,7 +28418,7 @@ namespace sol { : basic_coroutine(L, index, detail::get_default_handler::value>(L)) { } basic_coroutine(lua_State* L, absolute_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety @@ -28364,7 +28427,7 @@ namespace sol { : basic_coroutine(L, index, detail::get_default_handler::value>(L)) { } basic_coroutine(lua_State* L, raw_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety @@ -28373,7 +28436,7 @@ namespace sol { : basic_coroutine(L, index, detail::get_default_handler::value>(L)) { } basic_coroutine(lua_State* L, ref_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); @@ -28441,7 +28504,7 @@ namespace sol { meta::enable, basic_userdata>>, meta::neg>, is_lua_reference>> = meta::enabler> basic_userdata(T&& r) noexcept : base_t(std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_userdata>::value) { auto pp = stack::push_pop(*this); type_assert(lua_state(), -1, type::userdata); @@ -28458,20 +28521,20 @@ namespace sol { } template >> = meta::enabler> basic_userdata(lua_State* L, T&& r) : base_t(L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(L, -1, handler); #endif // Safety } basic_userdata(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_userdata(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(L, -1, handler); @@ -28491,7 +28554,7 @@ namespace sol { meta::enable, basic_lightuserdata>>, meta::neg>, is_lua_reference>> = meta::enabler> basic_lightuserdata(T&& r) noexcept : base_t(std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) if (!is_lightuserdata>::value) { auto pp = stack::push_pop(*this); type_assert(lua_state(), -1, type::lightuserdata); @@ -28508,20 +28571,20 @@ namespace sol { } template >> = meta::enabler> basic_lightuserdata(lua_State* L, T&& r) : basic_lightuserdata(L, std::forward(r)) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), -1, handler); #endif // Safety } basic_lightuserdata(lua_State* L, int index = -1) : base_t(L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) constructor_handler handler {}; stack::check(L, index, handler); #endif // Safety } basic_lightuserdata(lua_State* L, ref_index index) : base_t(L, index) { -#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) +#if SOL_IS_ON(SOL_SAFE_REFERENCES) auto pp = stack::push_pop(*this); constructor_handler handler {}; stack::check(lua_state(), index, handler); @@ -28826,13 +28889,14 @@ namespace sol { // end of sol/variadic_results.hpp -#if SOL_IS_ON(SOL_COMPILER_GCC_I_) +#if SOL_IS_ON(SOL_COMPILER_GCC) #pragma GCC diagnostic pop -#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) +#elif SOL_IS_ON(SOL_COMPILER_CLANG) +#elif SOL_IS_ON(SOL_COMPILER_VCXX) #pragma warning(pop) #endif // g++ -#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_) +#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE) #undef check #pragma pop_macro("check") #endif // Unreal Engine 4 Bullshit