From ac096aa2a0921efde96b76252dffb119dcf27efc Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 5 Feb 2017 16:01:50 +0100 Subject: Update sol2 (nw) --- 3rdparty/sol2/sol/stack_push.hpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to '3rdparty/sol2/sol/stack_push.hpp') diff --git a/3rdparty/sol2/sol/stack_push.hpp b/3rdparty/sol2/sol/stack_push.hpp index 0478bcbe1ff..9a839107fde 100644 --- a/3rdparty/sol2/sol/stack_push.hpp +++ b/3rdparty/sol2/sol/stack_push.hpp @@ -71,7 +71,7 @@ namespace sol { template static int push_fx(lua_State* L, F&& f, T* obj) { if (obj == nullptr) - return stack::push(L, nil); + return stack::push(L, lua_nil); T** pref = static_cast(lua_newuserdata(L, sizeof(T*))); *pref = obj; f(); @@ -108,7 +108,7 @@ namespace sol { }; template - struct pusher, meta::neg>, std::is_base_of>>>>::value>> { + struct pusher>, meta::neg>, std::is_base_of>>>>::value>> { template static int push(lua_State* L, Args&&... args) { return pusher>{}.push(L, std::forward(args)...); @@ -123,7 +123,7 @@ namespace sol { template >> = meta::enabler> static int push(lua_State* L, Arg&& arg) { if (unique_usertype_traits::is_null(arg)) - return stack::push(L, nil); + return stack::push(L, lua_nil); return push_deep(L, std::forward(arg)); } @@ -243,12 +243,12 @@ namespace sol { template struct pusher::value || std::is_base_of::value>> { - static int push(lua_State*, const T& ref) { - return ref.push(); + static int push(lua_State* L, const T& ref) { + return ref.push(L); } - static int push(lua_State*, T&& ref) { - return ref.push(); + static int push(lua_State* L, T&& ref) { + return ref.push(L); } }; @@ -261,8 +261,8 @@ namespace sol { }; template<> - struct pusher { - static int push(lua_State* L, nil_t) { + struct pusher { + static int push(lua_State* L, lua_nil_t) { lua_pushnil(L); return 1; } @@ -351,8 +351,7 @@ namespace sol { lua_CFunction cdel = detail::user_alloc_destroy; // Make sure we have a plain GC set for this data if (luaL_newmetatable(L, name) != 0) { - lua_pushlightuserdata(L, rawdata); - lua_pushcclosure(L, cdel, 1); + lua_pushcclosure(L, cdel, 0); lua_setfield(L, -2, "__gc"); } lua_setmetatable(L, -2); @@ -416,6 +415,8 @@ namespace sol { } static int push(lua_State* L, const char* str) { + if (str == nullptr) + return stack::push(L, lua_nil); return push_sized(L, str, std::char_traits::length(str)); } @@ -484,11 +485,11 @@ namespace sol { static int push(lua_State* L, const wchar_t* strb, const wchar_t* stre) { if (sizeof(wchar_t) == 2) { - std::wstring_convert> convert; + static std::wstring_convert> convert; std::string u8str = convert.to_bytes(strb, stre); return stack::push(L, u8str); } - std::wstring_convert> convert; + static std::wstring_convert> convert; std::string u8str = convert.to_bytes(strb, stre); return stack::push(L, u8str); } @@ -506,10 +507,10 @@ namespace sol { static int push(lua_State* L, const char16_t* strb, const char16_t* stre) { #ifdef _MSC_VER - std::wstring_convert, int16_t> convert; + static std::wstring_convert, int16_t> convert; std::string u8str = convert.to_bytes(reinterpret_cast(strb), reinterpret_cast(stre)); #else - std::wstring_convert, char16_t> convert; + static std::wstring_convert, char16_t> convert; std::string u8str = convert.to_bytes(strb, stre); #endif // VC++ is a shit return stack::push(L, u8str); @@ -528,10 +529,10 @@ namespace sol { static int push(lua_State* L, const char32_t* strb, const char32_t* stre) { #ifdef _MSC_VER - std::wstring_convert, int32_t> convert; + static std::wstring_convert, int32_t> convert; std::string u8str = convert.to_bytes(reinterpret_cast(strb), reinterpret_cast(stre)); #else - std::wstring_convert, char32_t> convert; + static std::wstring_convert, char32_t> convert; std::string u8str = convert.to_bytes(strb, stre); #endif // VC++ is a shit return stack::push(L, u8str); @@ -670,14 +671,14 @@ namespace sol { template<> struct pusher { static int push(lua_State* L, nullopt_t) { - return stack::push(L, nil); + return stack::push(L, lua_nil); } }; template<> struct pusher { static int push(lua_State* L, std::nullptr_t) { - return stack::push(L, nil); + return stack::push(L, lua_nil); } }; -- cgit v1.2.3-70-g09d2