Skip to content

Commit

Permalink
Make SCXML generation work again
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Aug 21, 2024
1 parent 9e5ea6a commit e93458c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 60 deletions.
35 changes: 21 additions & 14 deletions generator/src/generator/ScxmlModel.egl
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion generator/src/generator/XmiModel.egl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/generated/IScXmlTestImpl.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Statemachine ScXmlTest implementation interface
// Generated: 20.06.24, 11:05
// Generated: 21.08.24, 21:44

#pragma once

Expand Down
2 changes: 1 addition & 1 deletion test/generated/ScXmlTestDeclaration.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Statemachine ScXmlTest declaration
// Generated: 20.06.24, 11:05
// Generated: 21.08.24, 21:44

#pragma once

Expand Down
78 changes: 35 additions & 43 deletions test/generated/ScXmlTestInstance.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Statemachine ScXmlTest instance
// Generated: 20.06.24, 11:05
// Generated: 21.08.24, 21:44

#pragma once

Expand All @@ -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::Transition::ActionType>({&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::Transition::ActionType>({&ScXmlTest::Impl::Transition3Action1, &ScXmlTest::Impl::Transition3Action2});
return ScXmlTest::TransitionTo(ScXmlTest::kState_1State_3, kActions);
{
static const auto kActions = std::to_array<ScXmlTest::Transition::ActionType>({&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);

0 comments on commit e93458c

Please sign in to comment.