mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Havin' lots of derps these days. Fix #141
This commit is contained in:
parent
87eb901b01
commit
85daffaa00
|
@ -598,6 +598,17 @@ namespace sol {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct lua_type_of<this_state> : std::integral_constant<type, type::none> {};
|
struct lua_type_of<this_state> : std::integral_constant<type, type::none> {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct lua_type_of<T, std::enable_if_t<
|
||||||
|
meta::all<
|
||||||
|
meta::has_begin_end<T>,
|
||||||
|
meta::neg<meta::any<
|
||||||
|
std::is_base_of<reference, T>,
|
||||||
|
std::is_base_of<stack_reference, T>
|
||||||
|
>>
|
||||||
|
>::value
|
||||||
|
>> : std::integral_constant<type, type::table> {};
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -553,3 +553,23 @@ TEST_CASE("tables/add", "Basic test to make sure the 'add' feature works") {
|
||||||
REQUIRE(val == bigvec[i]);
|
REQUIRE(val == bigvec[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("tables/returns", "make sure that even references to vectors are being serialized as tables") {
|
||||||
|
sol::state lua;
|
||||||
|
std::vector<int> v{ 1, 2, 3 };
|
||||||
|
lua.set_function("f", [&]() -> std::vector<int>& {
|
||||||
|
return v;
|
||||||
|
});
|
||||||
|
lua.script("x = f()");
|
||||||
|
sol::object x = lua["x"];
|
||||||
|
sol::type xt = x.get_type();
|
||||||
|
REQUIRE(xt == sol::type::table);
|
||||||
|
sol::table t = x;
|
||||||
|
bool matching;
|
||||||
|
matching = t[1] == 1;
|
||||||
|
REQUIRE(matching);
|
||||||
|
matching = t[2] == 2;
|
||||||
|
REQUIRE(matching);
|
||||||
|
matching = t[3] == 3;
|
||||||
|
REQUIRE(matching);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user