new functions `lua_tointeger' and lua_pushinteger'

This commit is contained in:
Roberto Ierusalimschy
2003-10-07 17:13:41 -03:00
parent 21947deddc
commit f04fe526cd
11 changed files with 160 additions and 120 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: ltablib.c,v 1.20 2003/03/11 12:24:34 roberto Exp roberto $
** $Id: ltablib.c,v 1.21 2003/04/03 13:35:34 roberto Exp roberto $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -24,7 +24,7 @@ static int luaB_foreachi (lua_State *L) {
luaL_checktype(L, 2, LUA_TFUNCTION);
for (i=1; i<=n; i++) {
lua_pushvalue(L, 2); /* function */
lua_pushnumber(L, (lua_Number)i); /* 1st argument */
lua_pushinteger(L, i); /* 1st argument */
lua_rawgeti(L, 1, i); /* 2nd argument */
lua_call(L, 2, 1);
if (!lua_isnil(L, -1))
@@ -54,7 +54,7 @@ static int luaB_foreach (lua_State *L) {
static int luaB_getn (lua_State *L) {
lua_pushnumber(L, (lua_Number)aux_getn(L, 1));
lua_pushinteger(L, aux_getn(L, 1));
return 1;
}