From a9ff1d4187bddb3bfeeb4b1dc4273237a6614436 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Thu, 21 Jan 2021 15:58:27 -0500 Subject: [PATCH] Fix up string_view handling - Fix mispelling for is_stackED_based_v - Regenerate single - Repair badly named test - Remove unused variable names --- include/sol/coroutine.hpp | 7 +-- include/sol/packaged_coroutine.hpp | 6 +-- include/sol/pairs_iterator.hpp | 12 ++--- include/sol/protected_function.hpp | 11 ++--- include/sol/state_view.hpp | 4 +- include/sol/usertype_core.hpp | 6 +++ single/include/sol/config.hpp | 4 +- single/include/sol/forward.hpp | 4 +- single/include/sol/sol.hpp | 44 +++++++++++-------- .../source/usertypes.constructors.cpp | 2 +- .../source/usertypes.overload.cpp | 4 +- 11 files changed, 60 insertions(+), 44 deletions(-) diff --git a/include/sol/coroutine.hpp b/include/sol/coroutine.hpp index 28f4585d..74b985f8 100644 --- a/include/sol/coroutine.hpp +++ b/include/sol/coroutine.hpp @@ -145,9 +145,10 @@ namespace sol { basic_coroutine(proxy_base&& p) : basic_coroutine(std::move(p), detail::get_default_handler::value>(p.lua_state())) { } - template >, meta::neg>>> = meta::enabler> - basic_coroutine(Proxy&& p, Handler&& eh) : basic_coroutine(detail::force_cast(p), std::forward(eh)) { + template >, + meta::neg>>> = meta::enabler> + basic_coroutine(Proxy&& p, HandlerReference&& eh) : basic_coroutine(detail::force_cast(p), std::forward(eh)) { } template >> = meta::enabler> diff --git a/include/sol/packaged_coroutine.hpp b/include/sol/packaged_coroutine.hpp index 852ccd98..b87ef729 100644 --- a/include/sol/packaged_coroutine.hpp +++ b/include/sol/packaged_coroutine.hpp @@ -149,9 +149,9 @@ namespace sol { basic_packaged_coroutine(proxy_base&& p) : basic_packaged_coroutine(std::move(p), detail::get_default_handler::value>(p.lua_state())) { } - template >, meta::neg>>> = meta::enabler> - basic_packaged_coroutine(Proxy&& p, Handler&& eh) : basic_packaged_coroutine(detail::force_cast(p), std::forward(eh)) { + template >, meta::neg>>> = meta::enabler> + basic_packaged_coroutine(Proxy&& p, HandlerReference&& eh) : basic_packaged_coroutine(detail::force_cast(p), std::forward(eh)) { } template >> = meta::enabler> diff --git a/include/sol/pairs_iterator.hpp b/include/sol/pairs_iterator.hpp index db068f6b..7d107f74 100644 --- a/include/sol/pairs_iterator.hpp +++ b/include/sol/pairs_iterator.hpp @@ -198,27 +198,27 @@ namespace sol { return m_cached_key_value_pair; } - friend static bool operator==(const pairs_iterator& left, const pairs_iterator& right) noexcept { + friend bool operator==(const pairs_iterator& left, const pairs_iterator& right) noexcept { return left.m_table_ref == right.m_table_ref && left.m_iteration_index == right.m_iteration_index; } - friend static bool operator!=(const pairs_iterator& left, const pairs_iterator& right) noexcept { + friend bool operator!=(const pairs_iterator& left, const pairs_iterator& right) noexcept { return left.m_table_ref != right.m_table_ref || left.m_iteration_index != right.m_iteration_index; } - friend static bool operator==(const pairs_iterator& left, const pairs_sentinel&) noexcept { + friend bool operator==(const pairs_iterator& left, const pairs_sentinel&) noexcept { return left.m_key_index == empty_key_index; } - friend static bool operator!=(const pairs_iterator& left, const pairs_sentinel&) noexcept { + friend bool operator!=(const pairs_iterator& left, const pairs_sentinel&) noexcept { return left.m_key_index != empty_key_index; } - friend static bool operator==(const pairs_sentinel&, const pairs_iterator& left) noexcept { + friend bool operator==(const pairs_sentinel&, const pairs_iterator& left) noexcept { return left.m_key_index == empty_key_index; } - friend static bool operator!=(const pairs_sentinel&, const pairs_iterator& left) noexcept { + friend bool operator!=(const pairs_sentinel&, const pairs_iterator& left) noexcept { return left.m_key_index != empty_key_index; } diff --git a/include/sol/protected_function.hpp b/include/sol/protected_function.hpp index 25026ba8..b55992e5 100644 --- a/include/sol/protected_function.hpp +++ b/include/sol/protected_function.hpp @@ -121,10 +121,11 @@ namespace sol { template basic_protected_function(proxy_base&& p) : basic_protected_function(std::move(p), get_default_handler(p.lua_state())) { } - template >, meta::neg>>> = meta::enabler> - basic_protected_function(Proxy&& p, Handler&& eh) - : basic_protected_function(detail::force_cast(p), make_reference(p.lua_state(), std::forward(eh))) { + template >, + meta::neg>>> = meta::enabler> + basic_protected_function(Proxy&& p, HandlerReference&& eh) + : basic_protected_function(detail::force_cast(p), make_reference(p.lua_state(), std::forward(eh))) { } template >> = meta::enabler> @@ -277,7 +278,7 @@ namespace sol { auto get_error_handler() const noexcept { if constexpr (is_stateless_lua_reference_v) { - if constexpr (is_stacked_based_v) { + if constexpr (is_stack_based_v) { return stack_reference(lua_state(), m_error_handler.stack_index()); } else { diff --git a/include/sol/state_view.hpp b/include/sol/state_view.hpp index 429a03c4..ce353415 100644 --- a/include/sol/state_view.hpp +++ b/include/sol/state_view.hpp @@ -772,8 +772,8 @@ namespace sol { } template - usertype new_usertype(const std::string& name, Args&&... args) { - return global.new_usertype(name, std::forward(args)...); + usertype new_usertype(Args&&... args) { + return global.new_usertype(std::forward(args)...); } template diff --git a/include/sol/usertype_core.hpp b/include/sol/usertype_core.hpp index 9fbd6b94..d5d9c6b1 100644 --- a/include/sol/usertype_core.hpp +++ b/include/sol/usertype_core.hpp @@ -71,6 +71,12 @@ namespace sol { return s; } +#if SOL_IS_ON(SOL_CHAR8_T_I_) + inline auto make_string_view(const char8_t* s) { + return string_view(reinterpret_cast(s)); + } +#endif + inline auto make_string_view(call_construction) { return string_view(to_string(meta_function::call_function)); } diff --git a/single/include/sol/config.hpp b/single/include/sol/config.hpp index 6fbe691c..5b8abf69 100644 --- a/single/include/sol/config.hpp +++ b/single/include/sol/config.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 2021-01-21 08:26:13.647505 UTC -// This header was generated with sol v3.2.3 (revision f7d8e1e8) +// Generated 2021-01-21 20:56:50.106258 UTC +// This header was generated with sol v3.2.3 (revision c032cda5) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_CONFIG_HPP diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 9998b8ad..9d19cad0 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/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 2021-01-21 08:26:13.622520 UTC -// This header was generated with sol v3.2.3 (revision f7d8e1e8) +// Generated 2021-01-21 20:56:50.090246 UTC +// This header was generated with sol v3.2.3 (revision c032cda5) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index 50274fbd..3f8d76d1 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/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 2021-01-21 08:26:12.913504 UTC -// This header was generated with sol v3.2.3 (revision f7d8e1e8) +// Generated 2021-01-21 20:56:49.214244 UTC +// This header was generated with sol v3.2.3 (revision c032cda5) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -20275,10 +20275,11 @@ namespace sol { template basic_protected_function(proxy_base&& p) : basic_protected_function(std::move(p), get_default_handler(p.lua_state())) { } - template >, meta::neg>>> = meta::enabler> - basic_protected_function(Proxy&& p, Handler&& eh) - : basic_protected_function(detail::force_cast(p), make_reference(p.lua_state(), std::forward(eh))) { + template >, + meta::neg>>> = meta::enabler> + basic_protected_function(Proxy&& p, HandlerReference&& eh) + : basic_protected_function(detail::force_cast(p), make_reference(p.lua_state(), std::forward(eh))) { } template >> = meta::enabler> @@ -20431,7 +20432,7 @@ namespace sol { auto get_error_handler() const noexcept { if constexpr (is_stateless_lua_reference_v) { - if constexpr (is_stacked_based_v) { + if constexpr (is_stack_based_v) { return stack_reference(lua_state(), m_error_handler.stack_index()); } else { @@ -22621,6 +22622,12 @@ namespace sol { return s; } +#if SOL_IS_ON(SOL_CHAR8_T_I_) + inline auto make_string_view(const char8_t* s) { + return string_view(reinterpret_cast(s)); + } +#endif + inline auto make_string_view(call_construction) { return string_view(to_string(meta_function::call_function)); } @@ -24619,27 +24626,27 @@ namespace sol { return m_cached_key_value_pair; } - friend static bool operator==(const pairs_iterator& left, const pairs_iterator& right) noexcept { + friend bool operator==(const pairs_iterator& left, const pairs_iterator& right) noexcept { return left.m_table_ref == right.m_table_ref && left.m_iteration_index == right.m_iteration_index; } - friend static bool operator!=(const pairs_iterator& left, const pairs_iterator& right) noexcept { + friend bool operator!=(const pairs_iterator& left, const pairs_iterator& right) noexcept { return left.m_table_ref != right.m_table_ref || left.m_iteration_index != right.m_iteration_index; } - friend static bool operator==(const pairs_iterator& left, const pairs_sentinel&) noexcept { + friend bool operator==(const pairs_iterator& left, const pairs_sentinel&) noexcept { return left.m_key_index == empty_key_index; } - friend static bool operator!=(const pairs_iterator& left, const pairs_sentinel&) noexcept { + friend bool operator!=(const pairs_iterator& left, const pairs_sentinel&) noexcept { return left.m_key_index != empty_key_index; } - friend static bool operator==(const pairs_sentinel&, const pairs_iterator& left) noexcept { + friend bool operator==(const pairs_sentinel&, const pairs_iterator& left) noexcept { return left.m_key_index == empty_key_index; } - friend static bool operator!=(const pairs_sentinel&, const pairs_iterator& left) noexcept { + friend bool operator!=(const pairs_sentinel&, const pairs_iterator& left) noexcept { return left.m_key_index != empty_key_index; } @@ -27196,8 +27203,8 @@ namespace sol { } template - usertype new_usertype(const std::string& name, Args&&... args) { - return global.new_usertype(name, std::forward(args)...); + usertype new_usertype(Args&&... args) { + return global.new_usertype(std::forward(args)...); } template @@ -27599,9 +27606,10 @@ namespace sol { basic_coroutine(proxy_base&& p) : basic_coroutine(std::move(p), detail::get_default_handler::value>(p.lua_state())) { } - template >, meta::neg>>> = meta::enabler> - basic_coroutine(Proxy&& p, Handler&& eh) : basic_coroutine(detail::force_cast(p), std::forward(eh)) { + template >, + meta::neg>>> = meta::enabler> + basic_coroutine(Proxy&& p, HandlerReference&& eh) : basic_coroutine(detail::force_cast(p), std::forward(eh)) { } template >> = meta::enabler> diff --git a/tests/runtime_tests/source/usertypes.constructors.cpp b/tests/runtime_tests/source/usertypes.constructors.cpp index 39f03ce3..da2ed661 100644 --- a/tests/runtime_tests/source/usertypes.constructors.cpp +++ b/tests/runtime_tests/source/usertypes.constructors.cpp @@ -216,7 +216,7 @@ TEST_CASE("usertype/constructor list", "Show that we can create classes from use REQUIRE((z.as() == 9)); } -TEST_CASE("usertype/no_constructor", "make sure if no constructor is present, do not fix anything") { +TEST_CASE("usertype/no_constructor linking time", "make sure if no constructor is present, do not fix anything") { sol::state lua; lua.open_libraries(sol::lib::base); diff --git a/tests/runtime_tests/source/usertypes.overload.cpp b/tests/runtime_tests/source/usertypes.overload.cpp index ed7560c4..816434a5 100644 --- a/tests/runtime_tests/source/usertypes.overload.cpp +++ b/tests/runtime_tests/source/usertypes.overload.cpp @@ -72,10 +72,10 @@ inline namespace sol2_test_usertypes_overload { } }; - sol::object lua_TestClass2_GetByIndex(const sol::this_state& s, TestClass2* tc, const uint32_t index) { + sol::object lua_TestClass2_GetByIndex(const sol::this_state& s, TestClass2* tc, const uint32_t) { return sol::make_object(s, tc); } - sol::object lua_TestClass2_GetByName(const sol::this_state& s, TestClass2* tc, const std::string_view& name) { + sol::object lua_TestClass2_GetByName(const sol::this_state& s, TestClass2* tc, const std::string_view&) { return sol::make_object(s, tc); } } // namespace sol2_test_usertypes_overload