diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-03-16 13:58:41 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-03-16 13:58:41 -0300 |
| commit | 9ffae705ee8894d68bbc07a1a5f77a112c40efad (patch) | |
| tree | e162bb7ecfd1a3e6776cf09e62736ec8eb0fca41 /lbaselib.c | |
| parent | 6bfef60e77f5eec1057470010b4179ee6f830fe6 (diff) | |
| download | lua-9ffae705ee8894d68bbc07a1a5f77a112c40efad.tar.gz lua-9ffae705ee8894d68bbc07a1a5f77a112c40efad.tar.bz2 lua-9ffae705ee8894d68bbc07a1a5f77a112c40efad.zip | |
new "primitive" getn
Diffstat (limited to 'lbaselib.c')
| -rw-r--r-- | lbaselib.c | 10 |
1 files changed, 9 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.169 2005/02/28 17:24:41 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.170 2005/03/11 15:51:08 roberto Exp roberto $ |
| 3 | ** Basic library | 3 | ** Basic library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -332,6 +332,13 @@ static int luaB_assert (lua_State *L) { | |||
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | 334 | ||
| 335 | static int luaB_getn (lua_State *L) { | ||
| 336 | luaL_checktype(L, 1, LUA_TTABLE); | ||
| 337 | lua_pushinteger(L, lua_objsize(L, 1)); | ||
| 338 | return 1; | ||
| 339 | } | ||
| 340 | |||
| 341 | |||
| 335 | static int luaB_unpack (lua_State *L) { | 342 | static int luaB_unpack (lua_State *L) { |
| 336 | int i = luaL_optint(L, 2, LUA_FIRSTINDEX); | 343 | int i = luaL_optint(L, 2, LUA_FIRSTINDEX); |
| 337 | int e = luaL_optint(L, 3, -1); | 344 | int e = luaL_optint(L, 3, -1); |
| @@ -448,6 +455,7 @@ static const luaL_reg base_funcs[] = { | |||
| 448 | {"tostring", luaB_tostring}, | 455 | {"tostring", luaB_tostring}, |
| 449 | {"type", luaB_type}, | 456 | {"type", luaB_type}, |
| 450 | {"assert", luaB_assert}, | 457 | {"assert", luaB_assert}, |
| 458 | {"getn", luaB_getn}, | ||
| 451 | {"unpack", luaB_unpack}, | 459 | {"unpack", luaB_unpack}, |
| 452 | {"select", luaB_select}, | 460 | {"select", luaB_select}, |
| 453 | {"rawequal", luaB_rawequal}, | 461 | {"rawequal", luaB_rawequal}, |
