From e03f53d4dcba64968e22e45bc9c797a7160bb866 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Thu, 15 Aug 2019 08:14:06 -0400 Subject: [PATCH] more minor fixes for bad trait usage, wee --- include/sol/usertype_container.hpp | 107 +++++++++++++-------------- single/include/sol/forward.hpp | 4 +- single/include/sol/sol.hpp | 111 +++++++++++++++-------------- 3 files changed, 112 insertions(+), 110 deletions(-) diff --git a/include/sol/usertype_container.hpp b/include/sol/usertype_container.hpp index 6e7cbfc8..ce4a1bba 100644 --- a/include/sol/usertype_container.hpp +++ b/include/sol/usertype_container.hpp @@ -64,7 +64,8 @@ namespace sol { struct has_erase_after_test { private: template - static meta::sfinae_yes_t test(decltype(std::declval().erase_after(std::declval>()))*); + static meta::sfinae_yes_t test( + decltype(std::declval().erase_after(std::declval>()))*); template static meta::sfinae_no_t test(...); @@ -404,7 +405,8 @@ namespace sol { } static int index_set(lua_State* L) { - return luaL_error(L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle().c_str()); + return luaL_error( + L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle().c_str()); } static int add(lua_State* L) { @@ -463,7 +465,9 @@ namespace sol { }; template - struct usertype_container_default>, meta::has_value_type>>, meta::has_iterator>>>::value>> { + struct usertype_container_default>, meta::has_value_type>>, + meta::has_iterator>>>::value>> { private: using T = std::remove_pointer_t>>; @@ -475,32 +479,21 @@ namespace sol { using is_matched_lookup = meta::is_matched_lookup; using iterator = typename T::iterator; using value_type = typename T::value_type; - typedef meta::conditional_t, - meta::conditional_t>> - KV; + typedef meta::conditional_t, + meta::conditional_t>> + KV; typedef typename KV::first_type K; typedef typename KV::second_type V; typedef meta::conditional_t next_K; typedef decltype(*std::declval()) iterator_return; - typedef meta::conditional_t, - meta::conditional_t> - captured_type; + typedef meta::conditional_t, + meta::conditional_t> + captured_type; typedef typename meta::iterator_tag::type iterator_category; typedef std::is_same is_input_iterator; - typedef meta::conditional_t()))> - push_type; + typedef meta::conditional_t()))> push_type; typedef std::is_copy_assignable is_copyable; - typedef meta::neg, std::is_const>, meta::neg>> - is_writable; + typedef meta::neg, std::is_const>, meta::neg>> is_writable; typedef meta::unqualified_t>()))> key_type; typedef meta::all, meta::neg>> is_linear_integral; @@ -509,12 +502,10 @@ namespace sol { iterator it; std::size_t i; - iter(T& source, iterator it) - : source(source), it(std::move(it)), i(0) { + iter(T& source, iterator it) : source(source), it(std::move(it)), i(0) { } ~iter() { - } }; @@ -522,10 +513,13 @@ namespace sol { #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE auto p = stack::unqualified_check_get(L, 1); if (!p) { - luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle().c_str()); + luaL_error(L, + "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", + detail::demangle().c_str()); } if (p.value() == nullptr) { - luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); + luaL_error( + L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); } return *p.value(); #else @@ -613,9 +607,7 @@ namespace sol { } static detail::error_result get_comparative(std::true_type, lua_State* L, T& self, K& key) { - auto fx = [&](const value_type& r) -> bool { - return key == get_key(is_associative(), r); - }; + auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); }; auto e = deferred_uc::end(L, self); auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx)); if (it == e) { @@ -625,7 +617,9 @@ namespace sol { } static detail::error_result get_comparative(std::false_type, lua_State*, T&, K&) { - return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'", detail::demangle().data(), detail::demangle().data()); + return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'", + detail::demangle().data(), + detail::demangle().data()); } static detail::error_result get_it(std::false_type, lua_State* L, T& self, K& key) { @@ -649,7 +643,8 @@ namespace sol { } static detail::error_result set_writable(std::false_type, lua_State*, T&, iterator&, stack_object) { - return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); + return detail::error_result( + "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); } static detail::error_result set_category(std::input_iterator_tag, lua_State* L, T& self, stack_object okey, stack_object value) { @@ -690,11 +685,10 @@ namespace sol { static detail::error_result set_comparative(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) { decltype(auto) key = okey.as(); if (!is_writable::value) { - return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); + return detail::error_result( + "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); } - auto fx = [&](const value_type& r) -> bool { - return key == get_key(is_associative(), r); - }; + auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); }; auto e = deferred_uc::end(L, self); auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx)); if (it == e) { @@ -704,12 +698,14 @@ namespace sol { } static detail::error_result set_comparative(std::false_type, lua_State*, T&, stack_object, stack_object) { - return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key", detail::demangle().data(), detail::demangle().data()); + return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key", + detail::demangle().data(), + detail::demangle().data()); } template static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) { - if constexpr(meta::has_insert::value) { + if constexpr (meta::has_insert::value) { self.insert(it, value_type(key, value.as())); return {}; } @@ -717,13 +713,14 @@ namespace sol { (void)self; (void)it; (void)key; - return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); + return detail::error_result( + "cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); } } template static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) { - if constexpr(has_insert::value) { + if constexpr (meta::has_insert::value) { self.insert(it, key); return {}; } @@ -731,7 +728,8 @@ namespace sol { (void)self; (void)it; (void)key; - return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle().c_str()); + return detail::error_result( + "cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle().c_str()); } } @@ -822,7 +820,8 @@ namespace sol { template static detail::error_result find_comparative(std::false_type, lua_State*, T&) { - return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable", detail::demangle().c_str()); + return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable", + detail::demangle().c_str()); } template @@ -914,7 +913,7 @@ namespace sol { template static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) { - if constexpr(meta::has_insert::value) { + if constexpr (meta::has_insert::value) { self.insert(pos, value_type(key.as(), stack::unqualified_get(L, 3))); return {}; } @@ -923,7 +922,8 @@ namespace sol { (void)self; (void)key; (void)pos; - return detail::error_result("cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); + return detail::error_result( + "cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); } } @@ -990,7 +990,8 @@ namespace sol { } static detail::error_result insert_after_has(std::false_type, lua_State*, T&, stack_object, stack_object) { - return detail::error_result("cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle().data()); + return detail::error_result( + "cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle().data()); } static detail::error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) { @@ -1019,9 +1020,7 @@ namespace sol { } static detail::error_result erase_integral(std::false_type, lua_State* L, T& self, const K& key) { - auto fx = [&](const value_type& r) -> bool { - return key == r; - }; + auto fx = [&](const value_type& r) -> bool { return key == r; }; auto e = deferred_uc::end(L, self); auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx)); if (it == e) { @@ -1106,7 +1105,7 @@ namespace sol { } static detail::error_result get_start(lua_State* L, T& self, K& key) { - return get_associative_find(std::integral_constant::value>(), L, self, key); + return get_associative_find(std::integral_constant < bool, is_associative::value&& has_find::value > (), L, self, key); } static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) { @@ -1333,8 +1332,7 @@ namespace sol { T& source; iterator it; - iter(T& source, iterator it) - : source(source), it(std::move(it)) { + iter(T& source, iterator it) : source(source), it(std::move(it)) { } }; @@ -1342,10 +1340,13 @@ namespace sol { auto p = stack::unqualified_check_get(L, 1); #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE if (!p) { - luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle().c_str()); + luaL_error(L, + "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", + detail::demangle().c_str()); } if (p.value() == nullptr) { - luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); + luaL_error( + L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); } #endif // Safe getting with error return *p.value(); diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index c96fdf09..c7fa132e 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 2019-08-15 06:28:23.273623 UTC -// This header was generated with sol v3.0.3 (revision cb3acaa) +// Generated 2019-08-15 12:13:47.368988 UTC +// This header was generated with sol v3.0.3 (revision c3c08df) // 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 b8a92c20..8c9402d9 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 2019-08-15 06:28:22.668458 UTC -// This header was generated with sol v3.0.3 (revision cb3acaa) +// Generated 2019-08-15 12:13:46.408546 UTC +// This header was generated with sol v3.0.3 (revision c3c08df) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -19027,7 +19027,8 @@ namespace sol { struct has_erase_after_test { private: template - static meta::sfinae_yes_t test(decltype(std::declval().erase_after(std::declval>()))*); + static meta::sfinae_yes_t test( + decltype(std::declval().erase_after(std::declval>()))*); template static meta::sfinae_no_t test(...); @@ -19367,7 +19368,8 @@ namespace sol { } static int index_set(lua_State* L) { - return luaL_error(L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle().c_str()); + return luaL_error( + L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle().c_str()); } static int add(lua_State* L) { @@ -19426,7 +19428,9 @@ namespace sol { }; template - struct usertype_container_default>, meta::has_value_type>>, meta::has_iterator>>>::value>> { + struct usertype_container_default>, meta::has_value_type>>, + meta::has_iterator>>>::value>> { private: using T = std::remove_pointer_t>>; @@ -19438,32 +19442,21 @@ namespace sol { using is_matched_lookup = meta::is_matched_lookup; using iterator = typename T::iterator; using value_type = typename T::value_type; - typedef meta::conditional_t, - meta::conditional_t>> - KV; + typedef meta::conditional_t, + meta::conditional_t>> + KV; typedef typename KV::first_type K; typedef typename KV::second_type V; typedef meta::conditional_t next_K; typedef decltype(*std::declval()) iterator_return; - typedef meta::conditional_t, - meta::conditional_t> - captured_type; + typedef meta::conditional_t, + meta::conditional_t> + captured_type; typedef typename meta::iterator_tag::type iterator_category; typedef std::is_same is_input_iterator; - typedef meta::conditional_t()))> - push_type; + typedef meta::conditional_t()))> push_type; typedef std::is_copy_assignable is_copyable; - typedef meta::neg, std::is_const>, meta::neg>> - is_writable; + typedef meta::neg, std::is_const>, meta::neg>> is_writable; typedef meta::unqualified_t>()))> key_type; typedef meta::all, meta::neg>> is_linear_integral; @@ -19472,12 +19465,10 @@ namespace sol { iterator it; std::size_t i; - iter(T& source, iterator it) - : source(source), it(std::move(it)), i(0) { + iter(T& source, iterator it) : source(source), it(std::move(it)), i(0) { } ~iter() { - } }; @@ -19485,10 +19476,13 @@ namespace sol { #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE auto p = stack::unqualified_check_get(L, 1); if (!p) { - luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle().c_str()); + luaL_error(L, + "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", + detail::demangle().c_str()); } if (p.value() == nullptr) { - luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); + luaL_error( + L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); } return *p.value(); #else @@ -19576,9 +19570,7 @@ namespace sol { } static detail::error_result get_comparative(std::true_type, lua_State* L, T& self, K& key) { - auto fx = [&](const value_type& r) -> bool { - return key == get_key(is_associative(), r); - }; + auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); }; auto e = deferred_uc::end(L, self); auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx)); if (it == e) { @@ -19588,7 +19580,9 @@ namespace sol { } static detail::error_result get_comparative(std::false_type, lua_State*, T&, K&) { - return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'", detail::demangle().data(), detail::demangle().data()); + return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'", + detail::demangle().data(), + detail::demangle().data()); } static detail::error_result get_it(std::false_type, lua_State* L, T& self, K& key) { @@ -19612,7 +19606,8 @@ namespace sol { } static detail::error_result set_writable(std::false_type, lua_State*, T&, iterator&, stack_object) { - return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); + return detail::error_result( + "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); } static detail::error_result set_category(std::input_iterator_tag, lua_State* L, T& self, stack_object okey, stack_object value) { @@ -19653,11 +19648,10 @@ namespace sol { static detail::error_result set_comparative(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) { decltype(auto) key = okey.as(); if (!is_writable::value) { - return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); + return detail::error_result( + "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle().data()); } - auto fx = [&](const value_type& r) -> bool { - return key == get_key(is_associative(), r); - }; + auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); }; auto e = deferred_uc::end(L, self); auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx)); if (it == e) { @@ -19667,12 +19661,14 @@ namespace sol { } static detail::error_result set_comparative(std::false_type, lua_State*, T&, stack_object, stack_object) { - return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key", detail::demangle().data(), detail::demangle().data()); + return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key", + detail::demangle().data(), + detail::demangle().data()); } template static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) { - if constexpr(meta::has_insert::value) { + if constexpr (meta::has_insert::value) { self.insert(it, value_type(key, value.as())); return {}; } @@ -19680,13 +19676,14 @@ namespace sol { (void)self; (void)it; (void)key; - return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); + return detail::error_result( + "cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); } } template static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) { - if constexpr(has_insert::value) { + if constexpr (meta::has_insert::value) { self.insert(it, key); return {}; } @@ -19694,7 +19691,8 @@ namespace sol { (void)self; (void)it; (void)key; - return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle().c_str()); + return detail::error_result( + "cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle().c_str()); } } @@ -19785,7 +19783,8 @@ namespace sol { template static detail::error_result find_comparative(std::false_type, lua_State*, T&) { - return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable", detail::demangle().c_str()); + return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable", + detail::demangle().c_str()); } template @@ -19877,7 +19876,7 @@ namespace sol { template static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) { - if constexpr(meta::has_insert::value) { + if constexpr (meta::has_insert::value) { self.insert(pos, value_type(key.as(), stack::unqualified_get(L, 3))); return {}; } @@ -19886,7 +19885,8 @@ namespace sol { (void)self; (void)key; (void)pos; - return detail::error_result("cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); + return detail::error_result( + "cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle().c_str()); } } @@ -19953,7 +19953,8 @@ namespace sol { } static detail::error_result insert_after_has(std::false_type, lua_State*, T&, stack_object, stack_object) { - return detail::error_result("cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle().data()); + return detail::error_result( + "cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle().data()); } static detail::error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) { @@ -19982,9 +19983,7 @@ namespace sol { } static detail::error_result erase_integral(std::false_type, lua_State* L, T& self, const K& key) { - auto fx = [&](const value_type& r) -> bool { - return key == r; - }; + auto fx = [&](const value_type& r) -> bool { return key == r; }; auto e = deferred_uc::end(L, self); auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx)); if (it == e) { @@ -20069,7 +20068,7 @@ namespace sol { } static detail::error_result get_start(lua_State* L, T& self, K& key) { - return get_associative_find(std::integral_constant::value>(), L, self, key); + return get_associative_find(std::integral_constant < bool, is_associative::value&& has_find::value > (), L, self, key); } static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) { @@ -20296,8 +20295,7 @@ namespace sol { T& source; iterator it; - iter(T& source, iterator it) - : source(source), it(std::move(it)) { + iter(T& source, iterator it) : source(source), it(std::move(it)) { } }; @@ -20305,10 +20303,13 @@ namespace sol { auto p = stack::unqualified_check_get(L, 1); #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE if (!p) { - luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle().c_str()); + luaL_error(L, + "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", + detail::demangle().c_str()); } if (p.value() == nullptr) { - luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); + luaL_error( + L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle().c_str()); } #endif // Safe getting with error return *p.value();