From d14345f016aaa9137e961982bb3b03c850a47572 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sat, 17 Mar 2018 09:09:37 -0400 Subject: [PATCH] MSVC is an ass and will probably continue to be an ass for a while to come. --- single/sol/sol.hpp | 119 ++++++++++++++++++++++++++----------- single/sol/sol_forward.hpp | 4 +- sol/load_result.hpp | 5 ++ sol/proxy.hpp | 7 ++- 4 files changed, 96 insertions(+), 39 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index ec3da021..d7e869f9 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-03-12 00:06:06.950598 UTC -// This header was generated with sol v2.19.5 (revision 22ecb74) +// Generated 2018-03-17 13:09:07.758298 UTC +// This header was generated with sol v2.19.5 (revision 947945d) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -1688,7 +1688,7 @@ namespace sol { namespace meta_detail { template , std::tuple>> = meta::enabler> decltype(auto) force_tuple(T&& x) { - return std::forward_as_tuple(std::forward(x)); + return std::tuple>(std::forward(x)); } template , std::tuple>> = meta::enabler> @@ -12560,13 +12560,9 @@ namespace sol { construct_match(constructor_match(obj), L, argcount, 1 + static_cast(syntax)); userdataref.push(); - luaL_getmetatable(L, &meta[0]); - if (type_of(L, -1) == type::lua_nil) { - lua_pop(L, 1); - return luaL_error(L, "sol: unable to get usertype metatable"); - } + stack::stack_detail::undefined_metatable umf(L, &meta[0]); + umf(); - lua_setmetatable(L, -2); return 1; } @@ -12847,7 +12843,7 @@ namespace sol { typedef constructor_list F; static int call(lua_State* L, F&) { - const auto& metakey = usertype_traits::metatable(); + const auto& meta = usertype_traits::metatable(); int argcount = lua_gettop(L); call_syntax syntax = argcount > 0 ? stack::get_call_syntax(L, usertype_traits::user_metatable(), 1) : call_syntax::dot; argcount -= static_cast(syntax); @@ -12858,13 +12854,9 @@ namespace sol { construct_match(constructor_match(obj), L, argcount, boost + 1 + static_cast(syntax)); userdataref.push(); - luaL_getmetatable(L, &metakey[0]); - if (type_of(L, -1) == type::lua_nil) { - lua_pop(L, 1); - return luaL_error(L, "sol: unable to get usertype metatable"); - } + stack::stack_detail::undefined_metatable umf(L, &meta[0]); + umf(); - lua_setmetatable(L, -2); return 1; } }; @@ -12876,7 +12868,7 @@ namespace sol { struct onmatch { template int operator()(types, index_value, types r, types a, lua_State* L, int, int start, F& f) { - const auto& metakey = usertype_traits::metatable(); + const auto& meta = usertype_traits::metatable(); T* obj = detail::usertype_allocate(L); reference userdataref(L, -1); @@ -12884,14 +12876,8 @@ namespace sol { stack::call_into_lua(r, a, L, boost + start, func, detail::implicit_wrapper(obj)); userdataref.push(); - luaL_getmetatable(L, &metakey[0]); - if (type_of(L, -1) == type::lua_nil) { - lua_pop(L, 1); - std::string err = "sol: unable to get usertype metatable for "; - err += usertype_traits::name(); - return luaL_error(L, err.c_str()); - } - lua_setmetatable(L, -2); + stack::stack_detail::undefined_metatable umf(L, &meta[0]); + umf(); return 1; } @@ -12918,11 +12904,25 @@ namespace sol { struct lua_call_wrapper, is_index, is_variable, checked, boost, clean_stack, std::enable_if_t::value>> { typedef destructor_wrapper F; - static int call(lua_State* L, const F& f) { + static int call_void(std::true_type, lua_State* L, const F& f) { + typedef meta::bind_traits> bt; + typedef typename bt::template arg_at<0> arg0; + typedef meta::unqualified_t O; + + O& obj = stack::get(L); + f.fx(detail::implicit_wrapper(obj)); + return 0; + } + + static int call_void(std::false_type, lua_State* L, const F& f) { T& obj = stack::get(L); f.fx(detail::implicit_wrapper(obj)); return 0; } + + static int call(lua_State* L, const F& f) { + return call_void(std::is_void(), L, f); + } }; template @@ -14153,6 +14153,20 @@ namespace sol { lua_CFunction cf = call_detail::construct; return stack::push(L, cf); } + + static int push(lua_State* L, constructor_list) { + lua_CFunction cf = call_detail::construct; + return stack::push(L, cf); + } + }; + + template + struct pusher> { + typedef constructor_list cl_t; + static int push(lua_State* L, cl_t cl) { + typedef typename meta::bind_traits::return_type T; + return stack::push>(L, cl); + } }; template @@ -14167,6 +14181,16 @@ namespace sol { } }; + template + struct pusher> { + template + static int push(lua_State* L, C&& c) { + typedef typename meta::bind_traits::template arg_at<0> arg0; + typedef meta::unqualified_t> T; + return stack::push>>(L, std::forward(c)); + } + }; + template struct pusher>> { static int push(lua_State* L, destructor_wrapper) { @@ -14177,11 +14201,38 @@ namespace sol { template struct pusher>> { - static int push(lua_State* L, destructor_wrapper c) { + static int push(lua_State* L, destructor_wrapper&& c) { lua_CFunction cf = call_detail::call_user, 2>; int upvalues = 0; upvalues += stack::push(L, nullptr); - upvalues += stack::push>(L, std::move(c)); + upvalues += stack::push>>(L, std::move(c)); + return stack::push(L, c_closure(cf, upvalues)); + } + + static int push(lua_State* L, const destructor_wrapper& c) { + lua_CFunction cf = call_detail::call_user, 2>; + int upvalues = 0; + upvalues += stack::push(L, nullptr); + upvalues += stack::push>>(L, c); + return stack::push(L, c_closure(cf, upvalues)); + } + }; + + template + struct pusher> { + static int push(lua_State* L, destructor_wrapper&& c) { + lua_CFunction cf = call_detail::call_user, 2>; + int upvalues = 0; + upvalues += stack::push(L, nullptr); + upvalues += stack::push>>(L, std::move(c)); + return stack::push(L, c_closure(cf, upvalues)); + } + + static int push(lua_State* L, const destructor_wrapper& c) { + lua_CFunction cf = call_detail::call_user, 2>; + int upvalues = 0; + upvalues += stack::push(L, nullptr); + upvalues += stack::push>>(L, c); return stack::push(L, c_closure(cf, upvalues)); } }; @@ -14868,11 +14919,12 @@ namespace sol { template decltype(auto) call(Args&&... args) { -#ifdef SOL_SAFE_FUNCTION - return get().template call(std::forward(args)...); +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 191326128 && _MSC_FULL_VER >= 191200000 + // MSVC is ass sometimes + return get().call(std::forward(args)...); #else return get().template call(std::forward(args)...); -#endif // Safe function usage +#endif } template @@ -20079,9 +20131,8 @@ namespace sol { template decltype(auto) call(Args&&... args) { -#if defined(_MSC_VER) && _MSC_VER == 1913 - // This compiler is bananas - // B, A N A N A S +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 191326128 && _MSC_FULL_VER >= 191200000 + // MSVC is ass sometimes return get().call(std::forward(args)...); #else return get().template call(std::forward(args)...); diff --git a/single/sol/sol_forward.hpp b/single/sol/sol_forward.hpp index 48709d74..5be85114 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-03-12 00:06:07.281639 UTC -// This header was generated with sol v2.19.5 (revision 22ecb74) +// Generated 2018-03-17 13:09:07.970531 UTC +// This header was generated with sol v2.19.5 (revision 947945d) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/sol/load_result.hpp b/sol/load_result.hpp index 1d396f31..272f8d70 100644 --- a/sol/load_result.hpp +++ b/sol/load_result.hpp @@ -122,7 +122,12 @@ namespace sol { template decltype(auto) call(Args&&... args) { +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 191326128 && _MSC_FULL_VER >= 191200000 + // MSVC is ass sometimes + return get().call(std::forward(args)...); +#else return get().template call(std::forward(args)...); +#endif } template diff --git a/sol/proxy.hpp b/sol/proxy.hpp index 13067066..fe937942 100644 --- a/sol/proxy.hpp +++ b/sol/proxy.hpp @@ -126,11 +126,12 @@ namespace sol { template decltype(auto) call(Args&&... args) { -#ifdef SOL_SAFE_FUNCTION - return get().template call(std::forward(args)...); +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 191326128 && _MSC_FULL_VER >= 191200000 + // MSVC is ass sometimes + return get().call(std::forward(args)...); #else return get().template call(std::forward(args)...); -#endif // Safe function usage +#endif } template