Use the new syntax when generating expressions and actions for properties (#5976)

This commit is contained in:
D8H
2023-11-29 15:20:38 +01:00
committed by GitHub
parent b6a1332124
commit 3744e98065
2 changed files with 8 additions and 19 deletions

View File

@@ -128,11 +128,7 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
} else { } else {
gd::Instruction action; gd::Instruction action;
action.SetType("SetReturn" + numberOrString); action.SetType("SetReturn" + numberOrString);
gd::String receiver = isBehavior ? "Object.Behavior::" : "Object."; action.AddParameter(property.GetName());
gd::String propertyPrefix =
(isSharedProperties ? "SharedProperty" : "Property");
action.AddParameter(receiver + propertyPrefix + property.GetName() +
"()");
event.GetActions().Insert(action, 0); event.GetActions().Insert(action, 0);
} }
} }
@@ -233,15 +229,13 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
gd::Instruction action; gd::Instruction action;
action.SetType(setterType); action.SetType(setterType);
action.AddParameter("Object"); action.AddParameter("Object");
gd::String parameterGetterCall =
"GetArgumentAs" + numberOrString + "(\"Value\")";
if (isBehavior) { if (isBehavior) {
action.AddParameter("Behavior"); action.AddParameter("Behavior");
action.AddParameter("="); action.AddParameter("=");
action.AddParameter(parameterGetterCall); action.AddParameter("Value");
} else { } else {
action.AddParameter("="); action.AddParameter("=");
action.AddParameter(parameterGetterCall); action.AddParameter("Value");
} }
event.GetActions().Insert(action, 0); event.GetActions().Insert(action, 0);
} }

View File

@@ -91,8 +91,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
auto &getterAction = getterEvent.GetActions().at(0); auto &getterAction = getterEvent.GetActions().at(0);
REQUIRE(getterAction.GetType() == "SetReturnNumber"); REQUIRE(getterAction.GetType() == "SetReturnNumber");
REQUIRE(getterAction.GetParametersCount() == 1); REQUIRE(getterAction.GetParametersCount() == 1);
REQUIRE(getterAction.GetParameter(0).GetPlainString() == REQUIRE(getterAction.GetParameter(0).GetPlainString() == "MovementAngle");
"Object.Behavior::PropertyMovementAngle()");
} }
{ {
auto &setter = auto &setter =
@@ -124,8 +123,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
REQUIRE(setterAction.GetParameter(0).GetPlainString() == "Object"); REQUIRE(setterAction.GetParameter(0).GetPlainString() == "Object");
REQUIRE(setterAction.GetParameter(1).GetPlainString() == "Behavior"); REQUIRE(setterAction.GetParameter(1).GetPlainString() == "Behavior");
REQUIRE(setterAction.GetParameter(2).GetPlainString() == "="); REQUIRE(setterAction.GetParameter(2).GetPlainString() == "=");
REQUIRE(setterAction.GetParameter(3).GetPlainString() == REQUIRE(setterAction.GetParameter(3).GetPlainString() == "Value");
"GetArgumentAsNumber(\"Value\")");
} }
} }
@@ -343,8 +341,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
auto &getterAction = getterEvent.GetActions().at(0); auto &getterAction = getterEvent.GetActions().at(0);
REQUIRE(getterAction.GetType() == "SetReturnNumber"); REQUIRE(getterAction.GetType() == "SetReturnNumber");
REQUIRE(getterAction.GetParametersCount() == 1); REQUIRE(getterAction.GetParametersCount() == 1);
REQUIRE(getterAction.GetParameter(0).GetPlainString() == REQUIRE(getterAction.GetParameter(0).GetPlainString() == "MovementAngle");
"Object.PropertyMovementAngle()");
} }
{ {
auto &setter = auto &setter =
@@ -375,8 +372,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
REQUIRE(setterAction.GetParametersCount() == 3); REQUIRE(setterAction.GetParametersCount() == 3);
REQUIRE(setterAction.GetParameter(0).GetPlainString() == "Object"); REQUIRE(setterAction.GetParameter(0).GetPlainString() == "Object");
REQUIRE(setterAction.GetParameter(1).GetPlainString() == "="); REQUIRE(setterAction.GetParameter(1).GetPlainString() == "=");
REQUIRE(setterAction.GetParameter(2).GetPlainString() == REQUIRE(setterAction.GetParameter(2).GetPlainString() == "Value");
"GetArgumentAsNumber(\"Value\")");
} }
} }
@@ -578,8 +574,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
auto &getterAction = getterEvent.GetActions().at(0); auto &getterAction = getterEvent.GetActions().at(0);
REQUIRE(getterAction.GetType() == "SetReturnNumber"); REQUIRE(getterAction.GetType() == "SetReturnNumber");
REQUIRE(getterAction.GetParametersCount() == 1); REQUIRE(getterAction.GetParametersCount() == 1);
REQUIRE(getterAction.GetParameter(0).GetPlainString() == REQUIRE(getterAction.GetParameter(0).GetPlainString() == "MovementAngle");
"Object.Behavior::SharedPropertyMovementAngle()");
} }
{ {
auto &setter = auto &setter =