From c97aa9485caf253eceebc00cf08cfa8b179fe35e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 10 Nov 2010 16:05:36 -0200 Subject: new function 'luaL_setmetatable' --- lauxlib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 9dbf5519..b0fabe3f 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.225 2010/11/09 11:04:15 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.226 2010/11/10 17:38:10 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -224,6 +224,12 @@ LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { } +LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); + lua_setmetatable(L, -2); +} + + LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { void *p = lua_touserdata(L, ud); if (p != NULL) { /* value is a userdata? */ -- cgit v1.2.3-55-g6feb