Remove more instances of LuaOldStack
This commit is contained in:
@@ -20,14 +20,15 @@ int World::number_lua_tables(const IdVector &basis) {
|
|||||||
// This is conceptually recursive, but we're going to use an
|
// This is conceptually recursive, but we're going to use an
|
||||||
// explicit stack (the lua stack).
|
// explicit stack (the lua stack).
|
||||||
lua_State *L = state();
|
lua_State *L = state();
|
||||||
|
int nextid = 1;
|
||||||
|
{
|
||||||
LuaVar tnmap, ntmap, tangibles, tab, key, val, xid;
|
LuaVar tnmap, ntmap, tangibles, tab, key, val, xid;
|
||||||
LuaOldStack LS(L, tnmap, ntmap, tangibles, tab, key, val, xid);
|
LuaExtStack LS(L, tnmap, ntmap, tangibles, tab, key, val, xid);
|
||||||
LS.set(tnmap, LuaNewTable);
|
LS.set(tnmap, LuaNewTable);
|
||||||
LS.set(ntmap, LuaNewTable);
|
LS.set(ntmap, LuaNewTable);
|
||||||
LS.rawset(LuaRegistry, "tnmap", tnmap);
|
LS.rawset(LuaRegistry, "tnmap", tnmap);
|
||||||
LS.rawset(LuaRegistry, "ntmap", ntmap);
|
LS.rawset(LuaRegistry, "ntmap", ntmap);
|
||||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||||
int nextid = 1;
|
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
|
|
||||||
// Push all subtables onto the stack. Note that we may push
|
// Push all subtables onto the stack. Note that we may push
|
||||||
@@ -70,8 +71,8 @@ int World::number_lua_tables(const IdVector &basis) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LS.result();
|
|
||||||
assert(stack_is_clear());
|
assert(stack_is_clear());
|
||||||
return nextid - 1;
|
return nextid - 1;
|
||||||
}
|
}
|
||||||
@@ -79,8 +80,8 @@ int World::number_lua_tables(const IdVector &basis) {
|
|||||||
void World::pair_lua_tables(const IdVector &basis, lua_State *master) {
|
void World::pair_lua_tables(const IdVector &basis, lua_State *master) {
|
||||||
lua_State *synch = state();
|
lua_State *synch = state();
|
||||||
LuaVar stangibles, mtangibles, sntmap, mntmap, stnmap, mtnmap, stab, mtab, skey, mkey, sval, mval, sidx, midx;
|
LuaVar stangibles, mtangibles, sntmap, mntmap, stnmap, mtnmap, stab, mtab, skey, mkey, sval, mval, sidx, midx;
|
||||||
LuaOldStack SLS(synch, stangibles, stab, skey, sval, sntmap, stnmap, sidx);
|
LuaExtStack SLS(synch, stangibles, stab, skey, sval, sntmap, stnmap, sidx);
|
||||||
LuaOldStack MLS(master, mtangibles, mtab, mkey, mval, mntmap, mtnmap, midx);
|
LuaExtStack MLS(master, mtangibles, mtab, mkey, mval, mntmap, mtnmap, midx);
|
||||||
|
|
||||||
// Fetch the tangible databases
|
// Fetch the tangible databases
|
||||||
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
||||||
@@ -168,22 +169,21 @@ void World::pair_lua_tables(const IdVector &basis, lua_State *master) {
|
|||||||
lua_pushvalue(synch, sval.index());
|
lua_pushvalue(synch, sval.index());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MLS.result();
|
|
||||||
SLS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int World::number_remaining_tables(const IdVector &basis, lua_State *master) {
|
int World::number_remaining_tables(const IdVector &basis, lua_State *master) {
|
||||||
// This is conceptually recursive, but we're going to use an
|
// This is conceptually recursive, but we're going to use an
|
||||||
// explicit stack (the lua stack).
|
// explicit stack (the lua stack).
|
||||||
|
eng::vector<bool> visited;
|
||||||
|
int ntables;
|
||||||
|
{
|
||||||
lua_State *L = master;
|
lua_State *L = master;
|
||||||
LuaVar tnmap, ntmap, tangibles, tab, key, val, xid;
|
LuaVar tnmap, ntmap, tangibles, tab, key, val, xid;
|
||||||
LuaOldStack LS(L, tnmap, ntmap, tangibles, tab, key, val, xid);
|
LuaExtStack LS(L, tnmap, ntmap, tangibles, tab, key, val, xid);
|
||||||
LS.rawget(tnmap, LuaRegistry, "tnmap");
|
LS.rawget(tnmap, LuaRegistry, "tnmap");
|
||||||
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
||||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||||
int ntables = LS.rawlen(ntmap);
|
ntables = LS.rawlen(ntmap);
|
||||||
eng::vector<bool> visited;
|
|
||||||
visited.assign(ntables + 1, false);
|
visited.assign(ntables + 1, false);
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
|
|
||||||
@@ -234,15 +234,15 @@ int World::number_remaining_tables(const IdVector &basis, lua_State *master) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
LS.result();
|
|
||||||
assert(stack_is_clear());
|
assert(stack_is_clear());
|
||||||
return visited.size() - 1 - ntables;
|
return visited.size() - 1 - ntables;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::create_new_tables(int n) {
|
void World::create_new_tables(int n) {
|
||||||
|
{
|
||||||
LuaVar tnmap, ntmap, tab;
|
LuaVar tnmap, ntmap, tab;
|
||||||
LuaOldStack LS(state(), tnmap, ntmap, tab);
|
LuaExtStack LS(state(), tnmap, ntmap, tab);
|
||||||
LS.rawget(tnmap, LuaRegistry, "tnmap");
|
LS.rawget(tnmap, LuaRegistry, "tnmap");
|
||||||
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
||||||
assert(LS.istable(tnmap));
|
assert(LS.istable(tnmap));
|
||||||
@@ -255,13 +255,13 @@ void World::create_new_tables(int n) {
|
|||||||
LS.rawset(ntmap, id, tab);
|
LS.rawset(ntmap, id, tab);
|
||||||
LS.rawset(tnmap, tab, id);
|
LS.rawset(tnmap, tab, id);
|
||||||
}
|
}
|
||||||
LS.result();
|
}
|
||||||
assert(stack_is_clear());
|
assert(stack_is_clear());
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::unnumber_lua_tables() {
|
void World::unnumber_lua_tables() {
|
||||||
// All we have to do is remove these tables from the registry.
|
// All we have to do is remove these tables from the registry.
|
||||||
LuaOldStack LS(state());
|
LuaExtStack LS(state());
|
||||||
LS.rawset(LuaRegistry, "tnmap", LuaNil);
|
LS.rawset(LuaRegistry, "tnmap", LuaNil);
|
||||||
LS.rawset(LuaRegistry, "ntmap", LuaNil);
|
LS.rawset(LuaRegistry, "ntmap", LuaNil);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user