From c72a012927401b5bc5954423bd975345e62d74f2 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 17 Apr 2018 20:08:07 -0400 Subject: [PATCH] Fix Visual Studio 2015 builds, fix error handling printouts / exceptions, fix constexpr usage that trips up Visual Studio 2015. --- CMakeLists.txt | 2 +- appveyor.yml | 2 +- .../custom_global_transparent_argument.cpp | 10 +++++----- sol/state_handling.hpp | 18 +++++++++--------- tests/CMakeLists.txt | 4 +--- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 609889e6..abd298f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ cmake_minimum_required(VERSION 3.5.0) # # # project declaration -project(sol2 VERSION 2.19.0 LANGUAGES CXX C) +project(sol2 VERSION 2.20.0 LANGUAGES CXX C) include(GNUInstallDirs) diff --git a/appveyor.yml b/appveyor.yml index a4cc9ea6..10b5ca48 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,7 +20,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -version: 2.19.0-{build} +version: 2.20.0-{build} max_jobs: 4 diff --git a/examples/custom_global_transparent_argument.cpp b/examples/custom_global_transparent_argument.cpp index 7e955243..62b4e007 100644 --- a/examples/custom_global_transparent_argument.cpp +++ b/examples/custom_global_transparent_argument.cpp @@ -1,8 +1,8 @@ -#define SOL_CHECK_ARGUMENTS 1 -#include - -// Something that can't be collided with -constexpr static const auto& script_key = "GlobalResource.MySpecialIdentifier123"; +#define SOL_CHECK_ARGUMENTS 1 +#include + +// Something that can't be collided with +static const auto& script_key = "GlobalResource.MySpecialIdentifier123"; struct GlobalResource { int value = 2; diff --git a/sol/state_handling.hpp b/sol/state_handling.hpp index df497689..bb0922f8 100644 --- a/sol/state_handling.hpp +++ b/sol/state_handling.hpp @@ -46,8 +46,8 @@ namespace sol { #else (void)L; #endif - } - + } + inline int default_at_panic(lua_State* L) { #if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS (void)L; @@ -89,14 +89,14 @@ namespace sol { //std::cerr << std::endl; #endif // Printing return stack::push(L, msg); - } - - inline void set_default_state(lua_State* L, lua_CFunction panic_function = &default_at_panic, lua_CFunction traceback_function = c_call, exception_handler_function exf = detail::default_exception_handler) { + } + + inline void set_default_state(lua_State* L, lua_CFunction panic_function = &default_at_panic, lua_CFunction traceback_function = c_call, exception_handler_function exf = detail::default_exception_handler) { lua_atpanic(L, panic_function); protected_function::set_default_handler(object(L, in_place, traceback_function)); set_default_exception_handler(L, exf); register_main_thread(L); - stack::luajit_exception_handler(L); + stack::luajit_exception_handler(L); } inline std::size_t total_memory_used(lua_State* L) { @@ -149,7 +149,6 @@ namespace sol { std::cerr << err; std::cerr << std::endl; #endif -#if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS) // replacing information of stack error into pfr int target = result.stack_index(); if (result.pop_count() > 0) { @@ -161,11 +160,12 @@ namespace sol { if (towards != 0) { lua_rotate(L, top, towards); } +#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS + return result; #else // just throw our error throw error(detail::direct_error, err); -#endif - return result; +#endif // If exceptions are allowed } inline protected_function_result script_default_on_error(lua_State* L, protected_function_result pfr) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e86426ab..b7f99d60 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,7 +23,7 @@ # # # # sol2 tests if (CMAKE_GENERATOR MATCHES "Visual Studio 14 2015") - find_package(Catch 1.1.12 REQUIRED) + find_package(Catch 1.12.1 REQUIRED) else() find_package(Catch 2.1.2 REQUIRED) endif() @@ -71,8 +71,6 @@ function(CREATE_TEST test_target_name test_name is_single) target_compile_definitions(${test_target_name} PRIVATE SOL2_CI) endif() - target_compile_features(${test_target_name} - PRIVATE ${CXX_FEATURES}) if (CMAKE_DL_LIBS) target_link_libraries(${test_target_name} ${CMAKE_DL_LIBS})