Skip to content

Commit

Permalink
Beautify "no transition" code
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Aug 23, 2024
1 parent 5355887 commit 52909bc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions generator/src/generator/InstanceHandlerTransition.egl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[%
var actions = "";
var actions_with_comma = "";
if (transition.actions_list != null) {
statemachine.unique_id = statemachine.unique_id + 1;
actions = ", kActions" + statemachine.unique_id;
actions = "kActions" + statemachine.unique_id;
actions_with_comma = ", " + actions;
%]
static const auto kActions[%=statemachine.unique_id%] = std::to_array<[%=statemachine.name%]::[%=statemachine.transition_action_type%]>({[%=transition.actions_list%]});
[%
Expand All @@ -11,12 +13,12 @@ static const auto kActions[%=statemachine.unique_id%] = std::to_array<[%=statema
[%
if (transition.internal) {
%]
return [%=statemachine.name%]::TransitionTo([%=statemachine.name%]::kNone[%=actions%]);
return [%=statemachine.name%]::NoTransition([%=actions%]);
[%
}
if (transition.target_variable_name != null) {
%]
return [%=statemachine.name%]::TransitionTo([%=statemachine.name%]::[%=transition.target_variable_name%][%=actions%]);
return [%=statemachine.name%]::TransitionTo([%=statemachine.name%]::[%=transition.target_variable_name%][%=actions_with_comma%]);
[%
}

Expand Down
2 changes: 1 addition & 1 deletion test/generated/IXmiTestImpl.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Statemachine XmiTest implementation interface
// Generated: 22.08.24, 09:32
// Generated: 23.08.24, 06:47

#pragma once

Expand Down
2 changes: 1 addition & 1 deletion test/generated/XmiTestDeclaration.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Statemachine XmiTest declaration
// Generated: 22.08.24, 09:32
// Generated: 23.08.24, 06:47

#pragma once

Expand Down
4 changes: 2 additions & 2 deletions test/generated/XmiTestInstance.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Statemachine XmiTest instance
// Generated: 22.08.24, 09:32
// Generated: 23.08.24, 06:47

#pragma once

Expand Down Expand Up @@ -51,7 +51,7 @@ static XmiTest::Transition State_1State_2Handler(XmiTest::ImplPtr impl, XmiTest:
{
case XmiTest_GET_STATIC_EVENT_ID(Internal):
static const auto kActions1 = std::to_array<XmiTest::Transition::ActionType>({&XmiTest::Impl::State2InternalAction});
return XmiTest::TransitionTo(XmiTest::kNone, kActions1);
return XmiTest::NoTransition(kActions1);
break;

case XmiTest_GET_STATIC_EVENT_ID(Transition_3):
Expand Down

0 comments on commit 52909bc

Please sign in to comment.