diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-26 16:28:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-26 16:28:44 -0300 |
commit | f67ccfbdeb9595b0549a733d229a02a7c3205ddc (patch) | |
tree | b59a5afc174ac338e23ad58dc564640324ba6b19 /lapi.c | |
parent | cfcf2008069fc2d5574e10303dbe4f1ea3188636 (diff) | |
download | lua-f67ccfbdeb9595b0549a733d229a02a7c3205ddc.tar.gz lua-f67ccfbdeb9595b0549a733d229a02a7c3205ddc.tar.bz2 lua-f67ccfbdeb9595b0549a733d229a02a7c3205ddc.zip |
no more `lua_getn' function
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 39 |
1 files changed, 1 insertions, 38 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.202 2002/06/24 13:08:45 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.203 2002/06/25 19:15: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 | */ |
@@ -697,43 +697,6 @@ LUA_API int lua_next (lua_State *L, int index) { | |||
697 | } | 697 | } |
698 | 698 | ||
699 | 699 | ||
700 | LUA_API int lua_getn (lua_State *L, int index) { | ||
701 | StkId t; | ||
702 | const TObject *value; | ||
703 | int n; | ||
704 | lua_lock(L); | ||
705 | t = luaA_index(L, index); | ||
706 | api_check(L, ttype(t) == LUA_TTABLE); | ||
707 | value = luaH_getstr(hvalue(t), luaS_newliteral(L, "n")); /* = t.n */ | ||
708 | if (ttype(value) == LUA_TNUMBER) | ||
709 | lua_number2int(n, nvalue(value)); | ||
710 | else { | ||
711 | Node *nd; | ||
712 | Table *a = hvalue(t); | ||
713 | lua_Number max = 0; | ||
714 | int i; | ||
715 | i = sizearray(a); | ||
716 | while (i--) { | ||
717 | if (ttype(&a->array[i]) != LUA_TNIL) | ||
718 | break; | ||
719 | } | ||
720 | max = i+1; | ||
721 | i = sizenode(a); | ||
722 | nd = a->node; | ||
723 | while (i--) { | ||
724 | if (ttype(key(nd)) == LUA_TNUMBER && | ||
725 | ttype(val(nd)) != LUA_TNIL && | ||
726 | nvalue(key(nd)) > max) | ||
727 | max = nvalue(key(nd)); | ||
728 | nd++; | ||
729 | } | ||
730 | lua_number2int(n, max); | ||
731 | } | ||
732 | lua_unlock(L); | ||
733 | return n; | ||
734 | } | ||
735 | |||
736 | |||
737 | LUA_API void lua_concat (lua_State *L, int n) { | 700 | LUA_API void lua_concat (lua_State *L, int n) { |
738 | lua_lock(L); | 701 | lua_lock(L); |
739 | api_checknelems(L, n); | 702 | api_checknelems(L, n); |