From 5bc5def14d30264db5dea37c7c858159e49b89b6 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Thu, 4 May 2017 03:18:46 -0400 Subject: [PATCH] update single --- single/sol/sol.hpp | 49 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index c5b26687..b32194e0 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 2017-04-25 23:43:53.892903 UTC -// This header was generated with sol v2.17.1 (revision 0db6d99) +// Generated 2017-05-04 07:17:19.632331 UTC +// This header was generated with sol v2.17.1 (revision 7b78558) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -11782,7 +11782,7 @@ namespace sol { typedef std::array one; typedef std::array two; - template static one test(decltype(&C::find)); + template static one test(decltype(std::declval().find(std::declval>()))*); template static two test(...); public: @@ -11907,6 +11907,9 @@ namespace sol { else if (name == "clear") { return stack::push(L, &clear_call); } + else if (name == "find") { + return stack::push(L, &find_call); + } } } return stack::push(L, lua_nil); @@ -11939,6 +11942,9 @@ namespace sol { else if (name == "clear") { return stack::push(L, &clear_call); } + else if (name == "find") { + return stack::push(L, &find_call); + } } } @@ -12140,6 +12146,36 @@ namespace sol { return real_clear_call_capable(std::integral_constant::value>(), L); } + static int real_find_call_capable(std::false_type, std::false_type, lua_State*L) { + static const std::string& s = detail::demangle(); + return luaL_error(L, "sol: cannot call find on type %s", s.c_str()); + } + + static int real_find_call_capable(std::false_type, std::true_type, lua_State*L) { + return real_index_call(L); + } + + static int real_find_call_capable(std::true_type, std::false_type, lua_State* L) { + auto k = stack::check_get(L, 2); + if (k) { + auto& src = get_src(L); + auto it = src.find(*k); + if (it != src.end()) { + auto& v = *it; + return stack::push_reference(L, v); + } + } + return stack::push(L, lua_nil); + } + + static int real_find_call_capable(std::true_type, std::true_type, lua_State* L) { + return real_index_call(L); + } + + static int real_find_call(lua_State*L) { + return real_find_call_capable(std::integral_constant::value>(), is_associative(), L); + } + static int add_call(lua_State*L) { return detail::static_trampoline<(&real_add_call)>(L); } @@ -12152,6 +12188,10 @@ namespace sol { return detail::static_trampoline<(&real_clear_call)>(L); } + static int find_call(lua_State*L) { + return detail::static_trampoline<(&real_find_call)>(L); + } + static int length_call(lua_State*L) { return detail::static_trampoline<(&real_length_call)>(L); } @@ -12178,7 +12218,7 @@ namespace sol { template inline auto container_metatable() { typedef container_usertype_metatable> meta_cumt; - std::array reg = { { + std::array reg = { { { "__index", &meta_cumt::index_call }, { "__newindex", &meta_cumt::new_index_call }, { "__pairs", &meta_cumt::pairs_call }, @@ -12187,6 +12227,7 @@ namespace sol { { "clear", &meta_cumt::clear_call }, { "insert", &meta_cumt::insert_call }, { "add", &meta_cumt::add_call }, + { "find", &meta_cumt::find_call }, std::is_pointer::value ? luaL_Reg{ nullptr, nullptr } : luaL_Reg{ "__gc", &detail::usertype_alloc_destroy }, { nullptr, nullptr } } };