[Scummvm-git-logs] scummvm master -> 75ed7f2039060f1ad0e46b97c9db40ff92fc1a8e

moralrecordings code at moral.net.au
Thu May 14 12:01:24 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
75ed7f2039 DIRECTOR: LINGO: Replace Datum pointers in PCell


Commit: 75ed7f2039060f1ad0e46b97c9db40ff92fc1a8e
    https://github.com/scummvm/scummvm/commit/75ed7f2039060f1ad0e46b97c9db40ff92fc1a8e
Author: Scott Percival (code at moral.net.au)
Date: 2020-05-14T20:01:02+08:00

Commit Message:
DIRECTOR: LINGO: Replace Datum pointers in PCell

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-code.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 b4a39c0993..c02357665f 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -688,7 +688,7 @@ void LB::b_findPosNear(int nargs) {
 	prop.toLowercase();
 
 	for (uint i = 0; i < list.u.parr->size(); i++) {
-		Datum p = *list.u.parr->operator[](i).p;
+		Datum p = list.u.parr->operator[](i).p;
 		Common::String tgt = p.asString();
 		tgt.toLowercase();
 		if (tgt.find(prop.c_str()) == 0) {
@@ -715,7 +715,7 @@ void LB::b_getaProp(int nargs) {
 		Datum d;
 		int index = LC::compareArrays(LC::eqData, list, prop, true).u.i;
 		if (index > 0) {
-			d = *list.u.parr->operator[](index - 1).v;
+			d = list.u.parr->operator[](index - 1).v;
 		}
 		g_lingo->push(d);
 		break;
@@ -740,7 +740,7 @@ void LB::b_getAt(int nargs) {
 		break;
 	case PARRAY:
 		ARRBOUNDSCHECK(index, list);
-		g_lingo->push(*list.u.parr->operator[](index - 1).v);
+		g_lingo->push(list.u.parr->operator[](index - 1).v);
 		break;
 	default:
 		TYPECHECK2(list, ARRAY, PARRAY);
@@ -756,7 +756,7 @@ void LB::b_getLast(int nargs) {
 		g_lingo->push(list.u.farr->back());
 		break;
 	case PARRAY:
-		g_lingo->push(*list.u.parr->back().v);
+		g_lingo->push(list.u.parr->back().v);
 		break;
 	default:
 		TYPECHECK(list, ARRAY);
@@ -778,7 +778,7 @@ void LB::b_getOne(int nargs) {
 		Datum d;
 		int index = LC::compareArrays(LC::eqData, list, val, true, true).u.i;
 		if (index > 0) {
-			d = *list.u.parr->operator[](index - 1).p;
+			d = list.u.parr->operator[](index - 1).p;
 		}
 		g_lingo->push(d);
 		break;
@@ -834,7 +834,7 @@ void LB::b_getProp(int nargs) {
 	case PARRAY: {
 		int index = LC::compareArrays(LC::eqData, list, prop, true).u.i;
 		if (index > 0) {
-			g_lingo->push(*list.u.parr->operator[](index - 1).v);
+			g_lingo->push(list.u.parr->operator[](index - 1).v);
 		} else {
 			error("b_getProp: Property %s not found", prop.asString().c_str());
 		}
@@ -854,7 +854,7 @@ void LB::b_getPropAt(int nargs) {
 	TYPECHECK(list, PARRAY);
 	int index = indexD.asInt();
 
-	g_lingo->push(*list.u.parr->operator[](index - 1).p);
+	g_lingo->push(list.u.parr->operator[](index - 1).p);
 }
 
 void LB::b_list(int nargs) {
@@ -960,7 +960,7 @@ void LB::b_setaProp(int nargs) {
 	case PARRAY: {
 		int index = LC::compareArrays(LC::eqData, list, prop, true).u.i;
 		if (index > 0) {
-			*list.u.parr->operator[](index - 1).v = value;
+			list.u.parr->operator[](index - 1).v = value;
 		} else {
 			PCell cell = PCell(prop, value);
 			list.u.parr->push_back(cell);
@@ -993,7 +993,7 @@ void LB::b_setAt(int nargs) {
 		break;
 	case PARRAY:
 		ARRBOUNDSCHECK(index, list);
-		*list.u.parr->operator[](index - 1).v = value;
+		list.u.parr->operator[](index - 1).v = value;
 		break;
 	default:
 		break;
@@ -1011,7 +1011,7 @@ void LB::b_setProp(int nargs) {
 
 	int index = LC::compareArrays(LC::eqData, list, prop, true).u.i;
 	if (index > 0) {
-		*list.u.parr->operator[](index - 1).v = value;
+		list.u.parr->operator[](index - 1).v = value;
 	} else {
 		warning("b_setProp: Property not found");
 	}
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 073d4be005..b1bb7bca4d 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1011,14 +1011,14 @@ Datum LC::compareArrays(Datum (*compareFunc)(Datum, Datum), Datum d1, Datum d2,
 			a = d1.u.farr->operator[](i);
 		} else if (d1.type == PARRAY) {
 			PCell t = d1.u.parr->operator[](i);
-			a = value ? *t.v : *t.p;
+			a = value ? t.v : t.p;
 		}
 
 		if (d2.type == ARRAY) {
 			b = d2.u.farr->operator[](i);
 		} else if (d2.type == PARRAY) {
 			PCell t = d2.u.parr->operator[](i);
-			b = value ? *t.v : *t.p;
+			b = value ? t.v : t.p;
 		}
 
 		res = compareFunc(a, b);
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index c3c7279d42..3967f2b785 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -131,13 +131,8 @@ PCell::PCell() {
 }
 
 PCell::PCell(Datum &prop, Datum &val) {
-	p = new Datum;
-	p->type = prop.type;
-	p->u = prop.u;
-
-	v = new Datum;
-	v->type = val.type;
-	v->u = val.u;
+	p = prop;
+	v = val;
 }
 
 Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
@@ -602,8 +597,8 @@ Common::String Datum::asString(bool printonly) {
 		for (uint i = 0; i < u.parr->size(); i++) {
 			if (i > 0)
 				s += ", ";
-			Datum p = *u.parr->operator[](i).p;
-			Datum v = *u.parr->operator[](i).v;
+			Datum p = u.parr->operator[](i).p;
+			Datum v = u.parr->operator[](i).v;
 			s += Common::String::format("%s:%s", p.asString(printonly).c_str(), v.asString(printonly).c_str());
 		}
 
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index bc109f984c..047491334f 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -100,14 +100,6 @@ struct Symbol {	/* symbol table entry */
 	~Symbol();
 };
 
-struct PCell {
-	Datum *p;
-	Datum *v;
-
-	PCell();
-	PCell(Datum &prop, Datum &val);
-};
-
 struct Datum {	/* interpreter stack type */
 	int type;
 
@@ -208,6 +200,14 @@ struct Datum {	/* interpreter stack type */
 	int compareTo(Datum &d, bool ignoreCase = false);
 };
 
+struct PCell {
+	Datum p;
+	Datum v;
+
+	PCell();
+	PCell(Datum &prop, Datum &val);
+};
+
 struct Builtin {
 	void (*func)(void);
 	int nargs;




More information about the Scummvm-git-logs mailing list