diff --git a/include/sol/protected_function_result.hpp b/include/sol/protected_function_result.hpp index cfab474f..ca06cb59 100644 --- a/include/sol/protected_function_result.hpp +++ b/include/sol/protected_function_result.hpp @@ -101,7 +101,7 @@ namespace sol { using ValueType = typename UT::value_type; if constexpr (std::is_same_v) { if (valid()) { - return UT(nullopt); + return UT(); } return UT(error(detail::direct_error, stack::get(L, target))); } @@ -109,7 +109,7 @@ namespace sol { if (!valid()) { return UT(); } - return UT(stack::get(L, target)); + return stack::get(L, target); } } else { diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 9df699bd..d6de67ae 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 2020-05-22 13:37:42.297619 UTC -// This header was generated with sol v3.2.0 (revision d9c034d) +// Generated 2020-05-27 00:07:01.142852 UTC +// This header was generated with sol v3.2.0 (revision 465b472) // 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 de972818..6524f2df 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 2020-05-22 13:37:38.805887 UTC -// This header was generated with sol v3.2.0 (revision d9c034d) +// Generated 2020-05-27 00:07:00.664617 UTC +// This header was generated with sol v3.2.0 (revision 465b472) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -15197,7 +15197,7 @@ namespace sol { using ValueType = typename UT::value_type; if constexpr (std::is_same_v) { if (valid()) { - return UT(nullopt); + return UT(); } return UT(error(detail::direct_error, stack::get(L, target))); } @@ -15205,7 +15205,7 @@ namespace sol { if (!valid()) { return UT(); } - return UT(stack::get(L, target)); + return stack::get(L, target); } } else { diff --git a/tests/runtime_tests/source/container_shims.cpp b/tests/runtime_tests/source/container_shims.cpp index 61583254..9cff02b6 100644 --- a/tests/runtime_tests/source/container_shims.cpp +++ b/tests/runtime_tests/source/container_shims.cpp @@ -143,6 +143,13 @@ namespace sol { template <> struct usertype_container { + // Hooks Lua's syntax for #c + static int size(lua_State* L) { + my_vec& v = sol::stack::get(L, 1); + return stack::push(L, v.size()); + } + + // Used by default implementation static auto begin(lua_State*, my_vec& self) { return self.begin(); } @@ -150,11 +157,6 @@ namespace sol { return self.end(); } - static std::size_t size(lua_State* L) { - my_vec& v = sol::stack::get(L, 1); - return v.size(); - } - static std::ptrdiff_t index_adjustment(lua_State*, my_vec&) { return 0; } @@ -216,6 +218,8 @@ TEST_CASE("containers/custom indexing", "allow containers to set a custom indexi REQUIRE(result2.valid()); auto result3 = lua.safe_script("assert(c[-1] == nil)", sol::script_pass_on_error); REQUIRE(result3.valid()); + auto result4 = lua.safe_script("assert(#c == 10)", sol::script_pass_on_error); + REQUIRE(result4.valid()); } TEST_CASE("containers/containers of pointers", "containers of pointers shouldn't have their value_type's overly stripped") {