diff options
author | Philipp Janda <siffiejoe@gmx.net> | 2015-07-11 01:14:47 +0200 |
---|---|---|
committer | Philipp Janda <siffiejoe@gmx.net> | 2015-07-11 01:14:47 +0200 |
commit | fb114d8dc6810133ba9e10d75fa9887ee169bf5d (patch) | |
tree | 6f346ff4b573e102b166c42f4a43b3bcf85565b5 | |
parent | 823345b8b4de9e2a646dbcd471e05a1c7598d378 (diff) | |
download | lua-compat-5.3-fb114d8dc6810133ba9e10d75fa9887ee169bf5d.tar.gz lua-compat-5.3-fb114d8dc6810133ba9e10d75fa9887ee169bf5d.tar.bz2 lua-compat-5.3-fb114d8dc6810133ba9e10d75fa9887ee169bf5d.zip |
luaL_newmetatable sets __name on all Lua versions.
-rw-r--r-- | c-api/compat-5.3.h | 3 | ||||
-rw-r--r-- | tests/testmod.c | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h index cd6764c..e3bbb11 100644 --- a/c-api/compat-5.3.h +++ b/c-api/compat-5.3.h | |||
@@ -259,6 +259,9 @@ COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s); | |||
259 | #define luaL_getmetafield(L, o, e) \ | 259 | #define luaL_getmetafield(L, o, e) \ |
260 | (luaL_getmetafield(L, o, e) ? lua_type(L, -1) : LUA_TNIL) | 260 | (luaL_getmetafield(L, o, e) ? lua_type(L, -1) : LUA_TNIL) |
261 | 261 | ||
262 | #define luaL_newmetatable(L, tn) \ | ||
263 | (luaL_newmetatable(L, tn) ? (lua_pushstring(L, tn), lua_setfield(L, -2, "__name"), 1) : 0) | ||
264 | |||
262 | #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) | 265 | #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) |
263 | COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, | 266 | COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, |
264 | lua_CFunction openf, int glb ); | 267 | lua_CFunction openf, int glb ); |
diff --git a/tests/testmod.c b/tests/testmod.c index c2dc715..2293064 100644 --- a/tests/testmod.c +++ b/tests/testmod.c | |||
@@ -205,7 +205,10 @@ static int test_udata (lua_State *L) { | |||
205 | (void)u2; | 205 | (void)u2; |
206 | lua_pushlightuserdata(L, luaL_testudata(L, u1pos, tname)); | 206 | lua_pushlightuserdata(L, luaL_testudata(L, u1pos, tname)); |
207 | lua_pushlightuserdata(L, luaL_testudata(L, u2pos, tname)); | 207 | lua_pushlightuserdata(L, luaL_testudata(L, u2pos, tname)); |
208 | return 2; | 208 | luaL_getmetatable(L, "utype1"); |
209 | lua_getfield(L, -1, "__name"); | ||
210 | lua_replace(L, -2); | ||
211 | return 3; | ||
209 | } | 212 | } |
210 | 213 | ||
211 | static int test_subtable (lua_State *L) { | 214 | static int test_subtable (lua_State *L) { |