mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
update single
This commit is contained in:
parent
ffdff21487
commit
cd64453789
|
@ -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.
|
||||
|
|
|
@ -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 <codecvt>
|
||||
#include <locale>
|
||||
|
||||
namespace sol {
|
||||
namespace stack {
|
||||
|
||||
|
@ -4914,6 +4917,107 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<char> {
|
||||
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<std::wstring> {
|
||||
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<std::codecvt_utf8_utf16<wchar_t>> convert;
|
||||
std::wstring r = convert.from_bytes(str, str + len);
|
||||
return r;
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4) {
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
|
||||
std::wstring r = convert.from_bytes(str, str + len);
|
||||
return r;
|
||||
}
|
||||
// ... Uh, what the fuck do I even do here?
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
|
||||
std::wstring r = convert.from_bytes(str, str + len);
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<std::u16string> {
|
||||
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<std::codecvt_utf8_utf16<int16_t>, 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<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||
std::u16string r = convert.from_bytes(str, str + len);
|
||||
#endif // VC++ is a shit
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<std::u32string> {
|
||||
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<std::codecvt_utf8<int32_t>, 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<std::codecvt_utf8<char32_t>, char32_t> convert;
|
||||
std::u32string r = convert.from_bytes(str, str + len);
|
||||
#endif // VC++ is a shit
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<wchar_t> {
|
||||
static wchar_t get(lua_State* L, int index, record& tracking) {
|
||||
auto str = getter<std::wstring>{}.get(L, index, tracking);
|
||||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<char16_t> {
|
||||
static char get(lua_State* L, int index, record& tracking) {
|
||||
auto str = getter<std::u16string>{}.get(L, index, tracking);
|
||||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<char32_t> {
|
||||
static char32_t get(lua_State* L, int index, record& tracking) {
|
||||
auto str = getter<std::u32string>{}.get(L, index, tracking);
|
||||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<meta_function> {
|
||||
static meta_function get(lua_State *L, int index, record& tracking) {
|
||||
|
@ -4926,71 +5030,6 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<char> {
|
||||
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<std::wstring> {
|
||||
static std::wstring get(lua_State* L, int index, record& tracking) {
|
||||
tracking.use(1);
|
||||
return{};
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<std::u16string> {
|
||||
static std::u16string get(lua_State* L, int index, record& tracking) {
|
||||
tracking.use(1);
|
||||
return{};
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<std::u32string> {
|
||||
static std::u32string get(lua_State* L, int index, record& tracking) {
|
||||
tracking.use(1);
|
||||
return{};
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<wchar_t> {
|
||||
static wchar_t get(lua_State* L, int index, record& tracking) {
|
||||
tracking.use(1);
|
||||
auto str = getter<std::wstring>{}.get(L, index);
|
||||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<char16_t> {
|
||||
static char get(lua_State* L, int index, record& tracking) {
|
||||
tracking.use(1);
|
||||
auto str = getter<std::u16string>{}.get(L, index);
|
||||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<char32_t> {
|
||||
static char32_t get(lua_State* L, int index, record& tracking) {
|
||||
tracking.use(1);
|
||||
auto str = getter<std::u32string>{}.get(L, index);
|
||||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
|
||||
#endif // For a distant future
|
||||
|
||||
template<>
|
||||
struct getter<nil_t> {
|
||||
static nil_t get(lua_State*, int, record& tracking) {
|
||||
|
@ -5654,6 +5693,10 @@ namespace sol {
|
|||
return push_sized(L, str, std::char_traits<char>::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<const wchar_t*> {
|
||||
static int push(lua_State* L, const wchar_t* wstr) {
|
||||
return push(L, wstr, wstr + std::char_traits<wchar_t>::length(wstr));
|
||||
return push(L, wstr, std::char_traits<wchar_t>::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<std::codecvt_utf8_utf16<wchar_t>> convert;
|
||||
std::string u8str = convert.to_bytes(strb, stre);
|
||||
return stack::push(L, u8str);
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4) {
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
|
||||
std::string u8str = convert.to_bytes(strb, stre);
|
||||
return stack::push(L, u8str);
|
||||
}
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
|
||||
std::string u8str = convert.to_bytes(strb, stre);
|
||||
return stack::push(L, u8str);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct pusher<const char16_t*> {
|
||||
static int push(lua_State* L, const char16_t* u16str) {
|
||||
return push(L, u16str, u16str + std::char_traits<char16_t>::length(u16str));
|
||||
return push(L, u16str, std::char_traits<char16_t>::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<std::codecvt_utf8_utf16<int16_t>, int16_t> convert;
|
||||
std::string u8str = convert.to_bytes(reinterpret_cast<const int16_t*>(strb), reinterpret_cast<const int16_t*>(stre));
|
||||
#else
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, 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<char32_t>::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<std::codecvt_utf8<int32_t>, int32_t> convert;
|
||||
std::string u8str = convert.to_bytes(reinterpret_cast<const int32_t*>(strb), reinterpret_cast<const int32_t*>(stre));
|
||||
#else
|
||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> convert;
|
||||
std::string u8str = convert.to_bytes(strb, stre);
|
||||
#endif // VC++ is a shit
|
||||
return stack::push(L, u8str);
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
struct pusher<wchar_t[N]> {
|
||||
static int push(lua_State* L, const wchar_t(&str)[N]) {
|
||||
return stack::push<const wchar_t*>(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<const wchar_t*>(L, str, str + sz);
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
struct pusher<char16_t[N]> {
|
||||
static int push(lua_State* L, const char16_t(&str)[N]) {
|
||||
return stack::push<const char16_t*>(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<const char16_t*>(L, str, str + sz);
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
struct pusher<char32_t[N]> {
|
||||
static int push(lua_State* L, const char32_t(&str)[N]) {
|
||||
return stack::push<const char32_t*>(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<const char32_t*>(L, str, str + sz);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5762,7 +5853,7 @@ namespace sol {
|
|||
struct pusher<wchar_t> {
|
||||
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<char16_t> {
|
||||
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<char32_t> {
|
||||
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<std::wstring> {
|
||||
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<std::u16string> {
|
||||
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<std::u32string> {
|
||||
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<typename... Args>
|
||||
struct pusher<std::tuple<Args...>> {
|
||||
template <std::size_t... I, typename T>
|
||||
|
|
Loading…
Reference in New Issue
Block a user