Making sure everything is fixed on all compilers + g++ too now

This commit is contained in:
ThePhD 2016-06-08 11:23:17 -04:00
parent 220ff5a475
commit 89bf8d5cbb
4 changed files with 27 additions and 8 deletions

View File

@ -50,7 +50,7 @@ private:
public:
basic_table_iterator () : idx(-1), keyidx(-1) {
basic_table_iterator () : keyidx(-1), idx(-1) {
}

View File

@ -146,7 +146,7 @@ namespace sol {
}
template <std::size_t I = 0, typename F, typename... Args>
int make_regs(regs_t& l, int index, sol::call_construction&, F&, Args&&... args) {
int make_regs(regs_t& l, int index, sol::call_construction, F&&, Args&&... args) {
callconstructfunc = call<I + 1>;
secondarymeta = true;
int endindex = make_regs<I + 2>(l, index + 1, std::forward<Args>(args)...);
@ -154,7 +154,7 @@ namespace sol {
}
template <std::size_t I = 0, typename... Bases, typename... Args>
int make_regs(regs_t& l, int index, base_classes_tag&, bases<Bases...>&, Args&&... args) {
int make_regs(regs_t& l, int index, base_classes_tag, bases<Bases...>, Args&&... args) {
int endindex = make_regs<I + 2>(l, index + 1, std::forward<Args>(args)...);
if (sizeof...(Bases) < 1)
return endindex;
@ -174,7 +174,7 @@ namespace sol {
#endif // No Runtime Type Information vs. Throw-Style Inheritance
}
template <std::size_t I = 0, typename N, typename F, typename... Args>
template <std::size_t I = 0, typename N, typename F, typename... Args, typename = std::enable_if_t<!meta::any_same<meta::unqualified_t<N>, base_classes_tag, call_construction>::value>>
int make_regs(regs_t& l, int index, N&& n, F&&, Args&&... args) {
string_detail::string_shim shimname = usertype_detail::make_shim(n);
// Returnable scope

View File

@ -28,3 +28,20 @@ TEST_CASE("issues/stack-overflow", "make sure various operations repeated don't
}
);
}
TEST_CASE("issues/stack-overflow-2", "make sure basic iterators clean up properly when they're not iterated through (e.g., with empty())") {
sol::state lua;
sol::table t = lua.create_table_with(1, "wut");
int MAX = 50000;
auto fx = [&]() {
int a = 50;
for (int i = 0; i < MAX; ++i) {
if (t.empty()) {
a += 4;
}
a += 2;
}
};
REQUIRE_NOTHROW(fx());
}

View File

@ -915,7 +915,9 @@ TEST_CASE("usertype/coverage", "try all the things") {
lua.new_usertype<ext_getset>("ext_getset",
sol::call_constructor, sol::constructors<sol::types<>, sol::types<int>>(),
sol::meta_function::garbage_collect, sol::destructor(des<ext_getset>),
"x", sol::overload(&ext_getset::x, &ext_getset::x2, [](ext_getset& m, std::string x, int y) { return m.meow + 50 + y + x.length(); }),
"x", sol::overload(&ext_getset::x, &ext_getset::x2, [](ext_getset& m, std::string x, int y) {
return m.meow + 50 + y + x.length();
}),
"bark", &ext_getset::bark,
"meow", &ext_getset::meow,
"readonlybark", sol::readonly(&ext_getset::bark),
@ -935,7 +937,7 @@ print(w)
)");
int w = lua["w"];
REQUIRE(w == 27);
REQUIRE(w == (56 + 50 + 14 + 14));
lua.script(R"(
e:set(500)
@ -977,8 +979,8 @@ print(d)
int c = lua["c"];
int d = lua["d"];
REQUIRE(a == 5001);
REQUIRE(b == 9700);
REQUIRE(c == 9700);
REQUIRE(d == 56);
lua.script(R"(
e.writeonlypropbark = 500