diff options
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 20 |
1 files changed, 13 insertions, 7 deletions
| @@ -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 | ||
| 631 | LUA_API void lua_getglobal (lua_State *L, const char *var) { | 631 | LUA_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 | ||
| 642 | LUA_API void lua_gettable (lua_State *L, int idx) { | 643 | LUA_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 | ||
| 651 | LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { | 653 | LUA_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 | ||
| 662 | LUA_API void lua_rawget (lua_State *L, int idx) { | 665 | LUA_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 | ||
| 672 | LUA_API void lua_rawgeti (lua_State *L, int idx, lua_Integer n) { | 676 | LUA_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 | ||
| 683 | LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) { | 688 | LUA_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 | ||
