Browse Source
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
22 changed files with 574 additions and 16 deletions
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
@ -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> |
||||||
Loading…
Reference in new issue