eris: table nodes now have room to store sequence number
This commit is contained in:
@@ -215,6 +215,26 @@ static int pairsmeta (lua_State *L, const char *method, int iszero,
|
||||
}
|
||||
|
||||
|
||||
static int luaB_nkeys (lua_State *L) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
int n = lua_nkeys(L, 1);
|
||||
lua_pop(L, 1);
|
||||
lua_pushinteger(L, n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int luaB_nthkey (lua_State *L) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
int n = luaL_checkint(L, 2);
|
||||
if (lua_nthkey(L, 1, n)) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int luaB_next (lua_State *L) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
lua_settop(L, 2); /* create a 2nd argument if there isn't one */
|
||||
@@ -232,6 +252,15 @@ static int luaB_pairs (lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int luaB_rawpairs (lua_State *L) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */
|
||||
lua_pushcfunction(L, luaB_next); /* will return generator, */
|
||||
lua_pushvalue(L, 1); /* table */
|
||||
lua_pushnil(L);
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
static int ipairsaux (lua_State *L) {
|
||||
int i = luaL_checkint(L, 2);
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
@@ -432,7 +461,10 @@ static const luaL_Reg base_funcs[] = {
|
||||
{"loadstring", luaB_load},
|
||||
#endif
|
||||
{"next", luaB_next},
|
||||
{"nkeys", luaB_nkeys},
|
||||
{"nthkey", luaB_nthkey},
|
||||
{"pairs", luaB_pairs},
|
||||
{"rawpairs", luaB_rawpairs},
|
||||
{"pcall", luaB_pcall},
|
||||
{"print", luaB_print},
|
||||
{"rawequal", luaB_rawequal},
|
||||
|
||||
Reference in New Issue
Block a user