Browse Source

Restore lua 5.2/5.3 compatibility (fixes #1408)

Bart van Strien 7 years ago
parent
commit
fb793944e4
3 changed files with 16 additions and 1 deletions
  1. 9 0
      src/common/runtime.cpp
  2. 5 0
      src/common/runtime.h
  3. 2 1
      src/love.cpp

+ 9 - 0
src/common/runtime.cpp

@@ -879,4 +879,13 @@ Type *luax_type(lua_State *L, int idx)
 	return Type::byName(luaL_checkstring(L, 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
 } // love

+ 5 - 0
src/common/runtime.h

@@ -676,6 +676,11 @@ int luax_catchexcept(lua_State *L, const T& func, const F& finallyfunc)
 	return 0;
 	return 0;
 }
 }
 
 
+/**
+ * Compatibility shim for lua_resume
+ **/
+int luax_resume(lua_State *L, int nargs);
+
 } // love
 } // love
 
 
 #endif // LOVE_RUNTIME_H
 #endif // LOVE_RUNTIME_H

+ 2 - 1
src/love.cpp

@@ -19,6 +19,7 @@
  **/
  **/
 
 
 #include "common/version.h"
 #include "common/version.h"
+#include "common/runtime.h"
 #include "modules/love/love.h"
 #include "modules/love/love.h"
 #include <SDL.h>
 #include <SDL.h>
 
 
@@ -214,7 +215,7 @@ static DoneAction runlove(int argc, char **argv, int &retval)
 	lua_newthread(L);
 	lua_newthread(L);
 	lua_pushvalue(L, -2);
 	lua_pushvalue(L, -2);
 	int stackpos = lua_gettop(L);
 	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);
 		lua_pop(L, lua_gettop(L) - stackpos);
 
 
 	retval = 0;
 	retval = 0;