mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Some minor fixes and updates
This commit is contained in:
parent
471b5870e2
commit
72a445ff6a
|
@ -74,6 +74,7 @@ namespace sol {
|
|||
auto pp = stack::push_pop(*this);
|
||||
return stack::check<T>(base_t::lua_state(), -1, no_panic);
|
||||
}
|
||||
|
||||
template <bool invert_and_pop = false>
|
||||
basic_object(std::integral_constant<bool, invert_and_pop>, lua_State* L, int index = -1) noexcept : base_t(L, index) {
|
||||
if (invert_and_pop) {
|
||||
|
@ -90,6 +91,14 @@ namespace sol {
|
|||
basic_object(basic_object&&) = default;
|
||||
basic_object& operator=(const basic_object&) = default;
|
||||
basic_object& operator=(basic_object&&) = default;
|
||||
basic_object& operator=(const base_t& b) {
|
||||
base_t::operator=(b);
|
||||
return *this;
|
||||
}
|
||||
basic_object& operator=(base_t&& b) {
|
||||
base_t::operator=(std::move(b));
|
||||
return *this;
|
||||
}
|
||||
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) {}
|
||||
|
|
|
@ -334,15 +334,15 @@ namespace sol {
|
|||
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';
|
||||
return str.size() > 0 ? str[0] : wchar_t(0);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct getter<char16_t> {
|
||||
static char get(lua_State* L, int index, record& tracking) {
|
||||
static char16_t get(lua_State* L, int index, record& tracking) {
|
||||
auto str = getter<std::u16string>{}.get(L, index, tracking);
|
||||
return str.size() > 0 ? str[0] : '\0';
|
||||
return str.size() > 0 ? str[0] : char16_t(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -350,7 +350,7 @@ namespace sol {
|
|||
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';
|
||||
return str.size() > 0 ? str[0] : char32_t(0);
|
||||
}
|
||||
};
|
||||
#endif // codecvt header support
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace sol {
|
|||
};
|
||||
|
||||
template <typename... Tn>
|
||||
struct tie_size<::sol::tie_t<Tn...>> : ::std::tuple_size<::std::tuple<Tn...>> { };
|
||||
struct tie_size< tie_t<Tn...> > : std::tuple_size< std::tuple<Tn...> > { };
|
||||
|
||||
namespace adl_barrier_detail {
|
||||
template <typename... Tn>
|
||||
|
|
|
@ -138,8 +138,8 @@ namespace sol {
|
|||
typedef std::shared_ptr<T> actual_type;
|
||||
static const bool value = true;
|
||||
|
||||
static bool is_null(const actual_type& value) {
|
||||
return value == nullptr;
|
||||
static bool is_null(const actual_type& p) {
|
||||
return p == nullptr;
|
||||
}
|
||||
|
||||
static type* get(const actual_type& p) {
|
||||
|
@ -153,8 +153,8 @@ namespace sol {
|
|||
typedef std::unique_ptr<T, D> actual_type;
|
||||
static const bool value = true;
|
||||
|
||||
static bool is_null(const actual_type& value) {
|
||||
return value == nullptr;
|
||||
static bool is_null(const actual_type& p) {
|
||||
return p == nullptr;
|
||||
}
|
||||
|
||||
static type* get(const actual_type& p) {
|
||||
|
|
|
@ -349,7 +349,6 @@ TEST_CASE("usertype/usertype-utility-derived", "usertype classes must play nice
|
|||
lua.set_usertype(derivedusertype);
|
||||
|
||||
lua.script("derived = Derived.new(7)");
|
||||
Derived& derived = lua["derived"];
|
||||
lua.script("dgn = derived:get_num()\n"
|
||||
"print(dgn)");
|
||||
lua.script("dgn10 = derived:get_num_10()\n"
|
||||
|
@ -608,6 +607,8 @@ TEST_CASE("usertype/destructor-tests", "Show that proper copies / destruction ha
|
|||
REQUIRE(created == 4);
|
||||
REQUIRE(destroyed == 0);
|
||||
REQUIRE(std::addressof(x1) == std::addressof(x1ref));
|
||||
REQUIRE(std::addressof(x1copyref) != std::addressof(x1));
|
||||
REQUIRE(std::addressof(x2copyref) != std::addressof(x2));
|
||||
}
|
||||
REQUIRE(created == 4);
|
||||
REQUIRE(destroyed == 4);
|
||||
|
|
Loading…
Reference in New Issue
Block a user