aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-01-07 10:41:48 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-01-07 10:41:48 -0200
commit511679313f2c380ef86527e638663bf562083289 (patch)
tree85014f989cd7524997cc879b75b70797842d2131
parent868ff40339fc72b7bf3c916afcdc2a992398346c (diff)
downloadlua-511679313f2c380ef86527e638663bf562083289.tar.gz
lua-511679313f2c380ef86527e638663bf562083289.tar.bz2
lua-511679313f2c380ef86527e638663bf562083289.zip
new function 'rawlen'
-rw-r--r--lbaselib.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 64dfb549..bc169563 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.256 2010/12/17 15:14:58 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.257 2010/12/27 18:00:38 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*/
@@ -133,6 +133,15 @@ static int luaB_rawequal (lua_State *L) {
133} 133}
134 134
135 135
136static int luaB_rawlen (lua_State *L) {
137 int t = lua_type(L, 1);
138 luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1,
139 "table or string expected");
140 lua_pushinteger(L, lua_rawlen(L, 1));
141 return 1;
142}
143
144
136static int luaB_rawget (lua_State *L) { 145static int luaB_rawget (lua_State *L) {
137 luaL_checktype(L, 1, LUA_TTABLE); 146 luaL_checktype(L, 1, LUA_TTABLE);
138 luaL_checkany(L, 2); 147 luaL_checkany(L, 2);
@@ -447,6 +456,7 @@ static const luaL_Reg base_funcs[] = {
447 {"pcall", luaB_pcall}, 456 {"pcall", luaB_pcall},
448 {"print", luaB_print}, 457 {"print", luaB_print},
449 {"rawequal", luaB_rawequal}, 458 {"rawequal", luaB_rawequal},
459 {"rawlen", luaB_rawlen},
450 {"rawget", luaB_rawget}, 460 {"rawget", luaB_rawget},
451 {"rawset", luaB_rawset}, 461 {"rawset", luaB_rawset},
452 {"select", luaB_select}, 462 {"select", luaB_select},