diff options
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.244 2003/08/27 21:01:44 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.245 2003/10/07 20:13:41 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 | */ |
@@ -498,6 +498,19 @@ LUA_API void lua_gettable (lua_State *L, int idx) { | |||
498 | } | 498 | } |
499 | 499 | ||
500 | 500 | ||
501 | LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { | ||
502 | StkId t; | ||
503 | TObject key; | ||
504 | lua_lock(L); | ||
505 | t = luaA_index(L, idx); | ||
506 | api_checkvalidindex(L, t); | ||
507 | setsvalue(&key, luaS_new(L, k)); | ||
508 | luaV_gettable(L, t, &key, L->top); | ||
509 | api_incr_top(L); | ||
510 | lua_unlock(L); | ||
511 | } | ||
512 | |||
513 | |||
501 | LUA_API void lua_rawget (lua_State *L, int idx) { | 514 | LUA_API void lua_rawget (lua_State *L, int idx) { |
502 | StkId t; | 515 | StkId t; |
503 | lua_lock(L); | 516 | lua_lock(L); |
@@ -582,6 +595,20 @@ LUA_API void lua_settable (lua_State *L, int idx) { | |||
582 | } | 595 | } |
583 | 596 | ||
584 | 597 | ||
598 | LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { | ||
599 | StkId t; | ||
600 | TObject key; | ||
601 | lua_lock(L); | ||
602 | api_checknelems(L, 1); | ||
603 | t = luaA_index(L, idx); | ||
604 | api_checkvalidindex(L, t); | ||
605 | setsvalue(&key, luaS_new(L, k)); | ||
606 | luaV_settable(L, t, &key, L->top - 1); | ||
607 | L->top--; /* pop value */ | ||
608 | lua_unlock(L); | ||
609 | } | ||
610 | |||
611 | |||
585 | LUA_API void lua_rawset (lua_State *L, int idx) { | 612 | LUA_API void lua_rawset (lua_State *L, int idx) { |
586 | StkId t; | 613 | StkId t; |
587 | lua_lock(L); | 614 | lua_lock(L); |