Added two new stack disciplines to LuaStack
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
class PrintMachine {
|
||||
public:
|
||||
LuaVar tabchpos_;
|
||||
LuaStack LS_;
|
||||
LuaOldStack 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;
|
||||
LuaStack LS(L, loffset, pairs, key, val, lchpos, nextseq);
|
||||
LuaOldStack 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.
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
}
|
||||
|
||||
// Atomic print interface.
|
||||
PrintMachine(LuaStack &LS0, LuaSlot root, bool quote, std::ostream *os) :
|
||||
PrintMachine(LuaCoreStack &LS0, LuaSlot root, bool quote, std::ostream *os) :
|
||||
LS_(LS0.state(), tabchpos_) {
|
||||
output_ = os;
|
||||
atomic_print(LS_.xtype(root), root, quote);
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
}
|
||||
|
||||
// Pretty print interface.
|
||||
PrintMachine(LuaStack &LS0, LuaSlot root, bool indent, int level, bool expand, std::ostream *os) :
|
||||
PrintMachine(LuaCoreStack &LS0, LuaSlot root, bool indent, int level, bool expand, std::ostream *os) :
|
||||
LS_(LS0.state(), tabchpos_) {
|
||||
next_id_ = 1;
|
||||
indent_ = indent;
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
|
||||
void PrettyPrintOptions::parse(LuaKeywordParser &kp) {
|
||||
LuaVar option;
|
||||
LuaStack LS(kp.state(), option);
|
||||
LuaOldStack LS(kp.state(), option);
|
||||
if (kp.parse(option, "indent")) {
|
||||
indent = LS.ckboolean(option);
|
||||
}
|
||||
@@ -261,11 +261,11 @@ void PrettyPrintOptions::parse(LuaKeywordParser &kp) {
|
||||
LS.result();
|
||||
}
|
||||
|
||||
void atomic_print(LuaStack &LS, LuaSlot val, bool quote, std::ostream *os) {
|
||||
void atomic_print(LuaCoreStack &LS, LuaSlot val, bool quote, std::ostream *os) {
|
||||
PrintMachine pm(LS, val, quote, os);
|
||||
}
|
||||
|
||||
void pprint(LuaStack &LS, LuaSlot val, const PrettyPrintOptions &opts, std::ostream *os) {
|
||||
void pprint(LuaCoreStack &LS, LuaSlot val, const PrettyPrintOptions &opts, std::ostream *os) {
|
||||
PrintMachine pm(LS, val, opts.indent, opts.level, opts.expand, os);
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ LuaDefine(string_pprint, "obj1, obj2, ...",
|
||||
"|") {
|
||||
int n = lua_gettop(L);
|
||||
LuaRet result;
|
||||
LuaStack LS(L, result);
|
||||
LuaOldStack LS(L, result);
|
||||
util::ostringstream oss;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
LuaSpecial root(i);
|
||||
@@ -310,7 +310,7 @@ LuaDefine(string_pprintx, "options",
|
||||
LuaArg loptions;
|
||||
LuaRet result;
|
||||
LuaVar value;
|
||||
LuaStack LS(L, loptions, result, value);
|
||||
LuaOldStack LS(L, loptions, result, value);
|
||||
PrettyPrintOptions options;
|
||||
LuaKeywordParser kp(LS, loptions);
|
||||
options.parse(kp);
|
||||
@@ -333,7 +333,7 @@ LuaDefine(string_print, "obj",
|
||||
"|") {
|
||||
LuaArg val;
|
||||
LuaRet result;
|
||||
LuaStack LS(L, val, result);
|
||||
LuaOldStack LS(L, val, result);
|
||||
eng::ostringstream oss;
|
||||
atomic_print(LS, val, false, &oss);
|
||||
LS.set(result, oss.str());
|
||||
@@ -350,7 +350,7 @@ LuaDefine(tostring, "obj",
|
||||
"|") {
|
||||
LuaArg val;
|
||||
LuaRet result;
|
||||
LuaStack LS(L, val, result);
|
||||
LuaOldStack LS(L, val, result);
|
||||
eng::ostringstream oss;
|
||||
atomic_print(LS, val, false, &oss);
|
||||
LS.set(result, oss.str());
|
||||
@@ -360,7 +360,7 @@ LuaDefine(tostring, "obj",
|
||||
LuaDefine(string_isidentifier, "str", "return true if the string is a valid lua identifier") {
|
||||
LuaArg str;
|
||||
LuaRet result;
|
||||
LuaStack LS(L, str, result);
|
||||
LuaOldStack 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