[Scummvm-git-logs] scummvm master -> fff03c9002583809b556ef5718a3aecb9b63f396
sev-
sev at scummvm.org
Sun Apr 5 23:24:12 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5f83a7967d DIRECTOR: Rename Datum::toType() to Datum::makeType() as less confusing
fff03c9002 DIRECTOR: Implement Datum::getPrintable() for printing out
Commit: 5f83a7967d2eba76e0bd0e6c39e5198a42f402d6
https://github.com/scummvm/scummvm/commit/5f83a7967d2eba76e0bd0e6c39e5198a42f402d6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-06T00:45:14+02:00
Commit Message:
DIRECTOR: Rename Datum::toType() to Datum::makeType() as less confusing
Changed paths:
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/lingo-bytecode.cpp
engines/director/lingo/lingo-code.cpp
engines/director/lingo/lingo-codegen.cpp
engines/director/lingo/lingo-funcs.cpp
engines/director/lingo/lingo-the.cpp
engines/director/lingo/lingo.cpp
engines/director/lingo/lingo.h
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 41fd552b46..62dcb2cea4 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -290,7 +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.toString();
+ d.makeString();
s += *d.u.s;
if (i != nargs - 1)
@@ -341,48 +341,48 @@ void LB::b_abs(int nargs) {
void LB::b_atan(int nargs) {
Datum d = g_lingo->pop();
- d.toFloat();
+ d.makeFloat();
d.u.f = atan(d.u.f);
g_lingo->push(d);
}
void LB::b_cos(int nargs) {
Datum d = g_lingo->pop();
- d.toFloat();
+ d.makeFloat();
d.u.f = cos(d.u.f);
g_lingo->push(d);
}
void LB::b_exp(int nargs) {
Datum d = g_lingo->pop();
- d.toInt(); // Lingo uses int, so we're enforcing it
- d.toFloat();
+ d.makeInt(); // Lingo uses int, so we're enforcing it
+ d.makeFloat();
d.u.f = exp(d.u.f);
g_lingo->push(d);
}
void LB::b_float(int nargs) {
Datum d = g_lingo->pop();
- d.toFloat();
+ d.makeFloat();
g_lingo->push(d);
}
void LB::b_integer(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
g_lingo->push(d);
}
void LB::b_log(int nargs) {
Datum d = g_lingo->pop();
- d.toFloat();
+ d.makeFloat();
d.u.f = log(d.u.f);
g_lingo->push(d);
}
void LB::b_pi(int nargs) {
Datum d;
- d.toFloat();
+ d.makeFloat();
d.u.f = M_PI;
g_lingo->push(d);
}
@@ -390,8 +390,8 @@ void LB::b_pi(int nargs) {
void LB::b_power(int nargs) {
Datum d1 = g_lingo->pop();
Datum d2 = g_lingo->pop();
- d1.toFloat();
- d2.toFloat();
+ d1.makeFloat();
+ d2.makeFloat();
d1.u.f = pow(d2.u.f, d1.u.f);
g_lingo->push(d1);
}
@@ -400,7 +400,7 @@ void LB::b_random(int nargs) {
Datum max = g_lingo->pop();
Datum res;
- max.toInt();
+ max.makeInt();
res.u.i = g_lingo->_vm->_rnd.getRandomNumber(max.u.i - 1) + 1;
res.type = INT;
@@ -410,21 +410,21 @@ void LB::b_random(int nargs) {
void LB::b_sin(int nargs) {
Datum d = g_lingo->pop();
- d.toFloat();
+ d.makeFloat();
d.u.f = sin(d.u.f);
g_lingo->push(d);
}
void LB::b_sqrt(int nargs) {
Datum d = g_lingo->pop();
- d.toFloat();
+ d.makeFloat();
d.u.f = sqrt(d.u.f);
g_lingo->push(d);
}
void LB::b_tan(int nargs) {
Datum d = g_lingo->pop();
- d.toFloat();
+ d.makeFloat();
d.u.f = tan(d.u.f);
g_lingo->push(d);
}
@@ -440,8 +440,8 @@ void LB::b_chars(int nargs) {
if (s.type != STRING)
error("Incorrect type for 'chars' function: %s", s.type2str());
- to.toInt();
- from.toInt();
+ to.makeInt();
+ from.makeInt();
int len = strlen(s.u.s->c_str());
int f = MAX(0, MIN(len, from.u.i - 1));
@@ -473,7 +473,7 @@ void LB::b_charToNum(int nargs) {
void LB::b_delete(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
warning("STUB: b_delete");
@@ -483,7 +483,7 @@ void LB::b_delete(int nargs) {
void LB::b_hilite(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
warning("STUB: b_hilite");
@@ -493,7 +493,7 @@ void LB::b_hilite(int nargs) {
void LB::b_length(int nargs) {
Datum d = g_lingo->pop();
if (d.type == REFERENCE)
- d.toString();
+ d.makeString();
if (d.type != STRING)
error("Incorrect type for 'length' function: %s", d.type2str());
@@ -509,7 +509,7 @@ void LB::b_length(int nargs) {
void LB::b_numToChar(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
g_lingo->push(Datum((char)d.u.i));
}
@@ -522,8 +522,8 @@ void LB::b_offset(int nargs) {
Datum target = g_lingo->pop();
Datum source = g_lingo->pop();
- target.toString();
- source.toString();
+ target.makeString();
+ source.makeString();
warning("STUB: b_offset()");
@@ -532,13 +532,13 @@ void LB::b_offset(int nargs) {
void LB::b_string(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
g_lingo->push(d);
}
void LB::b_value(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
warning("STUB: b_value()");
g_lingo->push(d);
}
@@ -657,7 +657,7 @@ void LB::b_getAt(int nargs) {
Datum index = g_lingo->pop();
Datum list = g_lingo->pop();
if (index.type == FLOAT)
- index.toInt();
+ index.makeInt();
if (index.type != INT) {
warning("b_getAt: index arg should be of type INT or FLOAT, not %s", index.type2str());
@@ -758,7 +758,7 @@ void LB::b_closeDA(int nargs) {
void LB::b_closeResFile(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_closeResFile(%s)", d.u.s->c_str());
@@ -768,7 +768,7 @@ void LB::b_closeResFile(int nargs) {
void LB::b_closeXlib(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_closeXlib(%s)", d.u.s->c_str());
@@ -786,7 +786,7 @@ void LB::b_getNthFileNameInFolder(int nargs) {
void LB::b_openDA(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_openDA(%s)", d.u.s->c_str());
@@ -796,7 +796,7 @@ void LB::b_openDA(int nargs) {
void LB::b_openResFile(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_openResFile(%s)", d.u.s->c_str());
@@ -806,7 +806,7 @@ void LB::b_openResFile(int nargs) {
void LB::b_openXlib(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_openXlib(%s)", d.u.s->c_str());
@@ -826,7 +826,7 @@ void LB::b_setCallBack(int nargs) {
void LB::b_showResFile(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_showResFile(%s)", d.u.s->c_str());
@@ -836,7 +836,7 @@ void LB::b_showResFile(int nargs) {
void LB::b_showXlib(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_showXlib(%s)", d.u.s->c_str());
@@ -846,7 +846,7 @@ void LB::b_showXlib(int nargs) {
void LB::b_xFactoryList(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_xFactoryList(%s)", d.u.s->c_str());
@@ -875,14 +875,14 @@ void LB::b_nothing(int nargs) {
void LB::b_delay(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
g_director->getCurrentScore()->_nextFrameTime = g_system->getMillis() + (float)d.u.i / 60 * 1000;
}
void LB::b_do(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_do(%s)", d.u.s->c_str());
}
@@ -1042,7 +1042,7 @@ void LB::b_startTimer(int nargs) {
///////////////////
void LB::b_factoryP(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
d.u.i = 1;
g_lingo->push(d);
@@ -1052,7 +1052,7 @@ void LB::b_factoryP(int nargs) {
void LB::b_floatP(int nargs) {
Datum d = g_lingo->pop();
int res = (d.type == FLOAT) ? 1 : 0;
- d.toInt();
+ d.makeInt();
d.u.i = res;
g_lingo->push(d);
}
@@ -1067,7 +1067,7 @@ void LB::b_ilk(int nargs) {
void LB::b_integerp(int nargs) {
Datum d = g_lingo->pop();
int res = (d.type == INT) ? 1 : 0;
- d.toInt();
+ d.makeInt();
d.u.i = res;
g_lingo->push(d);
}
@@ -1075,7 +1075,7 @@ void LB::b_integerp(int nargs) {
void LB::b_objectp(int nargs) {
Datum d = g_lingo->pop();
int res = (d.type == OBJECT) ? 1 : 0;
- d.toInt();
+ d.makeInt();
d.u.i = res;
g_lingo->push(d);
}
@@ -1089,7 +1089,7 @@ void LB::b_pictureP(int nargs) {
void LB::b_stringp(int nargs) {
Datum d = g_lingo->pop();
int res = (d.type == STRING) ? 1 : 0;
- d.toInt();
+ d.makeInt();
d.u.i = res;
g_lingo->push(d);
}
@@ -1097,7 +1097,7 @@ void LB::b_stringp(int nargs) {
void LB::b_symbolp(int nargs) {
Datum d = g_lingo->pop();
int res = (d.type == SYMBOL) ? 1 : 0;
- d.toInt();
+ d.makeInt();
d.u.i = res;
g_lingo->push(d);
}
@@ -1105,7 +1105,7 @@ void LB::b_symbolp(int nargs) {
void LB::b_voidP(int nargs) {
Datum d = g_lingo->pop();
int res = (d.type == VOID) ? 1 : 0;
- d.toInt();
+ d.makeInt();
d.u.i = res;
g_lingo->push(d);
}
@@ -1117,7 +1117,7 @@ void LB::b_voidP(int nargs) {
void LB::b_alert(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
warning("STUB: b_alert(%s)", d.u.s->c_str());
@@ -1144,12 +1144,12 @@ void LB::b_cursor(int nargs) {
if (d.type == ARRAY) {
Datum sprite = d.u.farr->operator[](0);
Datum mask = d.u.farr->operator[](1);
- sprite.toInt();
- mask.toInt();
+ sprite.makeInt();
+ mask.makeInt();
g_lingo->func_cursor(sprite.u.i, mask.u.i);
} else {
- d.toInt();
+ d.makeInt();
g_lingo->func_cursor(d.u.i, -1);
}
}
@@ -1169,8 +1169,8 @@ void LB::b_constrainH(int nargs) {
Datum num = g_lingo->pop();
Datum sprite = g_lingo->pop();
- num.toInt();
- sprite.toInt();
+ num.makeInt();
+ sprite.makeInt();
warning("STUB: b_constrainH(%d, %d)", sprite.u.i, num.u.i);
@@ -1181,8 +1181,8 @@ void LB::b_constrainV(int nargs) {
Datum num = g_lingo->pop();
Datum sprite = g_lingo->pop();
- num.toInt();
- sprite.toInt();
+ num.makeInt();
+ sprite.makeInt();
warning("STUB: b_constrainV(%d, %d)", sprite.u.i, num.u.i);
@@ -1235,7 +1235,7 @@ void LB::b_installMenu(int nargs) {
// installMenu castNum
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
if (g_director->getVersion() < 4)
d.u.i += g_director->getCurrentScore()->_castIDoffset;
@@ -1368,7 +1368,7 @@ Common::String Lingo::genMenuHandler(int *commandId, Common::String &command) {
void LB::b_label(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
warning("STUB: b_label(%d)", d.u.i);
g_lingo->push(Datum(0));
@@ -1376,7 +1376,7 @@ void LB::b_label(int nargs) {
void LB::b_marker(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
int marker = g_lingo->func_marker(d.u.i);
g_lingo->push(marker);
}
@@ -1481,7 +1481,7 @@ void LB::b_ramNeeded(int nargs) {
void LB::b_rollOver(int nargs) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
int arg = d.u.i;
@@ -1539,7 +1539,7 @@ void LB::b_zoomBox(int nargs) {
int delayTicks = 1;
if (nargs > 2) {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
delayTicks = d.u.i;
}
@@ -1547,8 +1547,8 @@ void LB::b_zoomBox(int nargs) {
Datum endSprite = g_lingo->pop();
Datum startSprite = g_lingo->pop();
- startSprite.toInt();
- endSprite.toInt();
+ startSprite.makeInt();
+ endSprite.makeInt();
Score *score = g_director->getCurrentScore();
uint16 curFrame = score->getCurrentFrame();
@@ -1627,8 +1627,8 @@ void LB::b_point(int nargs) {
Datum x = g_lingo->pop();
Datum d;
- x.toFloat();
- y.toFloat();
+ x.makeFloat();
+ y.makeFloat();
d.u.farr = new DatumArray;
@@ -1704,7 +1704,7 @@ void LB::b_beep(int nargs) {
void LB::b_mci(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
g_lingo->func_mci(*d.u.s);
}
@@ -1712,7 +1712,7 @@ void LB::b_mci(int nargs) {
void LB::b_mciwait(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
g_lingo->func_mciwait(*d.u.s);
}
@@ -1939,7 +1939,7 @@ void LB::b_window(int nargs) {
void LB::b_numberofchars(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
int len = strlen(d.u.s->c_str());
delete d.u.s;
@@ -1952,7 +1952,7 @@ void LB::b_numberofchars(int nargs) {
void LB::b_numberofitems(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
int numberofitems = 1;
Common::String contents = *d.u.s;
for (uint32 i = 0; i < d.u.s->size(); i++) {
@@ -1970,7 +1970,7 @@ void LB::b_numberofitems(int nargs) {
void LB::b_numberoflines(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
int numberoflines = 1;
Common::String contents = *d.u.s;
for (uint32 i = 0; i < d.u.s->size(); i++) {
@@ -1988,7 +1988,7 @@ void LB::b_numberoflines(int nargs) {
void LB::b_numberofwords(int nargs) {
Datum d = g_lingo->pop();
- d.toString();
+ d.makeString();
int numberofwords = 0;
Common::String contents = *d.u.s;
for (uint32 i = 1; i < d.u.s->size(); i++) {
@@ -2009,7 +2009,7 @@ void LB::b_lastcharof(int nargs) {
Datum d = g_lingo->pop();
warning("STUB: b_lastcharof");
- d.toInt();
+ d.makeInt();
d.u.i = 0;
g_lingo->push(d);
@@ -2019,7 +2019,7 @@ void LB::b_lastitemof(int nargs) {
Datum d = g_lingo->pop();
warning("STUB: b_lastitemof");
- d.toInt();
+ d.makeInt();
d.u.i = 0;
g_lingo->push(d);
@@ -2029,7 +2029,7 @@ void LB::b_lastlineof(int nargs) {
Datum d = g_lingo->pop();
warning("STUB: b_lastlineof");
- d.toInt();
+ d.makeInt();
d.u.i = 0;
g_lingo->push(d);
@@ -2039,7 +2039,7 @@ void LB::b_lastwordof(int nargs) {
Datum d = g_lingo->pop();
warning("STUB: b_lastwordof");
- d.toInt();
+ d.makeInt();
d.u.i = 0;
g_lingo->push(d);
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index cf10970924..83ed32c81d 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -262,7 +262,7 @@ void LC::cb_localcall() {
void LC::cb_methodcall() {
g_lingo->readInt();
Datum obj = g_lingo->pop();
- obj.toString();
+ obj.makeString();
warning("STUB: cb_methodcall(%s)", obj.u.s->c_str());
Datum nargs = g_lingo->pop();
@@ -450,7 +450,7 @@ void LC::cb_v4theentitypush() {
int bank = g_lingo->readInt();
Datum firstArg = g_lingo->pop();
- firstArg.toInt();
+ firstArg.makeInt();
Datum result;
result.u.s = NULL;
result.type = VOID;
@@ -536,7 +536,7 @@ void LC::cb_v4theentityassign() {
int bank = g_lingo->readInt();
Datum firstArg = g_lingo->pop();
- firstArg.toInt();
+ firstArg.makeInt();
Datum value = g_lingo->pop();
Datum result;
result.u.s = NULL;
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 1d405b932e..c61ef6177b 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -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].toString()->c_str(), (*d.u.farr)[1].toString()->c_str());
+ warning("point(%s, %s", (*d.u.farr)[0].makeString()->c_str(), (*d.u.farr)[1].makeString()->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.toString()->c_str());
+ warning("%s", d.makeString()->c_str());
break;
default:
warning("--unknown--");
@@ -587,8 +587,8 @@ Datum LC::modData(Datum d1, Datum d2) {
return LC::mapBinaryOp(LC::modData, d1, d2);
}
- d1.toInt();
- d2.toInt();
+ d1.makeInt();
+ d2.makeInt();
if (d2.u.i == 0)
error("division by zero");
@@ -631,8 +631,8 @@ void LC::c_ampersand() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toString();
- d2.toString();
+ d1.makeString();
+ d2.makeString();
*d1.u.s += *d2.u.s;
@@ -649,8 +649,8 @@ void LC::c_after() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toString();
- d2.toString();
+ d1.makeString();
+ d2.makeString();
*d1.u.s = *d2.u.s + *d1.u.s;
@@ -663,8 +663,8 @@ void LC::c_concat() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toString();
- d2.toString();
+ d1.makeString();
+ d2.makeString();
*d1.u.s += " ";
*d1.u.s += *d2.u.s;
@@ -678,8 +678,8 @@ void LC::c_contains() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toString();
- d2.toString();
+ d1.makeString();
+ d2.makeString();
Common::String *s1 = toLowercaseMac(d1.u.s);
Common::String *s2 = toLowercaseMac(d2.u.s);
@@ -701,8 +701,8 @@ void LC::c_starts() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toString();
- d2.toString();
+ d1.makeString();
+ d2.makeString();
Common::String *s1 = toLowercaseMac(d1.u.s);
Common::String *s2 = toLowercaseMac(d2.u.s);
@@ -750,7 +750,7 @@ void LC::c_of() {
Datum last_char = g_lingo->pop();
Datum first_char = g_lingo->pop();
- target.toString();
+ target.makeString();
Common::String result = *target.u.s;
if (first_line.u.i > 0) {
@@ -937,8 +937,8 @@ void LC::c_and() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toInt();
- d2.toInt();
+ d1.makeInt();
+ d2.makeInt();
d1.u.i = (d1.u.i && d2.u.i) ? 1 : 0;
@@ -949,8 +949,8 @@ void LC::c_or() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toInt();
- d2.toInt();
+ d1.makeInt();
+ d2.makeInt();
d1.u.i = (d1.u.i || d2.u.i) ? 1 : 0;
@@ -960,7 +960,7 @@ void LC::c_or() {
void LC::c_not() {
Datum d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
d.u.i = ~d.u.i ? 1 : 0;
@@ -1059,7 +1059,7 @@ void LC::c_jump() {
void LC::c_jumpifz() {
uint jump = g_lingo->readInt();
Datum test = g_lingo->pop();
- test.toInt();
+ test.makeInt();
if (test.u.i == 0) {
g_lingo->_pc = jump;
}
@@ -1074,7 +1074,7 @@ void LC::c_repeatwhilecode(void) {
g_lingo->execute(savepc + 2); /* condition */
d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
while (d.u.i) {
g_lingo->execute(body + savepc - 1); /* body */
@@ -1090,7 +1090,7 @@ void LC::c_repeatwhilecode(void) {
g_lingo->execute(savepc + 2); /* condition */
d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
}
if (!g_lingo->_returning)
@@ -1139,7 +1139,7 @@ void LC::c_repeatwithcode(void) {
g_lingo->execute(init + savepc - 1); /* condition */
d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
counter->u.i = d.u.i;
counter->type = INT;
@@ -1158,7 +1158,7 @@ void LC::c_repeatwithcode(void) {
counter->u.i += inc;
g_lingo->execute(finish + savepc - 1); /* condition */
d = g_lingo->pop();
- d.toInt();
+ d.makeInt();
if (counter->u.i == d.u.i + inc)
break;
@@ -1192,7 +1192,7 @@ void LC::c_ifcode(void) {
d = g_lingo->pop();
- if (d.toInt()) {
+ if (d.makeInt()) {
debugC(8, kDebugLingoExec, "executing then");
g_lingo->execute(then + savepc - 1);
} else if (elsep) { /* else part? */
@@ -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.toString()->c_str());
+ warning("STUB: c_tellcode(%s)", d1.makeString()->c_str());
g_lingo->_pc = end;
}
@@ -1521,8 +1521,8 @@ void LC::c_open() {
Datum d2 = g_lingo->pop();
Datum d1 = g_lingo->pop();
- d1.toString();
- d2.toString();
+ d1.makeString();
+ d2.makeString();
warning("STUB: c_open(%s, %s)", d1.u.s->c_str(), d2.u.s->c_str());
}
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index ab16fe1ab9..8342591528 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -92,7 +92,7 @@ void Lingo::printStack(const char *s, uint pc) {
for (uint i = 0; i < _stack.size(); i++) {
Datum d = _stack[i];
- d.toString();
+ d.makeString();
stack += Common::String::format("<%s> ", d.u.s->c_str());
}
debugC(5, kDebugLingoExec, "[%3d]: %s", pc, stack.c_str());
@@ -507,7 +507,7 @@ int Lingo::castIdFetch(Datum &var) {
else
warning("castIdFetch: reference to non-existent cast member: %s", var.u.s->c_str());
} else if (var.type == INT || var.type == FLOAT) {
- var.toInt();
+ var.makeInt();
if (!score->_loadedCast->contains(var.u.i))
warning("castIdFetch: reference to non-existent cast ID: %d", var.u.i);
else
@@ -583,7 +583,7 @@ void Lingo::varAssign(Datum &var, Datum &value) {
if (cast) {
switch (cast->_type) {
case kCastText:
- value.toString();
+ value.makeString();
((TextCast *)cast)->setText(value.u.s->c_str());
delete value.u.s;
break;
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index 44d5049fe1..d65bd9f3e6 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -181,7 +181,7 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
return;
if (movie.type != VOID) {
- movie.toString();
+ movie.makeString();
Common::String movieFilename = pathMakeRelative(*movie.u.s);
Common::String cleanedFilename;
@@ -235,7 +235,7 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
return;
}
- frame.toInt();
+ frame.makeInt();
_vm->_nextMovie.frameI = frame.u.i;
@@ -253,7 +253,7 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
return;
}
- frame.toInt();
+ frame.makeInt();
if (_vm->getCurrentScore())
_vm->getCurrentScore()->setCurrentFrame(frame.u.i);
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index aa56cd9384..919213aa6e 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -418,7 +418,7 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
d = getTheSprite(id, field);
break;
case kTheSqrt:
- id.toFloat();
+ id.makeFloat();
d.type = FLOAT;
d.u.f = sqrt(id.u.f);
break;
@@ -438,8 +438,8 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
if (debugChannelSet(3, kDebugLingoExec)) {
Datum idCopy = id;
Datum dCopy = d;
- idCopy.toString();
- dCopy.toString();
+ 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());
}
@@ -448,13 +448,13 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
setTheCast(id, field, d);
break;
case kTheColorDepth:
- _vm->_colorDepth = d.toInt();
+ _vm->_colorDepth = d.makeInt();
// bpp. 1, 2, 4, 8, 32
warning("STUB: Lingo::setTheEntity(): Set color depth to %d", _vm->_colorDepth);
break;
case kTheFloatPrecision:
- _floatPrecision = d.toInt();
+ _floatPrecision = d.makeInt();
_floatPrecision = MAX(0, MIN(_floatPrecision, 19)); // 0 to 19
_floatPrecisionFormat = Common::String::format("%%.%df", _floatPrecision);
break;
@@ -470,8 +470,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.toString()->c_str(), field2str(field),
- menuItemId.toString()->c_str(), d.toString()->c_str());
+ warning("STUB: setTheMenuItemEntity(%s, \"%s\", %s, \"%s\", %s)", entity2str(entity), menuId.makeString()->c_str(), field2str(field),
+ menuItemId.makeString()->c_str(), d.makeString()->c_str());
}
Datum Lingo::getTheSprite(Datum &id1, int field) {
@@ -515,7 +515,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_constraint;
break;
case kTheEditableText:
- d.toString();
+ d.makeString();
d.u.s = &sprite->_editableText;
break;
case kTheForeColor:
@@ -594,7 +594,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
int id = 0;
Score *score = _vm->getCurrentScore();
- d.toInt(); // Enforce Integer
+ d.makeInt(); // Enforce Integer
if (!score) {
warning("Lingo::setTheSprite(): The sprite %d field \"%s\" setting over non-active score", id, field2str(field));
@@ -633,7 +633,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
sprite->_constraint = d.u.i;
break;
case kTheEditableText:
- sprite->_editableText = *d.toString();
+ sprite->_editableText = *d.makeString();
break;
case kTheForeColor:
sprite->_foreColor = d.u.i;
@@ -727,7 +727,7 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
castType = score->_loadedCast->getVal(id)->_type;
castInfo = score->_castsInfo[id];
-
+
//TODO: castInfo uses full offsets, so check the higher value.
if (castInfo == nullptr)
castInfo = score->_castsInfo[id + score->_castIDoffset];
@@ -749,7 +749,7 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
d.u.i = castType;
break;
case kTheFileName:
- d.toString();
+ d.makeString();
d.u.s = &castInfo->fileName;
break;
case kTheForeColor:
@@ -771,11 +771,11 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
d.u.i = 1; //Not loaded handled above
break;
case kTheName:
- d.toString();
+ d.makeString();
d.u.s = &castInfo->name;
break;
case kTheScriptText:
- d.toString();
+ d.makeString();
d.u.s = &castInfo->script;
break;
case kTheWidth:
@@ -820,7 +820,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
}
ShapeCast *shape = (ShapeCast *)score->_loadedCast->getVal(id);
- d.toInt();
+ d.makeInt();
shape->_bgCol = d.u.i;
shape->_modified = 1;
}
@@ -836,7 +836,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
warning("Lingo::setTheCast(): The cast %d not found. type: %d", id, castType);
return;
}
- d.toString();
+ d.makeString();
castInfo->fileName = *d.u.s;
break;
case kTheForeColor:
@@ -851,7 +851,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
}
break;
case kTheHeight:
- d.toInt();
+ d.makeInt();
score->getCastMemberInitialRect(id).setHeight(d.u.i);
score->setCastMemberModified(id);
break;
@@ -860,7 +860,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
warning("Lingo::setTheCast(): The cast %d not found. type: %d", id, castType);
return;
}
- d.toString();
+ d.makeString();
castInfo->name = *d.u.s;
break;
case kTheScriptText:
@@ -868,7 +868,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
warning("Lingo::setTheCast(): The cast %d not found. type: %d", id, castType);
return;
}
- d.toString();
+ d.makeString();
addCode(d.u.s->c_str(), kSpriteScript, id);
castInfo->script = *d.u.s;
@@ -876,7 +876,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
case kTheText:
if (castType == kCastText) {
if (score->_loadedCast->contains(id) && score->_loadedCast->getVal(id)->_type == kCastText) {
- d.toString();
+ d.makeString();
((TextCast *)score->_loadedCast->getVal(id))->setText(d.u.s->c_str());
} else {
warning("Lingo::setTheCast(): Unknown STXT cast id %d", id);
@@ -887,7 +887,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
}
break;
case kTheWidth:
- d.toInt();
+ d.makeInt();
score->getCastMemberInitialRect(id).setWidth(d.u.i);
score->setCastMemberModified(id);
break;
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index a304ff5aed..a1ba5872c7 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -330,10 +330,10 @@ int Lingo::alignTypes(Datum &d1, Datum &d2) {
int opType = VOID;
if (d1.type == REFERENCE)
- d1.toString();
+ d1.makeString();
if (d2.type == REFERENCE)
- d2.toString();
+ d2.makeString();
if (d1.type == STRING) {
char *endPtr = 0;
@@ -359,8 +359,8 @@ int Lingo::alignTypes(Datum &d1, Datum &d2) {
if (d1.type == FLOAT || d2.type == FLOAT) {
opType = FLOAT;
- d1.toFloat();
- d2.toFloat();
+ d1.makeFloat();
+ d2.makeFloat();
} else if (d1.type == INT && d2.type == INT) {
opType = INT;
} else {
@@ -370,10 +370,10 @@ int Lingo::alignTypes(Datum &d1, Datum &d2) {
return opType;
}
-int Datum::toInt() {
+int Datum::makeInt() {
switch (type) {
case REFERENCE:
- toString();
+ makeString();
// fallthrough
case STRING:
{
@@ -400,7 +400,7 @@ int Datum::toInt() {
break;
}
default:
- warning("Incorrect operation toInt() for type: %s", type2str());
+ warning("Incorrect operation makeInt() for type: %s", type2str());
}
type = INT;
@@ -408,10 +408,10 @@ int Datum::toInt() {
return u.i;
}
-double Datum::toFloat() {
+double Datum::makeFloat() {
switch (type) {
case REFERENCE:
- toString();
+ makeString();
// fallthrough
case STRING:
{
@@ -438,7 +438,7 @@ double Datum::toFloat() {
// no-op
break;
default:
- warning("Incorrect operation toFloat() for type: %s", type2str());
+ warning("Incorrect operation makeFloat() for type: %s", type2str());
}
type = FLOAT;
@@ -446,7 +446,7 @@ double Datum::toFloat() {
return u.f;
}
-Common::String *Datum::toString() {
+Common::String *Datum::makeString() {
Common::String *s = new Common::String;
switch (type) {
case INT:
@@ -482,14 +482,14 @@ Common::String *Datum::toString() {
Score *score = g_director->getCurrentScore();
if (!score) {
- warning("toString(): No score");
+ warning("makeString(): No score");
*s = "";
break;
}
if (!score->_loadedCast->contains(idx)) {
if (!score->_loadedCast->contains(idx - score->_castIDoffset)) {
- warning("toString(): Unknown REFERENCE %d", idx);
+ warning("makeString(): Unknown REFERENCE %d", idx);
*s = "";
break;
} else {
@@ -507,13 +507,13 @@ Common::String *Datum::toString() {
if (i > 0)
*s += ", ";
Datum d = u.farr->operator[](i);
- *s += *d.toString();
+ *s += *d.makeString();
}
*s += "]";
break;
default:
- warning("Incorrect operation toString() for type: %s", type2str());
+ warning("Incorrect operation makeString() for type: %s", type2str());
}
u.s = s;
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 93d8fbdb1b..8817675cc7 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -108,9 +108,9 @@ struct Datum { /* interpreter stack type */
Datum(double val) { u.f = val; type = FLOAT; }
Datum(Common::String *val) { u.s = val; type = STRING; }
- double toFloat();
- int toInt();
- Common::String *toString();
+ double makeFloat();
+ int makeInt();
+ Common::String *makeString();
const char *type2str(bool isk = false);
};
Commit: fff03c9002583809b556ef5718a3aecb9b63f396
https://github.com/scummvm/scummvm/commit/fff03c9002583809b556ef5718a3aecb9b63f396
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-06T01:23:38+02:00
Commit Message:
DIRECTOR: Implement Datum::getPrintable() for printing out
Changed paths:
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/lingo-code.cpp
engines/director/lingo/lingo-codegen.cpp
engines/director/lingo/lingo-the.cpp
engines/director/lingo/lingo.cpp
engines/director/lingo/lingo.h
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 62dcb2cea4..cfc96698fe 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -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 += ", ";
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index c61ef6177b..7a7fb437c2 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -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;
}
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index 8342591528..55f501e84e 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -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());
}
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 919213aa6e..a1332510d6 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -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) {
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index a1ba5872c7..c1618e983a 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -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;
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 8817675cc7..b3ffa43bc1 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -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);
};
More information about the Scummvm-git-logs
mailing list