Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/image.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2015-05-05 00:11:10 +0300
committerSam Gross <colesbury@gmail.com>2015-06-26 21:50:45 +0300
commit92fd6a9de91656eb93e23a94f0e583f2c170adfe (patch)
tree3dc364a38843015d728108c312f37d973b038fd6
parent59f01474ea3c511b5dd862765ce2220ebbc75567 (diff)
Support Lua 5.2
-rw-r--r--[-rwxr-xr-x]README.md0
-rwxr-xr-xgeneric/jpeg.c2
-rwxr-xr-xgeneric/png.c2
-rw-r--r--generic/ppm.c2
-rw-r--r--image.c18
-rw-r--r--[-rwxr-xr-x]init.lua0
-rw-r--r--jpeg.c18
-rw-r--r--png.c18
-rw-r--r--ppm.c18
-rwxr-xr-xtest/test_flip.lua1
-rw-r--r--test/test_gaussian.lua1
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)},
diff --git a/image.c b/image.c
index 5bf2ab4..0bdd623 100644
--- a/image.c
+++ b/image.c
@@ -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;
}
diff --git a/init.lua b/init.lua
index 0819ec0..0819ec0 100755..100644
--- a/init.lua
+++ b/init.lua
diff --git a/jpeg.c b/jpeg.c
index f64f197..8c87e01 100644
--- a/jpeg.c
+++ b/jpeg.c
@@ -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;
}
diff --git a/png.c b/png.c
index 665bb8b..0acca5a 100644
--- a/png.c
+++ b/png.c
@@ -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;
}
diff --git a/ppm.c b/ppm.c
index 8e8c2e3..0303ffb 100644
--- a/ppm.c
+++ b/ppm.c
@@ -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]