Skip to content

Commit 5261912

Browse files
Bugfix Lua 5.4 not working #5781
In Lua 5.4 the function lua_resume now has an extra parameter. This out parameter returns the number of values on the top of the stack that were yielded or returned by the coroutine (in previous versions, those values were the entire stack.). The constant LUA_ERRGCMM was removed. Errors in finalizers are never propagated; instead, they generate a warning.
1 parent 365121d commit 5261912

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

third_party/sol2/sol2/sol.hpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,7 +3399,9 @@ namespace sol {
33993399
runtime = LUA_ERRRUN,
34003400
memory = LUA_ERRMEM,
34013401
handler = LUA_ERRERR,
3402+
#if SOL_LUA_VERSION < 504
34023403
gc = LUA_ERRGCMM,
3404+
#endif
34033405
syntax = LUA_ERRSYNTAX,
34043406
file = LUA_ERRFILE,
34053407
};
@@ -3409,7 +3411,9 @@ namespace sol {
34093411
yielded = LUA_YIELD,
34103412
runtime = LUA_ERRRUN,
34113413
memory = LUA_ERRMEM,
3414+
#if SOL_LUA_VERSION < 504
34123415
gc = LUA_ERRGCMM,
3416+
#endif
34133417
handler = LUA_ERRERR,
34143418
dead = -1,
34153419
};
@@ -3418,7 +3422,9 @@ namespace sol {
34183422
ok = LUA_OK,
34193423
syntax = LUA_ERRSYNTAX,
34203424
memory = LUA_ERRMEM,
3425+
#if SOL_LUA_VERSION < 504
34213426
gc = LUA_ERRGCMM,
3427+
#endif
34223428
file = LUA_ERRFILE,
34233429
};
34243430

@@ -3462,8 +3468,10 @@ namespace sol {
34623468
return names[3];
34633469
case call_status::handler:
34643470
return names[4];
3471+
#if SOL_LUA_VERSION < 504
34653472
case call_status::gc:
34663473
return names[5];
3474+
#endif
34673475
case call_status::syntax:
34683476
return names[6];
34693477
case call_status::file:
@@ -3485,8 +3493,10 @@ namespace sol {
34853493
return names[0];
34863494
case load_status::memory:
34873495
return names[1];
3496+
#if SOL_LUA_VERSION < 504
34883497
case load_status::gc:
34893498
return names[2];
3499+
#endif
34903500
case load_status::syntax:
34913501
return names[3];
34923502
case load_status::file:
@@ -14374,9 +14384,12 @@ namespace sol {
1437414384
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
1437514385
#if SOL_LUA_VERSION < 502
1437614386
stats = static_cast<call_status>(lua_resume(lua_state(), static_cast<int>(argcount)));
14377-
#else
14387+
#elif SOL_LUA_VERSION < 504
1437814388
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount)));
14379-
#endif // Lua 5.1 compat
14389+
#else
14390+
int nstack = 0;
14391+
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nstack));
14392+
#endif
1438014393
}
1438114394

1438214395
template<std::size_t... I, typename... Ret>

0 commit comments

Comments
 (0)