At this point, most functions have been LuaStack refactored
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
class PrintMachine {
|
||||
public:
|
||||
LuaVar tabchpos_;
|
||||
LuaOldStack LS_;
|
||||
LuaExtStack LS_;
|
||||
int next_id_;
|
||||
bool indent_;
|
||||
std::ostream *output_;
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
lua_State *L = LS_.state();
|
||||
lua_checkstack(L, 20);
|
||||
LuaVar loffset, pairs, key, val, lchpos, nextseq;
|
||||
LuaOldStack LS(L, loffset, pairs, key, val, lchpos, nextseq);
|
||||
LuaExtStack LS(L, loffset, pairs, key, val, lchpos, nextseq);
|
||||
|
||||
// Determine the extended type of the object. If the
|
||||
// expand flag is true, try to coerce it to a general table.
|
||||
@@ -113,7 +113,6 @@ public:
|
||||
if (xtype != LUA_TT_GENERAL) {
|
||||
atomic_print(xtype, value, true);
|
||||
if ((xtype < LUA_TT_GENERAL) || (!expand)) {
|
||||
LS.result();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -207,8 +206,6 @@ public:
|
||||
(*output_) << " ";
|
||||
}
|
||||
(*output_) << "}";
|
||||
|
||||
LS.result();
|
||||
}
|
||||
|
||||
// Atomic print interface.
|
||||
@@ -216,7 +213,6 @@ public:
|
||||
LS_(LS0.state(), tabchpos_) {
|
||||
output_ = os;
|
||||
atomic_print(LS_.xtype(root), root, quote);
|
||||
LS_.result();
|
||||
}
|
||||
|
||||
// Pretty print interface.
|
||||
@@ -242,13 +238,12 @@ public:
|
||||
}
|
||||
(*os).put(pre[i]);
|
||||
}
|
||||
LS_.result();
|
||||
}
|
||||
};
|
||||
|
||||
void PrettyPrintOptions::parse(LuaKeywordParser &kp) {
|
||||
LuaVar option;
|
||||
LuaOldStack LS(kp.state(), option);
|
||||
LuaExtStack LS(kp.state(), option);
|
||||
if (kp.parse(option, "indent")) {
|
||||
indent = LS.ckboolean(option);
|
||||
}
|
||||
@@ -258,7 +253,6 @@ void PrettyPrintOptions::parse(LuaKeywordParser &kp) {
|
||||
if (kp.parse(option, "expand")) {
|
||||
expand = LS.ckboolean(option);
|
||||
}
|
||||
LS.result();
|
||||
}
|
||||
|
||||
void atomic_print(LuaCoreStack &LS, LuaSlot val, bool quote, std::ostream *os) {
|
||||
@@ -278,8 +272,7 @@ LuaDefine(string_pprint, "obj1, obj2, ...",
|
||||
"|top-level table."
|
||||
"|") {
|
||||
int n = lua_gettop(L);
|
||||
LuaRet result;
|
||||
LuaOldStack LS(L, result);
|
||||
LuaCoreStack LS(L);
|
||||
util::ostringstream oss;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
LuaSpecial root(i);
|
||||
@@ -287,8 +280,10 @@ LuaDefine(string_pprint, "obj1, obj2, ...",
|
||||
if (i < n) oss << "\n";
|
||||
}
|
||||
oss << std::endl;
|
||||
lua_settop(L, 1);
|
||||
LuaSpecial result(1);
|
||||
LS.set(result, oss.view());
|
||||
return LS.result();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LuaDefine(string_pprintx, "options",
|
||||
@@ -310,7 +305,7 @@ LuaDefine(string_pprintx, "options",
|
||||
LuaArg loptions;
|
||||
LuaRet result;
|
||||
LuaVar value;
|
||||
LuaOldStack LS(L, loptions, result, value);
|
||||
LuaDefStack LS(L, loptions, result, value);
|
||||
PrettyPrintOptions options;
|
||||
LuaKeywordParser kp(LS, loptions);
|
||||
options.parse(kp);
|
||||
@@ -333,7 +328,7 @@ LuaDefine(string_print, "obj",
|
||||
"|") {
|
||||
LuaArg val;
|
||||
LuaRet result;
|
||||
LuaOldStack LS(L, val, result);
|
||||
LuaDefStack LS(L, val, result);
|
||||
eng::ostringstream oss;
|
||||
atomic_print(LS, val, false, &oss);
|
||||
LS.set(result, oss.str());
|
||||
@@ -350,7 +345,7 @@ LuaDefine(tostring, "obj",
|
||||
"|") {
|
||||
LuaArg val;
|
||||
LuaRet result;
|
||||
LuaOldStack LS(L, val, result);
|
||||
LuaDefStack LS(L, val, result);
|
||||
eng::ostringstream oss;
|
||||
atomic_print(LS, val, false, &oss);
|
||||
LS.set(result, oss.str());
|
||||
@@ -360,7 +355,7 @@ LuaDefine(tostring, "obj",
|
||||
LuaDefine(string_isidentifier, "str", "return true if the string is a valid lua identifier") {
|
||||
LuaArg str;
|
||||
LuaRet result;
|
||||
LuaOldStack LS(L, str, result);
|
||||
LuaDefStack LS(L, str, result);
|
||||
if (LS.isstring(str)) {
|
||||
eng::string s = LS.ckstring(str);
|
||||
LS.set(result, sv::is_lua_id(s));
|
||||
|
||||
Reference in New Issue
Block a user