diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-11-10 16:05:36 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-11-10 16:05:36 -0200 |
commit | c97aa9485caf253eceebc00cf08cfa8b179fe35e (patch) | |
tree | b54254b30e4354f4fdad5264cfd4e7baa9e40ab5 /lauxlib.c | |
parent | e885b91326986f1b5a341e9ff1444c4f46c6241a (diff) | |
download | lua-c97aa9485caf253eceebc00cf08cfa8b179fe35e.tar.gz lua-c97aa9485caf253eceebc00cf08cfa8b179fe35e.tar.bz2 lua-c97aa9485caf253eceebc00cf08cfa8b179fe35e.zip |
new function 'luaL_setmetatable'
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.225 2010/11/09 11:04:15 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.226 2010/11/10 17:38:10 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -224,6 +224,12 @@ LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { | |||
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { | ||
228 | luaL_getmetatable(L, tname); | ||
229 | lua_setmetatable(L, -2); | ||
230 | } | ||
231 | |||
232 | |||
227 | LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { | 233 | LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { |
228 | void *p = lua_touserdata(L, ud); | 234 | void *p = lua_touserdata(L, ud); |
229 | if (p != NULL) { /* value is a userdata? */ | 235 | if (p != NULL) { /* value is a userdata? */ |