mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
fixed ipairs swap bug
This commit is contained in:
parent
882f337c48
commit
9a0b5ef34a
|
@ -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 2017-10-26 17:14:51.531340 UTC
|
||||
// This header was generated with sol v2.18.5 (revision 540d322)
|
||||
// Generated 2017-10-30 18:38:03.122522 UTC
|
||||
// This header was generated with sol v2.18.5 (revision 882f337)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -15337,12 +15337,12 @@ namespace sol {
|
|||
}
|
||||
int p;
|
||||
if (ip) {
|
||||
p = stack::push_reference(L, it->first);
|
||||
}
|
||||
else {
|
||||
++i.i;
|
||||
p = stack::push_reference(L, i.i);
|
||||
}
|
||||
else {
|
||||
p = stack::push_reference(L, it->first);
|
||||
}
|
||||
p += stack::stack_detail::push_reference<push_type>(L, detail::deref(it->second));
|
||||
std::advance(it, 1);
|
||||
return p;
|
||||
|
|
|
@ -1004,12 +1004,12 @@ namespace sol {
|
|||
}
|
||||
int p;
|
||||
if (ip) {
|
||||
p = stack::push_reference(L, it->first);
|
||||
}
|
||||
else {
|
||||
++i.i;
|
||||
p = stack::push_reference(L, i.i);
|
||||
}
|
||||
else {
|
||||
p = stack::push_reference(L, it->first);
|
||||
}
|
||||
p += stack::stack_detail::push_reference<push_type>(L, detail::deref(it->second));
|
||||
std::advance(it, 1);
|
||||
return p;
|
||||
|
|
|
@ -632,6 +632,28 @@ void associative_unordered_container_check(sol::state& lua, T& items) {
|
|||
REQUIRE((v3 == 30));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void associative_ordered_container_key_value_check(sol::state& lua, T& data, T& reflect) {
|
||||
typedef typename T::key_type K;
|
||||
typedef typename T::mapped_type V;
|
||||
lua["collect"] = [&reflect](K k, V v) {
|
||||
reflect.insert({ k, v });
|
||||
};
|
||||
|
||||
#if SOL_LUA_VERSION > 502
|
||||
lua["val"] = data;
|
||||
lua.script(R"(
|
||||
for k, v in pairs(val) do
|
||||
collect(k, v)
|
||||
end
|
||||
print()
|
||||
)");
|
||||
#else
|
||||
reflect = data;
|
||||
#endif
|
||||
REQUIRE((data == reflect));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fixed_container_check(sol::state& lua, T& items) {
|
||||
{
|
||||
|
@ -912,6 +934,27 @@ TEST_CASE("containers/associative unordered containers", "check associative (map
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("containers/associative ordered pairs", "check to make sure pairs works properly for key-value types") {
|
||||
struct bar {};
|
||||
std::unique_ptr<bar> ua(new bar()), ub(new bar()), uc(new bar());
|
||||
bar* a = ua.get();
|
||||
bar* b = ub.get();
|
||||
bar* c = uc.get();
|
||||
|
||||
SECTION("map") {
|
||||
sol::state lua;
|
||||
std::map<std::string, bar*> data({ { "a", a },{ "b", b },{ "c", c } });
|
||||
std::map<std::string, bar*> reflect;
|
||||
associative_ordered_container_key_value_check(lua, data, reflect);
|
||||
}
|
||||
SECTION("multimap") {
|
||||
sol::state lua;
|
||||
std::multimap<std::string, bar*> data({ { "a", a },{ "b", b },{ "c", c } });
|
||||
std::multimap<std::string, bar*> reflect;
|
||||
associative_ordered_container_key_value_check(lua, data, reflect);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("containers/auxiliary functions test", "make sure the manipulation functions are present and usable and working across various container types") {
|
||||
sol::state lua;
|
||||
lua.open_libraries();
|
||||
|
|
Loading…
Reference in New Issue
Block a user