From b3594c0ed721dc4b67818a797422faac70f33a83 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Thu, 11 Aug 2016 09:35:00 -0400 Subject: [PATCH] Update single and release --- single/sol/sol.hpp | 129 ++++++++++++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 42 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index a0a8f433..3585ecb1 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-11 11:25:37.090286 UTC -// This header was generated with sol v2.10.5 (revision b88a49a) +// Generated 2016-08-11 13:34:43.803767 UTC +// This header was generated with sol v2.11.0 (revision 7a53305) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -740,9 +740,7 @@ namespace sol { // beginning of sol\optional.hpp -#if __cplusplus > 201402L -#include -#elif defined(SOL_USE_BOOST) +#if defined(SOL_USE_BOOST) #include #else // beginning of Optional\optional.hpp @@ -953,12 +951,18 @@ T* static_addressof(T& ref) template constexpr U convert(U v) { return v; } - + +} // namespace detail_ + +namespace detail { + struct in_place_of {}; } // namespace detail constexpr struct trivial_init_t{} trivial_init{}; -constexpr struct in_place_t{} in_place{}; +struct in_place_tag { struct init {}; constexpr in_place_tag(init) {} in_place_tag() = delete; }; +constexpr inline in_place_tag in_place(detail::in_place_of) { return in_place_tag(in_place_tag::init()); } +using in_place_t = in_place_tag(&)(detail::in_place_of); struct nullopt_t { @@ -1136,11 +1140,11 @@ public: template explicit constexpr optional(in_place_t, Args&&... args) - : OptionalBase(in_place_t{}, constexpr_forward(args)...) {} + : OptionalBase(in_place, constexpr_forward(args)...) {} template >)> OPTIONAL_CONSTEXPR_INIT_LIST explicit optional(in_place_t, ::std::initializer_list il, Args&&... args) - : OptionalBase(in_place_t{}, il, constexpr_forward(args)...) {} + : OptionalBase(in_place, il, constexpr_forward(args)...) {} // 20.5.4.2, Destructor ~optional() = default; @@ -1735,23 +1739,43 @@ namespace std # endif //___SOL_OPTIONAL_HPP___ // end of Optional\optional.hpp -#endif // C++ 14 +#endif // Boost vs. Better optional namespace sol { -#if __cplusplus > 201402L - template - using optional = sol::optional; - using nullopt_t = std::nullopt_t; - constexpr nullopt_t nullopt = std::nullopt; -#elif defined(SOL_USE_BOOST) +#if defined(SOL_USE_BOOST) template using optional = boost::optional; using nullopt_t = boost::none_t; const nullopt_t nullopt = boost::none; -#else -#endif // C++ 14 -} + + namespace detail { + struct in_place_of {}; + } // detail + + struct in_place_tag { struct init {}; constexpr in_place_tag(init) {} in_place_tag() = delete; }; + constexpr inline in_place_tag in_place(detail::in_place_of) { return in_place_tag(in_place_tag::init()); } + using in_place_t = in_place_tag(&)(detail::in_place_of); +#endif // Boost vs. Better optional + + namespace detail { + template + struct in_place_of_i {}; + template + struct in_place_of_t {}; + } + + template + constexpr inline in_place_tag in_place(detail::in_place_of_t) { return in_place_tag(in_place_tag::init()); } + template + constexpr inline in_place_tag in_place(detail::in_place_of_i) { return in_place_tag(in_place_tag::init()); } + + template + using in_place_type_t = in_place_tag(&)(detail::in_place_of_t); + template + using in_place_index_t = in_place_tag(&)(detail::in_place_of_i); + +} // sol // end of sol\optional.hpp @@ -3909,7 +3933,7 @@ namespace sol { } // overload allows to use a pusher of a specific type, but pass in any kind of args - template + template::value>> inline int push(lua_State* L, Arg&& arg, Args&&... args) { return pusher>{}.push(L, std::forward(arg), std::forward(args)...); } @@ -4868,7 +4892,7 @@ namespace sol { tracking.use(1); std::size_t len; auto str = lua_tolstring(L, index, &len); - return{ str, len }; + return std::string( str, len ); } }; @@ -5641,13 +5665,18 @@ namespace sol { lua_pushlstring(L, str, N - 1); return 1; } + + static int push(lua_State* L, const char(&str)[N], std::size_t sz) { + lua_pushlstring(L, str, sz); + return 1; + } }; template <> struct pusher { static int push(lua_State* L, char c) { const char str[2] = { c, '\0' }; - return stack::push(L, str); + return stack::push(L, str, 1); } }; @@ -5657,6 +5686,11 @@ namespace sol { lua_pushlstring(L, str.c_str(), str.size()); return 1; } + + static int push(lua_State* L, const std::string& str, std::size_t sz) { + lua_pushlstring(L, str.c_str(), sz); + return 1; + } }; template<> @@ -8702,6 +8736,27 @@ namespace sol { // end of sol\variadic_args.hpp namespace sol { + + template ::value, typename T> + R make_reference(lua_State* L, T&& value) { + int backpedal = stack::push(L, std::forward(value)); + R r = stack::get(L, -backpedal); + if (should_pop) { + lua_pop(L, backpedal); + } + return r; + } + + template ::value, typename... Args> + R make_reference(lua_State* L, Args&&... args) { + int backpedal = stack::push(L, std::forward(args)...); + R r = stack::get(L, -backpedal); + if (should_pop) { + lua_pop(L, backpedal); + } + return r; + } + template class basic_object : public base_t { private: @@ -8726,6 +8781,12 @@ namespace sol { auto pp = stack::push_pop(*this); return stack::check(base_t::lua_state(), -1, no_panic); } + template + basic_object(std::integral_constant, lua_State* L, int index = -1) noexcept : base_t(L, index) { + if (invert_and_pop) { + lua_pop(L, -index); + } + } public: basic_object() noexcept = default; @@ -8739,6 +8800,10 @@ namespace sol { basic_object(const stack_reference& r) noexcept : basic_object(r.lua_state(), r.stack_index()) {} basic_object(stack_reference&& r) noexcept : basic_object(r.lua_state(), r.stack_index()) {} basic_object(lua_State* L, int index = -1) noexcept : base_t(L, index) {} + template + basic_object(lua_State* L, in_place_type_t, Args&&... args) noexcept : basic_object(std::integral_constant::value>(), L, -stack::push(L, std::forward(args)...)) {} + template + basic_object(lua_State* L, in_place_t, T&& arg, Args&&... args) noexcept : basic_object(L, in_place, std::forward(arg), std::forward(args)...) {} template decltype(auto) as() const { @@ -8753,26 +8818,6 @@ namespace sol { } }; - template ::value, typename T> - R make_reference(lua_State* L, T&& value) { - int backpedal = stack::push(L, std::forward(value)); - R r = stack::get(L, -backpedal); - if (should_pop) { - lua_pop(L, backpedal); - } - return r; - } - - template ::value, typename... Args> - object make_reference(lua_State* L, Args&&... args) { - int backpedal = stack::push(L, std::forward(args)...); - object r = stack::get(L, -backpedal); - if (should_pop) { - lua_pop(L, backpedal); - } - return r; - } - template object make_object(lua_State* L, T&& value) { return make_reference(L, std::forward(value));