From fb793944e4d7374637e81f56555140cc414150c7 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Thu, 3 May 2018 20:04:16 +0200 Subject: [PATCH] Restore lua 5.2/5.3 compatibility (fixes #1408) --- src/common/runtime.cpp | 9 +++++++++ src/common/runtime.h | 5 +++++ src/love.cpp | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 23d0e9867..e3415e1cc 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -879,4 +879,13 @@ Type *luax_type(lua_State *L, int idx) return Type::byName(luaL_checkstring(L, idx)); } +int luax_resume(lua_State *L, int nargs) +{ +#if LUA_VERSION_NUM >= 502 + return lua_resume(L, nullptr, nargs); +#else + return lua_resume(L, nargs); +#endif +} + } // love diff --git a/src/common/runtime.h b/src/common/runtime.h index eee50cc16..562ac3cdf 100644 --- a/src/common/runtime.h +++ b/src/common/runtime.h @@ -676,6 +676,11 @@ int luax_catchexcept(lua_State *L, const T& func, const F& finallyfunc) return 0; } +/** + * Compatibility shim for lua_resume + **/ +int luax_resume(lua_State *L, int nargs); + } // love #endif // LOVE_RUNTIME_H diff --git a/src/love.cpp b/src/love.cpp index a4a2444c6..913d8b133 100644 --- a/src/love.cpp +++ b/src/love.cpp @@ -19,6 +19,7 @@ **/ #include "common/version.h" +#include "common/runtime.h" #include "modules/love/love.h" #include @@ -214,7 +215,7 @@ static DoneAction runlove(int argc, char **argv, int &retval) lua_newthread(L); lua_pushvalue(L, -2); int stackpos = lua_gettop(L); - while (lua_resume(L, 0) == LUA_YIELD) + while (love::luax_resume(L, 0) == LUA_YIELD) lua_pop(L, lua_gettop(L) - stackpos); retval = 0;