Skip to content

Commit

Permalink
Use the new syntax when generating expressions and actions for proper…
Browse files Browse the repository at this point in the history
…ties (#5976)
  • Loading branch information
D8H authored Nov 29, 2023
1 parent b6a1332 commit 3744e98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
12 changes: 3 additions & 9 deletions Core/GDCore/IDE/PropertyFunctionGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
} else {
gd::Instruction action;
action.SetType("SetReturn" + numberOrString);
gd::String receiver = isBehavior ? "Object.Behavior::" : "Object.";
gd::String propertyPrefix =
(isSharedProperties ? "SharedProperty" : "Property");
action.AddParameter(receiver + propertyPrefix + property.GetName() +
"()");
action.AddParameter(property.GetName());
event.GetActions().Insert(action, 0);
}
}
Expand Down Expand Up @@ -233,15 +229,13 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
gd::Instruction action;
action.SetType(setterType);
action.AddParameter("Object");
gd::String parameterGetterCall =
"GetArgumentAs" + numberOrString + "(\"Value\")";
if (isBehavior) {
action.AddParameter("Behavior");
action.AddParameter("=");
action.AddParameter(parameterGetterCall);
action.AddParameter("Value");
} else {
action.AddParameter("=");
action.AddParameter(parameterGetterCall);
action.AddParameter("Value");
}
event.GetActions().Insert(action, 0);
}
Expand Down
15 changes: 5 additions & 10 deletions Core/tests/PropertyFunctionGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
auto &getterAction = getterEvent.GetActions().at(0);
REQUIRE(getterAction.GetType() == "SetReturnNumber");
REQUIRE(getterAction.GetParametersCount() == 1);
REQUIRE(getterAction.GetParameter(0).GetPlainString() ==
"Object.Behavior::PropertyMovementAngle()");
REQUIRE(getterAction.GetParameter(0).GetPlainString() == "MovementAngle");
}
{
auto &setter =
Expand Down Expand Up @@ -124,8 +123,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
REQUIRE(setterAction.GetParameter(0).GetPlainString() == "Object");
REQUIRE(setterAction.GetParameter(1).GetPlainString() == "Behavior");
REQUIRE(setterAction.GetParameter(2).GetPlainString() == "=");
REQUIRE(setterAction.GetParameter(3).GetPlainString() ==
"GetArgumentAsNumber(\"Value\")");
REQUIRE(setterAction.GetParameter(3).GetPlainString() == "Value");
}
}

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

Expand Down Expand Up @@ -578,8 +574,7 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
auto &getterAction = getterEvent.GetActions().at(0);
REQUIRE(getterAction.GetType() == "SetReturnNumber");
REQUIRE(getterAction.GetParametersCount() == 1);
REQUIRE(getterAction.GetParameter(0).GetPlainString() ==
"Object.Behavior::SharedPropertyMovementAngle()");
REQUIRE(getterAction.GetParameter(0).GetPlainString() == "MovementAngle");
}
{
auto &setter =
Expand Down

0 comments on commit 3744e98

Please sign in to comment.