Get rid of several instances of LuaOldStack
This commit is contained in:
@@ -36,7 +36,7 @@ void LuaSnap::serialize(StreamBuffer *sb) {
|
|||||||
// lua variables that we'll need.
|
// lua variables that we'll need.
|
||||||
LuaVar key, value;
|
LuaVar key, value;
|
||||||
LuaRet permstable, regcopy;
|
LuaRet permstable, regcopy;
|
||||||
LuaOldStack LS(state_, permstable, regcopy, key, value);
|
LuaDefStack LS(state_, permstable, regcopy, key, value);
|
||||||
|
|
||||||
// Construct a copy of the registry table.
|
// Construct a copy of the registry table.
|
||||||
LS.set(regcopy, LuaNewTable);
|
LS.set(regcopy, LuaNewTable);
|
||||||
@@ -93,7 +93,7 @@ void LuaSnap::deserialize(StreamBuffer *sb) {
|
|||||||
// Set up a stack frame.
|
// Set up a stack frame.
|
||||||
LuaArg permstable, regcopy;
|
LuaArg permstable, regcopy;
|
||||||
LuaVar key, value;
|
LuaVar key, value;
|
||||||
LuaOldStack LS(state_, permstable, regcopy, key, value);
|
LuaDefStack LS(state_, permstable, regcopy, key, value);
|
||||||
|
|
||||||
assert(LS.istable(regcopy));
|
assert(LS.istable(regcopy));
|
||||||
|
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ eng::string LuaCoreStack::classname(LuaSlot tab) const {
|
|||||||
eng::string result;
|
eng::string result;
|
||||||
if ((istable(tab)) && (gettabletype(tab) == LUA_TT_CLASS)) {
|
if ((istable(tab)) && (gettabletype(tab) == LUA_TT_CLASS)) {
|
||||||
LuaVar classes, name, dup;
|
LuaVar classes, name, dup;
|
||||||
LuaOldStack LS(L_, classes, name, dup);
|
LuaExtStack LS(L_, classes, name, dup);
|
||||||
// Get the classes table from the registry.
|
// Get the classes table from the registry.
|
||||||
LS.rawget(classes, LuaRegistry, "classes");
|
LS.rawget(classes, LuaRegistry, "classes");
|
||||||
|
|
||||||
@@ -245,9 +245,7 @@ eng::string LuaCoreStack::classname(LuaSlot tab) const {
|
|||||||
if (LS.isstring(name)) {
|
if (LS.isstring(name)) {
|
||||||
LS.rawget(dup, classes, name);
|
LS.rawget(dup, classes, name);
|
||||||
if (LS.rawequal(dup, tab)) {
|
if (LS.rawequal(dup, tab)) {
|
||||||
result = LS.ckstring(name);
|
return LS.ckstring(name);
|
||||||
LS.result();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,9 +253,7 @@ eng::string LuaCoreStack::classname(LuaSlot tab) const {
|
|||||||
LS.set(name, LuaNil);
|
LS.set(name, LuaNil);
|
||||||
while (LS.next(classes, name, dup)) {
|
while (LS.next(classes, name, dup)) {
|
||||||
if (LS.rawequal(dup, tab)) {
|
if (LS.rawequal(dup, tab)) {
|
||||||
result = LS.ckstring(name);
|
return LS.ckstring(name);
|
||||||
LS.result();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,52 +263,43 @@ eng::string LuaCoreStack::classname(LuaSlot tab) const {
|
|||||||
eng::string LuaCoreStack::getclass(LuaSlot classtab, LuaSlot classname) const {
|
eng::string LuaCoreStack::getclass(LuaSlot classtab, LuaSlot classname) const {
|
||||||
lua_checkstack(L_, 20);
|
lua_checkstack(L_, 20);
|
||||||
LuaVar globtab, cname;
|
LuaVar globtab, cname;
|
||||||
LuaOldStack LS(L_, globtab, cname);
|
LuaExtStack LS(L_, globtab, cname);
|
||||||
LS.getglobaltable(globtab);
|
LS.getglobaltable(globtab);
|
||||||
|
|
||||||
if (LS.isstring(classname)) {
|
if (LS.isstring(classname)) {
|
||||||
if (!validclassname(LS.ckstring(classname))) {
|
if (!validclassname(LS.ckstring(classname))) {
|
||||||
eng::string err = "invalid class name: " + LS.ckstring(classname);
|
eng::string err = "invalid class name: " + LS.ckstring(classname);
|
||||||
LS.result();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
LS.rawget(classtab, globtab, classname);
|
LS.rawget(classtab, globtab, classname);
|
||||||
if (!LS.istable(classtab)) {
|
if (!LS.istable(classtab)) {
|
||||||
eng::string err = "not a class: " + LS.ckstring(classname);
|
eng::string err = "not a class: " + LS.ckstring(classname);
|
||||||
LS.result();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
LS.rawget(cname, classtab, "__class");
|
LS.rawget(cname, classtab, "__class");
|
||||||
if (!LS.rawequal(cname, classname)) {
|
if (!LS.rawequal(cname, classname)) {
|
||||||
eng::string err = "not a valid class: " + LS.ckstring(classname);
|
eng::string err = "not a valid class: " + LS.ckstring(classname);
|
||||||
LS.result();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
LS.result();
|
|
||||||
return "";
|
return "";
|
||||||
} else if (LS.istable(classname)) {
|
} else if (LS.istable(classname)) {
|
||||||
LS.rawget(cname, classname, "__class");
|
LS.rawget(cname, classname, "__class");
|
||||||
if (!LS.isstring(cname)) {
|
if (!LS.isstring(cname)) {
|
||||||
eng::string err = "table is not a class.";
|
eng::string err = "table is not a class.";
|
||||||
LS.result();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (!validclassname(LS.ckstring(cname))) {
|
if (!validclassname(LS.ckstring(cname))) {
|
||||||
eng::string err = "invalid class name: " + LS.ckstring(cname);
|
eng::string err = "invalid class name: " + LS.ckstring(cname);
|
||||||
LS.result();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
LS.rawget(classtab, globtab, cname);
|
LS.rawget(classtab, globtab, cname);
|
||||||
if (!LS.rawequal(classtab, classname)) {
|
if (!LS.rawequal(classtab, classname)) {
|
||||||
eng::string err = "not a valid class: " + LS.ckstring(cname);
|
eng::string err = "not a valid class: " + LS.ckstring(cname);
|
||||||
LS.result();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
LS.result();
|
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
eng::string err = "getclass expects a string or a classtab";
|
eng::string err = "getclass expects a string or a classtab";
|
||||||
LS.result();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,9 +313,8 @@ eng::string LuaCoreStack::getclass(LuaSlot tab, std::string_view name) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LuaCoreStack::makeclass(LuaSlot classtab, LuaSlot classname) const {
|
void LuaCoreStack::makeclass(LuaSlot classtab, LuaSlot classname) const {
|
||||||
lua_checkstack(L_, 20);
|
|
||||||
LuaVar classes, globtab, cname;
|
LuaVar classes, globtab, cname;
|
||||||
LuaOldStack LS(L_, classes, globtab, cname);
|
LuaExtStack LS(L_, classes, globtab, cname);
|
||||||
|
|
||||||
// Validate the class name.
|
// Validate the class name.
|
||||||
assert(LS.validclassname(classname));
|
assert(LS.validclassname(classname));
|
||||||
@@ -356,9 +342,6 @@ void LuaCoreStack::makeclass(LuaSlot classtab, LuaSlot classname) const {
|
|||||||
LS.settabletype(classtab, LUA_TT_CLASS);
|
LS.settabletype(classtab, LUA_TT_CLASS);
|
||||||
LS.rawset(classtab, "__class", classname);
|
LS.rawset(classtab, "__class", classname);
|
||||||
LS.rawset(classtab, "__index", classtab);
|
LS.rawset(classtab, "__index", classtab);
|
||||||
|
|
||||||
// Put the stack back.
|
|
||||||
LS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaCoreStack::makeclass(LuaSlot tab, std::string_view name) const {
|
void LuaCoreStack::makeclass(LuaSlot tab, std::string_view name) const {
|
||||||
@@ -370,7 +353,7 @@ void LuaCoreStack::makeclass(LuaSlot tab, std::string_view name) const {
|
|||||||
|
|
||||||
void LuaCoreStack::maketan(LuaSlot tab, int64_t id) const {
|
void LuaCoreStack::maketan(LuaSlot tab, int64_t id) const {
|
||||||
LuaVar tangibles, metatab;
|
LuaVar tangibles, metatab;
|
||||||
LuaOldStack LS(L_, tangibles, metatab);
|
LuaExtStack LS(L_, tangibles, metatab);
|
||||||
|
|
||||||
// Try to get the existing tangible.
|
// Try to get the existing tangible.
|
||||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||||
@@ -378,7 +361,6 @@ void LuaCoreStack::maketan(LuaSlot tab, int64_t id) const {
|
|||||||
|
|
||||||
// If we succeeded, return it.
|
// If we succeeded, return it.
|
||||||
if (LS.istable(tab)) {
|
if (LS.istable(tab)) {
|
||||||
LS.result();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,8 +379,6 @@ void LuaCoreStack::maketan(LuaSlot tab, int64_t id) const {
|
|||||||
|
|
||||||
// Store the database into the tangibles table.
|
// Store the database into the tangibles table.
|
||||||
LS.rawset(tangibles, id, tab);
|
LS.rawset(tangibles, id, tab);
|
||||||
|
|
||||||
LS.result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -807,7 +807,7 @@ int lfn_http_request(lua_State *L, const char *method) {
|
|||||||
|
|
||||||
LuaArg request;
|
LuaArg request;
|
||||||
LuaRet response;
|
LuaRet response;
|
||||||
LuaOldStack LS(L, request, response);
|
LuaDefStack LS(L, request, response);
|
||||||
LuaKeywordParser kp(LS, request);
|
LuaKeywordParser kp(LS, request);
|
||||||
HttpClientRequest req;
|
HttpClientRequest req;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user