mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
I can spell good I promise
update bootstrap to properly use depsfile
This commit is contained in:
parent
4c2748eaef
commit
7744a49cfe
|
@ -165,11 +165,13 @@ ninja.newline()
|
|||
ninja.rule('bootstrap', command = ' '.join(['python'] + sys.argv), generator = True)
|
||||
ninja.rule('compile', command = '$cxx -MMD -MF $out.d -c $cxxflags -Werror $in -o $out',
|
||||
deps = 'gcc', depfile = '$out.d',
|
||||
description = 'Compiling $in to $out')
|
||||
ninja.rule('link', command = '$cxx $cxxflags $in -o $out $ldflags', description = 'Creating $out')
|
||||
description = 'compiling $in to $out')
|
||||
ninja.rule('link', command = '$cxx $cxxflags $in -o $out $ldflags', description = 'creating $out')
|
||||
ninja.rule('tests_runner', command = tests)
|
||||
ninja.rule('examples_runner', command = 'cmd /c ' + (' && '.join(examples)) if 'win32' in sys.platform else ' && '.join(examples) )
|
||||
ninja.rule('example', command = '$cxx $cxxflags $in -o $out $ldflags')
|
||||
ninja.rule('example', command = '$cxx $cxxflags -MMD -MF $out.d $in -o $out $ldflags',
|
||||
deps = 'gcc', depfile = '$out.d',
|
||||
description = 'compiling example $in to $out')
|
||||
ninja.rule('installer', command = copy_command)
|
||||
ninja.rule('uninstaller', command = remove_command)
|
||||
ninja.newline()
|
||||
|
|
|
@ -113,12 +113,12 @@ namespace sol {
|
|||
index = lua_absindex(L, index);
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, index) != 0) {
|
||||
decltype(auto) key = stack::check_get<K>(L, -1);
|
||||
decltype(auto) key = stack::check_get<K>(L, -2);
|
||||
if (!key) {
|
||||
lua_pop(L, 1);
|
||||
continue;
|
||||
}
|
||||
arr.emplace(std::forward<decltype(key)>(key), stack::get<V>(L, -1));
|
||||
associative.emplace(std::forward<decltype(*key)>(*key), stack::get<V>(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
return associative;
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
#include <catch.hpp>
|
||||
#include <sol.hpp>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include "test_stack_guard.hpp"
|
||||
|
||||
std::string free_function() {
|
||||
|
@ -573,3 +575,51 @@ TEST_CASE("tables/returns", "make sure that even references to vectors are being
|
|||
matching = t[3] == 3;
|
||||
REQUIRE(matching);
|
||||
}
|
||||
|
||||
TEST_CASE("tables/vector_roundtrip", "make sure vectors can be round-tripped") {
|
||||
sol::state lua;
|
||||
std::vector<int> v{ 1, 2, 3 };
|
||||
lua.set_function("f", [&]() -> std::vector<int>& {
|
||||
return v;
|
||||
});
|
||||
lua.script("x = f()");
|
||||
std::vector<int> x = lua["x"];
|
||||
bool areequal = x == v;
|
||||
REQUIRE(areequal);
|
||||
}
|
||||
|
||||
TEST_CASE("tables/list_roundtrip", "make sure lists can be round-tripped") {
|
||||
sol::state lua;
|
||||
std::list<int> v{ 1, 2, 3 };
|
||||
lua.set_function("f", [&]() -> std::list<int>& {
|
||||
return v;
|
||||
});
|
||||
lua.script("x = f()");
|
||||
std::list <int> x = lua["x"];
|
||||
bool areequal = x == v;
|
||||
REQUIRE(areequal);
|
||||
}
|
||||
|
||||
TEST_CASE("tables/map_roundtrip", "make sure maps can be round-tripped") {
|
||||
sol::state lua;
|
||||
std::map<std::string, int> v{ { "a", 1 },{ "b", 2 },{ "c", 3 } };
|
||||
lua.set_function("f", [&]() -> std::map<std::string, int>& {
|
||||
return v;
|
||||
});
|
||||
lua.script("x = f()");
|
||||
std::map<std::string, int> x = lua["x"];
|
||||
bool areequal = x == v;
|
||||
REQUIRE(areequal);
|
||||
}
|
||||
|
||||
TEST_CASE("tables/unordered_map_roundtrip", "make sure unordered_maps can be round-tripped") {
|
||||
sol::state lua;
|
||||
std::unordered_map<std::string, int> v{ { "a", 1 },{ "b", 2 },{ "c", 3 } };
|
||||
lua.set_function("f", [&]() -> std::unordered_map<std::string, int>& {
|
||||
return v;
|
||||
});
|
||||
lua.script("x = f()");
|
||||
std::unordered_map<std::string, int> x = lua["x"];
|
||||
bool areequal = x == v;
|
||||
REQUIRE(areequal);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user