[liblua=$enableval], [liblua=auto])
if test "x${liblua}" != "xno"; then
- PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1,
+ PKG_CHECK_MODULES(LUA, lua5.3 >= 5.3,
[
HAVE_LUA=yes
AC_DEFINE(HAVE_LUA, 1, [define to enable lua support])
],
[
- PKG_CHECK_MODULES(LUA, lua >= 5.1,
- [
- HAVE_LUA=yes
- AC_DEFINE(HAVE_LUA, 1, [define to enable lua support])
- ],
- [
- HAVE_LUA=no
- AC_MSG_WARN([$LUA_PKG_ERRORS])
- ])
- ])
+ PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1,
+ [
+ HAVE_LUA=yes
+ AC_DEFINE(HAVE_LUA, 1, [define to enable lua support])
+ ],
+ [
+ PKG_CHECK_MODULES(LUA, lua >= 5.1,
+ [
+ HAVE_LUA=yes
+ AC_DEFINE(HAVE_LUA, 1, [define to enable lua support])
+ ],
+ [
+ HAVE_LUA=no
+ AC_MSG_WARN([$LUA_PKG_ERRORS])
+ ])
+ ])
+ ])
else
HAVE_LUA=disabled
fi
static lua_State *L; /** The LUA object needed for all operations (NOTE: That is
* a upper-case variable to match the documentation!) */
+/* Taking that definition from lua 5.1 source */
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502
+int luaL_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);
+}
+
+# define LUA_register_meta(L, meta) luaL_setfuncs(L, meta, 0);
+# define LUA_register_global(L, string, func) \
+ lua_newtable(L); \
+ luaL_setfuncs(L, func, 0); \
+ lua_pushvalue(L, -1); \
+ lua_setglobal(L, string)
+#else
+# define LUA_register_meta(L, meta) luaL_register(L, NULL, meta)
+# define LUA_register_global(L, string, func) luaL_register(L, string, func)
+#endif
+
static FileData *lua_check_image(lua_State *L, int index)
{
FileData **fd;
{"get_marks", lua_image_get_marks},
{NULL, NULL}
};
- luaL_register(L, "Image", image_methods);
+ LUA_register_global(L, "Image", image_methods);
luaL_newmetatable(L, "Image");
- luaL_register(L, NULL, meta_methods);
+ LUA_register_meta(L, meta_methods);
lua_pushliteral(L, "__index");
lua_pushvalue(L, -3);
lua_settable(L, -3);
{"get_datum", lua_exif_get_datum},
{NULL, NULL}
};
- luaL_register(L, "Exif", exif_methods);
+ LUA_register_global(L, "Exif", exif_methods);
luaL_newmetatable(L, "Exif");
- luaL_register(L, NULL, meta_methods);
+ LUA_register_meta(L, meta_methods);
lua_pushliteral(L, "__index");
lua_pushvalue(L, -3);
lua_settable(L, -3);