diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-27 09:49:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-27 09:49:53 -0300 |
commit | 405e3a4597d6f935a7ac224ce67dce660e69c7be (patch) | |
tree | 8c1914067e66e00a339bd1a25ec785e33186ede3 /lapi.c | |
parent | 81215cd59f58923ae9807d34f1dd46a51f400e4b (diff) | |
download | lua-405e3a4597d6f935a7ac224ce67dce660e69c7be.tar.gz lua-405e3a4597d6f935a7ac224ce67dce660e69c7be.tar.bz2 lua-405e3a4597d6f935a7ac224ce67dce660e69c7be.zip |
metatable always return some value
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.179 2002/03/20 12:51:29 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.180 2002/03/26 20:46:10 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -400,9 +400,10 @@ LUA_API void lua_newtable (lua_State *L) { | |||
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | LUA_API void lua_getmetatable (lua_State *L, int objindex) { | 403 | LUA_API int lua_getmetatable (lua_State *L, int objindex) { |
404 | StkId obj; | 404 | StkId obj; |
405 | Table *mt; | 405 | Table *mt; |
406 | int res; | ||
406 | lua_lock(L); | 407 | lua_lock(L); |
407 | obj = luaA_indexAcceptable(L, objindex); | 408 | obj = luaA_indexAcceptable(L, objindex); |
408 | switch (ttype(obj)) { | 409 | switch (ttype(obj)) { |
@@ -415,12 +416,17 @@ LUA_API void lua_getmetatable (lua_State *L, int objindex) { | |||
415 | default: | 416 | default: |
416 | mt = hvalue(defaultmeta(L)); | 417 | mt = hvalue(defaultmeta(L)); |
417 | } | 418 | } |
418 | if (mt == hvalue(defaultmeta(L))) | 419 | if (mt == hvalue(defaultmeta(L))) { |
419 | setnilvalue(L->top); | 420 | setnilvalue(L->top); |
420 | else | 421 | res = 0; |
422 | } | ||
423 | else { | ||
421 | sethvalue(L->top, mt); | 424 | sethvalue(L->top, mt); |
425 | res = 1; | ||
426 | } | ||
422 | api_incr_top(L); | 427 | api_incr_top(L); |
423 | lua_unlock(L); | 428 | lua_unlock(L); |
429 | return res; | ||
424 | } | 430 | } |
425 | 431 | ||
426 | 432 | ||