Skip to content

Commit b2c22ea

Browse files
committed
1 parent 29c03ea commit b2c22ea

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

include/sol/table_core.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,9 @@ namespace sol {
318318
basic_table_core(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
319319
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
320320
auto pp = stack::push_pop(*this);
321+
int table_index = pp.index_of(*this);
321322
constructor_handler handler{};
322-
stack::check<basic_table_core>(lua_state(), -1, handler);
323+
stack::check<basic_table_core>(lua_state(), table_index, handler);
323324
#endif // Safety
324325
}
325326
basic_table_core(lua_State* L, const new_table& nt) : base_t(L, -stack::push(L, nt)) {
@@ -336,8 +337,9 @@ namespace sol {
336337
basic_table_core(lua_State* L, ref_index index) : basic_table_core(detail::no_safety, L, index) {
337338
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
338339
auto pp = stack::push_pop(*this);
340+
int table_index = pp.index_of(*this);
339341
constructor_handler handler{};
340-
stack::check<basic_table_core>(lua_state(), -1, handler);
342+
stack::check<basic_table_core>(lua_state(), table_index, handler);
341343
#endif // Safety
342344
}
343345
template <typename T,
@@ -347,8 +349,9 @@ namespace sol {
347349
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
348350
if (!is_table<meta::unqualified_t<T>>::value) {
349351
auto pp = stack::push_pop(*this);
352+
int table_index = pp.index_of(*this);
350353
constructor_handler handler{};
351-
stack::check<basic_table_core>(lua_state(), -1, handler);
354+
stack::check<basic_table_core>(lua_state(), table_index, handler);
352355
}
353356
#endif // Safety
354357
}
@@ -535,8 +538,9 @@ namespace sol {
535538
lua_State* L = base_t::lua_state();
536539
if constexpr (std::is_invocable_v<Fx, Key, Value>) {
537540
auto pp = stack::push_pop(*this);
541+
int table_index = pp.index_of(*this);
538542
stack::push(L, lua_nil);
539-
while (lua_next(L, -2)) {
543+
while (lua_next(L, table_index)) {
540544
Key key(L, -2);
541545
Value value(L, -1);
542546
auto pn = stack::pop_n(L, 1);
@@ -545,8 +549,9 @@ namespace sol {
545549
}
546550
else {
547551
auto pp = stack::push_pop(*this);
552+
int table_index = pp.index_of(*this);
548553
stack::push(L, lua_nil);
549-
while (lua_next(L, -2)) {
554+
while (lua_next(L, table_index)) {
550555
Key key(L, -2);
551556
Value value(L, -1);
552557
auto pn = stack::pop_n(L, 1);
@@ -558,8 +563,9 @@ namespace sol {
558563

559564
size_t size() const {
560565
auto pp = stack::push_pop(*this);
566+
int table_index = pp.index_of(*this);
561567
lua_State* L = base_t::lua_state();
562-
lua_len(L, -1);
568+
lua_len(L, table_index);
563569
return stack::pop<size_t>(L);
564570
}
565571

single/include/sol/forward.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
// This file was generated with a script.
23-
// Generated 2019-09-01 06:26:40.948435 UTC
24-
// This header was generated with sol v3.0.3 (revision e8649d2)
23+
// Generated 2019-09-08 23:53:48.445628 UTC
24+
// This header was generated with sol v3.0.3 (revision 29c03ea)
2525
// https://github.com/ThePhD/sol2
2626

2727
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP

single/include/sol/sol.hpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
// This file was generated with a script.
23-
// Generated 2019-09-01 06:26:40.339961 UTC
24-
// This header was generated with sol v3.0.3 (revision e8649d2)
23+
// Generated 2019-09-08 23:53:47.830273 UTC
24+
// This header was generated with sol v3.0.3 (revision 29c03ea)
2525
// https://github.com/ThePhD/sol2
2626

2727
#ifndef SOL_SINGLE_INCLUDE_HPP
@@ -23009,8 +23009,9 @@ namespace sol {
2300923009
basic_table_core(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
2301023010
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
2301123011
auto pp = stack::push_pop(*this);
23012+
int table_index = pp.index_of(*this);
2301223013
constructor_handler handler{};
23013-
stack::check<basic_table_core>(lua_state(), -1, handler);
23014+
stack::check<basic_table_core>(lua_state(), table_index, handler);
2301423015
#endif // Safety
2301523016
}
2301623017
basic_table_core(lua_State* L, const new_table& nt) : base_t(L, -stack::push(L, nt)) {
@@ -23027,8 +23028,9 @@ namespace sol {
2302723028
basic_table_core(lua_State* L, ref_index index) : basic_table_core(detail::no_safety, L, index) {
2302823029
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
2302923030
auto pp = stack::push_pop(*this);
23031+
int table_index = pp.index_of(*this);
2303023032
constructor_handler handler{};
23031-
stack::check<basic_table_core>(lua_state(), -1, handler);
23033+
stack::check<basic_table_core>(lua_state(), table_index, handler);
2303223034
#endif // Safety
2303323035
}
2303423036
template <typename T,
@@ -23038,8 +23040,9 @@ namespace sol {
2303823040
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
2303923041
if (!is_table<meta::unqualified_t<T>>::value) {
2304023042
auto pp = stack::push_pop(*this);
23043+
int table_index = pp.index_of(*this);
2304123044
constructor_handler handler{};
23042-
stack::check<basic_table_core>(lua_state(), -1, handler);
23045+
stack::check<basic_table_core>(lua_state(), table_index, handler);
2304323046
}
2304423047
#endif // Safety
2304523048
}
@@ -23226,8 +23229,9 @@ namespace sol {
2322623229
lua_State* L = base_t::lua_state();
2322723230
if constexpr (std::is_invocable_v<Fx, Key, Value>) {
2322823231
auto pp = stack::push_pop(*this);
23232+
int table_index = pp.index_of(*this);
2322923233
stack::push(L, lua_nil);
23230-
while (lua_next(L, -2)) {
23234+
while (lua_next(L, table_index)) {
2323123235
Key key(L, -2);
2323223236
Value value(L, -1);
2323323237
auto pn = stack::pop_n(L, 1);
@@ -23236,8 +23240,9 @@ namespace sol {
2323623240
}
2323723241
else {
2323823242
auto pp = stack::push_pop(*this);
23243+
int table_index = pp.index_of(*this);
2323923244
stack::push(L, lua_nil);
23240-
while (lua_next(L, -2)) {
23245+
while (lua_next(L, table_index)) {
2324123246
Key key(L, -2);
2324223247
Value value(L, -1);
2324323248
auto pn = stack::pop_n(L, 1);
@@ -23249,8 +23254,9 @@ namespace sol {
2324923254

2325023255
size_t size() const {
2325123256
auto pp = stack::push_pop(*this);
23257+
int table_index = pp.index_of(*this);
2325223258
lua_State* L = base_t::lua_state();
23253-
lua_len(L, -1);
23259+
lua_len(L, table_index);
2325423260
return stack::pop<size_t>(L);
2325523261
}
2325623262

0 commit comments

Comments
 (0)