diff options
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 48 |
1 files changed, 38 insertions, 10 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.152 2011/09/26 20:17:27 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.153 2011/09/30 12:43:17 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 | */ |
| @@ -629,11 +629,24 @@ LUA_API void lua_rawget (lua_State *L, int idx) { | |||
| 629 | 629 | ||
| 630 | 630 | ||
| 631 | LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { | 631 | LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { |
| 632 | StkId o; | 632 | StkId t; |
| 633 | lua_lock(L); | 633 | lua_lock(L); |
| 634 | o = index2addr(L, idx); | 634 | t = index2addr(L, idx); |
| 635 | api_check(L, ttistable(o), "table expected"); | 635 | api_check(L, ttistable(t), "table expected"); |
| 636 | setobj2s(L, L->top, luaH_getint(hvalue(o), n)); | 636 | setobj2s(L, L->top, luaH_getint(hvalue(t), n)); |
| 637 | api_incr_top(L); | ||
| 638 | lua_unlock(L); | ||
| 639 | } | ||
| 640 | |||
| 641 | |||
| 642 | LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) { | ||
| 643 | StkId t; | ||
| 644 | TValue k; | ||
| 645 | lua_lock(L); | ||
| 646 | t = index2addr(L, idx); | ||
| 647 | api_check(L, ttistable(t), "table expected"); | ||
| 648 | setpvalue(&k, cast(void *, p)); | ||
| 649 | setobj2s(L, L->top, luaH_get(hvalue(t), &k)); | ||
| 637 | api_incr_top(L); | 650 | api_incr_top(L); |
| 638 | lua_unlock(L); | 651 | lua_unlock(L); |
| 639 | } | 652 | } |
| @@ -741,13 +754,28 @@ LUA_API void lua_rawset (lua_State *L, int idx) { | |||
| 741 | 754 | ||
| 742 | 755 | ||
| 743 | LUA_API void lua_rawseti (lua_State *L, int idx, int n) { | 756 | LUA_API void lua_rawseti (lua_State *L, int idx, int n) { |
| 744 | StkId o; | 757 | StkId t; |
| 745 | lua_lock(L); | 758 | lua_lock(L); |
| 746 | api_checknelems(L, 1); | 759 | api_checknelems(L, 1); |
| 747 | o = index2addr(L, idx); | 760 | t = index2addr(L, idx); |
| 748 | api_check(L, ttistable(o), "table expected"); | 761 | api_check(L, ttistable(t), "table expected"); |
| 749 | luaH_setint(L, hvalue(o), n, L->top - 1); | 762 | luaH_setint(L, hvalue(t), n, L->top - 1); |
| 750 | luaC_barrierback(L, gcvalue(o), L->top-1); | 763 | luaC_barrierback(L, gcvalue(t), L->top-1); |
| 764 | L->top--; | ||
| 765 | lua_unlock(L); | ||
| 766 | } | ||
| 767 | |||
| 768 | |||
| 769 | LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { | ||
| 770 | StkId t; | ||
| 771 | TValue k; | ||
| 772 | lua_lock(L); | ||
| 773 | api_checknelems(L, 1); | ||
| 774 | t = index2addr(L, idx); | ||
| 775 | api_check(L, ttistable(t), "table expected"); | ||
| 776 | setpvalue(&k, cast(void *, p)); | ||
| 777 | setobj2t(L, luaH_set(L, hvalue(t), &k), L->top - 1); | ||
| 778 | luaC_barrierback(L, gcvalue(t), L->top - 1); | ||
| 751 | L->top--; | 779 | L->top--; |
| 752 | lua_unlock(L); | 780 | lua_unlock(L); |
| 753 | } | 781 | } |
