commit 511679313f2c380ef86527e638663bf562083289
parent 868ff40339fc72b7bf3c916afcdc2a992398346c
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 7 Jan 2011 10:41:24 -0200
new function 'rawlen'
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lbaselib.c b/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.256 2010/12/17 15:14:58 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.257 2010/12/27 18:00:38 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -133,6 +133,15 @@ static int luaB_rawequal (lua_State *L) {
}
+static int luaB_rawlen (lua_State *L) {
+ int t = lua_type(L, 1);
+ luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1,
+ "table or string expected");
+ lua_pushinteger(L, lua_rawlen(L, 1));
+ return 1;
+}
+
+
static int luaB_rawget (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
luaL_checkany(L, 2);
@@ -447,6 +456,7 @@ static const luaL_Reg base_funcs[] = {
{"pcall", luaB_pcall},
{"print", luaB_print},
{"rawequal", luaB_rawequal},
+ {"rawlen", luaB_rawlen},
{"rawget", luaB_rawget},
{"rawset", luaB_rawset},
{"select", luaB_select},