mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-18 18:30:59 +00:00
DIRECTOR: Implement Datum::getPrintable() for printing out
This commit is contained in:
parent
5f83a7967d
commit
fff03c9002
@ -290,8 +290,7 @@ void Lingo::printSTUBWithArglist(const char *funcname, int nargs, const char *pr
|
||||
for (int i = 0; i < nargs; i++) {
|
||||
Datum d = _stack[_stack.size() - nargs + i];
|
||||
|
||||
d.makeString();
|
||||
s += *d.u.s;
|
||||
s += d.getPrintable();
|
||||
|
||||
if (i != nargs - 1)
|
||||
s += ", ";
|
||||
|
@ -217,7 +217,7 @@ void LC::c_printtop(void) {
|
||||
warning("%s", d.u.s->c_str());
|
||||
break;
|
||||
case POINT:
|
||||
warning("point(%s, %s", (*d.u.farr)[0].makeString()->c_str(), (*d.u.farr)[1].makeString()->c_str());
|
||||
warning("point(%s, %s", (*d.u.farr)[0].getPrintable().c_str(), (*d.u.farr)[1].getPrintable().c_str());
|
||||
break;
|
||||
case SYMBOL:
|
||||
warning("%s", d.type2str(true));
|
||||
@ -226,7 +226,7 @@ void LC::c_printtop(void) {
|
||||
warning("#%s", d.u.s->c_str());
|
||||
break;
|
||||
case ARRAY:
|
||||
warning("%s", d.makeString()->c_str());
|
||||
warning("%s", d.getPrintable().c_str());
|
||||
break;
|
||||
default:
|
||||
warning("--unknown--");
|
||||
@ -1244,7 +1244,7 @@ void LC::c_tellcode() {
|
||||
uint start = g_lingo->_pc;
|
||||
uint end = g_lingo->readInt() + start - 1;
|
||||
|
||||
warning("STUB: c_tellcode(%s)", d1.makeString()->c_str());
|
||||
warning("STUB: c_tellcode(%s)", d1.getPrintable().c_str());
|
||||
|
||||
g_lingo->_pc = end;
|
||||
}
|
||||
|
@ -92,8 +92,7 @@ void Lingo::printStack(const char *s, uint pc) {
|
||||
|
||||
for (uint i = 0; i < _stack.size(); i++) {
|
||||
Datum d = _stack[i];
|
||||
d.makeString();
|
||||
stack += Common::String::format("<%s> ", d.u.s->c_str());
|
||||
stack += Common::String::format("<%s> ", d.getPrintable().c_str());
|
||||
}
|
||||
debugC(5, kDebugLingoExec, "[%3d]: %s", pc, stack.c_str());
|
||||
}
|
||||
|
@ -436,11 +436,7 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
|
||||
|
||||
void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
|
||||
if (debugChannelSet(3, kDebugLingoExec)) {
|
||||
Datum idCopy = id;
|
||||
Datum dCopy = d;
|
||||
idCopy.makeString();
|
||||
dCopy.makeString();
|
||||
debugC(3, kDebugLingoExec, "Lingo::setTheEntity(\"%s\", %s, \"%s\", %s)", field2str(field), idCopy.u.s->c_str(), entity2str(entity), dCopy.u.s->c_str());
|
||||
debugC(3, kDebugLingoExec, "Lingo::setTheEntity(\"%s\", %s, \"%s\", %s)", field2str(field), id.getPrintable().c_str(), entity2str(entity), d.getPrintable().c_str());
|
||||
}
|
||||
|
||||
switch (entity) {
|
||||
@ -470,8 +466,8 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
|
||||
}
|
||||
|
||||
void Lingo::setTheMenuItemEntity(int entity, Datum &menuId, int field, Datum &menuItemId, Datum &d) {
|
||||
warning("STUB: setTheMenuItemEntity(%s, \"%s\", %s, \"%s\", %s)", entity2str(entity), menuId.makeString()->c_str(), field2str(field),
|
||||
menuItemId.makeString()->c_str(), d.makeString()->c_str());
|
||||
warning("STUB: setTheMenuItemEntity(%s, \"%s\", %s, \"%s\", %s)", entity2str(entity), menuId.getPrintable().c_str(), field2str(field),
|
||||
menuItemId.getPrintable().c_str(), d.getPrintable().c_str());
|
||||
}
|
||||
|
||||
Datum Lingo::getTheSprite(Datum &id1, int field) {
|
||||
|
@ -446,8 +446,8 @@ double Datum::makeFloat() {
|
||||
return u.f;
|
||||
}
|
||||
|
||||
Common::String *Datum::makeString() {
|
||||
Common::String *s = new Common::String;
|
||||
Common::String *Datum::makeString(bool printonly) {
|
||||
Common::String *s = new Common::String();
|
||||
switch (type) {
|
||||
case INT:
|
||||
*s = Common::String::format("%d", u.i);
|
||||
@ -460,15 +460,29 @@ Common::String *Datum::makeString() {
|
||||
break;
|
||||
case FLOAT:
|
||||
*s = Common::String::format(g_lingo->_floatPrecisionFormat.c_str(), u.f);
|
||||
if (printonly)
|
||||
*s += "f"; // 0.0f
|
||||
break;
|
||||
case STRING:
|
||||
*s = *u.s;
|
||||
if (!printonly) {
|
||||
*s = *u.s;
|
||||
} else {
|
||||
*s = Common::String::format("\"%s\"", u.s->c_str());
|
||||
}
|
||||
break;
|
||||
case SYMBOL:
|
||||
*s = Common::String::format("#%s", u.s->c_str());
|
||||
if (!printonly) {
|
||||
*s = Common::String::format("#%s", u.s->c_str());
|
||||
} else {
|
||||
*s = Common::String::format("symbol: #%s", u.s->c_str());
|
||||
}
|
||||
break;
|
||||
case OBJECT:
|
||||
*s = Common::String::format("#%s", u.s->c_str());
|
||||
if (!printonly) {
|
||||
*s = Common::String::format("#%s", u.s->c_str());
|
||||
} else {
|
||||
*s = Common::String::format("object: #%s", u.s->c_str());
|
||||
}
|
||||
break;
|
||||
case VOID:
|
||||
*s = "#void";
|
||||
@ -497,7 +511,11 @@ Common::String *Datum::makeString() {
|
||||
}
|
||||
}
|
||||
|
||||
*s = ((TextCast *)score->_loadedCast->getVal(idx))->_ptext;
|
||||
if (!printonly) {
|
||||
*s = ((TextCast *)score->_loadedCast->getVal(idx))->_ptext;
|
||||
} else {
|
||||
*s = Common::String::format("reference: \"%s\"", ((TextCast *)score->_loadedCast->getVal(idx))->_ptext.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ARRAY:
|
||||
@ -507,7 +525,7 @@ Common::String *Datum::makeString() {
|
||||
if (i > 0)
|
||||
*s += ", ";
|
||||
Datum d = u.farr->operator[](i);
|
||||
*s += *d.makeString();
|
||||
*s += *d.makeString(printonly);
|
||||
}
|
||||
|
||||
*s += "]";
|
||||
@ -516,6 +534,12 @@ Common::String *Datum::makeString() {
|
||||
warning("Incorrect operation makeString() for type: %s", type2str());
|
||||
}
|
||||
|
||||
if (printonly)
|
||||
return s;
|
||||
|
||||
if (type == STRING)
|
||||
delete u.s;
|
||||
|
||||
u.s = s;
|
||||
type = STRING;
|
||||
|
||||
|
@ -110,7 +110,8 @@ struct Datum { /* interpreter stack type */
|
||||
|
||||
double makeFloat();
|
||||
int makeInt();
|
||||
Common::String *makeString();
|
||||
Common::String *makeString(bool printonly = false);
|
||||
Common::String getPrintable() { return *makeString(true); }
|
||||
|
||||
const char *type2str(bool isk = false);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user