From 0f1f7859f189708f8c3aec9d7618cdc6c70f11b4 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sun, 7 Aug 2016 20:57:38 -0400 Subject: [PATCH] single update --- single/sol/sol.hpp | 162 +++++++++++++++++++++++++++++++-------------- 1 file changed, 112 insertions(+), 50 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index ed51e837..5bd7ca41 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 2016-08-07 18:04:43.043807 UTC -// This header was generated with sol v2.10.0 (revision 57333bb) +// Generated 2016-08-08 00:57:18.871859 UTC +// This header was generated with sol v2.10.5 (revision 49cc3bd) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -6705,17 +6705,20 @@ namespace sol { template inline decltype(auto) property(F&& f, G&& g) { - using namespace sol; typedef lua_bind_traits> left_traits; typedef lua_bind_traits> right_traits; - return property_detail::property(meta::boolean<(left_traits::arity < right_traits::arity)>(), std::forward(f), std::forward(g)); + return property_detail::property(meta::boolean<(left_traits::free_arity < right_traits::free_arity)>(), std::forward(f), std::forward(g)); } template inline decltype(auto) property(F&& f) { - using namespace sol; typedef lua_bind_traits> left_traits; - return property_detail::property(meta::boolean<(left_traits::arity == 0)>(), std::forward(f)); + return property_detail::property(meta::boolean<(left_traits::free_arity < 2)>(), std::forward(f)); + } + + template + inline decltype(auto) readonly_property(F&& f) { + return property_detail::property(std::true_type(), std::forward(f)); } // Allow someone to make a member variable readonly (const) @@ -6749,11 +6752,6 @@ namespace sol { namespace sol { namespace call_detail { - template - inline decltype(auto) pick(std::integral_constant, F&& f) { - return std::forward(f); - } - template inline auto& pick(std::true_type, property_wrapper& f) { return f.read; @@ -6795,12 +6793,12 @@ namespace sol { namespace overload_detail { template - inline int overload_match_arity(sol::types<>, std::index_sequence<>, std::index_sequence, Match&&, lua_State* L, int, int, Args&&...) { + inline int overload_match_arity(types<>, std::index_sequence<>, std::index_sequence, Match&&, lua_State* L, int, int, Args&&...) { return luaL_error(L, "sol: no matching function call takes this number of arguments and the specified types"); } template - inline int overload_match_arity(sol::types, std::index_sequence, std::index_sequence, Match&& matchfx, lua_State* L, int fxarity, int start, Args&&... args) { + inline int overload_match_arity(types, std::index_sequence, std::index_sequence, Match&& matchfx, lua_State* L, int fxarity, int start, Args&&... args) { typedef lua_bind_traits> traits; typedef meta::tuple_types return_types; typedef typename traits::free_args_list args_list; @@ -6865,41 +6863,51 @@ namespace sol { template struct agnostic_lua_call_wrapper { - template - static int var_call(std::true_type, lua_State* L, Fx&& f) { + template + static int call(lua_State* L, Fx&& f, Args&&... args) { typedef wrapper> wrap; typedef typename wrap::returns_list returns_list; typedef typename wrap::free_args_list args_list; typedef typename wrap::caller caller; - return stack::call_into_lua(returns_list(), args_list(), L, boost + ( is_index ? 2 : 3 ), caller(), std::forward(f)); - } - - template - static int var_call(std::false_type, lua_State* L, Fx&& f) { - typedef wrapper> wrap; - typedef typename wrap::free_args_list args_list; - typedef typename wrap::returns_list returns_list; - typedef typename wrap::caller caller; - return stack::call_into_lua(returns_list(), args_list(), L, boost + 1, caller(), std::forward(f)); - } - - template - static int call(lua_State* L, Fx&& f) { - return var_call(std::integral_constant(), L, std::forward(f)); + return stack::call_into_lua(returns_list(), args_list(), L, boost + 1, caller(), std::forward(f), std::forward(args)...); } }; - template - struct agnostic_lua_call_wrapper, is_index, is_variable, checked, boost, C> { + template + struct agnostic_lua_call_wrapper, true, is_variable, checked, boost, C> { template static int call(lua_State* L, F&& f) { - if (is_index) { - return stack::push(L, detail::unwrap(f.value)); - } - else { - detail::unwrap(f.value) = stack::get>(L, 3 + boost); - return 0; - } + return stack::push_reference(L, detail::unwrap(f.value)); + } + }; + + template + struct agnostic_lua_call_wrapper, false, is_variable, checked, boost, C> { + template + static int call_assign(std::true_type, lua_State* L, V&& f) { + detail::unwrap(f.value) = stack::get>(L, boost + (is_variable ? 3 : 1)); + return 0; + } + + template + static int call_assign(std::false_type, lua_State* L, Args&&...) { + return luaL_error(L, "sol: cannot write to this variable: copy assignment/constructor not available"); + } + + template + static int call_const(std::false_type, lua_State* L, Args&&... args) { + typedef meta::unwrapped_t R; + return call_assign(std::is_assignable>, R>(), L, std::forward(args)...); + } + + template + static int call_const(std::true_type, lua_State* L, Args&&...) { + return luaL_error(L, "sol: cannot write to a readonly (const) variable"); + } + + template + static int call(lua_State* L, V&& f) { + return call_const(std::is_const>(), L, f); } }; @@ -6973,7 +6981,7 @@ namespace sol { template struct lua_call_wrapper::value>> { - typedef sol::lua_bind_traits traits_type; + typedef lua_bind_traits traits_type; typedef wrapper> wrap; typedef typename wrap::object_type object_type; @@ -7031,7 +7039,7 @@ namespace sol { template struct lua_call_wrapper::value>> { - typedef sol::lua_bind_traits traits_type; + typedef lua_bind_traits traits_type; typedef wrapper> wrap; typedef typename wrap::object_type object_type; @@ -7062,8 +7070,8 @@ namespace sol { }; template - struct lua_call_wrapper, is_index, is_variable, checked, boost, C> { - typedef sol::constructor_list F; + struct lua_call_wrapper, is_index, is_variable, checked, boost, C> { + typedef constructor_list F; static int call(lua_State* L, F&) { const auto& metakey = usertype_traits::metatable; @@ -7092,8 +7100,8 @@ namespace sol { }; template - struct lua_call_wrapper, is_index, is_variable, checked, boost, C> { - typedef sol::constructor_wrapper F; + struct lua_call_wrapper, is_index, is_variable, checked, boost, C> { + typedef constructor_wrapper F; struct onmatch { template @@ -7132,8 +7140,8 @@ namespace sol { }; template - struct lua_call_wrapper, is_index, is_variable, checked, boost, std::enable_if_t::value>> { - typedef sol::destructor_wrapper F; + struct lua_call_wrapper, is_index, is_variable, checked, boost, std::enable_if_t::value>> { + typedef destructor_wrapper F; static int call(lua_State* L, const F&) { return destruct(L); @@ -7141,8 +7149,8 @@ namespace sol { }; template - struct lua_call_wrapper, is_index, is_variable, checked, boost, std::enable_if_t::value>> { - typedef sol::destructor_wrapper F; + struct lua_call_wrapper, is_index, is_variable, checked, boost, std::enable_if_t::value>> { + typedef destructor_wrapper F; static int call(lua_State* L, const F& f) { T& obj = stack::get(L); @@ -7168,6 +7176,60 @@ namespace sol { } }; + template + struct lua_call_wrapper, is_index, is_variable, checked, boost, C> { + typedef std::conditional_t P; + typedef meta::unqualified_t

U; + typedef lua_bind_traits traits_type; + + template + static int self_call(lua_State* L, F&& f) { + typedef wrapper wrap; + typedef meta::unqualified_t> object_type; + typedef meta::pop_front_type_t args_list; + typedef T Ta; +#ifdef SOL_SAFE_USERTYPE + object_type* po = static_cast(stack::get(L, 1)); + if (po == nullptr) { + if (is_variable) { + return luaL_error(L, "sol: 'self' argument is nil (bad '.' access?)"); + } + return luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument)"); + } + object_type& o = *po; +#else + object_type& o = static_cast(stack::get(L, 1)); +#endif // Safety + typedef typename wrap::returns_list returns_list; + typedef typename wrap::caller caller; + return stack::call_into_lua(returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), f, o); + } + + template + static int defer_call(std::false_type, lua_State* L, F&& f, Args&&... args) { + return self_call(L, pick(meta::boolean(), f), std::forward(args)...); + } + + template + static int defer_call(std::true_type, lua_State* L, F&& f, Args&&... args) { + auto& p = pick(meta::boolean(), std::forward(f)); + return lua_call_wrapper, is_index, is_variable, checked, boost>{}.call(L, p, std::forward(args)...); + } + + template + static int call(lua_State* L, F&& f, Args&&... args) { + typedef meta::any< + std::is_void, + std::is_same, + meta::is_specialization_of, + meta::is_specialization_of, + meta::is_specialization_of, + std::is_member_pointer + > is_specialized; + return defer_call(is_specialized(), L, std::forward(f), std::forward(args)...); + } + }; + template struct lua_call_wrapper, is_index, is_variable, checked, boost, C> { typedef protect_t F; @@ -9150,7 +9212,7 @@ namespace sol { template static int real_call_with(lua_State* L, usertype_metatable& um) { - auto& f = call_detail::pick(std::integral_constant(), std::get(um.functions)); + auto& f = std::get(um.functions); return call_detail::call_wrapped(L, f); }