Browse Source

Update sol2 and lua

Also renames lua/lua.hpp to lua/lua_global.hpp.

The previous name broke version auto-detection in sol2, which involves
calling `__has_include(<lua/lua.hpp>)`.
pull/8079/head
Gleb Mazovetskiy 8 months ago committed by Anders Jenbo
parent
commit
740868af3f
  1. 3
      .github/workflows/vita.yml
  2. 7
      3rdParty/Lua/CMakeLists.txt
  3. 28
      3rdParty/sol2/CMakeLists.txt
  4. 56
      3rdParty/sol2/patches/0001-Reduce-cmake_minimum_required-to-3.22.patch
  5. 35
      3rdParty/sol2/patches/0002-Fix-array-index-out-of-bounds-in-stack_field.hpp.patch
  6. 25
      3rdParty/sol2/patches/0003-Change-end-to-sen-in-usertype_container.hpp.patch
  7. 27
      3rdParty/sol2/patches/0004-Fix-missing-Lua-Lua-target-when-using-system-Lua.patch
  8. 25
      3rdParty/sol2/patches/0005-fix-INTERFACE_LINK_LIBRARIES-property-for-lualib.patch
  9. 51
      3rdParty/sol2/patches/0006-Overload-stateless_reference_equals-and-stateless_re.patch
  10. 200
      3rdParty/sol2/patches/0007-Add-Nerixyz-s-test-and-fix-for-C-17.patch
  11. 65
      3rdParty/sol2/patches/0008-Faster-track-for-lightuserdata_value.patch
  12. 47
      3rdParty/sol2/patches/0009-Work-around-1581.patch
  13. 2
      Source/CMakeLists.txt
  14. 2
      Source/diablo.cpp
  15. 2
      Source/discord/discord.cpp
  16. 2
      Source/engine/render/scrollrt.cpp
  17. 2
      Source/lua/autocomplete.cpp
  18. 3
      Source/lua/lua_global.cpp
  19. 0
      Source/lua/lua_global.hpp
  20. 2
      Source/lua/repl.cpp
  21. 2
      test/timedemo_test.cpp
  22. 4
      uwp-project/devilutionx.vcxproj

3
.github/workflows/vita.yml

@ -36,7 +36,8 @@ jobs:
apk add \ apk add \
gettext \ gettext \
git \ git \
samurai samurai \
patch
- name: Configure CMake - name: Configure CMake
run: | run: |

7
3rdParty/Lua/CMakeLists.txt vendored

@ -13,11 +13,14 @@ endif()
include(FetchContent) include(FetchContent)
FetchContent_Declare_ExcludeFromAll(Lua FetchContent_Declare_ExcludeFromAll(Lua
URL https://github.com/walterschell/Lua/archive/88246d621abf7b6fba9332f49229d507f020e450.tar.gz URL https://github.com/walterschell/Lua/archive/3ed55a56eaa05c9221f40b3c07d0e908eb1067b0.tar.gz
URL_HASH MD5=03b76927cb5341ffc53bea12c37ddcca URL_HASH MD5=77907b8209f77c65cb681a5012f2d804
) )
FetchContent_MakeAvailable_ExcludeFromAll(Lua) FetchContent_MakeAvailable_ExcludeFromAll(Lua)
# Needed for sol2
set(LUA_VERSION_STRING "5.4.7" PARENT_SCOPE)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND DARWIN_MAJOR_VERSION VERSION_EQUAL 8) if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND DARWIN_MAJOR_VERSION VERSION_EQUAL 8)
# We need legacy-support from MacPorts for: # We need legacy-support from MacPorts for:
# localtime_r gmtime_r # localtime_r gmtime_r

28
3rdParty/sol2/CMakeLists.txt vendored

@ -1,11 +1,33 @@
include(functions/FetchContent_ExcludeFromAll_backport) include(functions/FetchContent_ExcludeFromAll_backport)
include(FetchContent)
find_package(Patch REQUIRED)
set(SOL2_ENABLE_INSTALL OFF) set(SOL2_ENABLE_INSTALL OFF)
set(SOL2_BUILD_LUA OFF)
set(SOL2_LUA_VERSION "${LUA_VERSION_STRING}")
include(FetchContent)
FetchContent_Declare_ExcludeFromAll(sol2 FetchContent_Declare_ExcludeFromAll(sol2
URL https://github.com/ThePhD/sol2/archive/2b0d2fe8ba0074e16b499940c4f3126b9c7d3471.tar.gz URL https://github.com/ThePhD/sol2/archive/c1f95a773c6f8f4fde8ca3efe872e7286afe4444.tar.gz
URL_HASH MD5=869937e96e7c739b89920d12256fef4f URL_HASH MD5=845ce869733636632d857d8517ac3eb5
# https://github.com/ThePhD/sol2/pull/1712
PATCH_COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0001-Reduce-cmake_minimum_required-to-3.22.patch || true
# https://github.com/ThePhD/sol2/pull/1722
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0002-Fix-array-index-out-of-bounds-in-stack_field.hpp.patch || true
# https://github.com/ThePhD/sol2/pull/1676
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0003-Change-end-to-sen-in-usertype_container.hpp.patch || true
# https://github.com/ThePhD/sol2/pull/1704
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0004-Fix-missing-Lua-Lua-target-when-using-system-Lua.patch || true
# https://github.com/ThePhD/sol2/pull/1705
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0005-fix-INTERFACE_LINK_LIBRARIES-property-for-lualib.patch || true
# https://github.com/ThePhD/sol2/pull/1716
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0006-Overload-stateless_reference_equals-and-stateless_re.patch || true
# https://github.com/ThePhD/sol2/pull/1716
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0007-Add-Nerixyz-s-test-and-fix-for-C-17.patch || true
# https://github.com/ThePhD/sol2/pull/1674
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0008-Faster-track-for-lightuserdata_value.patch || true
# https://github.com/ThePhD/sol2/pull/1722
COMMAND "${Patch_EXECUTABLE}" -p0 -N < ${CMAKE_CURRENT_LIST_DIR}/patches/0009-Work-around-1581.patch || true
) )
FetchContent_MakeAvailable_ExcludeFromAll(sol2) FetchContent_MakeAvailable_ExcludeFromAll(sol2)

56
3rdParty/sol2/patches/0001-Reduce-cmake_minimum_required-to-3.22.patch vendored

@ -0,0 +1,56 @@
From d81d82dbea310f8491ec7a6e2cbcb78516c52b8d Mon Sep 17 00:00:00 2001
From: Gleb Mazovetskiy <glex.spb@gmail.com>
Date: Fri, 4 Jul 2025 18:44:27 +0100
Subject: [PATCH 1/9] Reduce `cmake_minimum_required` to 3.22
Ubuntu 22.04 CMake is 3.22.
Debian stable CMake is 3.25.
Debian oldstable (EOL in 2026) has CMake 3.25 in bullseye-backports.
---
CMakeLists.txt | 2 +-
documentation/CMakeLists.txt | 2 +-
single/CMakeLists.txt | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git CMakeLists.txt CMakeLists.txt
index b54f71a3..507d9be5 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -22,7 +22,7 @@
# # # # sol2
# # # Required minimum version statement
-cmake_minimum_required(VERSION 3.26.0)
+cmake_minimum_required(VERSION 3.22)
# # # Project Include - file that is included after project declaration is finished
set(CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Includes/Project.cmake")
diff --git documentation/CMakeLists.txt documentation/CMakeLists.txt
index 1c7b6758..ba780c0f 100644
--- documentation/CMakeLists.txt
+++ documentation/CMakeLists.txt
@@ -22,7 +22,7 @@
# # # # sol2, documentation generation
# # # Required minimum version statement
-cmake_minimum_required(VERSION 3.26.0)
+cmake_minimum_required(VERSION 3.22)
find_package(Doxygen REQUIRED)
find_package(Python3 REQUIRED)
diff --git single/CMakeLists.txt single/CMakeLists.txt
index 2d55fe32..a16926de 100644
--- single/CMakeLists.txt
+++ single/CMakeLists.txt
@@ -22,7 +22,7 @@
# # # # sol3, single
# # # Required minimum version statement
-cmake_minimum_required(VERSION 3.26.0)
+cmake_minimum_required(VERSION 3.22)
find_package(Python3 REQUIRED)
--
2.48.1

35
3rdParty/sol2/patches/0002-Fix-array-index-out-of-bounds-in-stack_field.hpp.patch vendored

@ -0,0 +1,35 @@
From 24241c564783a8dc9bca24aac69e0fb9cee76949 Mon Sep 17 00:00:00 2001
From: martin nylin <martin.nylin@gmail.com>
Date: Tue, 11 Mar 2025 21:28:44 +0100
Subject: [PATCH 2/9] Fix array index out of bounds in stack_field.hpp
---
include/sol/stack_field.hpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git include/sol/stack_field.hpp include/sol/stack_field.hpp
index 9dd66e2e..3b815225 100644
--- include/sol/stack_field.hpp
+++ include/sol/stack_field.hpp
@@ -113,7 +113,17 @@ namespace sol { namespace stack {
lua_getglobal(L, &key[0]);
}
else {
- lua_getfield(L, tableindex, &key[0]);
+ if constexpr (std::is_same_v<std::decay_t<Key>, const char*>) {
+ // Handle const char* case
+ if (key != nullptr) {
+ lua_getfield(L, tableindex, key);
+ } else {
+ push(L, lua_nil);
+ }
+ } else {
+ // Handle std::string case
+ lua_getfield(L, tableindex, key.c_str());
+ }
}
}
else if constexpr (std::is_same_v<T, meta_function>) {
--
2.48.1

25
3rdParty/sol2/patches/0003-Change-end-to-sen-in-usertype_container.hpp.patch vendored

@ -0,0 +1,25 @@
From 12a596d1b592acccd0ddee7df3b4e33f25550ff8 Mon Sep 17 00:00:00 2001
From: martin nylin <martin.nylin@gmail.com>
Date: Tue, 11 Mar 2025 20:58:43 +0100
Subject: [PATCH 3/9] Change end() to sen() in usertype_container.hpp
---
include/sol/usertype_container.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git include/sol/usertype_container.hpp include/sol/usertype_container.hpp
index 6d25d2a8..3ff81724 100644
--- include/sol/usertype_container.hpp
+++ include/sol/usertype_container.hpp
@@ -1189,7 +1189,7 @@ namespace sol {
static int next_associative(std::true_type, lua_State* L_) {
iter& i = stack::unqualified_get<user<iter>>(L_, 1);
auto& it = i.it();
- auto& end = i.end();
+ auto& end = i.sen();
if (it == end) {
return stack::push(L_, lua_nil);
}
--
2.48.1

27
3rdParty/sol2/patches/0004-Fix-missing-Lua-Lua-target-when-using-system-Lua.patch vendored

@ -0,0 +1,27 @@
From c5496869eab66dbf2ee1cb6d7f10536da809ace0 Mon Sep 17 00:00:00 2001
From: syzygial <67280346+syzygial@users.noreply.github.com>
Date: Sat, 31 May 2025 22:38:52 -0400
Subject: [PATCH 4/9] Fix missing Lua::Lua target when using system Lua
---
CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git CMakeLists.txt CMakeLists.txt
index 507d9be5..ed1a6b59 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -276,6 +276,10 @@ if (sol2-is-top-level-project)
set(LUA_LIBRARIES ${lualib})
endif()
+ if(NOT TARGET Lua::Lua)
+ add_library(Lua::Lua ALIAS ${lualib})
+ endif()
+
if (NOT LUA_FOUND AND NOT LUABUILD_FOUND)
message(FATAL_ERROR "sol2 Lua \"${SOL2_LUA_VERSION}\" not found and could not be targeted for building")
endif()
--
2.48.1

25
3rdParty/sol2/patches/0005-fix-INTERFACE_LINK_LIBRARIES-property-for-lualib.patch vendored

@ -0,0 +1,25 @@
From f433abdad78bf7601563674f292ac4c96b042220 Mon Sep 17 00:00:00 2001
From: syzygial <67280346+syzygial@users.noreply.github.com>
Date: Sat, 31 May 2025 12:04:26 -0400
Subject: [PATCH 5/9] fix INTERFACE_LINK_LIBRARIES property for lualib
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git CMakeLists.txt CMakeLists.txt
index ed1a6b59..1e2edf9a 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -270,7 +270,7 @@ if (sol2-is-top-level-project)
set_target_properties(${lualib}
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR}
- INTERFACE_LINK_LIBRARIES "${LUA_SEARCH_DEPENDENCY_LIBS} ${CMAKE_DL_LIBS}"
+ INTERFACE_LINK_LIBRARIES "${LUA_SEARCH_DEPENDENCY_LIBS};${CMAKE_DL_LIBS}"
IMPORTED_LINK_INTERFACE_LANGUAGES C
IMPORTED_LOCATION ${lualiblocation})
set(LUA_LIBRARIES ${lualib})
--
2.48.1

51
3rdParty/sol2/patches/0006-Overload-stateless_reference_equals-and-stateless_re.patch vendored

@ -0,0 +1,51 @@
From ee5af5e0564d1dad7d37e9849404b5be0849142f Mon Sep 17 00:00:00 2001
From: Evil Eye <malusluminis@hotmail.com>
Date: Thu, 10 Jul 2025 17:53:18 +0200
Subject: [PATCH 6/9] Overload stateless_reference_equals and
stateless_reference_hash to prevent implicit conversion of stack_reference to
stateless_reference
---
include/sol/reference.hpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git include/sol/reference.hpp include/sol/reference.hpp
index c7781552..e7be661a 100644
--- include/sol/reference.hpp
+++ include/sol/reference.hpp
@@ -828,6 +828,8 @@ namespace sol {
stateless_reference_equals(lua_State* L_) noexcept : stateless_stack_reference_equals(L_) {
}
+ using stateless_stack_reference_equals::operator();
+
bool operator()(const lua_nil_t& lhs, const stateless_reference& rhs) const noexcept {
return rhs.equals(lua_state(), lhs);
}
@@ -839,6 +841,14 @@ namespace sol {
bool operator()(const stateless_reference& lhs, const stateless_reference& rhs) const noexcept {
return lhs.equals(lua_state(), rhs);
}
+
+ bool operator()(const stateless_stack_reference& lhs, const stateless_reference& rhs) const noexcept {
+ return rhs.equals(lua_state(), lhs);
+ }
+
+ bool operator()(const stateless_reference& lhs, const stateless_stack_reference& rhs) const noexcept {
+ return lhs.equals(lua_state(), rhs);
+ }
};
struct reference_equals : public stack_reference_equals {
@@ -878,6 +888,8 @@ namespace sol {
stateless_reference_hash(lua_State* L_) noexcept : stateless_stack_reference_hash(L_) {
}
+ using stateless_stack_reference_hash::operator();
+
result_type operator()(const stateless_reference& lhs) const noexcept {
std::hash<const void*> h;
return h(lhs.pointer(lua_state()));
--
2.48.1

200
3rdParty/sol2/patches/0007-Add-Nerixyz-s-test-and-fix-for-C-17.patch vendored

@ -0,0 +1,200 @@
From 6ec30440f64de88a2ac1e909532c99ae0c3ee61f Mon Sep 17 00:00:00 2001
From: Evil Eye <malusluminis@hotmail.com>
Date: Sat, 12 Jul 2025 15:33:54 +0200
Subject: [PATCH 7/9] Add Nerixyz's test and fix for C++17
---
include/sol/usertype_storage.hpp | 4 ++
tests/regression_tests/1716/CMakeLists.txt | 45 ++++++++++++++
.../source/1716 - registry indexing leak.cpp | 61 +++++++++++++++++++
tests/regression_tests/1716/source/main.cpp | 31 ++++++++++
tests/regression_tests/CMakeLists.txt | 1 +
5 files changed, 142 insertions(+)
create mode 100644 tests/regression_tests/1716/CMakeLists.txt
create mode 100644 tests/regression_tests/1716/source/1716 - registry indexing leak.cpp
create mode 100644 tests/regression_tests/1716/source/main.cpp
diff --git include/sol/usertype_storage.hpp include/sol/usertype_storage.hpp
index bdca6146..691a025b 100644
--- include/sol/usertype_storage.hpp
+++ include/sol/usertype_storage.hpp
@@ -502,7 +502,11 @@ namespace sol { namespace u_detail {
stateless_reference* target = nullptr;
{
stack_reference k = stack::get<stack_reference>(L, 2);
+#if __cpp_lib_generic_unordered_lookup >= 201811L
auto it = self.auxiliary_keys.find(k);
+#else
+ auto it = self.auxiliary_keys.find(basic_reference(k));
+#endif
if (it != self.auxiliary_keys.cend()) {
target = &it->second;
}
diff --git tests/regression_tests/1716/CMakeLists.txt tests/regression_tests/1716/CMakeLists.txt
new file mode 100644
index 00000000..33ca975c
--- /dev/null
+++ tests/regression_tests/1716/CMakeLists.txt
@@ -0,0 +1,45 @@
+# # # # 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.
+
+# # # # sol2 tests - simple regression tests
+
+file(GLOB_RECURSE sources
+ LIST_DIRECTORIES FALSE
+ CONFIG_DEPENDS source/*.cpp)
+
+sol2_create_basic_test(sol2.tests.regression_1716 sol2::sol2 ${sources})
+sol2_create_basic_test(sol2.tests.regression_1716.SOL_ALL_SAFETIES_ON sol2::sol2 ${sources})
+target_compile_options(sol2.tests.regression_1716
+ PRIVATE
+ ${--allow-unreachable-code})
+target_compile_definitions(sol2.tests.regression_1716.SOL_ALL_SAFETIES_ON
+ PRIVATE
+ SOL_ALL_SAFETIES_ON=1)
+target_compile_options(sol2.tests.regression_1716.SOL_ALL_SAFETIES_ON
+ PRIVATE
+ ${--allow-unreachable-code})
+if (SOL2_TESTS_SINGLE)
+ sol2_create_basic_test(sol2.single.tests.regression_1716 sol2::sol2::single ${sources})
+ target_compile_options(sol2.single.tests.regression_1716
+ PRIVATE
+ ${--allow-unreachable-code})
+endif()
diff --git tests/regression_tests/1716/source/1716 - registry indexing leak.cpp tests/regression_tests/1716/source/1716 - registry indexing leak.cpp
new file mode 100644
index 00000000..9bc263f6
--- /dev/null
+++ tests/regression_tests/1716/source/1716 - registry indexing leak.cpp
@@ -0,0 +1,61 @@
+// 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.
+
+#include <catch2/catch_all.hpp>
+
+#include <sol/sol.hpp>
+
+TEST_CASE("#1716 - index and newindex should not leak values into the registry", "[sol2][regression][issue1716]") {
+ class vector {
+ public:
+ vector() = default;
+
+ static int my_index(vector&, int) {
+ return 0;
+ }
+
+ static void my_new_index(vector&, int, int) {
+ return;
+ }
+ };
+
+ sol::state lua;
+ lua.open_libraries(sol::lib::base);
+ lua.new_usertype<vector>("vector",
+ sol::constructors<sol::types<>>(), //
+ sol::meta_function::index,
+ &vector::my_index, //
+ sol::meta_function::new_index,
+ &vector::my_new_index);
+ auto begin = lua.registry().size();
+ lua.script(R"(
+ local v = vector.new()
+ local unused = 0
+ for i=1,100 do
+ unused = v[1]
+ v[1] = 1
+ end
+ )");
+
+ REQUIRE(lua.registry().size() <= begin + 1);
+}
diff --git tests/regression_tests/1716/source/main.cpp tests/regression_tests/1716/source/main.cpp
new file mode 100644
index 00000000..43e1e320
--- /dev/null
+++ tests/regression_tests/1716/source/main.cpp
@@ -0,0 +1,31 @@
+// 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.
+
+#define CATCH_CONFIG_RUNNER
+
+#include <catch2/catch_all.hpp>
+
+int main(int argc, char* argv[]) {
+ int result = Catch::Session().run(argc, argv);
+ return result;
+}
diff --git tests/regression_tests/CMakeLists.txt tests/regression_tests/CMakeLists.txt
index 7af8ed61..31400503 100644
--- tests/regression_tests/CMakeLists.txt
+++ tests/regression_tests/CMakeLists.txt
@@ -23,4 +23,5 @@
# # # # sol2 tests
add_subdirectory(1011)
+add_subdirectory(1716)
add_subdirectory(simple)
--
2.48.1

65
3rdParty/sol2/patches/0008-Faster-track-for-lightuserdata_value.patch vendored

@ -0,0 +1,65 @@
From f0d0ef4007c64a5a91146d834375a1684d27241c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Per=C5=82akowski?= <pawel@ok.info.pl>
Date: Tue, 25 Feb 2025 17:39:39 +0100
Subject: [PATCH 8/9] Faster track for lightuserdata_value
---
include/sol/stack_check_qualified.hpp | 2 +-
include/sol/stack_check_unqualified.hpp | 4 +---
include/sol/stack_core.hpp | 5 ++---
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git include/sol/stack_check_qualified.hpp include/sol/stack_check_qualified.hpp
index cc2394af..3ce5b642 100644
--- include/sol/stack_check_qualified.hpp
+++ include/sol/stack_check_qualified.hpp
@@ -28,7 +28,7 @@
namespace sol { namespace stack {
- template <typename X, type expected, typename>
+ template <typename X, typename>
struct qualified_checker {
template <typename Handler>
static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
diff --git include/sol/stack_check_unqualified.hpp include/sol/stack_check_unqualified.hpp
index d75557c4..18974987 100644
--- include/sol/stack_check_unqualified.hpp
+++ include/sol/stack_check_unqualified.hpp
@@ -389,9 +389,7 @@ namespace sol { namespace stack {
return success;
}
else if constexpr (meta::is_specialization_of_v<T, user>) {
- unqualified_checker<lightuserdata_value, type::userdata> c;
- (void)c;
- return c.check(L_, index, std::forward<Handler>(handler), tracking);
+ return stack::unqualified_check<detail::as_value_tag<lightuserdata_value>>(L_, index, std::forward<Handler>(handler), tracking);
}
else {
if constexpr (std::is_pointer_v<T>) {
diff --git include/sol/stack_core.hpp include/sol/stack_core.hpp
index c4f5e203..2ce3ca2b 100644
--- include/sol/stack_core.hpp
+++ include/sol/stack_core.hpp
@@ -571,7 +571,7 @@ namespace sol {
template <typename T, type t, typename = void>
struct unqualified_checker;
- template <typename T, type t, typename = void>
+ template <typename T, typename = void>
struct qualified_checker;
template <typename T, typename = void>
@@ -1002,8 +1002,7 @@ namespace sol {
return sol_lua_check(types<T>(), L, index, std::forward<Handler>(handler), tracking);
}
else {
- using Tu = meta::unqualified_t<T>;
- qualified_checker<T, lua_type_of_v<Tu>> c{};
+ qualified_checker<T> c{};
return c.check(L, index, std::forward<Handler>(handler), tracking);
}
}
--
2.48.1

47
3rdParty/sol2/patches/0009-Work-around-1581.patch vendored

@ -0,0 +1,47 @@
From 56cef1c15fb6f5b78e5debcb62d8ac914a0f007c Mon Sep 17 00:00:00 2001
From: Gleb Mazovetskiy <glex.spb@gmail.com>
Date: Sun, 20 Jul 2025 09:03:08 +0100
Subject: [PATCH 9/9] Work around #1581
See https://github.com/ThePhD/sol2/issues/1581#issuecomment-2103463524
---
include/sol/function_types_stateless.hpp | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git include/sol/function_types_stateless.hpp include/sol/function_types_stateless.hpp
index a2f66ba0..fe0f3f0b 100644
--- include/sol/function_types_stateless.hpp
+++ include/sol/function_types_stateless.hpp
@@ -320,7 +320,13 @@ namespace sol { namespace function_detail {
}
template <bool is_yielding, bool no_trampoline>
- static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
+ static int call(lua_State* L)
+#if SOL_IS_ON(SOL_COMPILER_CLANG)
+ // apparent regression in clang 18 - llvm/llvm-project#91362
+#else
+ noexcept(std::is_nothrow_copy_assignable_v<T>)
+#endif
+ {
int nr;
if constexpr (no_trampoline) {
nr = real_call(L);
@@ -360,7 +366,13 @@ namespace sol { namespace function_detail {
}
template <bool is_yielding, bool no_trampoline>
- static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
+ static int call(lua_State* L)
+#if SOL_IS_ON(SOL_COMPILER_CLANG)
+ // apparent regression in clang 18 - llvm/llvm-project#91362
+#else
+ noexcept(std::is_nothrow_copy_assignable_v<T>)
+#endif
+ {
int nr;
if constexpr (no_trampoline) {
nr = real_call(L);
--
2.48.1

2
Source/CMakeLists.txt

@ -97,7 +97,7 @@ set(libdevilutionx_SRCS
levels/trigs.cpp levels/trigs.cpp
lua/autocomplete.cpp lua/autocomplete.cpp
lua/lua.cpp lua/lua_global.cpp
lua/modules/audio.cpp lua/modules/audio.cpp
lua/modules/hellfire.cpp lua/modules/hellfire.cpp
lua/modules/dev.cpp lua/modules/dev.cpp

2
Source/diablo.cpp

@ -60,7 +60,7 @@
#include "levels/trigs.h" #include "levels/trigs.h"
#include "lighting.h" #include "lighting.h"
#include "loadsave.h" #include "loadsave.h"
#include "lua/lua.hpp" #include "lua/lua_global.hpp"
#include "menu.h" #include "menu.h"
#include "minitext.h" #include "minitext.h"
#include "missiles.h" #include "missiles.h"

2
Source/discord/discord.cpp

@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "levels/gendung.h" #include "levels/gendung.h"
#include "levels/setmaps.h" #include "levels/setmaps.h"
#include "lua/lua.hpp" #include "lua/lua_global.hpp"
#include "multi.h" #include "multi.h"
#include "panels/charpanel.hpp" #include "panels/charpanel.hpp"
#include "player.h" #include "player.h"

2
Source/engine/render/scrollrt.cpp

@ -40,7 +40,7 @@
#include "levels/gendung.h" #include "levels/gendung.h"
#include "levels/tile_properties.hpp" #include "levels/tile_properties.hpp"
#include "lighting.h" #include "lighting.h"
#include "lua/lua.hpp" #include "lua/lua_global.hpp"
#include "minitext.h" #include "minitext.h"
#include "missiles.h" #include "missiles.h"
#include "nthread.h" #include "nthread.h"

2
Source/lua/autocomplete.cpp

@ -13,7 +13,7 @@
#include "appfat.h" #include "appfat.h"
#include "engine/assets.hpp" #include "engine/assets.hpp"
#include "lua/lua.hpp" #include "lua/lua_global.hpp"
#include "lua/metadoc.hpp" #include "lua/metadoc.hpp"
#include "utils/algorithm/container.hpp" #include "utils/algorithm/container.hpp"
#include "utils/str_cat.hpp" #include "utils/str_cat.hpp"

3
Source/lua/lua.cpp → Source/lua/lua_global.cpp

@ -1,9 +1,10 @@
#include "lua/lua.hpp" #include "lua/lua_global.hpp"
#include <optional> #include <optional>
#include <string_view> #include <string_view>
#include <ankerl/unordered_dense.h> #include <ankerl/unordered_dense.h>
#include <sol/debug.hpp>
#include <sol/sol.hpp> #include <sol/sol.hpp>
#include <config.h> #include <config.h>

0
Source/lua/lua.hpp → Source/lua/lua_global.hpp

2
Source/lua/repl.cpp

@ -10,7 +10,7 @@
#include <sol/sol.hpp> #include <sol/sol.hpp>
#include <sol/utility/to_string.hpp> #include <sol/utility/to_string.hpp>
#include "lua/lua.hpp" #include "lua/lua_global.hpp"
#include "panels/console.hpp" #include "panels/console.hpp"
#include "utils/str_cat.hpp" #include "utils/str_cat.hpp"

2
test/timedemo_test.cpp

@ -7,7 +7,7 @@
#include "game_mode.hpp" #include "game_mode.hpp"
#include "headless_mode.hpp" #include "headless_mode.hpp"
#include "init.hpp" #include "init.hpp"
#include "lua/lua.hpp" #include "lua/lua_global.hpp"
#include "monstdat.h" #include "monstdat.h"
#include "options.h" #include "options.h"
#include "pfile.h" #include "pfile.h"

4
uwp-project/devilutionx.vcxproj

@ -74,7 +74,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link> <Link>
<AdditionalDependencies>sdl_image.lib;libpng16_staticd.lib;pkware.lib;fmtd.lib;zlibstatic.lib;bzip2.lib;libsmackerdec.lib;libmpq.lib;libdevilutionx.lib;lua_static.lib;sdl2.lib;sdl_audiolib.lib;asio.lib;sodium.lib;zt.lib;lwip_pic.lib;miniupnpc_pic.lib;natpmp_pic.lib;zt_pic.lib;zto_pic.lib;shlwapi.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>sdl_image.lib;libpng16_staticd.lib;pkware.lib;fmtd.lib;zlibstatic.lib;bzip2.lib;libsmackerdec.lib;libmpq.lib;libdevilutionx.lib;lua_static.lib;sdl2.lib;sdl_audiolib.lib;asio.lib;sodium.lib;zt.lib;lwip_pic.lib;miniupnpc_pic.lib;natpmp_pic.lib;zt_pic.lib;zto_pic.lib;shlwapi.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\build\SDL\VisualC-WinRT\x64\Debug\SDL-UWP;..\build\3rdParty\SDL_image\Debug;..\build\_deps\zlib-build\Debug;..\build\3rdParty\PKWare\Debug;..\build\3rdParty\bzip2\Debug;..\build\3rdParty\libsmackerdec\Debug;..\build\3rdParty\libmpq\Debug;..\build\_deps\lua-build\lua-5.4.6\Debug;..\build\_deps\sdl_audiolib-build\Debug;..\build\3rdParty\asio\Debug;..\build\_deps\libsodium-build\Debug;..\build\_deps\libzt-build\lib\Debug;..\build\_deps\libfmt-build\Debug;..\build\_deps\libpng-build\Debug;..\build\Source\libdevilutionx.dir\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>..\build\SDL\VisualC-WinRT\x64\Debug\SDL-UWP;..\build\3rdParty\SDL_image\Debug;..\build\_deps\zlib-build\Debug;..\build\3rdParty\PKWare\Debug;..\build\3rdParty\bzip2\Debug;..\build\3rdParty\libsmackerdec\Debug;..\build\3rdParty\libmpq\Debug;..\build\_deps\lua-build\lua-5.4.7\Debug;..\build\_deps\sdl_audiolib-build\Debug;..\build\3rdParty\asio\Debug;..\build\_deps\libsodium-build\Debug;..\build\_deps\libzt-build\lib\Debug;..\build\_deps\libfmt-build\Debug;..\build\_deps\libpng-build\Debug;..\build\Source\libdevilutionx.dir\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link> </Link>
<ClCompile> <ClCompile>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
@ -93,7 +93,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link> <Link>
<AdditionalDependencies>sdl_image.lib;libpng16_static.lib;pkware.lib;fmt.lib;zlibstatic.lib;bzip2.lib;libsmackerdec.lib;libmpq.lib;libdevilutionx.lib;lua_static.lib;sdl2.lib;sdl_audiolib.lib;sheenbidi.lib;asio.lib;sodium.lib;zt.lib;lwip_pic.lib;miniupnpc_pic.lib;natpmp_pic.lib;zt_pic.lib;zto_pic.lib;shlwapi.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>sdl_image.lib;libpng16_static.lib;pkware.lib;fmt.lib;zlibstatic.lib;bzip2.lib;libsmackerdec.lib;libmpq.lib;libdevilutionx.lib;lua_static.lib;sdl2.lib;sdl_audiolib.lib;sheenbidi.lib;asio.lib;sodium.lib;zt.lib;lwip_pic.lib;miniupnpc_pic.lib;natpmp_pic.lib;zt_pic.lib;zto_pic.lib;shlwapi.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\build\SDL\VisualC-WinRT\x64\Release\SDL-UWP;..\build\3rdParty\SDL_image\Release;..\build\_deps\zlib-build\Release;..\build\3rdParty\PKWare\Release;..\build\3rdParty\bzip2\Release;..\build\3rdParty\libsmackerdec\Release;..\build\3rdParty\libmpq\Release;..\build\_deps\lua-build\lua-5.4.6\Release;..\build\_deps\sdl_audiolib-build\Release;..\build\3rdParty\asio\Release;..\build\_deps\libsodium-build\Release;..\build\_deps\libzt-build\lib\Release;..\build\_deps\libfmt-build\Release;..\build\_deps\libpng-build\Release;..\build\_deps\sheenbidi-build\Release;..\build\Source\libdevilutionx.dir\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>..\build\SDL\VisualC-WinRT\x64\Release\SDL-UWP;..\build\3rdParty\SDL_image\Release;..\build\_deps\zlib-build\Release;..\build\3rdParty\PKWare\Release;..\build\3rdParty\bzip2\Release;..\build\3rdParty\libsmackerdec\Release;..\build\3rdParty\libmpq\Release;..\build\_deps\lua-build\lua-5.4.7\Release;..\build\_deps\sdl_audiolib-build\Release;..\build\3rdParty\asio\Release;..\build\_deps\libsodium-build\Release;..\build\_deps\libzt-build\lib\Release;..\build\_deps\libfmt-build\Release;..\build\_deps\libpng-build\Release;..\build\_deps\sheenbidi-build\Release;..\build\Source\libdevilutionx.dir\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link> </Link>
<ClCompile> <ClCompile>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>

Loading…
Cancel
Save