aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-12 17:57:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-12 17:57:40 -0300
commita3addae03634794b841b6c8c4dd8ff83542d8896 (patch)
tree66695864f7bd56c295ad7cd6a6465845103cd424 /lapi.c
parentad40bb1181d08821af6789147a28aa8370533d11 (diff)
downloadlua-a3addae03634794b841b6c8c4dd8ff83542d8896.tar.gz
lua-a3addae03634794b841b6c8c4dd8ff83542d8896.tar.bz2
lua-a3addae03634794b841b6c8c4dd8ff83542d8896.zip
lua_gettable and similars return type of gotten value
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/lapi.c b/lapi.c
index cc521b31..ae0da8c4 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.199 2014/02/25 14:30:21 roberto Exp roberto $ 2** $Id: lapi.c,v 2.200 2014/02/26 12:39:30 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*/
@@ -628,7 +628,7 @@ LUA_API int lua_pushthread (lua_State *L) {
628*/ 628*/
629 629
630 630
631LUA_API void lua_getglobal (lua_State *L, const char *var) { 631LUA_API int lua_getglobal (lua_State *L, const char *var) {
632 Table *reg = hvalue(&G(L)->l_registry); 632 Table *reg = hvalue(&G(L)->l_registry);
633 const TValue *gt; /* global table */ 633 const TValue *gt; /* global table */
634 lua_lock(L); 634 lua_lock(L);
@@ -636,19 +636,21 @@ LUA_API void lua_getglobal (lua_State *L, const char *var) {
636 setsvalue2s(L, L->top++, luaS_new(L, var)); 636 setsvalue2s(L, L->top++, luaS_new(L, var));
637 luaV_gettable(L, gt, L->top - 1, L->top - 1); 637 luaV_gettable(L, gt, L->top - 1, L->top - 1);
638 lua_unlock(L); 638 lua_unlock(L);
639 return ttnov(L->top - 1);
639} 640}
640 641
641 642
642LUA_API void lua_gettable (lua_State *L, int idx) { 643LUA_API int lua_gettable (lua_State *L, int idx) {
643 StkId t; 644 StkId t;
644 lua_lock(L); 645 lua_lock(L);
645 t = index2addr(L, idx); 646 t = index2addr(L, idx);
646 luaV_gettable(L, t, L->top - 1, L->top - 1); 647 luaV_gettable(L, t, L->top - 1, L->top - 1);
647 lua_unlock(L); 648 lua_unlock(L);
649 return ttnov(L->top - 1);
648} 650}
649 651
650 652
651LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { 653LUA_API int lua_getfield (lua_State *L, int idx, const char *k) {
652 StkId t; 654 StkId t;
653 lua_lock(L); 655 lua_lock(L);
654 t = index2addr(L, idx); 656 t = index2addr(L, idx);
@@ -656,20 +658,22 @@ LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
656 api_incr_top(L); 658 api_incr_top(L);
657 luaV_gettable(L, t, L->top - 1, L->top - 1); 659 luaV_gettable(L, t, L->top - 1, L->top - 1);
658 lua_unlock(L); 660 lua_unlock(L);
661 return ttnov(L->top - 1);
659} 662}
660 663
661 664
662LUA_API void lua_rawget (lua_State *L, int idx) { 665LUA_API int lua_rawget (lua_State *L, int idx) {
663 StkId t; 666 StkId t;
664 lua_lock(L); 667 lua_lock(L);
665 t = index2addr(L, idx); 668 t = index2addr(L, idx);
666 api_check(L, ttistable(t), "table expected"); 669 api_check(L, ttistable(t), "table expected");
667 setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); 670 setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
668 lua_unlock(L); 671 lua_unlock(L);
672 return ttnov(L->top - 1);
669} 673}
670 674
671 675
672LUA_API void lua_rawgeti (lua_State *L, int idx, lua_Integer n) { 676LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) {
673 StkId t; 677 StkId t;
674 lua_lock(L); 678 lua_lock(L);
675 t = index2addr(L, idx); 679 t = index2addr(L, idx);
@@ -677,10 +681,11 @@ LUA_API void lua_rawgeti (lua_State *L, int idx, lua_Integer n) {
677 setobj2s(L, L->top, luaH_getint(hvalue(t), n)); 681 setobj2s(L, L->top, luaH_getint(hvalue(t), n));
678 api_incr_top(L); 682 api_incr_top(L);
679 lua_unlock(L); 683 lua_unlock(L);
684 return ttnov(L->top - 1);
680} 685}
681 686
682 687
683LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) { 688LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) {
684 StkId t; 689 StkId t;
685 TValue k; 690 TValue k;
686 lua_lock(L); 691 lua_lock(L);
@@ -690,6 +695,7 @@ LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) {
690 setobj2s(L, L->top, luaH_get(hvalue(t), &k)); 695 setobj2s(L, L->top, luaH_get(hvalue(t), &k));
691 api_incr_top(L); 696 api_incr_top(L);
692 lua_unlock(L); 697 lua_unlock(L);
698 return ttnov(L->top - 1);
693} 699}
694 700
695 701