diff --git a/generator/src/generator/ScxmlModel.egl b/generator/src/generator/ScxmlModel.egl index 84f8151..35605ee 100644 --- a/generator/src/generator/ScxmlModel.egl +++ b/generator/src/generator/ScxmlModel.egl @@ -7,10 +7,10 @@ operation t_scxml getModel() : Tuple { var region = new Tuple(); result.region = region; - region.initial_id = self.a_initial; + region.initial_state_id = self.a_initial; region.initial_history = false; - region.states = new List(); + for (state in self.c_state) { region.states.add(state.getModel()); } @@ -23,6 +23,10 @@ operation t_state getModel() : Tuple { result.name = self.a_id; result.id = self.a_id; result.region = null; + result.parent_state_id = null; + result.entry = null; + result.exit = null; + result.transitions_for_trigger = new Map(); if (self.e_onentry.isDefined() and self.e_onentry.e_script.isDefined()) { result.entry = self.e_onentry.e_script.a_src; @@ -37,11 +41,11 @@ operation t_state getModel() : Tuple { result.region = region; if (self.e_initial.isDefined() and self.e_initial.e_transition.isDefined()) { - region.initial_id = self.e_initial.e_transition.a_target; + region.initial_state_id = self.e_initial.e_transition.a_target; region.initial_history = false; } if (self.e_history.isDefined() and self.e_history.e_transition.isDefined()) { - region.initial_id = self.e_history.e_transition.a_target; + region.initial_state_id = self.e_history.e_transition.a_target; region.initial_history = true; } @@ -53,29 +57,32 @@ operation t_state getModel() : Tuple { } } - result.transitions = new List(); - for (transition in self.c_transition) { - var t = transition.getModel(); - t.start = result.name; - result.transitions.add(t); + for (scxml_transition in self.c_transition) { + var transition = scxml_transition.getModel(result); + + if (not result.transitions_for_trigger.containsKey(transition.trigger)) { + result.transitions_for_trigger.put(transition.trigger, new List()); + } + result.transitions_for_trigger.get(transition.trigger).add(transition); } - + return result; } -operation t_transition getModel() : Tuple { +operation t_transition getModel(state: Tuple) : Tuple { var result = new Tuple(); - + result.actions = new List(); + result.guards = new List(); + result.all_transitions = new List(); result.target_state_id = self.a_target; + result.start = state.name; result.internal = (self.a_type = "internal"); result.trigger = self.a_event; - result.actions = new List(); for (script in self.c_script) { result.actions.add(script.a_src); } - result.guards = new List(); if (self.a_cond.isDefined()) { result.guards.add(self.a_cond); } diff --git a/generator/src/generator/XmiModel.egl b/generator/src/generator/XmiModel.egl index 06d36b8..1983202 100644 --- a/generator/src/generator/XmiModel.egl +++ b/generator/src/generator/XmiModel.egl @@ -87,7 +87,6 @@ operation Transition getModel(sm : Tuple, state : Tuple) : Tuple { result.actions = new List(); result.guards = new List(); result.all_transitions = new List(); - result.guard = null; result.target_state_id = null; result.trigger = null; result.start = state.name; diff --git a/test/generated/IScXmlTestImpl.hxx b/test/generated/IScXmlTestImpl.hxx index d2fc861..d164d04 100644 --- a/test/generated/IScXmlTestImpl.hxx +++ b/test/generated/IScXmlTestImpl.hxx @@ -1,5 +1,5 @@ // Statemachine ScXmlTest implementation interface -// Generated: 20.06.24, 11:05 +// Generated: 21.08.24, 21:44 #pragma once diff --git a/test/generated/ScXmlTestDeclaration.hxx b/test/generated/ScXmlTestDeclaration.hxx index eeec96c..c583343 100644 --- a/test/generated/ScXmlTestDeclaration.hxx +++ b/test/generated/ScXmlTestDeclaration.hxx @@ -1,5 +1,5 @@ // Statemachine ScXmlTest declaration -// Generated: 20.06.24, 11:05 +// Generated: 21.08.24, 21:44 #pragma once diff --git a/test/generated/ScXmlTestInstance.hxx b/test/generated/ScXmlTestInstance.hxx index 7ddfdf5..f7d4c46 100644 --- a/test/generated/ScXmlTestInstance.hxx +++ b/test/generated/ScXmlTestInstance.hxx @@ -1,5 +1,5 @@ // Statemachine ScXmlTest instance -// Generated: 20.06.24, 11:05 +// Generated: 21.08.24, 21:44 #pragma once @@ -17,128 +17,120 @@ // 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 being called in here + (void)impl; // impl parameter is unused when there is no guard function or action being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { default: - return ScXmlTest::UnhandledEvent(); + break; } + return ScXmlTest::UnhandledEvent(); } const ScXmlTest::State ScXmlTest::kState_1("State_1", &State_1Handler, nullptr, &ScXmlTest::kState_1State_2, &ScXmlTest::Impl::State1OnEntry, 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 being called in here + (void)impl; // impl parameter is unused when there is no guard function or action being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { case ScXmlTest_GET_STATIC_EVENT_ID(Internal): - if (true) { static const auto kActions = std::to_array({&ScXmlTest::Impl::State2InternalAction}); return ScXmlTest::TransitionTo(ScXmlTest::kNone, kActions); } - return ScXmlTest::UnhandledEvent(); + 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 kActions = std::to_array({&ScXmlTest::Impl::Transition3Action1, &ScXmlTest::Impl::Transition3Action2}); + return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_3, kActions); + } } - return ScXmlTest::UnhandledEvent(); + break; case ScXmlTest_GET_STATIC_EVENT_ID(Transition_6): - if (true) - { - return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4); - } - return ScXmlTest::UnhandledEvent(); + return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4); + break; default: - return ScXmlTest::UnhandledEvent(); + break; } + return ScXmlTest::UnhandledEvent(); } const ScXmlTest::State ScXmlTest::kState_1State_2("State_1::State_2", &State_1State_2Handler, &ScXmlTest::kState_1, nullptr, &ScXmlTest::Impl::State2OnEntry, nullptr); // 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 being called in here + (void)impl; // impl parameter is unused when there is no guard function or action being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { case ScXmlTest_GET_STATIC_EVENT_ID(Transition_7): - if (true) - { - return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4); - } - return ScXmlTest::UnhandledEvent(); + return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4); + break; default: - return ScXmlTest::UnhandledEvent(); + break; } + return ScXmlTest::UnhandledEvent(); } const ScXmlTest::State ScXmlTest::kState_1State_3("State_1::State_3", &State_1State_3Handler, &ScXmlTest::kState_1, nullptr, &ScXmlTest::Impl::State3OnEntry, &ScXmlTest::Impl::State3OnExit); // 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 being called in here + (void)impl; // impl parameter is unused when there is no guard function or action being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { case ScXmlTest_GET_STATIC_EVENT_ID(Transition_8): - if (true) - { - return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_2); - } - return ScXmlTest::UnhandledEvent(); + return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_2); + break; default: - return ScXmlTest::UnhandledEvent(); + break; } + return ScXmlTest::UnhandledEvent(); } const ScXmlTest::HistoryState ScXmlTest::kState_1State_4("State_1::State_4", &State_1State_4Handler, &ScXmlTest::kState_1, &ScXmlTest::kState_1State_4State_5, &ScXmlTest::Impl::State4OnEntry, &ScXmlTest::Impl::State4OnExit); // 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 being called in here + (void)impl; // impl parameter is unused when there is no guard function or action being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { case ScXmlTest_GET_STATIC_EVENT_ID(Transition_3): - if (true) - { - return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4State_6); - } - return ScXmlTest::UnhandledEvent(); + return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4State_6); + break; default: - return ScXmlTest::UnhandledEvent(); + break; } + return ScXmlTest::UnhandledEvent(); } const ScXmlTest::State ScXmlTest::kState_1State_4State_5("State_1::State_4::State_5", &State_1State_4State_5Handler, &ScXmlTest::kState_1State_4, nullptr, nullptr, nullptr); // 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 being called in here + (void)impl; // impl parameter is unused when there is no guard function or action being called in here switch(ScXmlTest_GET_INSTANCE_EVENT_ID(event)) { case ScXmlTest_GET_STATIC_EVENT_ID(Transition_4): - if (true) - { - return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4State_5); - } - return ScXmlTest::UnhandledEvent(); + return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_4State_5); + break; default: - return ScXmlTest::UnhandledEvent(); + break; } + return ScXmlTest::UnhandledEvent(); } const ScXmlTest::State ScXmlTest::kState_1State_4State_6("State_1::State_4::State_6", &State_1State_4State_6Handler, &ScXmlTest::kState_1State_4, nullptr, nullptr, nullptr); \ No newline at end of file