From 2594084de6e163f15a1516d64cf413de5b0d899f Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Tue, 8 Jan 2013 18:03:02 +0100 Subject: Added support for Lua 5.2 Should still work against Lua 5.1 as well. --- src/scripting/luautil.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/scripting/luautil.h') diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h index 1ff2ab8d..0d2a981d 100644 --- a/src/scripting/luautil.h +++ b/src/scripting/luautil.h @@ -103,7 +103,12 @@ public: luaL_newmetatable(s, mTypeName); // metatable lua_pushstring(s, "__index"); // metatable, "__index" - luaL_register(s, typeName, members); // metatable, "__index", {} + lua_createtable(s, 0, 0); // metatable, "__index", {} +#if LUA_VERSION_NUM < 502 + luaL_register(s, NULL, members); +#else + luaL_setfuncs(s, members, 0); +#endif lua_rawset(s, -3); // metatable lua_pop(s, 1); // -empty- } @@ -125,8 +130,12 @@ public: void *userData = lua_newuserdata(s, sizeof(T*)); * static_cast(userData) = object; +#if LUA_VERSION_NUM < 502 luaL_newmetatable(s, mTypeName); lua_setmetatable(s, -2); +#else + luaL_setmetatable(s, mTypeName); +#endif UserDataCache::insert(s, object); } -- cgit v1.2.3-60-g2f50