From f8ee7abe527a9e8414fc4965e5cbd0f8395fbeae Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sat, 12 May 2018 18:04:33 -0600 Subject: [PATCH] tfw no common_type for ternary... --- single/sol/sol.hpp | 8 ++++---- single/sol/sol_forward.hpp | 4 ++-- sol/usertype_metatable.hpp | 4 ++-- tests/test_usertypes.cpp | 24 ++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 71f46a35..6d383d68 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2018-05-12 15:15:35.133726 UTC -// This header was generated with sol v2.20.0 (revision 9106597) +// Generated 2018-05-13 00:04:17.889207 UTC +// This header was generated with sol v2.20.0 (revision db5494e) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -18339,8 +18339,8 @@ namespace sol { template static int core_indexing_call(lua_State* L) { usertype_metatable& f = toplevel - ? stack::get>(L, upvalue_index(usertype_detail::metatable_index)) - : stack::pop>(L); + ? static_cast(stack::get>(L, upvalue_index(usertype_detail::metatable_index))) + : static_cast(stack::pop>(L)); static const int keyidx = -2 + static_cast(is_index); if (toplevel && stack::get(L, keyidx) != type::string) { return is_index ? f.indexfunc(L) : f.newindexfunc(L); diff --git a/single/sol/sol_forward.hpp b/single/sol/sol_forward.hpp index 6a6a0f97..f1ebf394 100644 --- a/single/sol/sol_forward.hpp +++ b/single/sol/sol_forward.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2018-05-12 15:15:35.377146 UTC -// This header was generated with sol v2.20.0 (revision 9106597) +// Generated 2018-05-13 00:04:18.118574 UTC +// This header was generated with sol v2.20.0 (revision db5494e) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index a7c6e46d..a5ee4e0a 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -567,8 +567,8 @@ namespace sol { template static int core_indexing_call(lua_State* L) { usertype_metatable& f = toplevel - ? stack::get>(L, upvalue_index(usertype_detail::metatable_index)) - : stack::pop>(L); + ? static_cast(stack::get>(L, upvalue_index(usertype_detail::metatable_index))) + : static_cast(stack::pop>(L)); static const int keyidx = -2 + static_cast(is_index); if (toplevel && stack::get(L, keyidx) != type::string) { return is_index ? f.indexfunc(L) : f.newindexfunc(L); diff --git a/tests/test_usertypes.cpp b/tests/test_usertypes.cpp index f99fb4f4..be06a708 100644 --- a/tests/test_usertypes.cpp +++ b/tests/test_usertypes.cpp @@ -302,6 +302,12 @@ struct matrix_xi { return m; } }; +template +struct alignas(16) weird_aligned_wrapper { + void operator()(SelfType& self, sol::object param) const { + } + std::function lambda; +}; TEST_CASE("usertype/usertype", "Show that we can create classes from usertype and use them") { sol::state lua; @@ -1787,6 +1793,24 @@ TEST_CASE("usertype/runtime-replacement", "ensure that functions can be properly } } +TEST_CASE("usertype/alignment", "ensure that alignment does not trigger weird aliasing issues") { + struct aligned_base {}; + struct aligned_derived : aligned_base {}; + + sol::state lua; + + lua.new_usertype("Base", + "x", sol::writeonly_property(weird_aligned_wrapper{})); + lua.new_usertype("Derived", + sol::base_classes, sol::bases()); + + aligned_derived d; + lua["d"] = d; + + auto result = lua.safe_script("d.x = 5"); + REQUIRE(result.valid()); +} + TEST_CASE("usertype/meta-key-retrievals", "allow for special meta keys (__index, __newindex) to trigger methods even if overwritten directly") { SECTION("dynamically") { static int writes = 0;