From Lua 5.2: Add luaL_setmetatable().

Contributed by François Perrad.
This commit is contained in:
Mike Pall
2017-04-07 12:38:05 +02:00
parent cde968f91f
commit 2b8de8cfc6
3 changed files with 8 additions and 2 deletions

View File

@@ -1000,6 +1000,12 @@ LUA_API int lua_setmetatable(lua_State *L, int idx)
return 1;
}
LUALIB_API void luaL_setmetatable(lua_State *L, const char *tname)
{
lua_getfield(L, LUA_REGISTRYINDEX, tname);
lua_setmetatable(L, -2);
}
LUA_API int lua_setfenv(lua_State *L, int idx)
{
cTValue *o = index2adr(L, idx);