From fb114d8dc6810133ba9e10d75fa9887ee169bf5d Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Sat, 11 Jul 2015 01:14:47 +0200 Subject: luaL_newmetatable sets __name on all Lua versions. --- c-api/compat-5.3.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'c-api') 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); #define luaL_getmetafield(L, o, e) \ (luaL_getmetafield(L, o, e) ? lua_type(L, -1) : LUA_TNIL) +#define luaL_newmetatable(L, tn) \ + (luaL_newmetatable(L, tn) ? (lua_pushstring(L, tn), lua_setfield(L, -2, "__name"), 1) : 0) + #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int glb ); -- cgit v1.2.3-55-g6feb