diff --git a/docs/source/conf.py b/docs/source/conf.py index f3e90a42..8744c894 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -61,7 +61,7 @@ author = 'ThePhD' # The short X.Y version. version = '2.11' # The full version, including alpha/beta/rc tags. -release = '2.11.1' +release = '2.11.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 83ad1e70..7ff871a8 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-12 04:49:38.051104 UTC -// This header was generated with sol v2.11.2 (revision dcff206) +// Generated 2016-08-12 16:30:43.996035 UTC +// This header was generated with sol v2.11.3 (revision ffdff21) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -4780,6 +4780,9 @@ namespace sol { // end of sol\overload.hpp +#include +#include + namespace sol { namespace stack { @@ -4913,6 +4916,107 @@ namespace sol { return lua_tostring(L, index); } }; + + template<> + struct getter { + static char get(lua_State* L, int index, record& tracking) { + tracking.use(1); + size_t len; + auto str = lua_tolstring(L, index, &len); + return len > 0 ? str[0] : '\0'; + } + }; + + template<> + struct getter { + static std::wstring get(lua_State* L, int index, record& tracking) { + tracking.use(1); + size_t len; + auto str = lua_tolstring(L, index, &len); + if (len < 1) + return std::wstring(); + if (sizeof(wchar_t) == 2) { + std::wstring_convert> convert; + std::wstring r = convert.from_bytes(str, str + len); + return r; + } + else if (sizeof(wchar_t) == 4) { + std::wstring_convert> convert; + std::wstring r = convert.from_bytes(str, str + len); + return r; + } + // ... Uh, what the fuck do I even do here? + std::wstring_convert> convert; + std::wstring r = convert.from_bytes(str, str + len); + return r; + } + }; + + template<> + struct getter { + static std::u16string get(lua_State* L, int index, record& tracking) { + tracking.use(1); + size_t len; + auto str = lua_tolstring(L, index, &len); + if (len < 1) + return std::u16string(); +#ifdef _MSC_VER + std::wstring_convert, int16_t> convert; + auto intd = convert.from_bytes(str, str + len); + std::u16string r(intd.size(), '\0'); + std::memcpy(&r[0], intd.data(), intd.size() * sizeof(char16_t)); +#else + std::wstring_convert, char16_t> convert; + std::u16string r = convert.from_bytes(str, str + len); +#endif // VC++ is a shit + return r; + } + }; + + template<> + struct getter { + static std::u32string get(lua_State* L, int index, record& tracking) { + tracking.use(1); + size_t len; + auto str = lua_tolstring(L, index, &len); + if (len < 1) + return std::u32string(); +#ifdef _MSC_VER + std::wstring_convert, int32_t> convert; + auto intd = convert.from_bytes(str, str + len); + std::u32string r(intd.size(), '\0'); + std::memcpy(&r[0], intd.data(), r.size() * sizeof(char32_t)); +#else + std::wstring_convert, char32_t> convert; + std::u32string r = convert.from_bytes(str, str + len); +#endif // VC++ is a shit + return r; + } + }; + + template<> + struct getter { + static wchar_t get(lua_State* L, int index, record& tracking) { + auto str = getter{}.get(L, index, tracking); + return str.size() > 0 ? str[0] : '\0'; + } + }; + + template<> + struct getter { + static char get(lua_State* L, int index, record& tracking) { + auto str = getter{}.get(L, index, tracking); + return str.size() > 0 ? str[0] : '\0'; + } + }; + + template<> + struct getter { + static char32_t get(lua_State* L, int index, record& tracking) { + auto str = getter{}.get(L, index, tracking); + return str.size() > 0 ? str[0] : '\0'; + } + }; template<> struct getter { @@ -4926,71 +5030,6 @@ namespace sol { } }; - template<> - struct getter { - static char get(lua_State* L, int index, record& tracking) { - tracking.use(1); - size_t len; - auto str = lua_tolstring(L, index, &len); - return len > 0 ? str[0] : '\0'; - } - }; - -#if 0 - - template<> - struct getter { - static std::wstring get(lua_State* L, int index, record& tracking) { - tracking.use(1); - return{}; - } - }; - - template<> - struct getter { - static std::u16string get(lua_State* L, int index, record& tracking) { - tracking.use(1); - return{}; - } - }; - - template<> - struct getter { - static std::u32string get(lua_State* L, int index, record& tracking) { - tracking.use(1); - return{}; - } - }; - - template<> - struct getter { - static wchar_t get(lua_State* L, int index, record& tracking) { - tracking.use(1); - auto str = getter{}.get(L, index); - return str.size() > 0 ? str[0] : '\0'; - } - }; - - template<> - struct getter { - static char get(lua_State* L, int index, record& tracking) { - tracking.use(1); - auto str = getter{}.get(L, index); - return str.size() > 0 ? str[0] : '\0'; - } - }; - - template<> - struct getter { - static char32_t get(lua_State* L, int index, record& tracking) { - tracking.use(1); - auto str = getter{}.get(L, index); - return str.size() > 0 ? str[0] : '\0'; - } - }; - -#endif // For a distant future - template<> struct getter { static nil_t get(lua_State*, int, record& tracking) { @@ -5649,11 +5688,15 @@ namespace sol { lua_pushlstring(L, str, len); return 1; } - + static int push(lua_State* L, const char* str) { return push_sized(L, str, std::char_traits::length(str)); } + static int push(lua_State* L, const char* strb, const char* stre) { + return push_sized(L, strb, stre - strb); + } + static int push(lua_State* L, const char* str, std::size_t len) { return push_sized(L, str, len); } @@ -5702,27 +5745,52 @@ namespace sol { } }; -#if 0 - template<> struct pusher { static int push(lua_State* L, const wchar_t* wstr) { - return push(L, wstr, wstr + std::char_traits::length(wstr)); + return push(L, wstr, std::char_traits::length(wstr)); } - static int push(lua_State* L, const wchar_t* wstrb, const wchar_t* wstre) { - std::string str{}; - return stack::push(L, str); + + static int push(lua_State* L, const wchar_t* wstr, std::size_t sz) { + return push(L, wstr, wstr + sz); + } + + static int push(lua_State* L, const wchar_t* strb, const wchar_t* stre) { + if (sizeof(wchar_t) == 2) { + std::wstring_convert> convert; + std::string u8str = convert.to_bytes(strb, stre); + return stack::push(L, u8str); + } + else if (sizeof(wchar_t) == 4) { + std::wstring_convert> convert; + std::string u8str = convert.to_bytes(strb, stre); + return stack::push(L, u8str); + } + std::wstring_convert> convert; + std::string u8str = convert.to_bytes(strb, stre); + return stack::push(L, u8str); } }; template<> struct pusher { static int push(lua_State* L, const char16_t* u16str) { - return push(L, u16str, u16str + std::char_traits::length(u16str)); + return push(L, u16str, std::char_traits::length(u16str)); } - static int push(lua_State* L, const char16_t* u16strb, const char16_t* u16stre) { - std::string str{}; - return stack::push(L, str); + + static int push(lua_State* L, const char16_t* u16str, std::size_t sz) { + return push(L, u16str, u16str + sz); + } + + static int push(lua_State* L, const char16_t* strb, const char16_t* stre) { +#ifdef _MSC_VER + 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; + std::string u8str = convert.to_bytes(strb, stre); +#endif // VC++ is a shit + return stack::push(L, u8str); } }; @@ -5731,30 +5799,53 @@ namespace sol { static int push(lua_State* L, const char32_t* u32str) { return push(L, u32str, u32str + std::char_traits::length(u32str)); } - static int push(lua_State* L, const char32_t* u32strb, const char32_t* u32stre) { - std::string str{}; - return stack::push(L, str); + + static int push(lua_State* L, const char32_t* u32str, std::size_t sz) { + return push(L, u32str, u32str + sz); + } + + static int push(lua_State* L, const char32_t* strb, const char32_t* stre) { +#ifdef _MSC_VER + 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; + std::string u8str = convert.to_bytes(strb, stre); +#endif // VC++ is a shit + return stack::push(L, u8str); } }; template struct pusher { static int push(lua_State* L, const wchar_t(&str)[N]) { - return stack::push(L, str, str + N - 1); + return push(L, str, N - 1); + } + + static int push(lua_State* L, const wchar_t(&str)[N], std::size_t sz) { + return stack::push(L, str, str + sz); } }; template struct pusher { static int push(lua_State* L, const char16_t(&str)[N]) { - return stack::push(L, str, str + N - 1); + return push(L, str, N - 1); + } + + static int push(lua_State* L, const char16_t(&str)[N], std::size_t sz) { + return stack::push(L, str, str + sz); } }; template struct pusher { static int push(lua_State* L, const char32_t(&str)[N]) { - return stack::push(L, str, str + N - 1); + return push(L, str, N - 1); + } + + static int push(lua_State* L, const char32_t(&str)[N], std::size_t sz) { + return stack::push(L, str, str + sz); } }; @@ -5762,7 +5853,7 @@ namespace sol { struct pusher { static int push(lua_State* L, wchar_t c) { const wchar_t str[2] = { c, '\0' }; - return stack::push(L, str); + return stack::push(L, str, 1); } }; @@ -5770,7 +5861,7 @@ namespace sol { struct pusher { static int push(lua_State* L, char16_t c) { const char16_t str[2] = { c, '\0' }; - return stack::push(L, str); + return stack::push(L, str, 1); } }; @@ -5778,33 +5869,43 @@ namespace sol { struct pusher { static int push(lua_State* L, char32_t c) { const char32_t str[2] = { c, '\0' }; - return stack::push(L, str); + return stack::push(L, str, 1); } }; template<> struct pusher { static int push(lua_State* L, const std::wstring& wstr) { - return stack::push(L, wstr.data(), wstr.data() + wstr.size()); + return push(L, wstr.data(), wstr.size()); + } + + static int push(lua_State* L, const std::wstring& wstr, std::size_t sz) { + return stack::push(L, wstr.data(), wstr.data() + sz); } }; template<> struct pusher { static int push(lua_State* L, const std::u16string& u16str) { - return stack::push(L, u16str.data(), u16str.data() + u16str.size()); + return push(L, u16str, u16str.size()); + } + + static int push(lua_State* L, const std::u16string& u16str, std::size_t sz) { + return stack::push(L, u16str.data(), u16str.data() + sz); } }; template<> struct pusher { static int push(lua_State* L, const std::u32string& u32str) { - return stack::push(L, u32str.data(), u32str.data() + u32str.size()); + return push(L, u32str, u32str.size()); + } + + static int push(lua_State* L, const std::u32string& u32str, std::size_t sz) { + return stack::push(L, u32str.data(), u32str.data() + sz); } }; -#endif // Bad conversions - template struct pusher> { template