Get rid of more LuaOldStack
This commit is contained in:
@@ -192,8 +192,8 @@ static bool diff_tables(LuaCoreStack &SLS0, LuaSlot stnmap, LuaSlot stab,
|
|||||||
LuaCoreStack &MLS0, LuaSlot mtnmap, LuaSlot mtab,
|
LuaCoreStack &MLS0, LuaSlot mtnmap, LuaSlot mtab,
|
||||||
bool cmeta, StreamBuffer *sb) {
|
bool cmeta, StreamBuffer *sb) {
|
||||||
LuaVar skey, mkey, sval, mval, mnil;
|
LuaVar skey, mkey, sval, mval, mnil;
|
||||||
LuaOldStack SLS(SLS0.state(), skey, sval);
|
LuaExtStack SLS(SLS0.state(), skey, sval);
|
||||||
LuaOldStack MLS(MLS0.state(), mkey, mval, mnil);
|
LuaExtStack MLS(MLS0.state(), mkey, mval, mnil);
|
||||||
assert(MLS.istable(mtab));
|
assert(MLS.istable(mtab));
|
||||||
assert(SLS.istable(stab));
|
assert(SLS.istable(stab));
|
||||||
MLS.set(mnil, LuaNil);
|
MLS.set(mnil, LuaNil);
|
||||||
@@ -237,9 +237,6 @@ static bool diff_tables(LuaCoreStack &SLS0, LuaSlot stnmap, LuaSlot stab,
|
|||||||
}
|
}
|
||||||
|
|
||||||
sb->overwrite_int32(wc, nupdates);
|
sb->overwrite_int32(wc, nupdates);
|
||||||
|
|
||||||
SLS.result();
|
|
||||||
MLS.result();
|
|
||||||
return (nupdates > 0);
|
return (nupdates > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +320,7 @@ static void set_transmitted_value(LuaCoreStack &LS, LuaSlot tangibles, LuaSlot n
|
|||||||
|
|
||||||
static void patch_table(LuaCoreStack &LS0, LuaSlot tangibles, LuaSlot ntmap, LuaSlot tab, StreamBuffer *sb, DebugCollector *dbc) {
|
static void patch_table(LuaCoreStack &LS0, LuaSlot tangibles, LuaSlot ntmap, LuaSlot tab, StreamBuffer *sb, DebugCollector *dbc) {
|
||||||
LuaVar key, val;
|
LuaVar key, val;
|
||||||
LuaOldStack LS(LS0.state(), key, val);
|
LuaExtStack LS(LS0.state(), key, val);
|
||||||
int ndiffs = sb->read_int32();
|
int ndiffs = sb->read_int32();
|
||||||
for (int i = 0; i < ndiffs; i++) {
|
for (int i = 0; i < ndiffs; i++) {
|
||||||
set_transmitted_value(LS, tangibles, ntmap, key, sb, "key=", dbc);
|
set_transmitted_value(LS, tangibles, ntmap, key, sb, "key=", dbc);
|
||||||
@@ -334,13 +331,12 @@ static void patch_table(LuaCoreStack &LS0, LuaSlot tangibles, LuaSlot ntmap, Lua
|
|||||||
LS.rawset(tab, key, val);
|
LS.rawset(tab, key, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::patch_numbered_tables(StreamBuffer *sb, DebugCollector *dbc) {
|
void World::patch_numbered_tables(StreamBuffer *sb, DebugCollector *dbc) {
|
||||||
lua_State *L = state();
|
lua_State *L = state();
|
||||||
LuaVar tangibles, ntmap, tab;
|
LuaVar tangibles, ntmap, tab;
|
||||||
LuaOldStack LS(L, tangibles, ntmap, tab);
|
LuaExtStack LS(L, tangibles, ntmap, tab);
|
||||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||||
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
||||||
assert(LS.istable(tangibles));
|
assert(LS.istable(tangibles));
|
||||||
@@ -354,14 +350,13 @@ void World::patch_numbered_tables(StreamBuffer *sb, DebugCollector *dbc) {
|
|||||||
DebugHeader(dbc) << "Lua Table " << index << ":";
|
DebugHeader(dbc) << "Lua Table " << index << ":";
|
||||||
patch_table(LS, tangibles, ntmap, tab, sb, dbc);
|
patch_table(LS, tangibles, ntmap, tab, sb, dbc);
|
||||||
}
|
}
|
||||||
LS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::diff_numbered_tables(lua_State *master, StreamBuffer *sb) {
|
void World::diff_numbered_tables(lua_State *master, StreamBuffer *sb) {
|
||||||
lua_State *synch = state();
|
lua_State *synch = state();
|
||||||
LuaVar sntmap, mntmap, stnmap, mtnmap, stab, mtab;
|
LuaVar sntmap, mntmap, stnmap, mtnmap, stab, mtab;
|
||||||
LuaOldStack SLS(synch, sntmap, stnmap, stab);
|
LuaExtStack SLS(synch, sntmap, stnmap, stab);
|
||||||
LuaOldStack MLS(master, mntmap, mtnmap, mtab);
|
LuaExtStack MLS(master, mntmap, mtnmap, mtab);
|
||||||
SLS.rawget(sntmap, LuaRegistry, "ntmap");
|
SLS.rawget(sntmap, LuaRegistry, "ntmap");
|
||||||
MLS.rawget(mntmap, LuaRegistry, "ntmap");
|
MLS.rawget(mntmap, LuaRegistry, "ntmap");
|
||||||
SLS.rawget(stnmap, LuaRegistry, "tnmap");
|
SLS.rawget(stnmap, LuaRegistry, "tnmap");
|
||||||
@@ -392,14 +387,12 @@ void World::diff_numbered_tables(lua_State *master, StreamBuffer *sb) {
|
|||||||
assert(lua_gettop(master) == m_top);
|
assert(lua_gettop(master) == m_top);
|
||||||
}
|
}
|
||||||
sb->overwrite_int32(write_count_after, nmodified);
|
sb->overwrite_int32(write_count_after, nmodified);
|
||||||
SLS.result();
|
|
||||||
MLS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::patch_tangible_databases(StreamBuffer *sb, DebugCollector *dbc) {
|
void World::patch_tangible_databases(StreamBuffer *sb, DebugCollector *dbc) {
|
||||||
lua_State *L = state();
|
lua_State *L = state();
|
||||||
LuaVar tangibles, ntmap, tab;
|
LuaVar tangibles, ntmap, tab;
|
||||||
LuaOldStack LS(L, tangibles, ntmap, tab);
|
LuaExtStack LS(L, tangibles, ntmap, tab);
|
||||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||||
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
LS.rawget(ntmap, LuaRegistry, "ntmap");
|
||||||
assert(LS.istable(tangibles));
|
assert(LS.istable(tangibles));
|
||||||
@@ -413,14 +406,13 @@ void World::patch_tangible_databases(StreamBuffer *sb, DebugCollector *dbc) {
|
|||||||
DebugHeader(dbc) << "Tangible DB " << id << ":";
|
DebugHeader(dbc) << "Tangible DB " << id << ":";
|
||||||
patch_table(LS, tangibles, ntmap, tab, sb, dbc);
|
patch_table(LS, tangibles, ntmap, tab, sb, dbc);
|
||||||
}
|
}
|
||||||
LS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::diff_tangible_databases(const IdVector &basis, lua_State *master, StreamBuffer *sb) {
|
void World::diff_tangible_databases(const IdVector &basis, lua_State *master, StreamBuffer *sb) {
|
||||||
lua_State *synch = state();
|
lua_State *synch = state();
|
||||||
LuaVar stnmap, mtnmap, stangibles, mtangibles, stab, mtab;
|
LuaVar stnmap, mtnmap, stangibles, mtangibles, stab, mtab;
|
||||||
LuaOldStack SLS(synch, stnmap, stangibles, stab);
|
LuaExtStack SLS(synch, stnmap, stangibles, stab);
|
||||||
LuaOldStack MLS(master, mtnmap, mtangibles, mtab);
|
LuaExtStack MLS(master, mtnmap, mtangibles, mtab);
|
||||||
SLS.rawget(stnmap, LuaRegistry, "tnmap");
|
SLS.rawget(stnmap, LuaRegistry, "tnmap");
|
||||||
MLS.rawget(mtnmap, LuaRegistry, "tnmap");
|
MLS.rawget(mtnmap, LuaRegistry, "tnmap");
|
||||||
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
||||||
@@ -447,15 +439,13 @@ void World::diff_tangible_databases(const IdVector &basis, lua_State *master, St
|
|||||||
assert(lua_gettop(master) == m_top);
|
assert(lua_gettop(master) == m_top);
|
||||||
}
|
}
|
||||||
sb->overwrite_int32(write_count_after, nmodified);
|
sb->overwrite_int32(write_count_after, nmodified);
|
||||||
SLS.result();
|
|
||||||
MLS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaDefine(table_diffcompare, "mtnmap,mtab,stnmap,stab", "for unit testing only") {
|
LuaDefine(table_diffcompare, "mtnmap,mtab,stnmap,stab", "for unit testing only") {
|
||||||
LuaArg mtnmap, mtab, mstnmap, mstab;
|
LuaArg mtnmap, mtab, mstnmap, mstab;
|
||||||
LuaRet dbgstring;
|
LuaRet dbgstring;
|
||||||
LuaVar tthread;
|
LuaVar tthread;
|
||||||
LuaOldStack MLS(L, mtnmap, mtab, mstnmap, mstab, dbgstring, tthread);
|
LuaDefStack MLS(L, mtnmap, mtab, mstnmap, mstab, dbgstring, tthread);
|
||||||
// Check the arguments.
|
// Check the arguments.
|
||||||
MLS.checktable(mtnmap, "mtnmap");
|
MLS.checktable(mtnmap, "mtnmap");
|
||||||
MLS.checktable(mstnmap, "mstnmap");
|
MLS.checktable(mstnmap, "mstnmap");
|
||||||
@@ -470,7 +460,7 @@ LuaDefine(table_diffcompare, "mtnmap,mtab,stnmap,stab", "for unit testing only")
|
|||||||
lua_pushvalue(L, mstab.index());
|
lua_pushvalue(L, mstab.index());
|
||||||
lua_xmove(L, synch, 2);
|
lua_xmove(L, synch, 2);
|
||||||
LuaArg stnmap,stab;
|
LuaArg stnmap,stab;
|
||||||
LuaOldStack SLS(synch, stnmap, stab);
|
LuaDefStack SLS(synch, stnmap, stab);
|
||||||
|
|
||||||
// Call tablecmp_diff.
|
// Call tablecmp_diff.
|
||||||
StreamBuffer sb;
|
StreamBuffer sb;
|
||||||
@@ -485,7 +475,7 @@ LuaDefine(table_diffapply, "mtnmap,mtab,mstab", "for unit testing only") {
|
|||||||
LuaArg mtnmap, mtab, mstab;
|
LuaArg mtnmap, mtab, mstab;
|
||||||
LuaRet eql, eqlstr, rtab;
|
LuaRet eql, eqlstr, rtab;
|
||||||
LuaVar tthread, tangibles, mntmap, key, val;
|
LuaVar tthread, tangibles, mntmap, key, val;
|
||||||
LuaOldStack MLS(L, mtnmap, mtab, mstab, eql, eqlstr, rtab, tthread, tangibles, mntmap, key, val);
|
LuaDefStack MLS(L, mtnmap, mtab, mstab, eql, eqlstr, rtab, tthread, tangibles, mntmap, key, val);
|
||||||
// Check the arguments.
|
// Check the arguments.
|
||||||
MLS.checktable(mtnmap, "mtnmap");
|
MLS.checktable(mtnmap, "mtnmap");
|
||||||
MLS.checktable(mtab, "mtab");
|
MLS.checktable(mtab, "mtab");
|
||||||
@@ -509,7 +499,7 @@ LuaDefine(table_diffapply, "mtnmap,mtab,mstab", "for unit testing only") {
|
|||||||
lua_pushvalue(L, mstab.index());
|
lua_pushvalue(L, mstab.index());
|
||||||
lua_xmove(L, synch, 2);
|
lua_xmove(L, synch, 2);
|
||||||
LuaArg stnmap, stab;
|
LuaArg stnmap, stab;
|
||||||
LuaOldStack SLS(synch, stnmap, stab);
|
LuaDefStack SLS(synch, stnmap, stab);
|
||||||
|
|
||||||
// Call diff_tables and patch_tables
|
// Call diff_tables and patch_tables
|
||||||
StreamBuffer sb;
|
StreamBuffer sb;
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ void World::patch_tanclass(StreamBuffer *sb, DebugCollector *dbc) {
|
|||||||
DebugBlock dbb(dbc, "patch_tanclass");
|
DebugBlock dbb(dbc, "patch_tanclass");
|
||||||
lua_State *L = state();
|
lua_State *L = state();
|
||||||
LuaVar tangibles, tab, meta, sclass;
|
LuaVar tangibles, tab, meta, sclass;
|
||||||
LuaOldStack LS(L, tangibles, tab, meta, sclass);
|
LuaExtStack LS(L, tangibles, tab, meta, sclass);
|
||||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||||
|
|
||||||
int nmodified = sb->read_int32();
|
int nmodified = sb->read_int32();
|
||||||
@@ -242,15 +242,15 @@ void World::patch_tanclass(StreamBuffer *sb, DebugCollector *dbc) {
|
|||||||
LS.rawset(meta, "__index", sclass);
|
LS.rawset(meta, "__index", sclass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::diff_tanclass(int64_t actor_id, World *master, StreamBuffer *xsb) {
|
void World::diff_tanclass(int64_t actor_id, World *master, StreamBuffer *xsb) {
|
||||||
StreamBuffer tsb;
|
StreamBuffer tsb;
|
||||||
|
|
||||||
|
{
|
||||||
LuaVar stangibles, mtangibles, stab, mtab, smeta, mmeta, sclass, mclass;
|
LuaVar stangibles, mtangibles, stab, mtab, smeta, mmeta, sclass, mclass;
|
||||||
LuaOldStack SLS(state(), stangibles, stab, smeta, sclass);
|
LuaExtStack SLS(state(), stangibles, stab, smeta, sclass);
|
||||||
LuaOldStack MLS(master->state(), mtangibles, mtab, mmeta, mclass);
|
LuaExtStack MLS(master->state(), mtangibles, mtab, mmeta, mclass);
|
||||||
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
SLS.rawget(stangibles, LuaRegistry, "tangibles");
|
||||||
MLS.rawget(mtangibles, LuaRegistry, "tangibles");
|
MLS.rawget(mtangibles, LuaRegistry, "tangibles");
|
||||||
|
|
||||||
@@ -279,8 +279,7 @@ void World::diff_tanclass(int64_t actor_id, World *master, StreamBuffer *xsb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tsb.overwrite_int32(write_count_after, nmodified);
|
tsb.overwrite_int32(write_count_after, nmodified);
|
||||||
SLS.result();
|
}
|
||||||
MLS.result();
|
|
||||||
|
|
||||||
// Forward to client, and apply to server-synchronous.
|
// Forward to client, and apply to server-synchronous.
|
||||||
tsb.copy_into(xsb);
|
tsb.copy_into(xsb);
|
||||||
|
|||||||
Reference in New Issue
Block a user