new functions lua_rawsetp/lua_rawgetp
This commit is contained in:
48
lapi.c
48
lapi.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 2.152 2011/09/26 20:17:27 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.153 2011/09/30 12:43:17 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -629,11 +629,24 @@ LUA_API void lua_rawget (lua_State *L, int idx) {
|
||||
|
||||
|
||||
LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
|
||||
StkId o;
|
||||
StkId t;
|
||||
lua_lock(L);
|
||||
o = index2addr(L, idx);
|
||||
api_check(L, ttistable(o), "table expected");
|
||||
setobj2s(L, L->top, luaH_getint(hvalue(o), n));
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
setobj2s(L, L->top, luaH_getint(hvalue(t), n));
|
||||
api_incr_top(L);
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
|
||||
LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) {
|
||||
StkId t;
|
||||
TValue k;
|
||||
lua_lock(L);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
setpvalue(&k, cast(void *, p));
|
||||
setobj2s(L, L->top, luaH_get(hvalue(t), &k));
|
||||
api_incr_top(L);
|
||||
lua_unlock(L);
|
||||
}
|
||||
@@ -741,13 +754,28 @@ LUA_API void lua_rawset (lua_State *L, int idx) {
|
||||
|
||||
|
||||
LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
|
||||
StkId o;
|
||||
StkId t;
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 1);
|
||||
o = index2addr(L, idx);
|
||||
api_check(L, ttistable(o), "table expected");
|
||||
luaH_setint(L, hvalue(o), n, L->top - 1);
|
||||
luaC_barrierback(L, gcvalue(o), L->top-1);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
luaH_setint(L, hvalue(t), n, L->top - 1);
|
||||
luaC_barrierback(L, gcvalue(t), L->top-1);
|
||||
L->top--;
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
|
||||
LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) {
|
||||
StkId t;
|
||||
TValue k;
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 1);
|
||||
t = index2addr(L, idx);
|
||||
api_check(L, ttistable(t), "table expected");
|
||||
setpvalue(&k, cast(void *, p));
|
||||
setobj2t(L, luaH_set(L, hvalue(t), &k), L->top - 1);
|
||||
luaC_barrierback(L, gcvalue(t), L->top - 1);
|
||||
L->top--;
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user