diff --git a/generator/src/generator/InstanceHandler.egl b/generator/src/generator/InstanceHandler.egl index 09457ad..ca01e7b 100644 --- a/generator/src/generator/InstanceHandler.egl +++ b/generator/src/generator/InstanceHandler.egl @@ -1,39 +1,39 @@ static [%=statemachine.name%]::[%=statemachine.transition_type%] [%=state.scoped_name%]Handler([%=statemachine.name%]::ImplPtr impl, [%=statemachine.name%]::Event event) { - (void)impl; // impl parameter is unused when there is no guard function being called in here + (void)impl; // impl parameter is unused when there is no guard function being called in here [% - if (not state.all_events.isEmpty()) { + if (not state.all_events.isEmpty()) { %] - switch([%=statemachine.name%]_GET_INSTANCE_EVENT_ID(event)) - { +switch([%=statemachine.name%]_GET_INSTANCE_EVENT_ID(event)) +{ [% for (trigger in state.all_events) { %] - case [%=statemachine.name%]_GET_STATIC_EVENT_ID([%=trigger%]): +case [%=statemachine.name%]_GET_STATIC_EVENT_ID([%=trigger%]): [% - var transition = state.transitions_for_trigger_transformed.get(trigger); + var transition = state.transitions_for_trigger_transformed.get(trigger); - var transitionRootTemplate : Template = TemplateFactory.load("InstanceHandlerTransitionRoot.egl"); - transitionRootTemplate.populate("state", state); - transitionRootTemplate.populate("statemachine", statemachine); - transitionRootTemplate.populate("transition", transition); + var transitionRootTemplate : Template = TemplateFactory.load("InstanceHandlerTransitionRoot.egl"); + transitionRootTemplate.populate("state", state); + transitionRootTemplate.populate("statemachine", statemachine); + transitionRootTemplate.populate("transition", transition); %] [%=transitionRootTemplate.process()%] - break; +break; [% } %] - default: - break; - } +default: +break; +} [% - } else { + } else { %] - (void) event; // No outgoing transitions +(void) event; // No outgoing transitions [% - } +} %] - return [%=statemachine.name%]::UnhandledEvent(); +return [%=statemachine.name%]::UnhandledEvent(); } diff --git a/generator/src/generator/InstanceHandlerTransition.egl b/generator/src/generator/InstanceHandlerTransition.egl index 5757cbe..536d7e2 100644 --- a/generator/src/generator/InstanceHandlerTransition.egl +++ b/generator/src/generator/InstanceHandlerTransition.egl @@ -1,28 +1,28 @@ [% - var actions = ""; - if (transition.actions_list != null) { - statemachine.unique_id = statemachine.unique_id + 1; - actions = ", kActions" + statemachine.unique_id; + var actions = ""; + if (transition.actions_list != null) { + statemachine.unique_id = statemachine.unique_id + 1; + actions = ", kActions" + statemachine.unique_id; %] - static const auto kActions[%=statemachine.unique_id%] = std::to_array<[%=statemachine.name%]::[%=statemachine.transition_action_type%]>({[%=transition.actions_list%]}); +static const auto kActions[%=statemachine.unique_id%] = std::to_array<[%=statemachine.name%]::[%=statemachine.transition_action_type%]>({[%=transition.actions_list%]}); [% - } + } %] [% - if (transition.internal) { + if (transition.internal) { %] - return [%=statemachine.name%]::TransitionTo([%=statemachine.name%]::kNone[%=actions%]); +return [%=statemachine.name%]::TransitionTo([%=statemachine.name%]::kNone[%=actions%]); [% - } - if (transition.target_variable_name != null) { + } + 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%]); [% - } + } - var transitionRootTemplate : Template = TemplateFactory.load("InstanceHandlerTransitionRoot.egl"); - transitionRootTemplate.populate("state", state); - transitionRootTemplate.populate("statemachine", statemachine); - transitionRootTemplate.populate("transition", transition); + var transitionRootTemplate : Template = TemplateFactory.load("InstanceHandlerTransitionRoot.egl"); + transitionRootTemplate.populate("state", state); + transitionRootTemplate.populate("statemachine", statemachine); + transitionRootTemplate.populate("transition", transition); %] [%=transitionRootTemplate.process()%] \ No newline at end of file diff --git a/generator/src/generator/InstanceHandlerTransitionRoot.egl b/generator/src/generator/InstanceHandlerTransitionRoot.egl index b2a1e83..e617a32 100644 --- a/generator/src/generator/InstanceHandlerTransitionRoot.egl +++ b/generator/src/generator/InstanceHandlerTransitionRoot.egl @@ -1,23 +1,23 @@ [% - var transitionTemplate : Template = TemplateFactory.load("InstanceHandlerTransition.egl"); - transitionTemplate.populate("state", state); - transitionTemplate.populate("statemachine", statemachine); + var transitionTemplate : Template = TemplateFactory.load("InstanceHandlerTransition.egl"); + transitionTemplate.populate("state", state); + transitionTemplate.populate("statemachine", statemachine); - for (transition in transition.trans_conditional) { - transitionTemplate.populate("transition", transition); + for (transition in transition.trans_conditional) { + transitionTemplate.populate("transition", transition); %] - if ([%=transition.guards_list%]) - { + if ([%=transition.guards_list%]) + { [%=transitionTemplate.process()%] - } + } [% - } + } %] [% - for (transition in transition.trans_unconditional) { - transitionTemplate.populate("transition", transition); + for (transition in transition.trans_unconditional) { + transitionTemplate.populate("transition", transition); %] [%=transitionTemplate.process()%] [% - } + } %] diff --git a/test/generated/IScXmlTestImpl.hxx b/test/generated/IScXmlTestImpl.hxx index d164d04..0a11999 100644 --- a/test/generated/IScXmlTestImpl.hxx +++ b/test/generated/IScXmlTestImpl.hxx @@ -1,5 +1,5 @@ // Statemachine ScXmlTest implementation interface -// Generated: 21.08.24, 21:44 +// Generated: 22.08.24, 11:29 #pragma once diff --git a/test/generated/ScXmlTestDeclaration.hxx b/test/generated/ScXmlTestDeclaration.hxx index c583343..2843a9f 100644 --- a/test/generated/ScXmlTestDeclaration.hxx +++ b/test/generated/ScXmlTestDeclaration.hxx @@ -1,5 +1,5 @@ // Statemachine ScXmlTest declaration -// Generated: 21.08.24, 21:44 +// Generated: 22.08.24, 11:29 #pragma once diff --git a/test/generated/ScXmlTestInstance.hxx b/test/generated/ScXmlTestInstance.hxx index f7d4c46..7d99a3b 100644 --- a/test/generated/ScXmlTestInstance.hxx +++ b/test/generated/ScXmlTestInstance.hxx @@ -1,5 +1,5 @@ // Statemachine ScXmlTest instance -// Generated: 21.08.24, 21:44 +// Generated: 22.08.24, 11:29 #pragma once @@ -17,13 +17,9 @@ // State State_1 static ScXmlTest::Transition State_1Handler(ScXmlTest::ImplPtr impl, ScXmlTest::Event event) { - (void)impl; // impl parameter is unused when there is no guard function or action being called in here + (void)impl; // impl parameter is unused when there is no guard function being called in here - switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) - { - default: - break; - } + (void) event; // No outgoing transitions return ScXmlTest::UnhandledEvent(); } const ScXmlTest::State ScXmlTest::kState_1("State_1", &State_1Handler, nullptr, &ScXmlTest::kState_1State_2, &ScXmlTest::Impl::State1OnEntry, nullptr); @@ -31,24 +27,20 @@ const ScXmlTest::State ScXmlTest::kState_1("State_1", &State_1Handler, nullptr, // State State_1::State_2 static ScXmlTest::Transition State_1State_2Handler(ScXmlTest::ImplPtr impl, ScXmlTest::Event event) { - (void)impl; // impl parameter is unused when there is no guard function or action being called in here + (void)impl; // impl parameter is unused when there is no guard function being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { case ScXmlTest_GET_STATIC_EVENT_ID(Internal): - { - static const auto kActions = std::to_array({&ScXmlTest::Impl::State2InternalAction}); - return ScXmlTest::TransitionTo(ScXmlTest::kNone, kActions); - } + static const auto kActions1 = std::to_array({&ScXmlTest::Impl::State2InternalAction}); + return ScXmlTest::TransitionTo(ScXmlTest::kNone, kActions1); break; case ScXmlTest_GET_STATIC_EVENT_ID(Transition_3): if (impl->State2Transition3Guard(event)) { - { - static const auto kActions = std::to_array({&ScXmlTest::Impl::Transition3Action1, &ScXmlTest::Impl::Transition3Action2}); - return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_3, kActions); - } + static const auto kActions2 = std::to_array({&ScXmlTest::Impl::Transition3Action1, &ScXmlTest::Impl::Transition3Action2}); + return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_3, kActions2); } break; @@ -66,7 +58,7 @@ const ScXmlTest::State ScXmlTest::kState_1State_2("State_1::State_2", &State_1St // State State_1::State_3 static ScXmlTest::Transition State_1State_3Handler(ScXmlTest::ImplPtr impl, ScXmlTest::Event event) { - (void)impl; // impl parameter is unused when there is no guard function or action being called in here + (void)impl; // impl parameter is unused when there is no guard function being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { @@ -84,7 +76,7 @@ const ScXmlTest::State ScXmlTest::kState_1State_3("State_1::State_3", &State_1St // State State_1::State_4 static ScXmlTest::Transition State_1State_4Handler(ScXmlTest::ImplPtr impl, ScXmlTest::Event event) { - (void)impl; // impl parameter is unused when there is no guard function or action being called in here + (void)impl; // impl parameter is unused when there is no guard function being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { @@ -102,7 +94,7 @@ const ScXmlTest::HistoryState ScXmlTest::kState_1State_4("State_1::State_4", &St // State State_1::State_4::State_5 static ScXmlTest::Transition State_1State_4State_5Handler(ScXmlTest::ImplPtr impl, ScXmlTest::Event event) { - (void)impl; // impl parameter is unused when there is no guard function or action being called in here + (void)impl; // impl parameter is unused when there is no guard function being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { @@ -120,7 +112,7 @@ const ScXmlTest::State ScXmlTest::kState_1State_4State_5("State_1::State_4::Stat // State State_1::State_4::State_6 static ScXmlTest::Transition State_1State_4State_6Handler(ScXmlTest::ImplPtr impl, ScXmlTest::Event event) { - (void)impl; // impl parameter is unused when there is no guard function or action being called in here + (void)impl; // impl parameter is unused when there is no guard function being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) {