Add basic lua 5.3 support

This commit is contained in:
Bart van Strien
2015-06-16 10:25:41 +02:00
parent df1bd42dec
commit 3cb777e2b7
39 changed files with 252 additions and 187 deletions
@@ -34,7 +34,7 @@ CompressedImageData *luax_checkcompressedimagedata(lua_State *L, int idx)
int w_CompressedImageData_getWidth(lua_State *L)
{
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
int miplevel = luaL_optint(L, 2, 1);
int miplevel = (int) luaL_optnumber(L, 2, 1);
int width = 0;
luax_catchexcept(L, [&](){ width = t->getWidth(miplevel - 1); });
@@ -46,7 +46,7 @@ int w_CompressedImageData_getWidth(lua_State *L)
int w_CompressedImageData_getHeight(lua_State *L)
{
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
int miplevel = luaL_optint(L, 2, 1);
int miplevel = (int) luaL_optnumber(L, 2, 1);
int height = 0;
luax_catchexcept(L, [&](){ height = t->getHeight(miplevel - 1); });
@@ -58,7 +58,7 @@ int w_CompressedImageData_getHeight(lua_State *L)
int w_CompressedImageData_getDimensions(lua_State *L)
{
CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
int miplevel = luaL_optint(L, 2, 1);
int miplevel = (int) luaL_optnumber(L, 2, 1);
int width = 0, height = 0;
luax_catchexcept(L, [&]()
+2 -2
View File
@@ -39,8 +39,8 @@ int w_newImageData(lua_State *L)
// Case 1: Integers.
if (lua_isnumber(L, 1))
{
int w = luaL_checkint(L, 1);
int h = luaL_checkint(L, 2);
int w = (int) luaL_checknumber(L, 1);
int h = (int) luaL_checknumber(L, 2);
if (w <= 0 || h <= 0)
return luaL_error(L, "Invalid image size.");
+10 -10
View File
@@ -68,8 +68,8 @@ int w_ImageData_getDimensions(lua_State *L)
int w_ImageData_getPixel(lua_State *L)
{
ImageData *t = luax_checkimagedata(L, 1);
int x = luaL_checkint(L, 2);
int y = luaL_checkint(L, 3);
int x = (int) luaL_checknumber(L, 2);
int y = (int) luaL_checknumber(L, 3);
pixel c;
luax_catchexcept(L, [&](){ c = t->getPixel(x, y); });
@@ -84,8 +84,8 @@ int w_ImageData_getPixel(lua_State *L)
int w_ImageData_setPixel(lua_State *L)
{
ImageData *t = luax_checkimagedata(L, 1);
int x = luaL_checkint(L, 2);
int y = luaL_checkint(L, 3);
int x = (int) luaL_checknumber(L, 2);
int y = (int) luaL_checknumber(L, 3);
pixel c;
if (lua_istable(L, 4))
@@ -205,12 +205,12 @@ int w_ImageData_paste(lua_State *L)
{
ImageData *t = luax_checkimagedata(L, 1);
ImageData *src = luax_checkimagedata(L, 2);
int dx = luaL_checkint(L, 3);
int dy = luaL_checkint(L, 4);
int sx = luaL_optint(L, 5, 0);
int sy = luaL_optint(L, 6, 0);
int sw = luaL_optint(L, 7, src->getWidth());
int sh = luaL_optint(L, 8, src->getHeight());
int dx = (int) luaL_checknumber(L, 3);
int dy = (int) luaL_checknumber(L, 4);
int sx = (int) luaL_optnumber(L, 5, 0);
int sy = (int) luaL_optnumber(L, 6, 0);
int sw = (int) luaL_optnumber(L, 7, src->getWidth());
int sh = (int) luaL_optnumber(L, 8, src->getHeight());
t->paste((love::image::ImageData *)src, dx, dy, sx, sy, sw, sh);
return 0;
}