new API functions lua_getstr/lua_setstr

This commit is contained in:
Roberto Ierusalimschy
2001-12-10 20:09:51 -02:00
parent 592a309177
commit 9cd36059ad
7 changed files with 30 additions and 45 deletions

8
lapi.c
View File

@@ -329,11 +329,11 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
*/
LUA_API void lua_getglobal (lua_State *L, const char *name) {
LUA_API void lua_getstr (lua_State *L, int index, const char *name) {
TObject o;
lua_lock(L);
setsvalue(&o, luaS_new(L, name));
luaV_gettable(L, gt(L), &o, L->top);
luaV_gettable(L, luaA_index(L, index), &o, L->top);
api_incr_top(L);
lua_unlock(L);
}
@@ -406,12 +406,12 @@ LUA_API void lua_geteventtable (lua_State *L, int objindex) {
*/
LUA_API void lua_setglobal (lua_State *L, const char *name) {
LUA_API void lua_setstr (lua_State *L, int index, const char *name) {
TObject o;
lua_lock(L);
api_checknelems(L, 1);
setsvalue(&o, luaS_new(L, name));
luaV_settable(L, gt(L), &o, L->top - 1);
luaV_settable(L, luaA_index(L, index), &o, L->top - 1);
L->top--; /* remove element from the top */
lua_unlock(L);
}