diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 09:48:16 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 09:48:16 -0300 |
commit | d766e2ae175495da85714d00e61d76174c5acc5b (patch) | |
tree | afc32a0787e57b2d6807b6e23bdd0a3cedf30945 /lbaselib.c | |
parent | f055a9dffd9ba403a99266a662b9992bc89dcaa1 (diff) | |
download | lua-d766e2ae175495da85714d00e61d76174c5acc5b.tar.gz lua-d766e2ae175495da85714d00e61d76174c5acc5b.tar.bz2 lua-d766e2ae175495da85714d00e61d76174c5acc5b.zip |
first (parcial) implementation of 'keyin'/'removekey'
(still no metamethods, no raw verssions)
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.318 2017/11/16 13:19:06 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.319 2018/02/05 17:10:52 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 | */ |
@@ -170,6 +170,24 @@ static int luaB_rawset (lua_State *L) { | |||
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | static int luaB_keyin (lua_State *L) { | ||
174 | luaL_checktype(L, 1, LUA_TTABLE); | ||
175 | luaL_checkany(L, 2); | ||
176 | lua_settop(L, 2); | ||
177 | lua_pushboolean(L, lua_keyin(L, 1)); | ||
178 | return 1; | ||
179 | } | ||
180 | |||
181 | |||
182 | static int luaB_removekey (lua_State *L) { | ||
183 | luaL_checktype(L, 1, LUA_TTABLE); | ||
184 | luaL_checkany(L, 2); | ||
185 | lua_settop(L, 2); | ||
186 | lua_removekey(L, 1); | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | |||
173 | static int pushmode (lua_State *L, int oldmode) { | 191 | static int pushmode (lua_State *L, int oldmode) { |
174 | lua_pushstring(L, (oldmode == LUA_GCINC) ? "incremental" : "generational"); | 192 | lua_pushstring(L, (oldmode == LUA_GCINC) ? "incremental" : "generational"); |
175 | return 1; | 193 | return 1; |
@@ -501,6 +519,8 @@ static const luaL_Reg base_funcs[] = { | |||
501 | {"rawlen", luaB_rawlen}, | 519 | {"rawlen", luaB_rawlen}, |
502 | {"rawget", luaB_rawget}, | 520 | {"rawget", luaB_rawget}, |
503 | {"rawset", luaB_rawset}, | 521 | {"rawset", luaB_rawset}, |
522 | {"keyin", luaB_keyin}, | ||
523 | {"removekey", luaB_removekey}, | ||
504 | {"select", luaB_select}, | 524 | {"select", luaB_select}, |
505 | {"setmetatable", luaB_setmetatable}, | 525 | {"setmetatable", luaB_setmetatable}, |
506 | {"tonumber", luaB_tonumber}, | 526 | {"tonumber", luaB_tonumber}, |