mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Turns out C++ sucks when all implementers don't do things equally as fast. WHO KNEW?
This commit is contained in:
parent
cd64453789
commit
0d1d5ebd09
8
docs/source/codecvt.rst
Normal file
8
docs/source/codecvt.rst
Normal file
|
@ -0,0 +1,8 @@
|
|||
std::(w/u16/u32)string support
|
||||
==============================
|
||||
because this is surprisingly hard using standard C++
|
||||
----------------------------------------------------
|
||||
|
||||
Individuals using Visual Studio 2015, or on Windows with the VC++ and MinGW compilers (possibly Clang++ on Windows as well) have ``<codecvt>`` headers, and thusly Sol will attempt to include it. Individuals on GC 4.9.x, Clang 3.5.x, Clang 3.6.x do not seem to have ``<codecvt>`` shipped with the standard library that comes with installation of these compilers. If you want ``std::wstring``, ``std::u16string``, ``std::u32string`` automatic handling then you need to make sure you have those headers and then define ``SOL_CODECVT_SUPPORT``.
|
||||
|
||||
ThePhD did not want this to have to be a thing, but slow implementations and such force my hand. When GCC 7.x comes out, ThePhD will consider removing the effect of defining this macro and leaving <codecvt> support in at all times.
|
|
@ -7,7 +7,7 @@
|
|||
:target: https://github.com/ThePhD/sol2
|
||||
:alt: sol2 repository
|
||||
|
||||
Sol 2.10
|
||||
Sol 2.11
|
||||
========
|
||||
a fast, simple C++ and Lua Binding
|
||||
----------------------------------
|
||||
|
@ -34,6 +34,7 @@ get going:
|
|||
safety
|
||||
exceptions
|
||||
rtti
|
||||
codecvt
|
||||
cmake
|
||||
licenses
|
||||
origin
|
||||
|
|
|
@ -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 16:30:43.996035 UTC
|
||||
// This header was generated with sol v2.11.3 (revision ffdff21)
|
||||
// Generated 2016-08-12 17:00:49.377996 UTC
|
||||
// This header was generated with sol v2.11.3 (revision cd64453)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -1785,6 +1785,19 @@ namespace sol {
|
|||
|
||||
#include <lua.hpp>
|
||||
|
||||
#if defined(_WIN32) || defined(_MSC_VER)
|
||||
#ifndef SOL_CODECVT_SUPPORT
|
||||
#define SOL_CODECVT_SUPPORT 1
|
||||
#endif // codecvt support
|
||||
#elif defined(__GNUC__)
|
||||
#if __GNUC__ == 5
|
||||
#ifndef SOL_CODECVT_SUPPORT
|
||||
#define SOL_CODECVT_SUPPORT 1
|
||||
#endif // codecvt support
|
||||
#endif // g++ 5.x.x
|
||||
#else
|
||||
#endif // Windows/VC++ vs. g++ vs Others
|
||||
|
||||
#ifdef LUAJIT_VERSION
|
||||
#ifndef SOL_LUAJIT
|
||||
#define SOL_LUAJIT
|
||||
|
@ -4927,6 +4940,7 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef SOL_CODECVT_SUPPORT
|
||||
template<>
|
||||
struct getter<std::wstring> {
|
||||
static std::wstring get(lua_State* L, int index, record& tracking) {
|
||||
|
@ -5017,6 +5031,7 @@ namespace sol {
|
|||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
#endif // codecvt Header Support
|
||||
|
||||
template<>
|
||||
struct getter<meta_function> {
|
||||
|
@ -5745,6 +5760,7 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef SOL_CODECVT_SUPPORT
|
||||
template<>
|
||||
struct pusher<const wchar_t*> {
|
||||
static int push(lua_State* L, const wchar_t* wstr) {
|
||||
|
@ -5905,6 +5921,7 @@ namespace sol {
|
|||
return stack::push(L, u32str.data(), u32str.data() + sz);
|
||||
}
|
||||
};
|
||||
#endif // Codecvt Header Support
|
||||
|
||||
template<typename... Args>
|
||||
struct pusher<std::tuple<Args...>> {
|
||||
|
|
|
@ -24,6 +24,21 @@
|
|||
|
||||
#include <lua.hpp>
|
||||
|
||||
#if defined(_WIN32) || defined(_MSC_VER)
|
||||
#ifndef SOL_CODECVT_SUPPORT
|
||||
#define SOL_CODECVT_SUPPORT 1
|
||||
#endif // codecvt support
|
||||
#elif defined(__GNUC__)
|
||||
#if __GNUC__ >= 5
|
||||
#ifndef SOL_CODECVT_SUPPORT
|
||||
#define SOL_CODECVT_SUPPORT 1
|
||||
#endif // codecvt support
|
||||
#endif // g++ 5.x.x
|
||||
#else
|
||||
// Clang sucks and doesn't really utilize codecvt support,
|
||||
// not without checking the library versions explicitly (and we're not gonna do that, so fuck you)
|
||||
#endif // Windows/VC++ vs. g++ vs Others
|
||||
|
||||
#ifdef LUAJIT_VERSION
|
||||
#ifndef SOL_LUAJIT
|
||||
#define SOL_LUAJIT
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
#include <memory>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#ifdef SOL_CODECVT_SUPPORT
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#endif
|
||||
|
||||
namespace sol {
|
||||
namespace stack {
|
||||
|
@ -177,6 +179,7 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef SOL_CODECVT_SUPPORT
|
||||
template<>
|
||||
struct getter<std::wstring> {
|
||||
static std::wstring get(lua_State* L, int index, record& tracking) {
|
||||
|
@ -267,6 +270,7 @@ namespace sol {
|
|||
return str.size() > 0 ? str[0] : '\0';
|
||||
}
|
||||
};
|
||||
#endif // codecvt Header Support
|
||||
|
||||
template<>
|
||||
struct getter<meta_function> {
|
||||
|
|
|
@ -26,8 +26,10 @@
|
|||
#include "raii.hpp"
|
||||
#include "optional.hpp"
|
||||
#include <memory>
|
||||
#ifdef SOL_CODECVT_SUPPORT
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#endif
|
||||
|
||||
namespace sol {
|
||||
namespace stack {
|
||||
|
@ -401,6 +403,7 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef SOL_CODECVT_SUPPORT
|
||||
template<>
|
||||
struct pusher<const wchar_t*> {
|
||||
static int push(lua_State* L, const wchar_t* wstr) {
|
||||
|
@ -561,6 +564,7 @@ namespace sol {
|
|||
return stack::push(L, u32str.data(), u32str.data() + sz);
|
||||
}
|
||||
};
|
||||
#endif // Codecvt Header Support
|
||||
|
||||
template<typename... Args>
|
||||
struct pusher<std::tuple<Args...>> {
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST_CASE("stack/strings", "test that strings can be roundtripped") {
|
|||
static const std::u32string utf32str_s = utf32str;
|
||||
static const std::wstring widestr_s = widestr;
|
||||
|
||||
|
||||
#ifdef SOL_CODECVT_SUPPORT
|
||||
lua["utf8"] = utf8str;
|
||||
lua["utf16"] = utf16str;
|
||||
lua["utf32"] = utf32str;
|
||||
|
@ -87,6 +87,7 @@ TEST_CASE("stack/strings", "test that strings can be roundtripped") {
|
|||
REQUIRE(utf16_to_char32 == utf32str[0]);
|
||||
REQUIRE(utf32_to_char32 == utf32str[0]);
|
||||
REQUIRE(wide_to_char32 == utf32str[0]);
|
||||
#endif // codecvt support
|
||||
}
|
||||
|
||||
TEST_CASE("detail/demangling", "test some basic demangling cases") {
|
||||
|
|
Loading…
Reference in New Issue
Block a user