mirror of
https://github.com/love2d/love.git
synced 2026-08-17 02:58:31 +02:00
Make love compile against lua5.2
This commit is contained in:
@@ -486,6 +486,13 @@ int luax_getregistry(lua_State *L, Registry r)
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int luax_typerror(lua_State *L, int narg, const char *tname)
|
||||
{
|
||||
const char *msg = lua_pushfstring(L, "%s expected, got %s",
|
||||
tname, luaL_typename(L, narg));
|
||||
return luaL_argerror(L, narg, msg);
|
||||
}
|
||||
|
||||
StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
|
||||
{
|
||||
{"Invalid", INVALID_ID},
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
// Lua
|
||||
extern "C" {
|
||||
#define LUA_COMPAT_ALL
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
@@ -346,6 +347,10 @@ int luax_insistlove(lua_State *L, const char *k);
|
||||
**/
|
||||
int luax_getregistry(lua_State *L, Registry r);
|
||||
|
||||
extern "C" { // Also called from luasocket
|
||||
int luax_typerror(lua_State *L, int narg, const char *tname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like luax_totype, but causes an error if the value at idx is not Proxy,
|
||||
* or is not the specified type.
|
||||
|
||||
@@ -249,7 +249,7 @@ int w_newGeometry(lua_State *L)
|
||||
vertex v;
|
||||
lua_rawgeti(L, 1, i+1);
|
||||
if (!lua_istable(L, -1))
|
||||
return luaL_typerror(L, 1, "table of tables");
|
||||
return luax_typerror(L, 1, "table of tables");
|
||||
|
||||
for (int j = 1; j <= 8; j++)
|
||||
lua_rawgeti(L, -j, j);
|
||||
|
||||
@@ -58,7 +58,7 @@ static T *_getScalars(lua_State *L, int count, size_t &dimension)
|
||||
else
|
||||
{
|
||||
delete[] values;
|
||||
luaL_typerror(L, 3 + i, "number or boolean");
|
||||
luax_typerror(L, 3 + i, "number or boolean");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ static T *_getVectors(lua_State *L, int count, size_t &dimension)
|
||||
if (!lua_istable(L, 3 + i))
|
||||
{
|
||||
delete[] values;
|
||||
luaL_typerror(L, 3 + i, "table");
|
||||
luax_typerror(L, 3 + i, "table");
|
||||
return 0;
|
||||
}
|
||||
if (lua_objlen(L, 3 + i) != dimension)
|
||||
@@ -98,7 +98,7 @@ static T *_getVectors(lua_State *L, int count, size_t &dimension)
|
||||
else
|
||||
{
|
||||
delete[] values;
|
||||
luaL_typerror(L, -1, "number or boolean");
|
||||
luax_typerror(L, -1, "number or boolean");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ int w_Shader_sendInt(lua_State *L)
|
||||
else if (lua_istable(L, 3))
|
||||
values = _getVectors<int>(L, count, dimension);
|
||||
else
|
||||
return luaL_typerror(L, 3, "number, boolean, or table");
|
||||
return luax_typerror(L, 3, "number, boolean, or table");
|
||||
|
||||
if (!values)
|
||||
return luaL_error(L, "Error in arguments.");
|
||||
@@ -162,7 +162,7 @@ int w_Shader_sendFloat(lua_State *L)
|
||||
else if (lua_istable(L, 3))
|
||||
values = _getVectors<float>(L, count, dimension);
|
||||
else
|
||||
return luaL_typerror(L, 3, "number, boolean, or table");
|
||||
return luax_typerror(L, 3, "number, boolean, or table");
|
||||
|
||||
if (!values)
|
||||
return luaL_error(L, "Error in arguments.");
|
||||
@@ -189,7 +189,7 @@ int w_Shader_sendMatrix(lua_State *L)
|
||||
const char *name = luaL_checkstring(L, 2);
|
||||
|
||||
if (!lua_istable(L, 3))
|
||||
return luaL_typerror(L, 3, "matrix table");
|
||||
return luax_typerror(L, 3, "matrix table");
|
||||
|
||||
lua_getfield(L, 3, "dimension");
|
||||
int dimension = lua_tointeger(L, -1);
|
||||
|
||||
@@ -52,7 +52,7 @@ LuaThread::~LuaThread()
|
||||
void LuaThread::threadFunction()
|
||||
{
|
||||
this->retain();
|
||||
lua_State * L = lua_open();
|
||||
lua_State *L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
#ifdef LOVE_BUILD_STANDALONE
|
||||
love::luax_preload(L, luaopen_love, "love");
|
||||
|
||||
Reference in New Issue
Block a user