diff options
author | Sam Gross <colesbury@gmail.com> | 2015-05-05 00:11:10 +0300 |
---|---|---|
committer | Sam Gross <colesbury@gmail.com> | 2015-06-26 21:50:45 +0300 |
commit | 92fd6a9de91656eb93e23a94f0e583f2c170adfe (patch) | |
tree | 3dc364a38843015d728108c312f37d973b038fd6 | |
parent | 59f01474ea3c511b5dd862765ce2220ebbc75567 (diff) |
Support Lua 5.2
-rw-r--r--[-rwxr-xr-x] | README.md | 0 | ||||
-rwxr-xr-x | generic/jpeg.c | 2 | ||||
-rwxr-xr-x | generic/png.c | 2 | ||||
-rw-r--r-- | generic/ppm.c | 2 | ||||
-rw-r--r-- | image.c | 18 | ||||
-rw-r--r--[-rwxr-xr-x] | init.lua | 0 | ||||
-rw-r--r-- | jpeg.c | 18 | ||||
-rw-r--r-- | png.c | 18 | ||||
-rw-r--r-- | ppm.c | 18 | ||||
-rwxr-xr-x | test/test_flip.lua | 1 | ||||
-rw-r--r-- | test/test_gaussian.lua | 1 |
11 files changed, 65 insertions, 15 deletions
diff --git a/README.md b/README.md index 9c71d7e..9c71d7e 100755..100644 --- a/README.md +++ b/README.md diff --git a/generic/jpeg.c b/generic/jpeg.c index 1a85bfc..e904171 100755 --- a/generic/jpeg.c +++ b/generic/jpeg.c @@ -496,7 +496,7 @@ int libjpeg_(Main_save)(lua_State *L) { return 1; } -static const luaL_reg libjpeg_(Main__)[] = +static const luaL_Reg libjpeg_(Main__)[] = { {"size", libjpeg_(Main_size)}, {"load", libjpeg_(Main_load)}, diff --git a/generic/png.c b/generic/png.c index 6702c12..b98028a 100755 --- a/generic/png.c +++ b/generic/png.c @@ -386,7 +386,7 @@ static int libpng_(Main_size)(lua_State *L) return 3; } -static const luaL_reg libpng_(Main__)[] = +static const luaL_Reg libpng_(Main__)[] = { {"load", libpng_(Main_load)}, {"size", libpng_(Main_size)}, diff --git a/generic/ppm.c b/generic/ppm.c index 92fc2d5..c3315d3 100644 --- a/generic/ppm.c +++ b/generic/ppm.c @@ -155,7 +155,7 @@ int libppm_(Main_save)(lua_State *L) { return 1; } -static const luaL_reg libppm_(Main__)[] = +static const luaL_Reg libppm_(Main__)[] = { {"load", libppm_(Main_load)}, {"save", libppm_(Main_save)}, @@ -45,9 +45,21 @@ DLL_EXPORT int luaopen_libimage(lua_State *L) image_DoubleMain_init(L); image_ByteMain_init(L); - luaL_register(L, "image.double", image_DoubleMain__); - luaL_register(L, "image.float", image_FloatMain__); - luaL_register(L, "image.byte", image_ByteMain__); + lua_newtable(L); + lua_pushvalue(L, -1); + lua_setglobal(L, "image"); + + lua_newtable(L); + luaT_setfuncs(L, image_DoubleMain__, 0); + lua_setfield(L, -2, "double"); + + lua_newtable(L); + luaT_setfuncs(L, image_FloatMain__, 0); + lua_setfield(L, -2, "float"); + + lua_newtable(L); + luaT_setfuncs(L, image_ByteMain__, 0); + lua_setfield(L, -2, "byte"); return 1; } @@ -17,9 +17,21 @@ DLL_EXPORT int luaopen_libjpeg(lua_State *L) libjpeg_DoubleMain_init(L); libjpeg_ByteMain_init(L); - luaL_register(L, "libjpeg.double", libjpeg_DoubleMain__); - luaL_register(L, "libjpeg.float", libjpeg_FloatMain__); - luaL_register(L, "libjpeg.byte", libjpeg_ByteMain__); + lua_newtable(L); + lua_pushvalue(L, -1); + lua_setglobal(L, "libjpeg"); + + lua_newtable(L); + luaT_setfuncs(L, libjpeg_DoubleMain__, 0); + lua_setfield(L, -2, "double"); + + lua_newtable(L); + luaT_setfuncs(L, libjpeg_FloatMain__, 0); + lua_setfield(L, -2, "float"); + + lua_newtable(L); + luaT_setfuncs(L, libjpeg_ByteMain__, 0); + lua_setfield(L, -2, "byte"); return 1; } @@ -22,9 +22,21 @@ DLL_EXPORT int luaopen_libpng(lua_State *L) libpng_DoubleMain_init(L); libpng_ByteMain_init(L); - luaL_register(L, "libpng.double", libpng_DoubleMain__); - luaL_register(L, "libpng.float", libpng_FloatMain__); - luaL_register(L, "libpng.byte", libpng_ByteMain__); + lua_newtable(L); + lua_pushvalue(L, -1); + lua_setglobal(L, "libpng"); + + lua_newtable(L); + luaT_setfuncs(L, libpng_DoubleMain__, 0); + lua_setfield(L, -2, "double"); + + lua_newtable(L); + luaT_setfuncs(L, libpng_FloatMain__, 0); + lua_setfield(L, -2, "float"); + + lua_newtable(L); + luaT_setfuncs(L, libpng_ByteMain__, 0); + lua_setfield(L, -2, "byte"); return 1; } @@ -50,9 +50,21 @@ DLL_EXPORT int luaopen_libppm(lua_State *L) libppm_DoubleMain_init(L); libppm_ByteMain_init(L); - luaL_register(L, "libppm.double", libppm_DoubleMain__); - luaL_register(L, "libppm.float", libppm_FloatMain__); - luaL_register(L, "libppm.byte", libppm_ByteMain__); + lua_newtable(L); + lua_pushvalue(L, -1); + lua_setglobal(L, "libppm"); + + lua_newtable(L); + luaT_setfuncs(L, libppm_DoubleMain__, 0); + lua_setfield(L, -2, "double"); + + lua_newtable(L); + luaT_setfuncs(L, libppm_FloatMain__, 0); + lua_setfield(L, -2, "float"); + + lua_newtable(L); + luaT_setfuncs(L, libppm_ByteMain__, 0); + lua_setfield(L, -2, "byte"); return 1; } diff --git a/test/test_flip.lua b/test/test_flip.lua index 4f9476d..c083c55 100755 --- a/test/test_flip.lua +++ b/test/test_flip.lua @@ -7,6 +7,7 @@ torch.setnumthreads(8) local precision = 1e-5 local mytester = torch.Tester() local test = {} +local unpack = unpack or table.unpack -- This is a correlated test (which is kinda lazy). We're assuming HFLIP is OK. function test.FlipAgainstHFlip() diff --git a/test/test_gaussian.lua b/test/test_gaussian.lua index 866bd27..493dc22 100644 --- a/test/test_gaussian.lua +++ b/test/test_gaussian.lua @@ -5,6 +5,7 @@ require 'image' -- - one using the c-based gaussian function -- This test is not particularly rigorous, but the function is very simple, so -- I'm not convinced it needs to be more complicated +local unpack = unpack or table.unpack sigma_horz = 0.1 + math.random() * 0.3; -- [0.1, 0.4] sigma_vert = 0.1 + math.random() * 0.3; -- [0.1, 0.4] |