diff --git a/.clang-format b/.clang-format index cc98bcf3..f75a5542 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/.dockerignore b/.dockerignore index c50cd66d..e64d3754 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/.gitignore b/.gitignore index cd6d4567..b4ae4dd8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -51,6 +51,7 @@ x86/ scratch/ # CMake +/.cmake build/ build-sol2/ CMakeCache.txt @@ -127,5 +128,5 @@ LuaJIT-2.0/ LuaJIT-2.1/ lua-5.1/ lua-5.2/ -~syncthing* -.tmp +~syncthing* +.tmp diff --git a/CMakeLists.txt b/CMakeLists.txt index d0cea8b8..b54f71a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -22,7 +22,7 @@ # # # # sol2 # # # Required minimum version statement -cmake_minimum_required(VERSION 3.16.0) +cmake_minimum_required(VERSION 3.26.0) # # # Project Include - file that is included after project declaration is finished set(CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Includes/Project.cmake") @@ -42,7 +42,7 @@ include(FetchContent) # # # Configuration # # Cached defines, strings, paths and options -set(SOL2_LUA_VERSION "5.3.5" CACHE STRING "The version of Lua needed. Can be 5.1, 5.2, 5.3, 5.4, LuaJIT, or a more specific 3-part version number for a specifc Lua (e.g., 5.3.5 or luajit-2.0.5)") +set(SOL2_LUA_VERSION "5.4.4" CACHE STRING "The version of Lua needed. Can be 5.1, 5.2, 5.3, 5.4, LuaJIT, or a more specific 3-part version number for a specifc Lua (e.g., 5.4.4 or luajit-2.0.5)") set(SOL2_BUILD_LUA TRUE CACHE BOOL "Always build Lua, do not search for it in the system") set(SOL2_PLATFORM "x64" CACHE STRING "Target platform to compile for when building binaries (x86, x64)") option(SOL2_CI "Whether or not we are in continguous integration mode" OFF) @@ -105,7 +105,7 @@ target_include_directories(sol2 ${sol2-system-include} configure_package_config_file( cmake/sol2-config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/cmake/sol2-config.cmake" - INSTALL_DESTINATION lib/cmake/sol2 + INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/sol2 NO_CHECK_REQUIRED_COMPONENTS_MACRO) write_basic_package_version_file( @@ -120,8 +120,9 @@ if(SOL2_ENABLE_INSTALL) EXPORT sol2) install(EXPORT sol2 + NAMESPACE sol2:: FILE sol2-targets.cmake - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/sol2") + DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/sol2") install(DIRECTORY include/sol DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") @@ -129,7 +130,7 @@ if(SOL2_ENABLE_INSTALL) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/sol2-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/sol2-config-version.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/sol2") + DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/sol2") endif() # # # sol2 Library - Single header target diff --git a/Dockerfile b/Dockerfile index 1d9925d3..ef91b51d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,7 @@ VOLUME /root/sol2 # Command line arguments, with default values ARG SOL2_PLATFORM=x64 ARG SOL2_LUA_VERSION=x64 -ARG SOL2_LUA_VERSION=5.3.5 +ARG SOL2_LUA_VERSION=5.4.4 ARG SOL2_TEST_SINGLE=false ARG SOL2_TEST_INTEROP=false ARG SOL2_CI=true diff --git a/LICENSE.txt b/LICENSE.txt index 633ce75b..dacba36c 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 05ca9e1d..cf0e9e61 100644 --- a/README.md +++ b/README.md @@ -124,32 +124,32 @@ You will need any flavor of python3 and an available compiler. The testing suite "A Sun For the Moon - A Zero-Overhead Lua Abstraction using C++" ThePhD Lua Workshop 2016 - Mashape, San Francisco, CA -[Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2016.10.14%20-%20ThePhD%20-%20No%20Overhead%20C%20Abstraction.pdf) +[Deck](https://github.com/ThePhD/sol2/blob/develop/documentation/presentation/2016.10.14%20-%20ThePhD%20-%20No%20Overhead%20C%20Abstraction.pdf) "Wrapping Lua C in C++ - Efficiently, Nicely, and with a Touch of Magic" ThePhD Boston C++ Meetup November 2017 - CiC (Milk Street), Boston, MA -[Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2017.11.08%20-%20ThePhD%20-%20Wrapping%20Lua%20C%20in%20C%2B%2B.pdf) +[Deck](https://github.com/ThePhD/sol2/blob/develop/documentation/presentation/2017.11.08%20-%20ThePhD%20-%20Wrapping%20Lua%20C%20in%20C%2B%2B.pdf) "Biting the CMake Bullet" ThePhD Boston C++ Meetup February 2018 - CiC (Main Street), Cambridge, MA -[Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2018.02.06%20-%20ThePhD%20-%20Biting%20the%20CMake%20Bullet.pdf) +[Deck](https://github.com/ThePhD/sol2/blob/develop/documentation/presentation/2018.02.06%20-%20ThePhD%20-%20Biting%20the%20CMake%20Bullet.pdf) "Compile Fast, Run Faster, Scale Forever: A look into the sol2 Library" ThePhD C++Now 2018 - Hudson Commons, Aspen Physics Center, Aspen, Colorado -[Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2018.05.10%20-%20ThePhD%20-%20Compile%20Fast%2C%20Run%20Faster%2C%20Scale%20Forever.pdf) +[Deck](https://github.com/ThePhD/sol2/blob/develop/documentation/presentation/2018.05.10%20-%20ThePhD%20-%20Compile%20Fast%2C%20Run%20Faster%2C%20Scale%20Forever.pdf) "Scripting at the Speed of Thought: Using Lua in C++ with sol2" ThePhD CppCon 2018 - 404 Keystone, Meydenbauer Center, Aspen, Colorado -[Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2018.09.28%20-%20ThePhD%20-%20Scripting%20at%20the%20Speed%20of%20Thought.pdf) +[Deck](https://github.com/ThePhD/sol2/blob/develop/documentation/presentation/2018.09.28%20-%20ThePhD%20-%20Scripting%20at%20the%20Speed%20of%20Thought.pdf) "The Plan for Tomorrow: Compile-Time Extension Points in C++" ThePhD C++Now 2019 - Flug Auditorium, Aspen Physics Center, Aspen, Colorado -[Deck](https://github.com/ThePhD/sol2/blob/develop/docs/presentations/2019.05.10%20-%20ThePhD%20-%20The%20Plan%20for%20Tomorrow%20-%20Compile-Time%20Extension%20Points%20in%20C%2b%2b.pdf) +[Deck](https://github.com/ThePhD/sol2/blob/develop/documentation/presentation/2019.05.10%20-%20ThePhD%20-%20The%20Plan%20for%20Tomorrow%20-%20Compile-Time%20Extension%20Points%20in%20C%2b%2b.pdf) diff --git a/cmake/Includes/Project.cmake b/cmake/Includes/Project.cmake index b121fdbe..e7c8d7a5 100644 --- a/cmake/Includes/Project.cmake +++ b/cmake/Includes/Project.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/cmake/Modules/CheckCompilerDiagnostic.cmake b/cmake/Modules/CheckCompilerDiagnostic.cmake index 846dc01f..b5a81d28 100644 --- a/cmake/Modules/CheckCompilerDiagnostic.cmake +++ b/cmake/Modules/CheckCompilerDiagnostic.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -89,4 +89,4 @@ function (check_compiler_diagnostic diagnostic) set(--allow-${diagnostic} $<${when}:${allow_prefix}${diagnostic_flag}> PARENT_SCOPE) set(--warn-${diagnostic} $<${when}:${warn_prefix}${diagnostic_flag}> PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/Modules/CheckCompilerFlag.cmake b/cmake/Modules/CheckCompilerFlag.cmake index 0b919a73..e9fc198c 100644 --- a/cmake/Modules/CheckCompilerFlag.cmake +++ b/cmake/Modules/CheckCompilerFlag.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/cmake/Modules/Common/Core.cmake b/cmake/Modules/Common/Core.cmake index ed9d95ed..77766e53 100644 --- a/cmake/Modules/Common/Core.cmake +++ b/cmake/Modules/Common/Core.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/cmake/Modules/FindVersion.cmake b/cmake/Modules/FindVersion.cmake index c12a7f49..bfd342d7 100644 --- a/cmake/Modules/FindVersion.cmake +++ b/cmake/Modules/FindVersion.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/cmake/Packages/FindKaguyaBuild.cmake b/cmake/Packages/FindKaguyaBuild.cmake index 0a6086a1..8d0579f8 100644 --- a/cmake/Packages/FindKaguyaBuild.cmake +++ b/cmake/Packages/FindKaguyaBuild.cmake @@ -2,7 +2,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -45,6 +45,7 @@ ExternalProject_Add(KAGUYA_BUILD_SOURCE GIT_SHALLOW TRUE GIT_SUBMODULES "" GIT_REPOSITORY https://github.com/satoren/kaguya.git + GIT_TAG main PREFIX ${kaguya_build_toplevel} SOURCE_DIR ${kaguya_build_toplevel} DOWNLOAD_DIR ${kaguya_build_toplevel} @@ -60,7 +61,7 @@ ExternalProject_Add(KAGUYA_BUILD_SOURCE add_library(${kaguya_lib} INTERFACE) add_dependencies(${kaguya_lib} KAGUYA_BUILD_SOURCE) target_include_directories(${kaguya_lib} INTERFACE ${kaguya_include_dirs}) -target_link_libraries(${kaguya_lib} INTERFACE ${LUA_LIBRARIES}) +target_link_libraries(${kaguya_lib} INTERFACE Lua::Lua) if (NOT MSVC) target_compile_options(${kaguya_lib} INTERFACE -Wno-noexcept-type -Wno-ignored-qualifiers -Wno-unused-parameter) @@ -73,4 +74,4 @@ set(KAGUYA_INCLUDE_DIRS ${kaguya_include_dirs}) FIND_PACKAGE_HANDLE_STANDARD_ARGS(KaguyaBuild FOUND_VAR KAGUYABUILD_FOUND REQUIRED_VARS KAGUYA_LIBRARIES KAGUYA_INCLUDE_DIRS - VERSION_VAR kaguya_version) \ No newline at end of file + VERSION_VAR kaguya_version) diff --git a/cmake/Packages/FindLua/set_version_vars.cmake b/cmake/Packages/FindLua/set_version_vars.cmake index 5df75acd..1f64f9f3 100644 --- a/cmake/Packages/FindLua/set_version_vars.cmake +++ b/cmake/Packages/FindLua/set_version_vars.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -74,4 +74,4 @@ function(_lua_set_version_vars _prefix _lua_suffix) set(_${_prefix}_include_subdirs "${_${_prefix}_include_subdirs}" PARENT_SCOPE) set(_${_prefix}_append_versions "${_${_prefix}_append_versions}" PARENT_SCOPE) set(_${_prefix}_library_names "${_${_prefix}_library_names}" PARENT_SCOPE) -endfunction(_lua_set_version_vars) \ No newline at end of file +endfunction(_lua_set_version_vars) diff --git a/cmake/Packages/FindLuaBridgeBuild.cmake b/cmake/Packages/FindLuaBridgeBuild.cmake index 7d3d92d0..1ee91652 100644 --- a/cmake/Packages/FindLuaBridgeBuild.cmake +++ b/cmake/Packages/FindLuaBridgeBuild.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -59,7 +59,7 @@ ExternalProject_Add(LUABRIDGE_BUILD_SOURCE add_library(${luabridge_lib} INTERFACE) add_dependencies(${luabridge_lib} LUABRIDGE_BUILD_SOURCE) target_include_directories(${luabridge_lib} INTERFACE ${luabridge_include_dirs}) -target_link_libraries(${luabridge_lib} INTERFACE ${LUA_LIBRARIES}) +target_link_libraries(${luabridge_lib} INTERFACE Lua::Lua) if (NOT MSVC) target_compile_options(${luabridge_lib} INTERFACE -Wno-noexcept-type -Wno-ignored-qualifiers -Wno-unused-parameter) @@ -72,5 +72,3 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuabridgeBuild FOUND_VAR LUABRIDGEBUILD_FOUND REQUIRED_VARS LUABRIDGE_LIBRARIES LUABRIDGE_INCLUDE_DIRS VERSION_VAR luabridge_version) - - diff --git a/cmake/Packages/FindLuaBuild.cmake b/cmake/Packages/FindLuaBuild.cmake index 42341271..14fd4d48 100644 --- a/cmake/Packages/FindLuaBuild.cmake +++ b/cmake/Packages/FindLuaBuild.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -39,7 +39,7 @@ function(find_lua_build LUA_VERSION) else() set(LUA_BUILD_LIBNAME lua-${LUA_VERSION}) endif() - set(LUA_BUILD_TOPLEVEL "${CMAKE_BINARY_DIR}/vendor/${LUA_BUILD_LIBNAME}") + set(LUA_BUILD_TOPLEVEL "${CMAKE_BINARY_DIR}/_deps/${LUA_BUILD_LIBNAME}") set(LUA_BUILD_INSTALL_DIR "${LUA_BUILD_TOPLEVEL}") # # Misc needed variables set(LUA_BUILD_LIBRARY_DESCRIPTION "The base name of the library to build either the static or the dynamic library") @@ -88,7 +88,7 @@ function(find_lua_build LUA_VERSION) endif() # # Export variables to the parent scope - set(LUA_LIBRARIES ${LUA_LIBRARIES} PARENT_SCOPE) + set(LUA_LIBRARIES Lua::Lua PARENT_SCOPE) set(LUA_INTERPRETER ${LUA_INTERPRETER} PARENT_SCOPE) set(LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIRS} PARENT_SCOPE) set(LUA_VERSION_STRING ${LUA_VERSION_STRING} PARENT_SCOPE) @@ -107,7 +107,7 @@ if (LuaBuild_FIND_VERSION) endif() endif() if (NOT LUA_VERSION) - set(LUA_VERSION 5.3.5) + set(LUA_VERSION 5.4.4) endif() find_lua_build(${LUA_VERSION}) unset(find_lua_build) diff --git a/cmake/Packages/FindLuaBuild/LuaJIT.cmake b/cmake/Packages/FindLuaBuild/LuaJIT.cmake index 557f29d6..e5b986d8 100644 --- a/cmake/Packages/FindLuaBuild/LuaJIT.cmake +++ b/cmake/Packages/FindLuaBuild/LuaJIT.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -29,12 +29,6 @@ set(lua_jit_build_included true) # import necessary standard modules include(ExternalProject) -# Latest iterations for specific sub-versions of LuaJIT -set(LUA_JIT_2.0_LATEST_VERSION 2.0.5) -set(LUA_JIT_${LUA_JIT_2.0_LATEST_VERSION}_COMMIT c88602f080dcafea6ba222a2f7cc1ea0e41ef3cc) -set(LUA_JIT_2.1_LATEST_VERSION 2.1.0-beta3) -set(LUA_JIT_${LUA_JIT_2.1_LATEST_VERSION}_COMMIT 80aaaeee99d7f7b06c9e75ed3a457c49d86fc4db) - # MD5 hashes taken off of LuaJIT's website # must be updated whenever a new version appears set(LUA_JIT_MD5_2.1.0-beta3.tar.gz eae40bc29d06ee5e3078f9444fcea39b) @@ -102,9 +96,9 @@ elseif (LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "([0-9]+\\.[0-9]+)") # extend version number with prefix if (${CMAKE_MATCH_1} EQUAL 2) if (${CMAKE_MATCH_2} EQUAL 0) - set(LUA_JIT_VERSION ${LUA_JIT_2.0_LATEST_VERSION}) + set(LUA_JIT_VERSION 2.0) elseif (${CMAKE_MATCH_2} EQUAL 1) - set(LUA_JIT_VERSION ${LUA_JIT_2.1_LATEST_VERSION}) + set(LUA_JIT_VERSION 2.1) endif() endif() if (NOT LUA_JIT_VERSION) @@ -112,7 +106,7 @@ elseif (LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "([0-9]+\\.[0-9]+)") set(LUA_JIT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.0) endif() elseif (LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "latest") - set(LUA_JIT_VERSION ${LUA_JIT_2.1_LATEST_VERSION}) + set(LUA_JIT_VERSION 2.1) else() MESSAGE(FATAL "Cannot deduce LuaJIT version from ${LUA_VERSION}") endif() @@ -205,7 +199,27 @@ if (MSVC) "C:/Program Files/Microsoft Visual Studio/2019/Professional/VC" "C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build" "C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary" - "C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC") + "C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC" + + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Community/VC/Auxiliary" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Community/VC" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/Build" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Professional/VC/Auxiliary" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Professional/VC" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC" + + "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build" + "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary" + "C:/Program Files/Microsoft Visual Studio/2022/Community/VC" + "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/Build" + "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary" + "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC" + "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build" + "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary" + "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC") if (VCVARS_ALL_BAT MATCHES "VCVARS_ALL_BAT-NOTFOUND") MESSAGE(FATAL_ERROR "Cannot find 'vcvarsall.bat' file or similar needed to build LuaJIT ${LUA_VERSION} on Windows") endif() @@ -215,9 +229,11 @@ if (MSVC) set(LUA_JIT_MAKE_COMMAND "${VCVARS_ALL_BAT}" x64) endif() set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} && cd src && msvcbuild.bat) - if (CMAKE_BUILD_TYPE MATCHES "Debug") - set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} debug) + if (BUILD_LUA_NOGC64) + set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} nogc64) endif() + + set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} $<$:debug>) if (NOT BUILD_LUA_AS_DLL) set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} static) endif() @@ -227,7 +243,7 @@ if (MSVC) set(LUA_JIT_PREBUILT_DLL "lua51.dll") set(LUA_JIT_PREBUILT_EXP "lua51.exp") set(LUA_JIT_PREBUILT_EXE "luajit.exe") -else () +else() # get the make command we need for this system find_program(MAKE_PROGRAM NAMES make mingw32-make mingw64-make) if (MAKE_PROGRAM MATCHES "MAKE_PROGRAM-NOTFOUND") @@ -241,6 +257,7 @@ else () set(LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_T=${LUA_JIT_EXE_FILENAME}") list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_A=${LUA_JIT_LIB_FILENAME}") set(LUA_JIT_MAKE_CFLAGS_MODIFICATIONS "") + set(LUA_JIT_MAKE_XCFLAGS_MODIFICATIONS "") set(LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS "") set(LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS "-fPIC") if (BUILD_LUA_AS_DLL) @@ -266,10 +283,28 @@ else () if (WIN32) list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_SYS=Windows" "TARGET_SYS=Windows" "TARGET_AR=ar rcus") endif() - list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "CFLAGS=${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}") + list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS $<$:"CCDEBUG=-g">) + if (BUILD_LUA_52_COMPATIBILITY) + list(APPEND LUA_JIT_MAKE_XCFLAGS_MODIFICATIONS "-DLUAJIT_ENABLE_LUA52COMPAT") + endif() + if (NOT BUILD_LUA_NOGC64) + list(APPEND LUA_JIT_MAKE_XCFLAGS_MODIFICATIONS "-DLUAJIT_ENABLE_GC64") + endif() + list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "CFLAGS=\"${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}\"") + list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "XCFLAGS=\"${LUA_JIT_MAKE_XCFLAGS_MODIFICATIONS}\"") list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "TARGET_CFLAGS=${LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS}") list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_CFLAGS=${LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS}") set(LUA_JIT_MAKE_COMMAND "${MAKE_PROGRAM}" ${LUA_JIT_MAKE_BUILD_MODIFICATIONS}) + if (APPLE) + if (CMAKE_OSX_DEPLOYMENT_TARGET) + set(MACOS_SDK_TARGET ${CMAKE_MACOSX_DEPLOYMENT_TARGET}) + elseif (MACOSX_DEPLOYMENT_TARGET) + set(MACOS_SDK_TARGET ${MACOSX_DEPLOYMENT_TARGET}) + endif() + if (MACOS_SDK_TARGET) + set(LUA_JIT_MAKE_COMMAND MACOSX_DEPLOYMENT_TARGET=${MACOS_SDK_TARGET} ${LUA_JIT_MAKE_COMMAND}) + endif() + endif() endif() set(LUA_JIT_BUILD_COMMAND BUILD_COMMAND ${LUA_JIT_MAKE_COMMAND}) @@ -289,23 +324,20 @@ file(TO_CMAKE_PATH "${LUA_JIT_IMP_LIB_FILE}" LUA_JIT_DESTINATION_LUA_IMP_LIB) file(TO_CMAKE_PATH "${LUA_JIT_LIB_FILE}" LUA_JIT_DESTINATION_LUA_LIB) file(TO_CMAKE_PATH "${LUA_JIT_EXE_FILE}" LUA_JIT_DESTINATION_LUA_INTERPRETER) -if (WIN32 AND NOT MSVC) - string(COMPARE EQUAL ${LUA_JIT_VERSION} ${LUA_JIT_2.0_LATEST_VERSION} lua_jit_same_version_20) - string(COMPARE EQUAL ${LUA_JIT_VERSION} ${LUA_JIT_2.1_LATEST_VERSION} lua_jit_same_version_21) - if (lua_jit_same_version_20 OR lua_jit_same_version_21) - #set (LUA_JIT_GIT_COMMIT ${LUA_JIT_${LUA_JIT_VERSION}_COMMIT}) - #set(LUA_JIT_GIT_TAG GIT_TAG ${LUA_JIT_GIT_COMMIT}) - endif() -elseif(LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "latest") +if(LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "latest") set(LUA_JIT_PULL_LATEST TRUE) endif() -set(LUA_JIT_BYPRODUCTS "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_SOURCE_LUA_INTERPRETER}") -set(LUA_JIT_INSTALL_BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_INTERPRETER}") +set(LUA_JIT_BYPRODUCTS "${LUA_JIT_SOURCE_LUA_INTERPRETER}") +set(LUA_JIT_INSTALL_BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_INTERPRETER}") -if (BUILD_LUA_AS_DLL AND MSVC) - set(LUA_JIT_BYPRODUCTS ${LUA_JIT_BYPRODUCTS} "${LUA_JIT_SOURCE_LUA_LIB_EXP}") - set(LUA_JIT_INSTALL_BYPRODUCTS ${LUA_JIT_INSTALL_BYPRODUCTS} "${LUA_JIT_DESTINATION_LUA_LIB_EXP}") +if (BUILD_LUA_AS_DLL) + set(LUA_JIT_BYPRODUCTS ${LUA_JIT_BYPRODUCTS} "${LUA_JIT_SOURCE_LUA_DLL}") + set(LUA_JIT_INSTALL_BYPRODUCTS ${LUA_JIT_INSTALL_BYPRODUCTS} "${LUA_JIT_SOURCE_LUA_DLL}") + if (MSVC) + set(LUA_JIT_BYPRODUCTS ${LUA_JIT_BYPRODUCTS} "${LUA_JIT_SOURCE_LUA_LIB_EXP}") + set(LUA_JIT_INSTALL_BYPRODUCTS ${LUA_JIT_INSTALL_BYPRODUCTS} "${LUA_JIT_DESTINATION_LUA_LIB_EXP}") + endif() endif() if (CMAKE_IMPORT_LIBRARY_SUFFIX AND BUILD_LUA_AS_DLL) @@ -319,44 +351,68 @@ endif() # # Post-Build moving steps for necessary items # Add post-step to move library afterwards set(LUA_JIT_POSTBUILD_COMMENTS "Executable - Moving \"${LUA_JIT_SOURCE_LUA_INTERPRETER}\" to \"${LUA_JIT_DESTINATION_LUA_INTERPRETER}\"...") -set(LUA_JIT_POSTBUILD_COMMANDS COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_INTERPRETER}" "${LUA_JIT_DESTINATION_LUA_INTERPRETER}") +set(LUA_JIT_POSTBUILD_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LUA_JIT_SOURCE_LUA_INTERPRETER} ${LUA_JIT_DESTINATION_LUA_INTERPRETER}) if (BUILD_LUA_AS_DLL) if (MSVC) set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS} Import Library - Moving \"${LUA_JIT_SOURCE_LUA_IMP_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_IMP_LIB}\"...") - set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_IMP_LIB}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${LUA_JIT_SOURCE_LUA_IMP_LIB} ${LUA_JIT_DESTINATION_LUA_IMP_LIB}) set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS} Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB_EXP}\" to \"${LUA_JIT_DESTINATION_LUA_LIB_EXP}\"...") - set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} && "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB_EXP}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LUA_JIT_SOURCE_LUA_LIB_EXP} ${LUA_JIT_DESTINATION_LUA_LIB_EXP}) endif() set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS} Dynamic Library - Moving \"${LUA_JIT_SOURCE_LUA_DLL}\" to \"${LUA_JIT_DESTINATION_LUA_DLL}\"...") - set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_DLL}") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LUA_JIT_SOURCE_LUA_DLL} ${LUA_JIT_DESTINATION_LUA_DLL}) else() set(LUA_JIT_POSTBUILD_COMMENTS "${LUA_JIT_POSTBUILD_COMMENTS} Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_LIB}\"...") - set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB}") + set(LUA_JIT_POSTBUILD_COMMANDS ${LUA_JIT_POSTBUILD_COMMANDS} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LUA_JIT_SOURCE_LUA_LIB} ${LUA_JIT_DESTINATION_LUA_LIB}) endif() if (LUA_LOCAL_DIR) - file(COPY "${LUA_LOCAL_DIR}/" - DESTINATION "${LUA_BUILD_TOPLEVEL}" - FILES_MATCHING REGEX ".*" + cmake_path(SET LUAJIT_BUILD_LOCAL_DIR NORMALIZE ${LUA_LOCAL_DIR}) +endif() +if (LUA_BUILD_TOPLEVEL) + cmake_path(SET LUA_BUILD_TOPLEVEL NORMALIZE ${LUA_BUILD_TOPLEVEL}) +endif() + +if (LUAJIT_BUILD_LOCAL_DIR) + MESSAGE(STATUS "Using LuaJIT ${LUA_JIT_VERSION} from local directory \"${LUAJIT_BUILD_LOCAL_DIR}\"") + file(GLOB_RECURSE LUAJIT_BUILD_LOCAL_DIR_FILES_NATIVE + LIST_DIRECTORIES FALSE + CONFIGURE_DEPENDS + ${LUAJIT_BUILD_LOCAL_DIR}/* + ) + cmake_path(CONVERT "${LUAJIT_BUILD_LOCAL_DIR_FILES_NATIVE}" TO_CMAKE_PATH_LIST LUAJIT_BUILD_LOCAL_DIR_FILES) + list(TRANSFORM LUAJIT_BUILD_LOCAL_DIR_FILES REPLACE "${LUAJIT_BUILD_LOCAL_DIR}(.*)" "${LUA_BUILD_TOPLEVEL}\\1" OUTPUT_VARIABLE LUAJIT_BUILD_TOPLEVEL_FILES) + add_custom_command(OUTPUT ${LUAJIT_BUILD_TOPLEVEL_FILES} + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${LUAJIT_BUILD_LOCAL_DIR} ${LUA_BUILD_TOPLEVEL} + WORKING_DIRECTORY "${LUA_BUILD_TOPLEVEL}" + DEPENDS ${LUAJIT_BUILD_LOCAL_DIR_FILES} + COMMENT "Copying LuaJIT files from \"${LUAJIT_BUILD_LOCAL_DIR}\" to \"${LUA_BUILD_TOPLEVEL}\" ..." ) add_custom_command(OUTPUT ${LUA_JIT_BYPRODUCTS} COMMAND ${LUA_JIT_MAKE_COMMAND} WORKING_DIRECTORY "${LUA_BUILD_TOPLEVEL}" - DEPENDS "${LUA_BUILD_TOPLEVEL}/Makefile" "${LUA_BUILD_TOPLEVEL}/src/msvcbuild.bat" - COMMENT "Building LuaJIT ${LUA_JIT_VERSION}..." + DEPENDS ${LUAJIT_BUILD_TOPLEVEL_FILES} + COMMENT "Building LuaJIT ${LUA_JIT_VERSION} from \"${LUA_BUILD_TOPLEVEL}\" ..." ) - add_custom_target(LUA_JIT-move + add_custom_target(LUA_JIT-bat-build + DEPENDS ${LUA_JIT_BYPRODUCTS} + ) + add_custom_command(OUTPUT ${LUA_JIT_INSTALL_BYPRODUCTS} ${LUA_JIT_POSTBUILD_COMMANDS} - COMMENT ${LUA_JIT_POSTBUILD_COMMENTS} - BYPRODUCTS ${LUA_JIT_INSTALL_BYPRODUCTS} + COMMENT "${LUA_JIT_POSTBUILD_COMMENTS}" + WORKING_DIRECTORY "${LUA_BUILD_TOPLEVEL}" DEPENDS ${LUA_JIT_BYPRODUCTS} ) + add_custom_target(LUA_JIT-move + DEPENDS LUA_JIT-bat-build ${LUA_JIT_INSTALL_BYPRODUCTS} + ) elseif (LUA_JIT_GIT_COMMIT OR LUA_JIT_PULL_LATEST) if (LUA_JIT_PULL_LATEST) MESSAGE(STATUS "Latest LuaJIT has been requested: pulling from git...") elseif (LUA_JIT_GIT_COMMIT) - MESSAGE(STATUS "LuaJIT '${LUA_VERSION}' requested has broken static library builds: using git '${LUA_JIT_GIT_COMMIT}'...") + MESSAGE(STATUS "LuaJIT '${LUA_VERSION}' requested has broken static library builds: using git '${LUA_JIT_GIT_COMMIT}'...") + set(LUA_JIT_GIT_TAG GIT_TAG ${LUA_JIT_GIT_COMMIT}) endif() ExternalProject_Add(LUA_JIT BUILD_IN_SOURCE TRUE @@ -398,7 +454,7 @@ else() BUILD_BYPRODUCTS ${LUA_JIT_BYPRODUCTS}) endif() -if (NOT LUA_LOCAL_DIR) +if (NOT LUAJIT_BUILD_LOCAL_DIR) ExternalProject_Add_Step(LUA_JIT move ALWAYS TRUE ${LUA_JIT_POSTBUILD_COMMANDS} @@ -412,11 +468,14 @@ endif() # # Lua Library add_library(${lualib} INTERFACE) +add_library(Lua::Lua ALIAS ${lualib}) add_dependencies(${lualib} LUA_JIT-move) target_include_directories(${lualib} - INTERFACE "${LUA_JIT_SOURCE_DIR}") + INTERFACE + "${LUA_JIT_SOURCE_DIR}") target_link_libraries(${lualib} - INTERFACE ${CMAKE_DL_LIBS}) + INTERFACE + ${CMAKE_DL_LIBS}) if (BUILD_LUA_AS_DLL) if (MSVC) target_link_libraries(${lualib} @@ -436,6 +495,6 @@ if (XCODE) endif () # # set externally-visible target indicator -set(LUA_LIBRARIES ${lualib}) +set(LUA_LIBRARIES Lua::Lua) set(LUA_INTERPRETER "") set(LUA_INCLUDE_DIRS "${LUA_JIT_INCLUDE_DIRS}") diff --git a/cmake/Packages/FindLuaBuild/LuaVanilla.cmake b/cmake/Packages/FindLuaBuild/LuaVanilla.cmake index a4186841..d71de535 100644 --- a/cmake/Packages/FindLuaBuild/LuaVanilla.cmake +++ b/cmake/Packages/FindLuaBuild/LuaVanilla.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -34,83 +34,8 @@ include(Common/Core) # Latest versions for specific sub-versions of Lua set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5) set(LUA_VANILLA_5.2_LATEST_VERSION 5.2.4) -set(LUA_VANILLA_5.3_LATEST_VERSION 5.3.5) -set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.1) - -# exact version, coming from CI: pull directly from Lua and use external project to build -# list of known md5 / sha1: must update when there are changes -set(LUA_VANILLA_MD5_5.4.1 1d575faef1c907292edd79e7a2784d30) -set(LUA_VANILLA_SHA1_5.4.1 88961e7d4fda58ca2c6163938fd48db8880e803d) -set(LUA_VANILLA_MD5_5.4.0 dbf155764e5d433fc55ae80ea7060b60) -set(LUA_VANILLA_SHA1_5.4.0 8cdbffa8a214a23d190d7c45f38c19518ae62e89) -set(LUA_VANILLA_MD5_5.3.5 4f4b4f323fd3514a68e0ab3da8ce3455) -set(LUA_VANILLA_SHA1_5.3.5 112eb10ff04d1b4c9898e121d6bdf54a81482447) -set(LUA_VANILLA_MD5_5.3.4 53a9c68bcc0eda58bdc2095ad5cdfc63) -set(LUA_VANILLA_SHA1_5.3.4 79790cfd40e09ba796b01a571d4d63b52b1cd950) -set(LUA_VANILLA_MD5_5.3.3 703f75caa4fdf4a911c1a72e67a27498) -set(LUA_VANILLA_SHA1_5.3.3 a0341bc3d1415b814cc738b2ec01ae56045d64ef) -set(LUA_VANILLA_MD5_5.3.2 33278c2ab5ee3c1a875be8d55c1ca2a1) -set(LUA_VANILLA_SHA1_5.3.2 7a47adef554fdca7d0c5536148de34579134a973) -set(LUA_VANILLA_MD5_5.3.1 797adacada8d85761c079390ff1d9961) -set(LUA_VANILLA_SHA1_5.3.1 1676c6a041d90b6982db8cef1e5fb26000ab6dee) -set(LUA_VANILLA_MD5_5.3.0 a1b0a7e92d0c85bbff7a8d27bf29f8af) -set(LUA_VANILLA_SHA1_5.3.0 1c46d1c78c44039939e820126b86a6ae12dadfba) -set(LUA_VANILLA_MD5_5.2.4 913fdb32207046b273fdb17aad70be13) -set(LUA_VANILLA_SHA1_5.2.4 ef15259421197e3d85b7d6e4871b8c26fd82c1cf) -set(LUA_VANILLA_MD5_5.2.3 dc7f94ec6ff15c985d2d6ad0f1b35654) -set(LUA_VANILLA_SHA1_5.2.3 926b7907bc8d274e063d42804666b40a3f3c124c) -set(LUA_VANILLA_MD5_5.2.2 efbb645e897eae37cad4344ce8b0a614) -set(LUA_VANILLA_SHA1_5.2.2 0857e41e5579726a4cb96732e80d7aa47165eaf5) -set(LUA_VANILLA_MD5_5.2.1 ae08f641b45d737d12d30291a5e5f6e3) -set(LUA_VANILLA_SHA1_5.2.1 6bb1b0a39b6a5484b71a83323c690154f86b2021) -set(LUA_VANILLA_MD5_5.2.0 f1ea831f397214bae8a265995ab1a93e) -set(LUA_VANILLA_SHA1_5.2.0 08f84c355cdd646f617f09cebea48bd832415829) -set(LUA_VANILLA_MD5_5.1.5 2e115fe26e435e33b0d5c022e4490567) -set(LUA_VANILLA_SHA1_5.1.5 b3882111ad02ecc6b972f8c1241647905cb2e3fc) -set(LUA_VANILLA_MD5_5.1.4 d0870f2de55d59c1c8419f36e8fac150) -set(LUA_VANILLA_SHA1_5.1.4 2b11c8e60306efb7f0734b747588f57995493db7) -set(LUA_VANILLA_MD5_5.1.3 a70a8dfaa150e047866dc01a46272599) -set(LUA_VANILLA_SHA1_5.1.3 89bc9f5a351402565b8077e8123327e7cd15f004) -set(LUA_VANILLA_MD5_5.1.2 687ce4c2a1ddff18f1008490fdc4e5e0) -set(LUA_VANILLA_SHA1_5.1.2 8a460d2d7e70e93cb72bf3d584405464763cb5f0) -set(LUA_VANILLA_MD5_5.1.1 22f4f912f20802c11006fe9b84d5c461) -set(LUA_VANILLA_SHA1_5.1.1 be13878ceef8e1ee7a4201261f0adf09f89f1005) -set(LUA_VANILLA_MD5_5.1 3e8dfe8be00a744cec2f9e766b2f2aee) -set(LUA_VANILLA_SHA1_5.1 1ae9ec317511d525c7999c842ca0b1ddde84e374) -set(LUA_VANILLA_MD5_5.0.3 feee27132056de2949ce499b0ef4c480) -set(LUA_VANILLA_SHA1_5.0.3 e7e91f78b8a8deb09b13436829bed557a46af8ae) -set(LUA_VANILLA_MD5_5.0.2 dea74646b7e5c621fef7174df83c34b1) -set(LUA_VANILLA_SHA1_5.0.2 a200cfd20a9a4c7da1206ae45dddf26186a9e0e7) -set(LUA_VANILLA_MD5_5.0.1 e0a450d84971a3f4563b98172d1e382c) -set(LUA_VANILLA_SHA1_5.0.1 03b47b4785178aca583333f01d8726a8ab9f7ae7) -set(LUA_VANILLA_MD5_5.0 6f14803fad389fb1cb15d17edfeddd91) -set(LUA_VANILLA_SHA1_5.0 88b1bc057857c0db5ace491c4af2c917a2b803bf) -set(LUA_VANILLA_MD5_4.0.1 a31d963dbdf727f9b34eee1e0d29132c) -set(LUA_VANILLA_SHA1_4.0.1 12f1864a7ecd4b8011862a07fa3f177b2e80e7d3) -set(LUA_VANILLA_MD5_4.0 be11522d46d33a931868c03694aaeeef) -set(LUA_VANILLA_SHA1_4.0 8d432c73ef6e98b81d252114be1a83182cc9607a) -set(LUA_VANILLA_MD5_3.2.2 374ba5c4839709922de40b8d10382705) -set(LUA_VANILLA_SHA1_3.2.2 fa50ff14c00d8523c8a3d1d3f4887ecc4400d0c3) -set(LUA_VANILLA_MD5_3.2.1 47264a1978df49fc1dea6ffcddb05b21) -set(LUA_VANILLA_SHA1_3.2.1 d43af5a1c7a65c0ddb4b0ac06c29ecf4cdd22367) -set(LUA_VANILLA_MD5_3.2 a6552da3d40ae9b04489a788262279e8) -set(LUA_VANILLA_SHA1_3.2 84cf9f0e7d00eed3ea8b4ac2b84254b714510b34) -set(LUA_VANILLA_MD5_3.1 d677f3827167eefdefc7b211397cfdfb) -set(LUA_VANILLA_SHA1_3.1 509485e3baafd946f4ffe2a984f8a63746adc32a) -set(LUA_VANILLA_MD5_3.0 997558ae76c2f1cd1e10fd3835c45c6a) -set(LUA_VANILLA_SHA1_3.0 5c8c910353f717ba29b4fe7d538994454229b335) -set(LUA_VANILLA_MD5_2.5 da915d58904e75b9b0fc18147e19b0bb) -set(LUA_VANILLA_SHA1_2.5 7920e12c40242932c22fa261ff114cc485a39d99) -set(LUA_VANILLA_MD5_2.4 5d035cc244285c1dbbcaaa0908b58965) -set(LUA_VANILLA_SHA1_2.4 74036935b36e6ae4ed17bd7a9408154f9a4a6b17) -set(LUA_VANILLA_MD5_2.2 a298b58e197ff8168ec907d6145252ef) -set(LUA_VANILLA_SHA1_2.2 2d8b1df94b2fb76f0f16ca1ddc54d5186b10df4b) -set(LUA_VANILLA_MD5_2.1 053a9f6728cc56f6a23716a6a1ede595) -set(LUA_VANILLA_SHA1_2.1 b9a797547f480bcb58b5d3da846c8ac8d2201df0) -set(LUA_VANILLA_MD5_1.1 9f83141cc8ea362497e272071eda5cf6) -set(LUA_VANILLA_SHA1_1.1 67209701eec5cc633e829d023fbff62d5d6c8e5e) -set(LUA_VANILLA_MD5_1.0 96e8399fc508d128badd8ac3aa8f2119) -set(LUA_VANILLA_SHA1_1.0 6a82d2ae7ce9ad98c7b4824a325b91522c0d6ebb) +set(LUA_VANILLA_5.3_LATEST_VERSION 5.3.6) +set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.4) # Clean up some variables if (LUA_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$") @@ -154,21 +79,6 @@ FIND_PACKAGE_MESSAGE(LUABUILD "Selecting PUC-RIO Lua ${LUA_VANILLA_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library with ${LUA_VANILLA_LANGUAGE} linkage..." "[${LUA_VANILLA_VERSION}][${LUA_VERSION}][${LUA_BUILD_LIBRARY_TYPE}][${LUA_VANILLA_LANGUAGE}]") -# Get Hashes to use for download -set(LUA_VANILLA_SHA1 ${LUA_VANILLA_SHA1_${LUA_VANILLA_VERSION}}) -set(LUA_VANILLA_MD5 ${LUA_VANILLA_MD5_${LUA_VANILLA_VERSION}}) - -if (LUA_VANILLA_MD5) - set(LUA_VANILLA_DOWNLOAD_MD5_COMMAND URL_MD5 ${LUA_VANILLA_MD5}) -else () - set(LUA_VANILLA_DOWNLOAD_MD5_COMMAND "") -endif() -if (LUA_VANILLA_SHA1) - set(LUA_VANILLA_DOWNLOAD_SHA1_COMMAND URL_HASH SHA1=${LUA_VANILLA_SHA1}) -else () - set(LUA_VANILLA_DOWNLOAD_SHA1_COMMAND "") -endif() - # # # Makefile and self-build configurations # # Potential compiler variables @@ -193,20 +103,20 @@ if (LUA_VANILLA_VERSION MATCHES "^5\\.1") lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c print.c ) -endif() + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c print.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP true) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.2") - set(LUA_VANILLA_LIB_SOURCES lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c + set(LUA_VANILLA_LIB_SOURCES lapi.c lbitlib.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c - lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c + lauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c) - set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + set(LUA_VANILLA_LUA_SOURCES lua.c) + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.3") set(LUA_VANILLA_LIB_SOURCES lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c @@ -215,9 +125,9 @@ elseif (LUA_VANILLA_VERSION MATCHES "^5\\.3") lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c loadlib.c linit.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4") if (LUA_VANILLA_VERSION MATCHES "work" OR LUA_VANILLA_VERSION MATCHES "alpha" OR LUA_VANILLA_VERSION MATCHES "beta") @@ -228,87 +138,69 @@ elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4") llex.c lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c) - set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + set(LUA_VANILLA_LUA_SOURCES lua.c) + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) else() - MESSAGE(WARNING "Using Lua 5.4.1 file list for ${LUA_VERSION} version") + MESSAGE(WARNING "Using Lua 5.4.4 file list for ${LUA_VERSION} version") set(LUA_VANILLA_LIB_SOURCES lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c ldblib.c ldebug.c ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c) - set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + set(LUA_VANILLA_LUA_SOURCES lua.c) + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) endif() -set(LUA_VANILLA_SOURCE_DIR "${LUA_BUILD_TOPLEVEL}/src") -prepend(LUA_VANILLA_LIB_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LIB_SOURCES}) -prepend(LUA_VANILLA_LUA_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LUA_SOURCES}) - # download, just for the sake of download + extract # or pull from local folder if (LUA_LOCAL_DIR) + set(LUA_VANILLA_SOURCE_DIR ${LUA_BUILD_TOPLEVEL}-src) + list(TRANSFORM LUA_VANILLA_LIB_SOURCES PREPEND "${LUA_VANILLA_SOURCE_DIR}/src/") + list(TRANSFORM LUA_VANILLA_LUA_SOURCES PREPEND "${LUA_VANILLA_SOURCE_DIR}/src/") file(COPY "${LUA_LOCAL_DIR}/src" - DESTINATION "${LUA_BUILD_TOPLEVEL}") + DESTINATION "${LUA_VANILLA_SOURCE_DIR}/") file(COPY "${LUA_LOCAL_DIR}/include" - DESTINATION "${LUA_BUILD_TOPLEVEL}") + DESTINATION "${LUA_VANILLA_SOURCE_DIR}/") add_custom_target(LUA_VANILLA DEPENDS "${LUA_VANILLA_LIB_SOURCES}" "${LUA_VANILLA_LUA_SOURCES}") - set(LUA_VANILLA_INCLUDE_DIRS ${LUA_VANILLA_INCLUDE_DIRS} "${LUA_VANILLA_SOURCE_DIR}" "${LUA_BUILD_TOPLEVEL}/include") + set(LUA_VANILLA_INCLUDE_DIRS ${LUA_VANILLA_INCLUDE_DIRS} "${LUA_VANILLA_SOURCE_DIR}/include") + set(LUA_VANILLA_INCLUDE_DIRS ${LUA_VANILLA_INCLUDE_DIRS} "${LUA_VANILLA_SOURCE_DIR}/src") else() - ExternalProject_Add(LUA_VANILLA - BUILD_IN_SOURCE TRUE - BUILD_ALWAYS FALSE - TLS_VERIFY TRUE - PREFIX ${LUA_BUILD_TOPLEVEL} - SOURCE_DIR ${LUA_BUILD_TOPLEVEL} - DOWNLOAD_DIR ${LUA_BUILD_TOPLEVEL} - TMP_DIR "${LUA_BUILD_TOPLEVEL}-tmp" - STAMP_DIR "${LUA_BUILD_TOPLEVEL}-stamp" - INSTALL_DIR "${LUA_BUILD_INSTALL_DIR}" - URL ${LUA_VANILLA_DOWNLOAD_URL} - URL_MD5 ${LUA_VANILLA_MD5} - URL_HASH SHA1=${LUA_VANILLA_SHA1} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - BUILD_BYPRODUCTS "${LUA_VANILLA_LIB_SOURCES}" "${LUA_VANILLA_LUA_SOURCES}") - - # make a quick lua.hpp for 5.1 targets that don't have it + include(FetchContent) + FetchContent_Declare( + lua-vanilla + URL ${LUA_VANILLA_DOWNLOAD_URL}) + FetchContent_GetProperties(lua-vanilla) + if ( NOT lua-vanilla_POPULATED) + # Fetch the content using previously declared details + FetchContent_Populate(lua-vanilla) + # do not add_subdirectory / build: we are JUST using ti as a download step! + endif() + list(TRANSFORM LUA_VANILLA_LIB_SOURCES PREPEND "${lua-vanilla_SOURCE_DIR}/src/") + list(TRANSFORM LUA_VANILLA_LUA_SOURCES PREPEND "${lua-vanilla_SOURCE_DIR}/src/") + # make a quick lua.hpp for targets that don't have it if (LUA_VANILLA_GENERATE_LUA_HPP) set(LUA_VANILLA_LUA_HPP_CONTENT "// lua.hpp // Lua header files for C++ // <> not supplied automatically because Lua also compiles as C++ - extern \"C\" { #include \"lua.h\" #include \"lualib.h\" #include \"lauxlib.h\" } ") - set(LUA_VANILLA_SOURCE_LUA_HPP "${LUA_BUILD_TOPLEVEL}-tmp/lua.hpp") - set(LUA_VANILLA_DESTINATION_LUA_HPP "${LUA_VANILLA_SOURCE_DIR}/lua.hpp") - file(WRITE "${LUA_VANILLA_SOURCE_LUA_HPP}" "${LUA_VANILLA_LUA_HPP_CONTENT}") + set(LUA_VANILLA_SOURCE_LUA_HPP "${lua-vanilla_SOURCE_DIR}/include/lua.hpp") + file(CONFIGURE OUTPUT "${LUA_VANILLA_SOURCE_LUA_HPP}" CONTENT "${LUA_VANILLA_LUA_HPP_CONTENT}" @ONLY) file(TO_NATIVE_PATH "${LUA_VANILLA_SOURCE_LUA_HPP}" LUA_VANILLA_SOURCE_LUA_HPP) - file(TO_NATIVE_PATH "${LUA_VANILLA_DESTINATION_LUA_HPP}" LUA_VANILLA_DESTINATION_LUA_HPP) - ExternalProject_Add_Step(LUA_VANILLA - prebuild - # after download, before build - DEPENDEES download - DEPENDERS build - BYPRODUCTS "${LUA_VANILLA_DESTINATION_LUA_HPP}" - COMMENT "Moving \"${LUA_VANILLA_SOURCE_LUA_HPP}\" to \"${LUA_VANILLA_DESTINATION_LUA_HPP}\"..." - COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_VANILLA_SOURCE_LUA_HPP}" "${LUA_VANILLA_DESTINATION_LUA_HPP}") endif() - set(LUA_VANILLA_INCLUDE_DIRS ${LUA_VANILLA_SOURCE_DIR}) + set(LUA_VANILLA_INCLUDE_DIRS ${lua-vanilla_SOURCE_DIR}/src) endif() # # Target names @@ -325,7 +217,8 @@ set(luacompiler "luac-${LUA_VANILLA_VERSION}") # make an actual, buildable target # that other parts of the code can depend on -add_library(${liblua} ${LUA_BUILD_LIBRARY_TYPE} "${LUA_VANILLA_LIB_SOURCES}") +add_library(${liblua} ${LUA_BUILD_LIBRARY_TYPE} ${LUA_VANILLA_LIB_SOURCES}) +add_library(Lua::Lua ALIAS ${liblua}) set_target_properties(${liblua} PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE} @@ -342,7 +235,9 @@ set_source_files_properties(${LUA_VANILLA_LIB_SOURCES} target_include_directories(${liblua} PUBLIC "${LUA_VANILLA_INCLUDE_DIRS}") target_compile_definitions(${liblua} - PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}) + PUBLIC + LUA_COMPAT_ALL + ${LUA_VANILLA_DLL_DEFINE}) if (MSVC) target_compile_options(${liblua} PRIVATE /W1) @@ -351,15 +246,15 @@ else() PRIVATE -w) endif() if (WIN32) - #target_compile_definitions(${liblua} - # PRIVATE LUA_USE_WINDOWS) else() - target_compile_definitions(${liblua} + target_compile_definitions(${liblua} PRIVATE LUA_USE_LINUX) endif() target_compile_options(${liblua} PRIVATE ${LUA_VANILLA_LUALIB_COMPILER_OPTIONS}) -add_dependencies(${liblua} LUA_VANILLA) +if (LUA_LOCAL_DIR) + add_dependencies(${liblua} LUA_VANILLA) +endif() target_link_libraries(${liblua} PRIVATE ${CMAKE_DL_LIBS}) if (UNIX) target_link_libraries(${liblua} PRIVATE m) @@ -445,4 +340,4 @@ set(LUA_INTERPRETER ${luainterpreter}) if (LUA_BUILD_LUA_COMPILER) set(LUA_COMPILER ${luacompiler}) endif() -set(LUA_INCLUDE_DIRS "${LUA_VANILLA_SOURCE_DIR}") +set(LUA_INCLUDE_DIRS ${LUA_VANILLA_INCLUDE_DIRS}) diff --git a/cmake/Packages/FindLuwraBuild.cmake b/cmake/Packages/FindLuwraBuild.cmake index d395f128..28a5a259 100644 --- a/cmake/Packages/FindLuwraBuild.cmake +++ b/cmake/Packages/FindLuwraBuild.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -59,7 +59,7 @@ ExternalProject_Add(LUWRA_BUILD_SOURCE add_library(${luwra_lib} INTERFACE) add_dependencies(${luwra_lib} LUWRA_BUILD_SOURCE) target_include_directories(${luwra_lib} INTERFACE ${luwra_include_dirs}) -target_link_libraries(${luwra_lib} INTERFACE ${LUA_LIBRARIES}) +target_link_libraries(${luwra_lib} INTERFACE Lua::Lua) if (NOT MSVC) target_compile_options(${luwra_lib} INTERFACE -Wno-noexcept-type -Wno-ignored-qualifiers -Wno-unused-parameter) diff --git a/cmake/Packages/FindSphinx.cmake b/cmake/Packages/FindSphinx.cmake index 55d83c3b..81b89f5c 100644 --- a/cmake/Packages/FindSphinx.cmake +++ b/cmake/Packages/FindSphinx.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -65,4 +65,4 @@ if (Sphinx_Build_FOUND AND NOT TARGET Sphinx::Build) set_property(TARGET Sphinx::Build PROPERTY IMPORTED_LOCATION ${Sphinx_Build_EXECUTABLE}) set_property(TARGET Sphinx::Build PROPERTY VERSION ${Sphinx_Build_VERSION}) mark_as_advanced(Sphinx_Build_EXECUTABLE Sphinx_Build_VERSION) -endif() \ No newline at end of file +endif() diff --git a/cmake/Packages/FindToLuappBuild.cmake b/cmake/Packages/FindToLuappBuild.cmake index 92247c3f..652dbc01 100644 --- a/cmake/Packages/FindToLuappBuild.cmake +++ b/cmake/Packages/FindToLuappBuild.cmake @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -65,7 +65,7 @@ set_target_properties(${toluapp_lib} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) target_include_directories(${toluapp_lib} PUBLIC ${toluapp_include_dirs}) -target_link_libraries(${toluapp_lib} PRIVATE ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) +target_link_libraries(${toluapp_lib} PRIVATE Lua::Lua ${CMAKE_DL_LIBS}) if (MSVC) target_compile_options(${toluapp_lib} PRIVATE /W1) diff --git a/cmake/sol2-config.cmake.in b/cmake/sol2-config.cmake.in index 7bbabe2c..0c48a993 100644 --- a/cmake/sol2-config.cmake.in +++ b/cmake/sol2-config.cmake.in @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/documentation/.clang-format b/documentation/.clang-format index a2c0dcaa..00ef7c2c 100644 --- a/documentation/.clang-format +++ b/documentation/.clang-format @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index 04e7af51..1c7b6758 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -22,7 +22,7 @@ # # # # sol2, documentation generation # # # Required minimum version statement -cmake_minimum_required(VERSION 3.16.0) +cmake_minimum_required(VERSION 3.26.0) find_package(Doxygen REQUIRED) find_package(Python3 REQUIRED) diff --git a/documentation/Doxyfile.in b/documentation/Doxyfile.in index 1cfbc867..7f15d537 100644 --- a/documentation/Doxyfile.in +++ b/documentation/Doxyfile.in @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/documentation/source/build.rst b/documentation/source/build.rst index 712f1826..2eba6bfb 100644 --- a/documentation/source/build.rst +++ b/documentation/source/build.rst @@ -3,7 +3,7 @@ build sol2 is a header-only library. -sol2 comes with a CMake script in the top level. It is primarily made for building and running the examples and tests, but it includes exported and configured targets (``sol2``, ``sol2_single``) for your use. +sol2 comes with a CMake script in the top level. It is primarily made for building and running the examples and tests, but it includes exported and configured targets (``sol2``, ``sol2_single``) for your use. ``sol2::sol2`` alias is defined for the ``sol2`` target as well. sol2 also comes with a Meson Script. If things stop working, file a bug report. diff --git a/documentation/source/conf.py b/documentation/source/conf.py index 2356ff35..b409d989 100644 --- a/documentation/source/conf.py +++ b/documentation/source/conf.py @@ -52,7 +52,7 @@ # General information about the project. project = 'sol2' -copyright = '2021, ThePhD' +copyright = '2022, ThePhD' author = 'ThePhD' # The version info for the project you're documenting, acts as replacement for @@ -349,4 +349,4 @@ def generate_doxygen_xml(app): def setup(app): # Add hook for building doxygen xml when needed - app.connect("builder-inited", generate_doxygen_xml) \ No newline at end of file + app.connect("builder-inited", generate_doxygen_xml) diff --git a/documentation/source/containers.rst b/documentation/source/containers.rst index f5d6d6fa..dd5256a6 100644 --- a/documentation/source/containers.rst +++ b/documentation/source/containers.rst @@ -7,6 +7,7 @@ Containers are objects that are meant to be inspected and iterated and whose job * Containers from C++ are stored as ``userdata`` with special ``usertype`` metatables with :ref:`special operations` - In Lua 5.1, this means containers pushed without wrappers like :doc:`as_table` and :doc:`nested` will not work with ``pairs`` or other built-in iteration functions from Lua + Lua 5.2+ will behave just fine (does not include LuaJIT 2.0.x) + + If this behaviour is needed using LuaJIT, the compilation flag `LUAJIT_ENABLE_LUA52COMPAT` can be used. - You must push containers into C++ by returning them directly and getting/setting them directly, and they will have a type of ``sol::type::userdata`` and treated like a usertype * Containers can be manipulated from both C++ and Lua, and, like userdata, will `reflect changes if you use a reference`_ to the data. * This means containers **do not automatically serialize as Lua tables** diff --git a/documentation/source/features.rst b/documentation/source/features.rst index c918cca2..6fc1faaf 100644 --- a/documentation/source/features.rst +++ b/documentation/source/features.rst @@ -171,7 +171,7 @@ kaguya - sol - * One of the few libraries with optional support! -* Basically the fastest in almomst all respects: http://sol2.readthedocs.io/en/latest/benchmarks.html +* Basically the fastest in almost all respects: http://sol2.readthedocs.io/en/latest/benchmarks.html * Overloading support can get messy with inheritance, see :doc:`here` * C++14/"C++1y" (-std=c++14, -std=c++1y, =std=c++1z) flags are used (available since GCC 4.9 and Clang 3.5) * Active issues, active individuals diff --git a/documentation/source/functions.rst b/documentation/source/functions.rst index 762d4081..2ea0b3ba 100644 --- a/documentation/source/functions.rst +++ b/documentation/source/functions.rst @@ -67,7 +67,7 @@ You can change this behavior by defining ``SOL_FUNCTION_CALL_VALUE_SEMANTICS``, .. note:: - This also means that you should pass and receive arguments in certain ways to maximize efficiency. For example, ``sol::table``, ``sol::object``, ``sol::userdata`` and friends are cheap to copy, and should simply by taken as values. This includes primitive types like ``int`` and ``double``. However, C++ types -- if you do not want copies -- should be taken as ``const type&`` or ``type&``, to save on copies if it's important. Note that taking references from Lua also means you can modify the data inside of Lua directly, so be careful. Lua by default deals with things mostly by reference (save for primitive types). + This also means that you should pass and receive arguments in certain ways to maximize efficiency. For example, ``sol::table``, ``sol::object``, ``sol::userdata`` and friends are cheap to copy, and should simply be taken as values. This includes primitive types like ``int`` and ``double``. However, C++ types -- if you do not want copies -- should be taken as ``const type&`` or ``type&``, to save on copies if it's important. Note that taking references from Lua also means you can modify the data inside of Lua directly, so be careful. Lua by default deals with things mostly by reference (save for primitive types). When you bind a function to Lua, please take any pointer arguments as ``T*``, unless you specifically know you are going to match the exact type of the unique/shared pointer and the class it wraps. sol2 cannot support "implicit wrapped pointer casting", such as taking a ``std::shared_ptr`` when the function is passed a ``std::shared_ptr``. Sometimes it may work because the compiler might be able to line up your classes in such a way that raw casts work, but this is undefined behavior through and through and sol2 has no mechanisms by which it can make this safe and not blow up in the user's face. diff --git a/documentation/source/safety.rst b/documentation/source/safety.rst index f4b4b4d2..f29bb11f 100644 --- a/documentation/source/safety.rst +++ b/documentation/source/safety.rst @@ -30,7 +30,7 @@ Safety Config * All calls from Lua will have their arguments checked * Turned on by default with clang++, g++ and VC++ if a basic check for building in debug mode is detected (lack of ``_NDEBUG`` or similar compiler-specific checks) -``SOL_SAFE_FUNCTION`` triggers the following change: +``SOL_SAFE_FUNCTIONS`` triggers the following change: * All uses of ``sol::function`` and ``sol::stack_function`` will default to ``sol::protected_function`` and ``sol::stack_protected_function``, respectively, rather than ``sol::unsafe_function`` and ``sol::stack_unsafe_function`` - Note this does not apply to ``sol::stack_aligned_function``: this variant must always be unprotected due to stack positioning requirements, especially in use with ``sol::stack_count`` * Will make any ``sol::state_view::script`` calls default to their safe variants if there is no supplied environment or error handler function diff --git a/documentation/source/tutorial/all-the-things.rst b/documentation/source/tutorial/all-the-things.rst index 34a36190..4e1c7295 100644 --- a/documentation/source/tutorial/all-the-things.rst +++ b/documentation/source/tutorial/all-the-things.rst @@ -22,7 +22,7 @@ asserts / prerequisites You'll need to ``#include `` somewhere in your code. sol is header-only, so you don't need to compile anything. However, **Lua must be compiled and available**. See the :doc:`getting started tutorial` for more details. -Below, you will see use of a function called ``sol_c_assert``. This is an assert macro that comes with sol2 for the expression purpose of checking things; it's value is immaterial. +Below, you will see use of a function called ``SOL_ASSERT``. This is an assert macro that comes with sol2 for the expression purpose of checking things; it's value is immaterial. diff --git a/documentation/source/tutorial/variables.rst b/documentation/source/tutorial/variables.rst index d2b7d3b8..8e361403 100644 --- a/documentation/source/tutorial/variables.rst +++ b/documentation/source/tutorial/variables.rst @@ -19,7 +19,7 @@ You can interact with the Lua Virtual Machine like so: :linenos: :lines: 1-10, 12-12, 20-24, 70- -From this example, you can see that there's many ways to pull out the varaibles you want. For example, to determine if a nested variable exists or not, you can use ``auto`` to capture the value of a ``table[key]`` lookup, and then use the ``.valid()`` method: +From this example, you can see that there's many ways to pull out the variables you want. For example, to determine if a nested variable exists or not, you can use ``auto`` to capture the value of a ``table[key]`` lookup, and then use the ``.valid()`` method: .. literalinclude:: ../../../examples/source/tutorials/variables_demo.cpp diff --git a/examples/.clang-format b/examples/.clang-format index adf570ac..9807f392 100644 --- a/examples/.clang-format +++ b/examples/.clang-format @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 59f1caa6..0ff8a112 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -24,7 +24,7 @@ function(sol2_add_example_properties target-name) target_link_libraries(${target-name} - PUBLIC Threads::Threads ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) + PUBLIC Threads::Threads Lua::Lua ${CMAKE_DL_LIBS}) target_compile_definitions(${target-name} PUBLIC SOL_PRINT_ERRORS=1) target_compile_options(${target-name} diff --git a/examples/customization/CMakeLists.txt b/examples/customization/CMakeLists.txt index 38f7ff94..11312dfe 100644 --- a/examples/customization/CMakeLists.txt +++ b/examples/customization/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -50,7 +50,7 @@ function (MAKE_CUSTOMIZATION_EXAMPLE example_suffix target_sol) endif() target_link_libraries(${customization_example_name} - PRIVATE Threads::Threads ${target_sol} ${LUA_LIBRARIES}) + PRIVATE Threads::Threads ${target_sol} Lua::Lua) target_include_directories(${customization_example_name} PRIVATE include) endfunction() diff --git a/examples/interop/LuaBridge/CMakeLists.txt b/examples/interop/LuaBridge/CMakeLists.txt index 73aa9e9b..1e2c0ae3 100644 --- a/examples/interop/LuaBridge/CMakeLists.txt +++ b/examples/interop/LuaBridge/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -30,7 +30,7 @@ function (make_luabridge_interop_example target_library example_suffix) add_executable(${example_name} source/LuaBridge.cpp) target_link_libraries(${example_name} - PRIVATE ${LUA_LIBRARIES} ${LUABRIDGE_LIBRARIES} + PRIVATE Lua::Lua ${LUABRIDGE_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) diff --git a/examples/interop/LuaBridge/source/LuaBridge.cpp b/examples/interop/LuaBridge/source/LuaBridge.cpp index f9092b3a..e06a73d5 100644 --- a/examples/interop/LuaBridge/source/LuaBridge.cpp +++ b/examples/interop/LuaBridge/source/LuaBridge.cpp @@ -71,7 +71,7 @@ void register_sol_stuff(lua_State* L) { "luabridge-created A { " << from_luabridge.value() << " }" << std::endl; - sol_c_assert(from_luabridge.value() == 24); + SOL_ASSERT(from_luabridge.value() == 24); }, [](A& from_luabridge, int second_arg) { std::cout << "calling 2-argument version with " @@ -79,8 +79,8 @@ void register_sol_stuff(lua_State* L) { << from_luabridge.value() << " } and integer argument of " << second_arg << std::endl; - sol_c_assert(from_luabridge.value() == 24); - sol_c_assert(second_arg == 5); + SOL_ASSERT(from_luabridge.value() == 24); + SOL_ASSERT(second_arg == 5); }); } @@ -88,7 +88,7 @@ void check_with_sol(lua_State* L) { sol::state_view lua(L); A& obj = lua["obj"]; (void)obj; - sol_c_assert(obj.value() == 24); + SOL_ASSERT(obj.value() == 24); } int main(int, char*[]) { @@ -132,4 +132,4 @@ f(obj, 5) -- call 2 argument version check_with_sol(L); return 0; -} \ No newline at end of file +} diff --git a/examples/interop/kaguya/CMakeLists.txt b/examples/interop/kaguya/CMakeLists.txt index 7e99e8b6..6b3a9acc 100644 --- a/examples/interop/kaguya/CMakeLists.txt +++ b/examples/interop/kaguya/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -30,7 +30,7 @@ function (make_kaguya_interop_example target_library example_suffix) add_executable(${example_name} source/kaguya.cpp) target_link_libraries(${example_name} - PRIVATE ${LUA_LIBRARIES} ${KAGUYA_LIBRARIES} + PRIVATE Lua::Lua ${KAGUYA_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) diff --git a/examples/interop/kaguya/source/kaguya.cpp b/examples/interop/kaguya/source/kaguya.cpp index ff3ffb27..b9e9c0ee 100644 --- a/examples/interop/kaguya/source/kaguya.cpp +++ b/examples/interop/kaguya/source/kaguya.cpp @@ -86,7 +86,7 @@ void register_sol_stuff(lua_State* L) { "kaguya-created ABC { " << from_kaguya.value() << " }" << std::endl; - sol_c_assert(from_kaguya.value() == 24); + SOL_ASSERT(from_kaguya.value() == 24); }, [](ABC& from_kaguya, int second_arg) { std::cout << "calling 2-argument version with " @@ -94,8 +94,8 @@ void register_sol_stuff(lua_State* L) { << from_kaguya.value() << " } and integer argument of " << second_arg << std::endl; - sol_c_assert(from_kaguya.value() == 24); - sol_c_assert(second_arg == 5); + SOL_ASSERT(from_kaguya.value() == 24); + SOL_ASSERT(second_arg == 5); }); } @@ -103,7 +103,7 @@ void check_with_sol(lua_State* L) { sol::state_view lua(L); ABC& obj = lua["obj"]; (void)obj; - sol_c_assert(obj.value() == 24); + SOL_ASSERT(obj.value() == 24); } int main(int, char*[]) { @@ -138,4 +138,4 @@ f(obj, 5) -- call 2 argument version check_with_sol(state.state()); return 0; -} \ No newline at end of file +} diff --git a/examples/interop/luwra/CMakeLists.txt b/examples/interop/luwra/CMakeLists.txt index 9a5cdf71..c070ffdd 100644 --- a/examples/interop/luwra/CMakeLists.txt +++ b/examples/interop/luwra/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -30,7 +30,7 @@ function (make_luwra_interop_example target_library example_suffix) add_executable(${example_name} source/luwra.cpp) target_link_libraries(${example_name} - PRIVATE ${LUA_LIBRARIES} ${LUWRA_LIBRARIES} + PRIVATE Lua::Lua ${LUWRA_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) diff --git a/examples/interop/luwra/source/luwra.cpp b/examples/interop/luwra/source/luwra.cpp index de6f6740..1f4497b9 100644 --- a/examples/interop/luwra/source/luwra.cpp +++ b/examples/interop/luwra/source/luwra.cpp @@ -83,7 +83,7 @@ void register_sol_stuff(lua_State* L) { "luwra-created ABC { " << from_luwra.value() << " }" << std::endl; - sol_c_assert(from_luwra.value() == 24); + SOL_ASSERT(from_luwra.value() == 24); }, [](ABC& from_luwra, int second_arg) { std::cout << "calling 2-argument version with " @@ -91,8 +91,8 @@ void register_sol_stuff(lua_State* L) { << from_luwra.value() << " } and integer argument of " << second_arg << std::endl; - sol_c_assert(from_luwra.value() == 24); - sol_c_assert(second_arg == 5); + SOL_ASSERT(from_luwra.value() == 24); + SOL_ASSERT(second_arg == 5); }); } @@ -100,7 +100,7 @@ void check_with_sol(lua_State* L) { sol::state_view lua(L); ABC& obj = lua["obj"]; (void)obj; - sol_c_assert(obj.value() == 24); + SOL_ASSERT(obj.value() == 24); } int main(int, char*[]) { @@ -128,4 +128,4 @@ f(obj, 5) -- call 2 argument version check_with_sol(state); return 0; -} \ No newline at end of file +} diff --git a/examples/interop/tolua/CMakeLists.txt b/examples/interop/tolua/CMakeLists.txt index 76a53c56..3f151ba9 100644 --- a/examples/interop/tolua/CMakeLists.txt +++ b/examples/interop/tolua/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -31,7 +31,7 @@ function(make_tolua_interop_example target_library example_suffix) add_executable(${example_name} source/tolua.cpp) target_link_libraries(${example_name} PRIVATE - ${LUA_LIBRARIES} ${TOLUAPP_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) + Lua::Lua ${TOLUAPP_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) target_compile_options(${example_name} diff --git a/examples/interop/tolua/source/tolua.cpp b/examples/interop/tolua/source/tolua.cpp index bf1d1d85..b49ea1b9 100644 --- a/examples/interop/tolua/source/tolua.cpp +++ b/examples/interop/tolua/source/tolua.cpp @@ -56,7 +56,7 @@ void register_sol_stuff(lua_State* L) { "tolua-created Player { health:" << from_tolua.getHealth() << " }" << std::endl; - sol_c_assert(from_tolua.getHealth() == 4); + SOL_ASSERT(from_tolua.getHealth() == 4); }, [](Player& from_tolua, int second_arg) { std::cout << "calling 2-argument version with " @@ -64,8 +64,8 @@ void register_sol_stuff(lua_State* L) { << from_tolua.getHealth() << " } and integer argument of " << second_arg << std::endl; - sol_c_assert(from_tolua.getHealth() == 4); - sol_c_assert(second_arg == 5); + SOL_ASSERT(from_tolua.getHealth() == 4); + SOL_ASSERT(second_arg == 5); }); } @@ -73,7 +73,7 @@ void check_with_sol(lua_State* L) { sol::state_view lua(L); Player& obj = lua["obj"]; (void)obj; - sol_c_assert(obj.getHealth() == 4); + SOL_ASSERT(obj.getHealth() == 4); } int main(int, char*[]) { @@ -110,4 +110,4 @@ f(obj, 5) -- call 2 argument version check_with_sol(L); return 0; -} \ No newline at end of file +} diff --git a/examples/require_dll_example/CMakeLists.txt b/examples/require_dll_example/CMakeLists.txt index 46981d1e..15c5df1d 100644 --- a/examples/require_dll_example/CMakeLists.txt +++ b/examples/require_dll_example/CMakeLists.txt @@ -1,7 +1,7 @@ # # # # sol2 # The MIT License (MIT) # -# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors +# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -46,7 +46,7 @@ function(make_require_from_dll_example target_lib example_lib_name_suffix) PUBLIC MY_OBJECT_DLL PRIVATE MY_OBJECT_BUILD) target_link_libraries(${example_lib_name} - PUBLIC ${target_lib} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) + PUBLIC ${target_lib} Lua::Lua ${CMAKE_DL_LIBS}) target_include_directories(${example_lib_name} PUBLIC "${LUA_INCLUDE_DIRS}") @@ -83,7 +83,7 @@ function(make_require_from_dll_example target_lib example_lib_name_suffix) # add executable target that represents require_from_dll program add_executable(${example_name} ${require_from_dll_sources}) target_link_libraries(${example_name} - PRIVATE my_object ${LUA_LIBRARIES} ${target_lib} ${CMAKE_DL_LIBS}) + PRIVATE my_object Lua::Lua ${target_lib} ${CMAKE_DL_LIBS}) target_include_directories(${example_name} PRIVATE ${LUA_INCLUDE_DIRS}) diff --git a/examples/require_dll_example/source/require_from_dll.cpp b/examples/require_dll_example/source/require_from_dll.cpp index 1d8f96bb..4ecb8748 100644 --- a/examples/require_dll_example/source/require_from_dll.cpp +++ b/examples/require_dll_example/source/require_from_dll.cpp @@ -27,9 +27,9 @@ print(obj.value))"; std::cout << "Something bad happened: " << err.what() << std::endl; } - sol_c_assert(script_result.valid()); + SOL_ASSERT(script_result.valid()); my_object::test& obj = lua["obj"]; - sol_c_assert(obj.value == 24); + SOL_ASSERT(obj.value == 24); return 0; -} \ No newline at end of file +} diff --git a/examples/source/any_return.cpp b/examples/source/any_return.cpp index 7530effb..cb389231 100644 --- a/examples/source/any_return.cpp +++ b/examples/source/any_return.cpp @@ -30,10 +30,10 @@ int main() { int result = lua["f"](1, 2); // result == 3 - sol_c_assert(result == 3); + SOL_ASSERT(result == 3); double result2 = lua["f"](false, 2.5); // result2 == 2.5 - sol_c_assert(result2 == 2.5); + SOL_ASSERT(result2 == 2.5); // call in Lua, get result // notice we only need 2 arguments here, not 3 @@ -41,7 +41,7 @@ int main() { lua.script("result3 = f(true, 5.5)"); double result3 = lua["result3"]; // result3 == 16.5 - sol_c_assert(result3 == 16.5); + SOL_ASSERT(result3 == 16.5); std::cout << "=== any_return ===" << std::endl; std::cout << "result : " << result << std::endl; @@ -50,4 +50,4 @@ int main() { std::cout << std::endl; return 0; -} \ No newline at end of file +} diff --git a/examples/source/as_returns.cpp b/examples/source/as_returns.cpp index 421a0618..bfb8a013 100644 --- a/examples/source/as_returns.cpp +++ b/examples/source/as_returns.cpp @@ -21,9 +21,9 @@ int main() { std::string v2 = lua["v2"]; std::string v3 = lua["v3"]; - sol_c_assert(v1 == "arf"); - sol_c_assert(v2 == "bark"); - sol_c_assert(v3 == "woof"); + SOL_ASSERT(v1 == "arf"); + SOL_ASSERT(v2 == "bark"); + SOL_ASSERT(v3 == "woof"); return 0; } diff --git a/examples/source/basic.cpp b/examples/source/basic.cpp index 9b45dc78..a155062b 100644 --- a/examples/source/basic.cpp +++ b/examples/source/basic.cpp @@ -46,7 +46,7 @@ int main() { "appear above this one!" << std::endl; int value = result; - sol_c_assert(value == 24); + SOL_ASSERT(value == 24); } else { std::cout << "the third script failed, check the " @@ -63,7 +63,7 @@ int main() { "wasn't supposed to! Panic!" << std::endl; int value = result; - sol_c_assert(value == 24); + SOL_ASSERT(value == 24); } else { sol::error err = result; diff --git a/examples/source/c_array.cpp b/examples/source/c_array.cpp index 68d1f021..6a535780 100644 --- a/examples/source/c_array.cpp +++ b/examples/source/c_array.cpp @@ -30,10 +30,10 @@ int main() { )"); something& s = lua["s"]; - sol_c_assert(s.arr[0] == 5); - sol_c_assert(s.arr[1] == 6); - sol_c_assert(s.arr[2] == 40); - sol_c_assert(s.arr[3] == 8); + SOL_ASSERT(s.arr[0] == 5); + SOL_ASSERT(s.arr[1] == 6); + SOL_ASSERT(s.arr[2] == 40); + SOL_ASSERT(s.arr[3] == 8); std::string string_array[] = { "first string", @@ -49,7 +49,7 @@ int main() { print(str_arr[3]) )"); - sol_c_assert(string_array[2] == "third string: modified"); + SOL_ASSERT(string_array[2] == "third string: modified"); return 0; } diff --git a/examples/source/c_call.cpp b/examples/source/c_call.cpp index 1e422657..d48560aa 100644 --- a/examples/source/c_call.cpp +++ b/examples/source/c_call.cpp @@ -40,15 +40,15 @@ int main() { // get the results and see // if it worked out int r1 = lua["r1"]; - sol_c_assert(r1 == 32); + SOL_ASSERT(r1 == 32); int r2 = lua["r2"]; - sol_c_assert(r2 == 1); + SOL_ASSERT(r2 == 1); double r3 = lua["r3"]; - sol_c_assert(r3 == 2.5); + SOL_ASSERT(r3 == 2.5); int r4 = lua["r4"]; - sol_c_assert(r4 == 32); + SOL_ASSERT(r4 == 32); int r5 = lua["r5"]; - sol_c_assert(r5 == 1); + SOL_ASSERT(r5 == 1); return 0; } diff --git a/examples/source/config.cpp b/examples/source/config.cpp index 1dcc8d51..a47b2580 100644 --- a/examples/source/config.cpp +++ b/examples/source/config.cpp @@ -31,9 +31,9 @@ height = 1080 screen.name = lua.get("name"); screen.width = lua.get("width"); screen.height = lua.get("height"); - sol_c_assert(screen.name == "Asus"); - sol_c_assert(screen.width == 1920); - sol_c_assert(screen.height == 1080); + SOL_ASSERT(screen.name == "Asus"); + SOL_ASSERT(screen.width == 1920); + SOL_ASSERT(screen.height == 1080); std::cout << "=== config ===" << std::endl; screen.print(); diff --git a/examples/source/container_usertype_as_container.cpp b/examples/source/container_usertype_as_container.cpp index 6f55b40e..3059c289 100644 --- a/examples/source/container_usertype_as_container.cpp +++ b/examples/source/container_usertype_as_container.cpp @@ -80,8 +80,8 @@ print("accumulate after :", ns:accumulate()) number_storage& ns = lua["ns"]; number_storage& ns_container = lua["ns_container"]; - sol_c_assert(&ns == &ns_container); - sol_c_assert(ns.size() == 3); + SOL_ASSERT(&ns == &ns_container); + SOL_ASSERT(ns.size() == 3); std::cout << std::endl; diff --git a/examples/source/containers_as_table.cpp b/examples/source/containers_as_table.cpp index 1a8c9063..9c9e8145 100644 --- a/examples/source/containers_as_table.cpp +++ b/examples/source/containers_as_table.cpp @@ -16,10 +16,10 @@ void demo( src) { std::cout << "demo, sol::nested<...>" << std::endl; const auto& listmap = src.value(); - sol_c_assert(listmap.size() == 2); + SOL_ASSERT(listmap.size() == 2); for (const auto& kvp : listmap) { const std::vector& strings = kvp.second; - sol_c_assert(strings.size() == 3); + SOL_ASSERT(strings.size() == 3); std::cout << "\t" << kvp.first << " = "; for (const auto& s : strings) { std::cout << "'" << s << "'" @@ -46,13 +46,13 @@ void demo_explicit(sol::as_table_t& strings = kvp.second.value(); - sol_c_assert(strings.size() == 3); + SOL_ASSERT(strings.size() == 3); std::cout << "\t" << kvp.first << " = "; for (const auto& s : strings) { std::cout << "'" << s << "'" @@ -85,4 +85,4 @@ g(t) std::cout << std::endl; return 0; -} \ No newline at end of file +} diff --git a/examples/source/coroutine_state.cpp b/examples/source/coroutine_state.cpp index 0845470e..6e2e894c 100644 --- a/examples/source/coroutine_state.cpp +++ b/examples/source/coroutine_state.cpp @@ -45,7 +45,7 @@ int main(int, char*[]) { transferred_into(); // check int i = lua["i"]; - sol_c_assert(i == 1); + SOL_ASSERT(i == 1); std::cout << std::endl; diff --git a/examples/source/custom_reader.cpp b/examples/source/custom_reader.cpp index d2d88344..90d36fbf 100644 --- a/examples/source/custom_reader.cpp +++ b/examples/source/custom_reader.cpp @@ -91,7 +91,7 @@ int main() { &reader, sol::script_pass_on_error); // make sure we ran loaded and ran the code successfully - sol_c_assert(result.valid()); + SOL_ASSERT(result.valid()); // note there are lua.load( ... ) variants that take a // custom reader than JUST run the code, too! diff --git a/examples/source/customization_convert_on_get.cpp b/examples/source/customization_convert_on_get.cpp index d7b0ed96..9fb311cb 100644 --- a/examples/source/customization_convert_on_get.cpp +++ b/examples/source/customization_convert_on_get.cpp @@ -56,8 +56,8 @@ int main() { number_shim thingsf = lua["vf"]; number_shim thingsg = lua["vg"]; - sol_c_assert(thingsf.num == 25); - sol_c_assert(thingsg.num == 35); + SOL_ASSERT(thingsf.num == 25); + SOL_ASSERT(thingsg.num == 35); return 0; } diff --git a/examples/source/customization_multiple.cpp b/examples/source/customization_multiple.cpp index 193ea8c4..db1e2108 100644 --- a/examples/source/customization_multiple.cpp +++ b/examples/source/customization_multiple.cpp @@ -64,8 +64,8 @@ int main() { sol::function f = lua["f"]; two_things things = f(two_things { 24, false }); - sol_c_assert(things.a == 24); - sol_c_assert(things.b == false); + SOL_ASSERT(things.a == 24); + SOL_ASSERT(things.b == false); // things.a == 24 // things.b == true diff --git a/examples/source/docs/inheritance.cpp b/examples/source/docs/inheritance.cpp index c011db46..096f4b5a 100644 --- a/examples/source/docs/inheritance.cpp +++ b/examples/source/docs/inheritance.cpp @@ -20,7 +20,7 @@ int main(int, char*[]) { sol::state lua; - lua.new_usertype("A", "call", &A::call); + lua.new_usertype("A", "call", &A::call); lua.new_usertype("B", "call", diff --git a/examples/source/docs/references_in_lambdas.cpp b/examples/source/docs/references_in_lambdas.cpp index 82101449..b3e54d3a 100644 --- a/examples/source/docs/references_in_lambdas.cpp +++ b/examples/source/docs/references_in_lambdas.cpp @@ -20,9 +20,9 @@ int main(int, char*[]) { test& from_lua_t2 = lua["t2"]; // not the same: 'f' lambda copied - sol_c_assert(&from_lua_t1 != &t); + SOL_ASSERT(&from_lua_t1 != &t); // the same: 'g' lambda returned reference - sol_c_assert(&from_lua_t2 == &t); + SOL_ASSERT(&from_lua_t2 == &t); return 0; } diff --git a/examples/source/docs/simple_functions.cpp b/examples/source/docs/simple_functions.cpp index d9921f2a..0eca59a6 100644 --- a/examples/source/docs/simple_functions.cpp +++ b/examples/source/docs/simple_functions.cpp @@ -7,11 +7,11 @@ int main() { int x = 0; lua.set_function("beep", [&x] { ++x; }); lua.script("beep()"); - sol_c_assert(x == 1); + SOL_ASSERT(x == 1); sol::function beep = lua["beep"]; beep(); - sol_c_assert(x == 2); + SOL_ASSERT(x == 2); return 0; } diff --git a/examples/source/docs/simple_structs.cpp b/examples/source/docs/simple_structs.cpp index 8ba4adb5..6bc2b5b7 100644 --- a/examples/source/docs/simple_structs.cpp +++ b/examples/source/docs/simple_structs.cpp @@ -22,10 +22,10 @@ int main() { vars& beep = lua["beep"]; int bopvalue = lua["bopvalue"]; - sol_c_assert(beep.boop == 1); - sol_c_assert(lua.get("beep").boop == 1); - sol_c_assert(beep.bop() == 2); - sol_c_assert(bopvalue == 2); + SOL_ASSERT(beep.boop == 1); + SOL_ASSERT(lua.get("beep").boop == 1); + SOL_ASSERT(beep.bop() == 2); + SOL_ASSERT(bopvalue == 2); return 0; } diff --git a/examples/source/docs/state_transfer.cpp b/examples/source/docs/state_transfer.cpp index af114daa..904eaf8f 100644 --- a/examples/source/docs/state_transfer.cpp +++ b/examples/source/docs/state_transfer.cpp @@ -44,7 +44,7 @@ int main(int, char*[]) { transferred_into(); // check int i = lua["i"]; - sol_c_assert(i == 1); + SOL_ASSERT(i == 1); return 0; } diff --git a/examples/source/docs/std_thread.cpp b/examples/source/docs/std_thread.cpp index 3c15f80b..6b8a30c2 100644 --- a/examples/source/docs/std_thread.cpp +++ b/examples/source/docs/std_thread.cpp @@ -23,7 +23,7 @@ struct worker_data { }; void worker_thread(worker_data& data) { - for (std::uint64_t loops = 0; true; ++loops) { + for ([[maybe_unused]] std::uint64_t loops = 0; true; ++loops) { // Wait until main() sends data std::unique_lock data_lock( data.until_ready_mutex); diff --git a/examples/source/dump.cpp b/examples/source/dump.cpp index decb448f..a9091e45 100644 --- a/examples/source/dump.cpp +++ b/examples/source/dump.cpp @@ -22,7 +22,7 @@ int main() { sol::load_result lr = lua.load("a = function (v) print(v) return v end"); // check if it's sucessfully loaded - sol_c_assert(lr.valid()); + SOL_ASSERT(lr.valid()); // turn it into a function, then dump the bytecode sol::protected_function target @@ -34,12 +34,12 @@ int main() { auto result2 = lua2.safe_script( target_bc.as_string_view(), sol::script_pass_on_error); // check if it was done properly - sol_c_assert(result2.valid()); + SOL_ASSERT(result2.valid()); // check in the second state if it was valid sol::protected_function pf = lua2["a"]; int v = pf(25557); - sol_c_assert(v == 25557); + SOL_ASSERT(v == 25557); return 0; -} \ No newline at end of file +} diff --git a/examples/source/dynamic_object.cpp b/examples/source/dynamic_object.cpp index a2a60ae6..65d58089 100644 --- a/examples/source/dynamic_object.cpp +++ b/examples/source/dynamic_object.cpp @@ -10,7 +10,9 @@ struct dynamic_object { std::unordered_map entries; - void dynamic_set(std::string key, sol::stack_object value) { + // Uses main_object since we may get objects from coroutine + // threads that might die before us. + void dynamic_set(std::string key, sol::main_object value) { auto it = entries.find(key); if (it == entries.cend()) { entries.insert( @@ -78,11 +80,11 @@ assert(value == 15) // does not work on d1: 'run' wasn't added to d1, only d2 auto script_result = lua.safe_script( "local value = d1:run(5)", sol::script_pass_on_error); - sol_c_assert(!script_result.valid()); + SOL_ASSERT(!script_result.valid()); sol::error err = script_result; std::cout << "received expected error: " << err.what() << std::endl; std::cout << std::endl; return 0; -} \ No newline at end of file +} diff --git a/examples/source/environments_on_functions.cpp b/examples/source/environments_on_functions.cpp index f434f54a..fde4ba9a 100644 --- a/examples/source/environments_on_functions.cpp +++ b/examples/source/environments_on_functions.cpp @@ -16,11 +16,11 @@ int main(int, char**) { sol::environment env_f(lua, sol::create); env_f["test"] = 31; bool env_f_set_success = sol::set_environment(env_f, f); - sol_c_assert(env_f_set_success); + SOL_ASSERT(env_f_set_success); // the function returns the value from the environment table int result = f(); - sol_c_assert(result == 31); + SOL_ASSERT(result == 31); // You can also protect from variables @@ -30,19 +30,19 @@ int main(int, char**) { sol::environment env_g(lua, sol::create); bool env_g_set_success = env_g.set_on(g); // same as set_environment - sol_c_assert(env_g_set_success); + SOL_ASSERT(env_g_set_success); g(); // the value can be retrieved from the env table int test = env_g["test"]; - sol_c_assert(test == 5); + SOL_ASSERT(test == 5); // the global environment // is not polluted at all, despite both functions being used // and set sol::object global_test = lua["test"]; - sol_c_assert(!global_test.valid()); + SOL_ASSERT(!global_test.valid()); // You can retrieve environments in C++ @@ -62,9 +62,9 @@ int main(int, char**) { int test_target_env = target_env["test"]; // the environment for f the one gotten from // `target` are the same - sol_c_assert(test_env_f == test_target_env); - sol_c_assert(test_env_f == 31); - sol_c_assert(env_f == target_env); + SOL_ASSERT(test_env_f == test_target_env); + SOL_ASSERT(test_env_f == 31); + SOL_ASSERT(env_f == target_env); }); lua.set_function( "check_g_env", [&env_g](sol::function target) { @@ -73,9 +73,9 @@ int main(int, char**) { = sol::get_environment(target); int test_env_g = env_g["test"]; int test_target_env = target_env["test"]; - sol_c_assert(test_env_g == test_target_env); - sol_c_assert(test_env_g == 5); - sol_c_assert(env_g == target_env); + SOL_ASSERT(test_env_g == test_target_env); + SOL_ASSERT(test_env_g == 5); + SOL_ASSERT(env_g == target_env); }); lua.script("check_f_env(f)"); diff --git a/examples/source/exception_handler.cpp b/examples/source/exception_handler.cpp index 78c3f67f..b751eadb 100644 --- a/examples/source/exception_handler.cpp +++ b/examples/source/exception_handler.cpp @@ -50,7 +50,7 @@ int main() { sol::protected_function_result pfr = lua.safe_script( "will_throw()", &sol::script_pass_on_error); - sol_c_assert(!pfr.valid()); + SOL_ASSERT(!pfr.valid()); sol::error err = pfr; std::cout << err.what() << std::endl; diff --git a/examples/source/functions.cpp b/examples/source/functions.cpp index 05070f2b..9a1db832 100644 --- a/examples/source/functions.cpp +++ b/examples/source/functions.cpp @@ -46,7 +46,7 @@ int main() { // calling a stateful lambda modifies the value lua.script("inc()"); - sol_c_assert(x == 10); + SOL_ASSERT(x == 10); if (x == 10) { // Do something based on this information std::cout << "Yahoo! x is " << x << std::endl; @@ -58,7 +58,7 @@ inc() inc() inc() )"); - sol_c_assert(x == 40); + SOL_ASSERT(x == 40); if (x == 40) { // Do something based on this information std::cout << "Yahoo! x is " << x << std::endl; @@ -70,8 +70,8 @@ inc() int value = add(10, 11); // second way to call the function int value2 = add.call(10, 11); - sol_c_assert(value == 21); - sol_c_assert(value2 == 21); + SOL_ASSERT(value == 21); + SOL_ASSERT(value2 == 21); if (value == 21 && value2 == 21) { std::cout << "Woo, value is 21!" << std::endl; } @@ -79,4 +79,4 @@ inc() std::cout << std::endl; return 0; -} \ No newline at end of file +} diff --git a/examples/source/index_and_newindex_usertype.cpp b/examples/source/index_and_newindex_usertype.cpp index bd830c24..9de25a6f 100644 --- a/examples/source/index_and_newindex_usertype.cpp +++ b/examples/source/index_and_newindex_usertype.cpp @@ -39,9 +39,9 @@ int main() { "print(v[2])\n"); vector& v = lua["v"]; - sol_c_assert(v[0] == 0.0); - sol_c_assert(v[1] == 0.0); - sol_c_assert(v[2] == 3.0); + SOL_ASSERT(v[0] == 0.0); + SOL_ASSERT(v[1] == 0.0); + SOL_ASSERT(v[2] == 3.0); return 0; } diff --git a/examples/source/indirect_function_calls.cpp b/examples/source/indirect_function_calls.cpp index 3e25baa9..ca396f4a 100644 --- a/examples/source/indirect_function_calls.cpp +++ b/examples/source/indirect_function_calls.cpp @@ -69,8 +69,8 @@ end int subtract_result = lua["subtract_result"]; int add_result = lua["add_result"]; - sol_c_assert(add_result == 6); - sol_c_assert(subtract_result == 4); + SOL_ASSERT(add_result == 6); + SOL_ASSERT(subtract_result == 4); std::cout << std::endl; return 0; diff --git a/examples/source/metatable_key_low_level.cpp b/examples/source/metatable_key_low_level.cpp index 37620d4a..6bfb2a96 100644 --- a/examples/source/metatable_key_low_level.cpp +++ b/examples/source/metatable_key_low_level.cpp @@ -28,7 +28,7 @@ int main(int, char*[]) { int result1 = b_as_function(1); // pass 'self' directly to argument int result2 = b_call(b, 1); - sol_c_assert(result1 == result2); - sol_c_assert(result1 == 1); - sol_c_assert(result2 == 1); + SOL_ASSERT(result1 == result2); + SOL_ASSERT(result1 == 1); + SOL_ASSERT(result2 == 1); } diff --git a/examples/source/multi_results.cpp b/examples/source/multi_results.cpp index 12241bee..f216cb1d 100644 --- a/examples/source/multi_results.cpp +++ b/examples/source/multi_results.cpp @@ -28,8 +28,8 @@ int main() { sol::tie(first, second) = multi(); // use the values - sol_c_assert(first == 10); - sol_c_assert(second == "goodbye"); + SOL_ASSERT(first == 10); + SOL_ASSERT(second == "goodbye"); // sol::as_returns // works with any iterable, @@ -48,9 +48,9 @@ int main() { int b = lua["b"]; int c = lua["c"]; - sol_c_assert(a == 55); - sol_c_assert(b == 66); - sol_c_assert(c == 77); + SOL_ASSERT(a == 55); + SOL_ASSERT(b == 66); + SOL_ASSERT(c == 77); // sol::variadic_results // you can push objects of different types @@ -74,9 +74,9 @@ int main() { bool u = lua["u"]; std::string v = lua["v"]; - sol_c_assert(t == 42); - sol_c_assert(u); - sol_c_assert(v == "awoo"); + SOL_ASSERT(t == 42); + SOL_ASSERT(u); + SOL_ASSERT(v == "awoo"); return 0; -} \ No newline at end of file +} diff --git a/examples/source/overloading_with_members.cpp b/examples/source/overloading_with_members.cpp index 48dee3d7..c15d1357 100644 --- a/examples/source/overloading_with_members.cpp +++ b/examples/source/overloading_with_members.cpp @@ -60,8 +60,8 @@ int main() { pup& barker = lua["barker"]; std::cout << barker.barks << std::endl; - sol_c_assert(barker.barks == 22); + SOL_ASSERT(barker.barks == 22); std::cout << std::endl; return 0; -} \ No newline at end of file +} diff --git a/examples/source/property.cpp b/examples/source/property.cpp index 2f173734..ae593f1b 100644 --- a/examples/source/property.cpp +++ b/examples/source/property.cpp @@ -15,7 +15,7 @@ class Player { } int get_max_hp() const { - return hp; + return maxhp; } void set_max_hp(int value) { diff --git a/examples/source/protect.cpp b/examples/source/protect.cpp index 18c6e79c..517609d6 100644 --- a/examples/source/protect.cpp +++ b/examples/source/protect.cpp @@ -20,7 +20,7 @@ int main(int, char*[]) { value = pcall(pm.gen,"wrong argument") )__"); bool value = lua["value"]; - sol_c_assert(!value); + SOL_ASSERT(!value); return 0; } diff --git a/examples/source/require.cpp b/examples/source/require.cpp index a661ae3a..3bb5bf69 100644 --- a/examples/source/require.cpp +++ b/examples/source/require.cpp @@ -44,10 +44,10 @@ s.bark = 20 )"); some_class& s = lua["s"]; - sol_c_assert(s.bark == 20); + SOL_ASSERT(s.bark == 20); std::cout << "s.bark = " << s.bark << std::endl; std::cout << std::endl; return 0; -} \ No newline at end of file +} diff --git a/examples/source/require_override_behavior.cpp b/examples/source/require_override_behavior.cpp index e6e44bfa..77467544 100644 --- a/examples/source/require_override_behavior.cpp +++ b/examples/source/require_override_behavior.cpp @@ -55,7 +55,7 @@ int main() { print(test) )", sol::script_pass_on_error); - sol_c_assert(a_result.valid()); + SOL_ASSERT(a_result.valid()); try { // this will always fail auto b_result = lua.safe_script(R"( @@ -65,7 +65,7 @@ int main() { sol::script_throw_on_error); // this will not be executed because of the throw, // but it better be true regardless! - sol_c_assert(!b_result.valid()); + SOL_ASSERT(!b_result.valid()); } catch (const std::exception& ex) { // Whenever sol2 throws an exception from panic, diff --git a/examples/source/runtime_additions.cpp b/examples/source/runtime_additions.cpp index 8fc322e3..68a995a1 100644 --- a/examples/source/runtime_additions.cpp +++ b/examples/source/runtime_additions.cpp @@ -34,7 +34,7 @@ obj:print() )"); object& obj = lua["obj"]; - sol_c_assert(obj.value == 1); + SOL_ASSERT(obj.value == 1); return 0; } diff --git a/examples/source/script_error_handling.cpp b/examples/source/script_error_handling.cpp index a06c64c9..76f0cb65 100644 --- a/examples/source/script_error_handling.cpp +++ b/examples/source/script_error_handling.cpp @@ -28,7 +28,7 @@ return 24 code, sol::script_default_on_error); // This will never be reached std::cout << value << std::endl; - sol_c_assert(value == 24); + SOL_ASSERT(value == 24); } catch (const sol::error& err) { std::cout << "Something went horribly wrong: " @@ -46,7 +46,7 @@ return 24 { sol::protected_function_result result = lua.script(code, sol::script_pass_on_error); - sol_c_assert(!result.valid()); + SOL_ASSERT(!result.valid()); if (!result.valid()) { sol::error err = result; sol::call_status status = result.status(); @@ -65,7 +65,7 @@ return 24 // any errors The two previous approaches are recommended { sol::load_result loaded_chunk = lua.load(code); - sol_c_assert(!loaded_chunk.valid()); + SOL_ASSERT(!loaded_chunk.valid()); if (!loaded_chunk.valid()) { sol::error err = loaded_chunk; sol::load_status status = loaded_chunk.status(); @@ -77,7 +77,7 @@ return 24 else { // Because the syntax is bad, this will never be // reached - sol_c_assert(false); + SOL_ASSERT(false); // If there is a runtime error (lua GC memory // error, nil access, etc.) it will be caught here sol::protected_function script_func diff --git a/examples/source/self_from_lua.cpp b/examples/source/self_from_lua.cpp index ff95d831..6adbec9a 100644 --- a/examples/source/self_from_lua.cpp +++ b/examples/source/self_from_lua.cpp @@ -19,7 +19,7 @@ int main() { // definitely the same thing& self = selfobj.as(); - sol_c_assert(&self == this); + SOL_ASSERT(&self == this); } void func(sol::this_state ts) const { @@ -32,7 +32,7 @@ int main() { thing& self = selfobj.as(); // definitely the same - sol_c_assert(&self == this); + SOL_ASSERT(&self == this); } }; diff --git a/examples/source/shared_ptr.cpp b/examples/source/shared_ptr.cpp index 4d992d52..659583f9 100644 --- a/examples/source/shared_ptr.cpp +++ b/examples/source/shared_ptr.cpp @@ -72,18 +72,18 @@ int main() { << ref_to_shared_ptr.use_count() << std::endl; - sol_c_assert( + SOL_ASSERT( ptr_to_my_type == ref_to_shared_ptr.get()); - sol_c_assert( + SOL_ASSERT( &ref_to_my_type == ref_to_shared_ptr.get()); - sol_c_assert(ref_to_shared_ptr->value == 10); + SOL_ASSERT(ref_to_shared_ptr->value == 10); // script affects all of them equally lua.script("shared.value = 20"); - sol_c_assert(ptr_to_my_type->value == 20); - sol_c_assert(ref_to_my_type.value == 20); - sol_c_assert(ref_to_shared_ptr->value == 20); + SOL_ASSERT(ptr_to_my_type->value == 20); + SOL_ASSERT(ref_to_my_type.value == 20); + SOL_ASSERT(ref_to_shared_ptr->value == 20); } { std::cout << "getting copy of shared_ptr..." @@ -98,15 +98,15 @@ int main() { << copy_of_shared_ptr.use_count() << std::endl; - sol_c_assert(copy_of_shared_ptr->value == 20); - sol_c_assert(copy_of_value.value == 20); + SOL_ASSERT(copy_of_shared_ptr->value == 20); + SOL_ASSERT(copy_of_value.value == 20); // script still affects pointer, but does not affect // copy of `my_type` lua.script("shared.value = 30"); - sol_c_assert(copy_of_shared_ptr->value == 30); - sol_c_assert(copy_of_value.value == 20); + SOL_ASSERT(copy_of_shared_ptr->value == 30); + SOL_ASSERT(copy_of_value.value == 20); } // set to nil and collect garbage to destroy it lua.script("shared = nil"); diff --git a/examples/source/shared_ptr_inheritance.cpp b/examples/source/shared_ptr_inheritance.cpp index a4cc22fe..2c3a484c 100644 --- a/examples/source/shared_ptr_inheritance.cpp +++ b/examples/source/shared_ptr_inheritance.cpp @@ -55,7 +55,7 @@ int main() { sol::protected_function_result result = lua.safe_script( "inspect_shape_table({shape=Box.new()})"); - sol_c_assert(result.valid()); + SOL_ASSERT(result.valid()); return 0; } diff --git a/examples/source/stack_aligned_function.cpp b/examples/source/stack_aligned_function.cpp index 423a77ff..ccd58eea 100644 --- a/examples/source/stack_aligned_function.cpp +++ b/examples/source/stack_aligned_function.cpp @@ -26,8 +26,8 @@ int main(int, char*[]) { int result = func(sol::stack_count(2)); // make sure everything is clean - sol_c_assert(result == 22); - sol_c_assert( + SOL_ASSERT(result == 22); + SOL_ASSERT( lua.stack_top() == 0); // stack is empty/balanced return 0; diff --git a/examples/source/stack_aligned_stack_handler_function.cpp b/examples/source/stack_aligned_stack_handler_function.cpp index 5ea58ed0..49cccd51 100644 --- a/examples/source/stack_aligned_stack_handler_function.cpp +++ b/examples/source/stack_aligned_stack_handler_function.cpp @@ -40,8 +40,8 @@ int main(int, char*[]) { traceback_handler.pop(); // make sure everything is clean - sol_c_assert(result == 22); - sol_c_assert( + SOL_ASSERT(result == 22); + SOL_ASSERT( lua.stack_top() == 0); // stack is empty/balanced return 0; diff --git a/examples/source/static_variables.cpp b/examples/source/static_variables.cpp index 3cfcfef4..16d26597 100644 --- a/examples/source/static_variables.cpp +++ b/examples/source/static_variables.cpp @@ -24,15 +24,15 @@ int main() { int direct_value = lua["test"]["direct"]; // direct_value == 2 - sol_c_assert(direct_value == 2); + SOL_ASSERT(direct_value == 2); std::cout << "direct_value: " << direct_value << std::endl; int global = lua["test"]["global"]; int global2 = lua["test"]["ref_global"]; // global == 25 // global2 == 25 - sol_c_assert(global == 25); - sol_c_assert(global2 == 25); + SOL_ASSERT(global == 25); + SOL_ASSERT(global2 == 25); std::cout << "First round of values --" << std::endl; std::cout << global << std::endl; @@ -51,8 +51,8 @@ int main() { // if muh_variable goes out of scope or is deleted // problems could arise, so be careful! - sol_c_assert(global == 25); - sol_c_assert(global2 == 542); + SOL_ASSERT(global == 25); + SOL_ASSERT(global2 == 542); std::cout << "Second round of values --" << std::endl; std::cout << "global : " << global << std::endl; diff --git a/examples/source/table_as_container.cpp b/examples/source/table_as_container.cpp index efb37896..e82bfe2b 100644 --- a/examples/source/table_as_container.cpp +++ b/examples/source/table_as_container.cpp @@ -27,11 +27,11 @@ int main() { "vectors = { Vector.new(3, 6), Vector.new(6, 3) }"); auto vectors = lua["vectors"].get>(); - sol_c_assert(vectors[0].x == 3); - sol_c_assert(vectors[0].y == 6); + SOL_ASSERT(vectors[0].x == 3); + SOL_ASSERT(vectors[0].y == 6); - sol_c_assert(vectors[1].x == 6); - sol_c_assert(vectors[1].y == 3); + SOL_ASSERT(vectors[1].x == 6); + SOL_ASSERT(vectors[1].y == 3); return 0; } diff --git a/examples/source/table_create_if_nil.cpp b/examples/source/table_create_if_nil.cpp index 4e7c3e98..8a04bd48 100644 --- a/examples/source/table_create_if_nil.cpp +++ b/examples/source/table_create_if_nil.cpp @@ -26,7 +26,7 @@ int main(int, char*[]) { auto result = lua.safe_script(code, sol::script_pass_on_error); // did not work - sol_c_assert(!result.valid()); + SOL_ASSERT(!result.valid()); // create values create_namespace_sf(lua); @@ -34,7 +34,7 @@ int main(int, char*[]) { auto result2 = lua.safe_script(code, sol::script_pass_on_error); // it worked properly - sol_c_assert(result2.valid()); + SOL_ASSERT(result2.valid()); std::cout << std::endl; diff --git a/examples/source/table_proxy.cpp b/examples/source/table_proxy.cpp index a2f5d747..bf49a976 100644 --- a/examples/source/table_proxy.cpp +++ b/examples/source/table_proxy.cpp @@ -27,14 +27,14 @@ int main() { // retrivies value inside of lua table above std::string value = z; - sol_c_assert(value == "arf!"); + SOL_ASSERT(value == "arf!"); // Can change the value later... z = 20; // Yay, lazy-evaluation! int changed_value = z; // now it's 20! - sol_c_assert(changed_value == 20); + SOL_ASSERT(changed_value == 20); lua.script("assert(bark.woof[2] == 20)"); lua["a_new_value"] = 24; diff --git a/examples/source/this_state.cpp b/examples/source/this_state.cpp index b7f79b9b..011aadd1 100644 --- a/examples/source/this_state.cpp +++ b/examples/source/this_state.cpp @@ -23,9 +23,9 @@ int main() { lua.script("second = bark(2, 2)"); // only takes 2 arguments int first = lua["first"]; - sol_c_assert(first == 6); + SOL_ASSERT(first == 6); int second = lua["second"]; - sol_c_assert(second == 6); + SOL_ASSERT(second == 6); return 0; -} \ No newline at end of file +} diff --git a/examples/source/tie.cpp b/examples/source/tie.cpp index 3f9aa1df..9083ca7c 100644 --- a/examples/source/tie.cpp +++ b/examples/source/tie.cpp @@ -18,21 +18,21 @@ int main(int, char*[]) { sol::function woof = lua["woof"]; double numwoof = woof(20); - sol_c_assert(numwoof == 55.0); + SOL_ASSERT(numwoof == 55.0); lua.script("function f () return 10, 11, 12 end"); sol::function f = lua["f"]; std::tuple abc = f(); - sol_c_assert(std::get<0>(abc) == 10); - sol_c_assert(std::get<1>(abc) == 11); - sol_c_assert(std::get<2>(abc) == 12); + SOL_ASSERT(std::get<0>(abc) == 10); + SOL_ASSERT(std::get<1>(abc) == 11); + SOL_ASSERT(std::get<2>(abc) == 12); // or int a, b, c; sol::tie(a, b, c) = f(); - sol_c_assert(a == 10); - sol_c_assert(b == 11); - sol_c_assert(c == 12); + SOL_ASSERT(a == 10); + SOL_ASSERT(b == 11); + SOL_ASSERT(c == 12); return 0; } diff --git a/examples/source/tutorials/multiple_return.cpp b/examples/source/tutorials/multiple_return.cpp index 5711549e..9fff9104 100644 --- a/examples/source/tutorials/multiple_return.cpp +++ b/examples/source/tutorials/multiple_return.cpp @@ -8,15 +8,15 @@ int main() { std::tuple result; result = lua["f"](1, 2, 3); - sol_c_assert(result == std::make_tuple(1, 2, 3)); + SOL_ASSERT(result == std::make_tuple(1, 2, 3)); int a, b; std::string c; // NOTE: sol::tie, NOT std::tie // (ESS OH ELL prefix, not ESS TEE DEE prefix) sol::tie(a, b, c) = lua["f"](1, 2, "bark"); - sol_c_assert(a == 1); - sol_c_assert(b == 2); - sol_c_assert(c == "bark"); + SOL_ASSERT(a == 1); + SOL_ASSERT(b == 2); + SOL_ASSERT(c == "bark"); return 0; } diff --git a/examples/source/tutorials/quick_n_dirty/functions_easy.cpp b/examples/source/tutorials/quick_n_dirty/functions_easy.cpp index 5f0a8b5b..940eee58 100644 --- a/examples/source/tutorials/quick_n_dirty/functions_easy.cpp +++ b/examples/source/tutorials/quick_n_dirty/functions_easy.cpp @@ -18,15 +18,15 @@ int main(int, char*[]) { = fx; int is_one = stdfx(1, 34.5, 3, "bark"); - sol_c_assert(is_one == 1); + SOL_ASSERT(is_one == 1); int is_also_one = fx(1, "boop", 3, "bark"); - sol_c_assert(is_also_one == 1); + SOL_ASSERT(is_also_one == 1); // call through operator[] int is_three = lua["g"](1, 2); - sol_c_assert(is_three == 3); + SOL_ASSERT(is_three == 3); double is_4_8 = lua["g"](2.4, 2.4); - sol_c_assert(is_4_8 == 4.8); + SOL_ASSERT(is_4_8 == 4.8); return 0; } diff --git a/examples/source/tutorials/quick_n_dirty/multiple_returns_from_lua.cpp b/examples/source/tutorials/quick_n_dirty/multiple_returns_from_lua.cpp index a3494e1e..8af9827a 100644 --- a/examples/source/tutorials/quick_n_dirty/multiple_returns_from_lua.cpp +++ b/examples/source/tutorials/quick_n_dirty/multiple_returns_from_lua.cpp @@ -14,9 +14,9 @@ int main(int, char*[]) { int b; std::string c; sol::tie(a, b, c) = lua["f"](100, 200, "bark"); - sol_c_assert(a == 100); - sol_c_assert(b == 200); - sol_c_assert(c == "bark"); + SOL_ASSERT(a == 100); + SOL_ASSERT(b == 200); + SOL_ASSERT(c == "bark"); return 0; } diff --git a/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp b/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp index 98719851..950a2d5c 100644 --- a/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp +++ b/examples/source/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp @@ -14,20 +14,20 @@ int main(int, char*[]) { std::tuple result = lua["f"](100, 200, 300); const std::tuple expected(100, 200, 300); - sol_c_assert(result == expected); + SOL_ASSERT(result == expected); std::tuple result2; result2 = lua["f"](100, 200, "BARK BARK BARK!"); const std::tuple expected2( 100, 200, "BARK BARK BARK!"); - sol_c_assert(result2 == expected2); + SOL_ASSERT(result2 == expected2); int a, b; std::string c; sol::tie(a, b, c) = lua["f"](100, 200, "bark"); - sol_c_assert(a == 100); - sol_c_assert(b == 200); - sol_c_assert(c == "bark"); + SOL_ASSERT(a == 100); + SOL_ASSERT(b == 200); + SOL_ASSERT(c == "bark"); lua.script(R"( a, b, c = f(150, 250, "woofbark") diff --git a/examples/source/tutorials/quick_n_dirty/namespacing.cpp b/examples/source/tutorials/quick_n_dirty/namespacing.cpp index 86b44001..3b9d22b1 100644 --- a/examples/source/tutorials/quick_n_dirty/namespacing.cpp +++ b/examples/source/tutorials/quick_n_dirty/namespacing.cpp @@ -51,7 +51,7 @@ int main() { // calling this function also works lua.script("bark.print_my_class(obj)"); my_class& obj = lua["obj"]; - sol_c_assert(obj.b == 25); + SOL_ASSERT(obj.b == 25); std::cout << std::endl; diff --git a/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp b/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp index 6ea0aba8..f4229a6e 100644 --- a/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp +++ b/examples/source/tutorials/quick_n_dirty/running_lua_code.cpp @@ -22,7 +22,7 @@ int main(int, char*[]) { // run a script, get the result int value = lua.script("return 54"); - sol_c_assert(value == 54); + SOL_ASSERT(value == 54); auto bad_code_result = lua.script("123 herp.derp", [](lua_State*, sol::protected_function_result pfr) { @@ -34,7 +34,7 @@ int main(int, char*[]) { return pfr; }); // it did not work - sol_c_assert(!bad_code_result.valid()); + SOL_ASSERT(!bad_code_result.valid()); // the default handler panics or throws, depending on your // settings uncomment for explosions: auto bad_code_result_2 diff --git a/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp b/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp index dcf56536..97e07249 100644 --- a/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp +++ b/examples/source/tutorials/quick_n_dirty/running_lua_code_low_level.cpp @@ -38,7 +38,7 @@ int main(int, char*[]) { sol::load_result script3 = lua.load("return 24"); // execute, get return value int value2 = script3(); - sol_c_assert(value2 == 24); + SOL_ASSERT(value2 == 24); std::cout << std::endl; diff --git a/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp b/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp index 7e639cad..78c4d199 100644 --- a/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp +++ b/examples/source/tutorials/quick_n_dirty/running_lua_code_safely.cpp @@ -42,12 +42,12 @@ int main(int, char*[]) { // run a script, get the result sol::optional maybe_value = lua.safe_script( "return 54", sol::script_pass_on_error); - sol_c_assert(maybe_value.has_value()); - sol_c_assert(*maybe_value == 54); + SOL_ASSERT(maybe_value.has_value()); + SOL_ASSERT(*maybe_value == 54); auto bad_code_result = lua.safe_script( "123 herp.derp", sol::script_pass_on_error); - sol_c_assert(!bad_code_result.valid()); + SOL_ASSERT(!bad_code_result.valid()); // you can also specify a handler function, and it'll // properly work here @@ -61,7 +61,7 @@ int main(int, char*[]) { return pfr; }); // it did not work - sol_c_assert(!bad_code_result2.valid()); + SOL_ASSERT(!bad_code_result2.valid()); // the default handler panics or throws, depending on your // settings uncomment for explosions: auto bad_code_result_2 diff --git a/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp b/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp index e9bb561f..89452f0d 100644 --- a/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp +++ b/examples/source/tutorials/quick_n_dirty/set_and_get_variables.cpp @@ -44,40 +44,40 @@ int main(int, char*[]) { // implicit conversion int number = lua["number"]; - sol_c_assert(number == 24); + SOL_ASSERT(number == 24); // explicit get auto number2 = lua.get("number2"); - sol_c_assert(number2 == 24.5); + SOL_ASSERT(number2 == 24.5); // strings too std::string important_string = lua["important_string"]; - sol_c_assert(important_string == "woof woof"); + SOL_ASSERT(important_string == "woof woof"); // dig into a table int value = lua["some_table"]["value"]; - sol_c_assert(value == 24); + SOL_ASSERT(value == 24); // get a function sol::function a_function = lua["a_function"]; int value_is_100 = a_function(); // convertible to std::function std::function a_std_function = a_function; int value_is_still_100 = a_std_function(); - sol_c_assert(value_is_100 == 100); - sol_c_assert(value_is_still_100 == 100); + SOL_ASSERT(value_is_100 == 100); + SOL_ASSERT(value_is_still_100 == 100); sol::object number_obj = lua.get("number"); // sol::type::number sol::type t1 = number_obj.get_type(); - sol_c_assert(t1 == sol::type::number); + SOL_ASSERT(t1 == sol::type::number); sol::object function_obj = lua["a_function"]; // sol::type::function sol::type t2 = function_obj.get_type(); - sol_c_assert(t2 == sol::type::function); + SOL_ASSERT(t2 == sol::type::function); bool is_it_really = function_obj.is>(); - sol_c_assert(is_it_really); + SOL_ASSERT(is_it_really); // will not contain data sol::optional check_for_me = lua["a_function"]; - sol_c_assert(check_for_me == sol::nullopt); + SOL_ASSERT(check_for_me == sol::nullopt); return 0; } diff --git a/examples/source/tutorials/quick_n_dirty/set_and_get_variables_exists.cpp b/examples/source/tutorials/quick_n_dirty/set_and_get_variables_exists.cpp index 26a05d71..f684173b 100644 --- a/examples/source/tutorials/quick_n_dirty/set_and_get_variables_exists.cpp +++ b/examples/source/tutorials/quick_n_dirty/set_and_get_variables_exists.cpp @@ -9,11 +9,11 @@ int main(int, char*[]) { lua.script("exists = 250"); int first_try = lua.get_or("exists", 322); - sol_c_assert(first_try == 250); + SOL_ASSERT(first_try == 250); lua.set("exists", sol::lua_nil); int second_try = lua.get_or("exists", 322); - sol_c_assert(second_try == 322); + SOL_ASSERT(second_try == 322); return 0; } diff --git a/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp b/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp index 20dbab04..b5046cf8 100644 --- a/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp +++ b/examples/source/tutorials/quick_n_dirty/tables_and_nesting.cpp @@ -23,21 +23,21 @@ int main(int, char*[]) { int bark1 = def["ghi"]["bark"]; int bark2 = lua["def"]["ghi"]["bark"]; - sol_c_assert(bark1 == 50); - sol_c_assert(bark2 == 50); + SOL_ASSERT(bark1 == 50); + SOL_ASSERT(bark2 == 50); int abcval1 = abc[0]; int abcval2 = ghi["woof"][0]; - sol_c_assert(abcval1 == 24); - sol_c_assert(abcval2 == 24); + SOL_ASSERT(abcval1 == 24); + SOL_ASSERT(abcval2 == 24); sol::optional will_not_error = lua["abc"]["DOESNOTEXIST"]["ghi"]; - sol_c_assert(will_not_error == sol::nullopt); + SOL_ASSERT(will_not_error == sol::nullopt); int also_will_not_error = lua["abc"]["def"]["ghi"]["jklm"].get_or(25); - sol_c_assert(also_will_not_error == 25); + SOL_ASSERT(also_will_not_error == 25); // if you don't go safe, // will throw (or do at_panic if no exceptions) diff --git a/examples/source/tutorials/quick_n_dirty/userdata.cpp b/examples/source/tutorials/quick_n_dirty/userdata.cpp index 6520d8c9..2dd43dde 100644 --- a/examples/source/tutorials/quick_n_dirty/userdata.cpp +++ b/examples/source/tutorials/quick_n_dirty/userdata.cpp @@ -52,11 +52,11 @@ int main(int, char*[]) { Doge& lua_dog_move = lua["dog_move"]; Doge& lua_dog_unique_ptr = lua["dog_unique_ptr"]; Doge& lua_dog_shared_ptr = lua["dog_shared_ptr"]; - sol_c_assert(lua_dog.tailwag == 50); - sol_c_assert(lua_dog_copy.tailwag == 30); - sol_c_assert(lua_dog_move.tailwag == 30); - sol_c_assert(lua_dog_unique_ptr.tailwag == 25); - sol_c_assert(lua_dog_shared_ptr.tailwag == 31); + SOL_ASSERT(lua_dog.tailwag == 50); + SOL_ASSERT(lua_dog_copy.tailwag == 30); + SOL_ASSERT(lua_dog_move.tailwag == 30); + SOL_ASSERT(lua_dog_unique_ptr.tailwag == 25); + SOL_ASSERT(lua_dog_shared_ptr.tailwag == 31); // lua will treat these types as opaque, and you will be // able to pass them around to C++ functions and Lua diff --git a/examples/source/tutorials/reading_functions.cpp b/examples/source/tutorials/reading_functions.cpp index 58044970..9a054315 100644 --- a/examples/source/tutorials/reading_functions.cpp +++ b/examples/source/tutorials/reading_functions.cpp @@ -13,17 +13,17 @@ int main() { // Get and immediately call int x = lua["f"](30); - sol_c_assert(x == 35); + SOL_ASSERT(x == 35); // Store it into a variable first, then call sol::unsafe_function f = lua["f"]; int y = f(20); - sol_c_assert(y == 25); + SOL_ASSERT(y == 25); // Store it into a variable first, then call sol::protected_function safe_f = lua["f"]; int z = safe_f(45); - sol_c_assert(z == 50); + SOL_ASSERT(z == 50); return 0; } diff --git a/examples/source/tutorials/variables_demo.cpp b/examples/source/tutorials/variables_demo.cpp index 4e1e0b3c..aca8599f 100644 --- a/examples/source/tutorials/variables_demo.cpp +++ b/examples/source/tutorials/variables_demo.cpp @@ -22,7 +22,7 @@ config = { = lua["config"] ["fullscreen"]; // can get nested variables sol::table config = lua["config"]; - sol_c_assert(!isfullscreen); + SOL_ASSERT(!isfullscreen); // can also get it using the "get" member function // auto replaces the unqualified type name @@ -32,8 +32,8 @@ config = { // too std::tuple xyresolutiontuple = resolution.get("x", "y"); - sol_c_assert(std::get<0>(xyresolutiontuple) == 1024); - sol_c_assert(std::get<1>(xyresolutiontuple) == 768); + SOL_ASSERT(std::get<0>(xyresolutiontuple) == 1024); + SOL_ASSERT(std::get<1>(xyresolutiontuple) == 768); // test variable auto bark = lua["config"]["bark"]; @@ -68,12 +68,12 @@ config = { // (it tries to get a number, and fullscreen is // not a number int is_defaulted = lua["config"]["fullscreen"].get_or(24); - sol_c_assert(is_defaulted == 24); + SOL_ASSERT(is_defaulted == 24); // This will result in the value of the config, which is // 'false' bool is_not_defaulted = lua["config"]["fullscreen"]; - sol_c_assert(!is_not_defaulted); + SOL_ASSERT(!is_not_defaulted); return 0; } diff --git a/examples/source/tutorials/writing_functions.cpp b/examples/source/tutorials/writing_functions.cpp index 78a70cdb..2653e97e 100644 --- a/examples/source/tutorials/writing_functions.cpp +++ b/examples/source/tutorials/writing_functions.cpp @@ -22,7 +22,7 @@ int main() { // Read out the global variable we stored in 'some_str' in // the quick lua code we just executed std::string some_str = lua["some_str"]; - sol_c_assert(some_str == "DaD"); + SOL_ASSERT(some_str == "DaD"); return 0; } diff --git a/examples/source/tutorials/writing_overloaded_template_functions.cpp b/examples/source/tutorials/writing_overloaded_template_functions.cpp index ba85ffca..b8a3b289 100644 --- a/examples/source/tutorials/writing_overloaded_template_functions.cpp +++ b/examples/source/tutorials/writing_overloaded_template_functions.cpp @@ -22,8 +22,8 @@ int main() { "my_str = my_combine('bark bark', ' woof woof')"); int my_num = lua["my_num"]; std::string my_str = lua["my_str"]; - sol_c_assert(my_num == 3); - sol_c_assert(my_str == "bark bark woof woof"); + SOL_ASSERT(my_num == 3); + SOL_ASSERT(my_str == "bark bark woof woof"); return 0; } diff --git a/examples/source/tutorials/writing_template_functions.cpp b/examples/source/tutorials/writing_template_functions.cpp index 00d7bc2b..5644aca3 100644 --- a/examples/source/tutorials/writing_template_functions.cpp +++ b/examples/source/tutorials/writing_template_functions.cpp @@ -21,13 +21,13 @@ int main() { lua.script("my_num = my_int_add(1, 2)"); int my_num = lua["my_num"]; - sol_c_assert(my_num == 3); + SOL_ASSERT(my_num == 3); lua.script( "my_str = my_string_combine('bark bark', ' woof " "woof')"); std::string my_str = lua["my_str"]; - sol_c_assert(my_str == "bark bark woof woof"); + SOL_ASSERT(my_str == "bark bark woof woof"); return 0; } diff --git a/examples/source/unique_ptr.cpp b/examples/source/unique_ptr.cpp index f9be1f2d..598c3fe2 100644 --- a/examples/source/unique_ptr.cpp +++ b/examples/source/unique_ptr.cpp @@ -63,31 +63,31 @@ int main() { my_type& ref_to_my_type = lua["unique"]; my_type* ptr_to_my_type = lua["unique"]; - sol_c_assert( + SOL_ASSERT( ptr_to_my_type == ref_to_unique_ptr.get()); - sol_c_assert( + SOL_ASSERT( &ref_to_my_type == ref_to_unique_ptr.get()); - sol_c_assert(ref_to_unique_ptr->value == 10); + SOL_ASSERT(ref_to_unique_ptr->value == 10); // script affects all of them equally lua.script("unique.value = 20"); - sol_c_assert(ptr_to_my_type->value == 20); - sol_c_assert(ref_to_my_type.value == 20); - sol_c_assert(ref_to_unique_ptr->value == 20); + SOL_ASSERT(ptr_to_my_type->value == 20); + SOL_ASSERT(ref_to_my_type.value == 20); + SOL_ASSERT(ref_to_unique_ptr->value == 20); } { std::cout << "getting copy of unique_ptr..." << std::endl; my_type copy_of_value = lua["unique"]; - sol_c_assert(copy_of_value.value == 20); + SOL_ASSERT(copy_of_value.value == 20); // script still affects pointer, but does not affect // copy of `my_type` lua.script("unique.value = 30"); - sol_c_assert(copy_of_value.value == 20); + SOL_ASSERT(copy_of_value.value == 20); } // set to nil and collect garbage to destroy it lua.script("unique = nil"); diff --git a/examples/source/usertype_bitfields.cpp b/examples/source/usertype_bitfields.cpp index 7edf75a7..a522edab 100644 --- a/examples/source/usertype_bitfields.cpp +++ b/examples/source/usertype_bitfields.cpp @@ -200,9 +200,9 @@ int main() { std::cout << "N: " << N << std::endl; std::cout << "D: " << D << std::endl; - sol_c_assert(C); - sol_c_assert(N); - sol_c_assert(D == 0xDF); + SOL_ASSERT(C); + SOL_ASSERT(N); + SOL_ASSERT(D == 0xDF); std::cout << std::endl; diff --git a/examples/source/usertype_call_from_c++.cpp b/examples/source/usertype_call_from_c++.cpp index 55d790c0..8ef83e98 100644 --- a/examples/source/usertype_call_from_c++.cpp +++ b/examples/source/usertype_call_from_c++.cpp @@ -24,20 +24,27 @@ int main(int, char*[]) { }; lua.new_usertype( - "test", "value", &cpp_object::value); + "cpp_object", "value", &cpp_object::value); lua.new_usertype("test", "func", &test::func); lua.script( "function test:lua_func(obj) print('lua_func', " - "obj.value) end"); + "obj.value) return obj.value end"); lua["obj"] = test {}; cpp_object cppobj; - lua["obj"]["func"](lua["obj"], cppobj); - lua["obj"]["lua_func"](lua["obj"], cppobj); + int obj_func_call = lua["obj"]["func"](lua["obj"], cppobj); + int obj_lua_func_call + = lua["obj"]["lua_func"](lua["obj"], cppobj); - lua["test"]["func"](lua["obj"], cppobj); - lua["test"]["lua_func"](lua["obj"], cppobj); + int test_func_call = lua["test"]["func"](lua["obj"], cppobj); + int test_lua_func_call + = lua["test"]["lua_func"](lua["obj"], cppobj); + + SOL_ASSERT(obj_func_call == 5); + SOL_ASSERT(obj_lua_func_call == 5); + SOL_ASSERT(test_func_call == 10); + SOL_ASSERT(test_lua_func_call == 5); // crashes // lua["obj"]["func"](cppobj); @@ -48,4 +55,4 @@ int main(int, char*[]) { // lua["test"]["lua_func"](cppobj); return 0; -} \ No newline at end of file +} diff --git a/examples/source/usertype_dynamic_get_set.cpp b/examples/source/usertype_dynamic_get_set.cpp index dc73e29f..9e2afdfe 100644 --- a/examples/source/usertype_dynamic_get_set.cpp +++ b/examples/source/usertype_dynamic_get_set.cpp @@ -162,8 +162,8 @@ int main() { sol::userdata v1 = lua["v1"]; double v1x = v1["x"]; double v1y = v1["y"]; - sol_c_assert(v1x == 1.000); - sol_c_assert(v1y == 0.000); + SOL_ASSERT(v1x == 1.000); + SOL_ASSERT(v1y == 0.000); v1[0] = 2.000; lua.script(R"( @@ -175,4 +175,4 @@ int main() { std::cout << std::endl; return 0; -} \ No newline at end of file +} diff --git a/examples/source/usertype_initializers.cpp b/examples/source/usertype_initializers.cpp index f8c4375a..e153087f 100644 --- a/examples/source/usertype_initializers.cpp +++ b/examples/source/usertype_initializers.cpp @@ -72,8 +72,8 @@ print('h2.data is ' .. h2.data) )"); holy& h1 = lua["h1"]; holy& h2 = lua["h2"]; - sol_c_assert(h1.data == 50); - sol_c_assert(h2.data == 0); + SOL_ASSERT(h1.data == 50); + SOL_ASSERT(h2.data == 0); } std::cout << std::endl; -} \ No newline at end of file +} diff --git a/examples/source/usertype_special_functions.cpp b/examples/source/usertype_special_functions.cpp index faa01260..22504ba0 100644 --- a/examples/source/usertype_special_functions.cpp +++ b/examples/source/usertype_special_functions.cpp @@ -65,8 +65,8 @@ int main() { vec& a1 = lua["a1"]; vec& s1 = lua["s1"]; - sol_c_assert(a1.x == 1 && a1.y == 1); - sol_c_assert(s1.x == 1 && s1.y == -1); + SOL_ASSERT(a1.x == 1 && a1.y == 1); + SOL_ASSERT(s1.x == 1 && s1.y == -1); lua["a2"] = lua["a1"]; @@ -75,4 +75,4 @@ int main() { )"); return 0; -} \ No newline at end of file +} diff --git a/examples/source/usertype_var.cpp b/examples/source/usertype_var.cpp index 22ed7522..34bf66b3 100644 --- a/examples/source/usertype_var.cpp +++ b/examples/source/usertype_var.cpp @@ -21,26 +21,26 @@ int main() { sol::var(std::ref(test::number))); int direct_value = lua["test"]["direct"]; - sol_c_assert(direct_value == 2); + SOL_ASSERT(direct_value == 2); int number = lua["test"]["number"]; - sol_c_assert(number == 25); + SOL_ASSERT(number == 25); int ref_number = lua["test"]["ref_number"]; - sol_c_assert(ref_number == 25); + SOL_ASSERT(ref_number == 25); test::number = 542; // number is its own memory: was passed by value // So does not change int number_again = lua["test"]["number"]; - sol_c_assert(number_again == 25); + SOL_ASSERT(number_again == 25); // ref_number is just test::number // passed through std::ref // so, it holds a reference // which can be updated int ref_number_again = lua["test"]["ref_number"]; - sol_c_assert(ref_number_again == 542); + SOL_ASSERT(ref_number_again == 542); // be careful about referencing local variables, // if they go out of scope but are still reference // you'll suffer dangling reference bugs! diff --git a/include/sol/abort.hpp b/include/sol/abort.hpp new file mode 100644 index 00000000..692244da --- /dev/null +++ b/include/sol/abort.hpp @@ -0,0 +1,47 @@ +// sol2 + +// The MIT License (MIT) + +// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors + +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// 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. + +#ifndef SOL_ABORT_HPP +#define SOL_ABORT_HPP + +#include + +#include + +#include + +// clang-format off +#if SOL_IS_ON(SOL_DEBUG_BUILD) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #define SOL_DEBUG_ABORT() \ + if (true) { ::std::abort(); } \ + static_assert(true, "") + #else + #define SOL_DEBUG_ABORT() ::std::abort() + #endif +#else + #define SOL_DEBUG_ABORT() static_assert(true, "") +#endif +// clang-format on + +#endif // SOL_ABORT_HPP diff --git a/include/sol/as_args.hpp b/include/sol/as_args.hpp index 5afe78b0..719a3cdc 100644 --- a/include/sol/as_args.hpp +++ b/include/sol/as_args.hpp @@ -2,7 +2,7 @@ // The MIT License (MIT) -// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors +// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/include/sol/as_returns.hpp b/include/sol/as_returns.hpp index 0ac499e6..982f408b 100644 --- a/include/sol/as_returns.hpp +++ b/include/sol/as_returns.hpp @@ -2,7 +2,7 @@ // The MIT License (MIT) -// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors +// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/include/sol/assert.hpp b/include/sol/assert.hpp index 860ac3de..7f27905d 100644 --- a/include/sol/assert.hpp +++ b/include/sol/assert.hpp @@ -2,7 +2,7 @@ // The MIT License (MIT) -// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors +// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -28,7 +28,7 @@ #include -#if SOL_IS_ON(SOL2_CI_I_) +#if SOL_IS_ON(SOL2_CI) struct pre_main { pre_main() { @@ -43,15 +43,15 @@ struct pre_main { // clang-format off -#if SOL_IS_ON(SOL_USER_C_ASSERT_I_) - #define sol_c_assert(...) SOL_C_ASSERT(__VA_ARGS__) +#if SOL_IS_ON(SOL_USER_ASSERT) + #define SOL_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 - #define sol_c_assert(...) \ + #define SOL_ASSERT(...) \ do { \ if (!(__VA_ARGS__)) { \ std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << std::endl; \ @@ -59,7 +59,7 @@ struct pre_main { } \ } while (false) #else - #define sol_c_assert(...) \ + #define SOL_ASSERT(...) \ do { \ if (false) { \ (void)(__VA_ARGS__); \ @@ -68,15 +68,15 @@ struct pre_main { #endif #endif -#if SOL_IS_ON(SOL_USER_M_ASSERT_I_) - #define sol_m_assert(message, ...) SOL_M_ASSERT(message, __VA_ARGS__) +#if SOL_IS_ON(SOL_USER_ASSERT_MSG) + #define SOL_ASSERT_MSG(message, ...) SOL_ASSERT_MSG(message, __VA_ARGS__) #else - #if SOL_IS_ON(SOL_DEBUG_BUILD_I_) + #if SOL_IS_ON(SOL_DEBUG_BUILD) #include #include #include - #define sol_m_assert(message, ...) \ + #define SOL_ASSERT_MSG(message, ...) \ do { \ if (!(__VA_ARGS__)) { \ std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << ": " << message << std::endl; \ @@ -84,7 +84,7 @@ struct pre_main { } \ } while (false) #else - #define sol_m_assert(message, ...) \ + #define SOL_ASSERT_MSG(message, ...) \ do { \ if (false) { \ (void)(__VA_ARGS__); \ diff --git a/include/sol/base_traits.hpp b/include/sol/base_traits.hpp index 9fae18e2..204afc27 100644 --- a/include/sol/base_traits.hpp +++ b/include/sol/base_traits.hpp @@ -2,7 +2,7 @@ // The MIT License (MIT) -// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors +// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -62,6 +62,39 @@ namespace sol { template