diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-09-16 16:49:45 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-09-16 16:49:45 -0300 |
| commit | 32a5d96dfc846ccfe63e6272d385fe963e025b61 (patch) | |
| tree | a8db9f8300dca5f951f475d7cad8619460141d07 /lauxlib.c | |
| parent | 8dae071f42bf036ea3f61468aca825397c8e33e4 (diff) | |
| download | lua-32a5d96dfc846ccfe63e6272d385fe963e025b61.tar.gz lua-32a5d96dfc846ccfe63e6272d385fe963e025b61.tar.bz2 lua-32a5d96dfc846ccfe63e6272d385fe963e025b61.zip | |
`setmetatable' cannot change protected objects
Diffstat (limited to 'lauxlib.c')
| -rw-r--r-- | lauxlib.c | 11 |
1 files changed, 9 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.84 2002/08/30 20:00:59 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.85 2002/09/05 19:45:42 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 | */ |
| @@ -147,7 +147,7 @@ LUALIB_API lua_Number luaL_opt_number (lua_State *L, int narg, lua_Number def) { | |||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | 149 | ||
| 150 | LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { | 150 | LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { |
| 151 | if (!lua_getmetatable(L, obj)) /* no metatable? */ | 151 | if (!lua_getmetatable(L, obj)) /* no metatable? */ |
| 152 | return 0; | 152 | return 0; |
| 153 | lua_pushstring(L, event); | 153 | lua_pushstring(L, event); |
| @@ -156,6 +156,13 @@ LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { | |||
| 156 | lua_pop(L, 2); /* remove metatable and metafield */ | 156 | lua_pop(L, 2); /* remove metatable and metafield */ |
| 157 | return 0; | 157 | return 0; |
| 158 | } | 158 | } |
| 159 | return 1; | ||
| 160 | } | ||
| 161 | |||
| 162 | |||
| 163 | LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { | ||
| 164 | if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ | ||
| 165 | return 0; | ||
| 159 | lua_pushvalue(L, obj); | 166 | lua_pushvalue(L, obj); |
| 160 | lua_call(L, 1, 1); | 167 | lua_call(L, 1, 1); |
| 161 | return 1; | 168 | return 1; |
