better API for luaL_getfield/setfield
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.70 2004/07/09 18:23:17 roberto Exp roberto $
|
** $Id: lauxlib.h,v 1.71 2004/09/21 16:54:32 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -72,8 +72,8 @@ LUALIB_API lua_State *(luaL_newstate) (void);
|
|||||||
|
|
||||||
LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
|
LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
|
||||||
const char *r);
|
const char *r);
|
||||||
LUALIB_API const char *luaL_getfield (lua_State *L, const char *fname);
|
LUALIB_API const char *luaL_getfield (lua_State *L, int idx, const char *fname);
|
||||||
LUALIB_API const char *luaL_setfield (lua_State *L, const char *fname);
|
LUALIB_API const char *luaL_setfield (lua_State *L, int idx, const char *fname);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
ltests.c
10
ltests.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 2.11 2004/08/24 20:12:06 roberto Exp roberto $
|
** $Id: ltests.c,v 2.12 2004/09/21 16:54:32 roberto Exp roberto $
|
||||||
** Internal Module for Debugging of the Lua Implementation
|
** Internal Module for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -1049,8 +1049,8 @@ static int auxgsub (lua_State *L) {
|
|||||||
static int auxgetf (lua_State *L) {
|
static int auxgetf (lua_State *L) {
|
||||||
const char *s = luaL_checkstring(L, 1);
|
const char *s = luaL_checkstring(L, 1);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
lua_pushstring(L, luaL_getfield(L, s));
|
lua_pushstring(L, luaL_getfield(L, 2, s));
|
||||||
lua_assert(lua_gettop(L) == 3);
|
lua_assert(lua_gettop(L) == 4);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1058,8 +1058,8 @@ static int auxgetf (lua_State *L) {
|
|||||||
static int auxsetf (lua_State *L) {
|
static int auxsetf (lua_State *L) {
|
||||||
const char *s = luaL_checkstring(L, 1);
|
const char *s = luaL_checkstring(L, 1);
|
||||||
lua_settop(L, 3);
|
lua_settop(L, 3);
|
||||||
lua_pushstring(L, luaL_setfield(L, s));
|
lua_pushstring(L, luaL_setfield(L, 2, s));
|
||||||
lua_assert(lua_gettop(L) == 2);
|
lua_assert(lua_gettop(L) == 3);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user