aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-03-27 09:49:53 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-03-27 09:49:53 -0300
commit405e3a4597d6f935a7ac224ce67dce660e69c7be (patch)
tree8c1914067e66e00a339bd1a25ec785e33186ede3 /lapi.c
parent81215cd59f58923ae9807d34f1dd46a51f400e4b (diff)
downloadlua-405e3a4597d6f935a7ac224ce67dce660e69c7be.tar.gz
lua-405e3a4597d6f935a7ac224ce67dce660e69c7be.tar.bz2
lua-405e3a4597d6f935a7ac224ce67dce660e69c7be.zip
metatable always return some value
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lapi.c b/lapi.c
index 1f8d296f..abc85e91 100644
--- a/lapi.c
+++ b/lapi.c
@@ -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
403LUA_API void lua_getmetatable (lua_State *L, int objindex) { 403LUA_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