Skip to content

Commit

Permalink
Generate human-readable state names
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Jan 20, 2024
1 parent 16b5aa0 commit eb22058
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion generator/src/generator/InstanceState.egl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
handlerTemplate.populate("statemachine", statemachine);
%]
// State [%=state.name%]
const [%=statemachine.name%]::[%=state.state_type%] [%=statemachine.name%]::[%=state.variable_name%]("[%=state.name%]", &[%=state.name%]Handler, [%=state.parent_variable_pointer%], [%=state.initial_variable_pointer%], [%=state.entry_pointer%], [%=state.exit_pointer%]);
const [%=statemachine.name%]::[%=state.state_type%] [%=statemachine.name%]::[%=state.variable_name%]("[%=state.readable_scoped_name%]", &[%=state.name%]Handler, [%=state.parent_variable_pointer%], [%=state.initial_variable_pointer%], [%=state.entry_pointer%], [%=state.exit_pointer%]);
[%=handlerTemplate.process()%]
[%
if (state.region.isDefined()) {
Expand Down
2 changes: 2 additions & 0 deletions generator/src/generator/Transformations.egl
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ operation Tuple transformState(statemachine : Tuple, region : Tuple, parent_stat

if (parent_state.isDefined()) {
self.scoped_name = parent_state.scoped_name + self.name;
self.readable_scoped_name = parent_state.readable_scoped_name + "::" + self.name;
} else {
self.scoped_name = self.name;
self.readable_scoped_name = self.name;
}
self.variable_name = "k" + self.scoped_name;

Expand Down
22 changes: 11 additions & 11 deletions test/generated/IoArHandlerMainInstance.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ IoArHandlerMain::Transition IoArHandlerMain::OpenHandler(ImplPtr impl, Event eve
}

// State ApplicationReady
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReady("ApplicationReady", &ApplicationReadyHandler, &kOpen, &kOpenApplicationReadyReady, nullptr, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReady("Open::ApplicationReady", &ApplicationReadyHandler, &kOpen, &kOpenApplicationReadyReady, nullptr, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::ApplicationReadyHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -136,7 +136,7 @@ IoArHandlerMain::Transition IoArHandlerMain::ApplicationReadyHandler(ImplPtr imp
}

// State DynamicReconfigurationRunning
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunning("DynamicReconfigurationRunning", &DynamicReconfigurationRunningHandler, &kOpenApplicationReady, &kOpenApplicationReadyDynamicReconfigurationRunningDrWaitPlugCnf, &Impl::StartDynReconfTimer, &Impl::StopDynReconfTimer);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunning("Open::ApplicationReady::DynamicReconfigurationRunning", &DynamicReconfigurationRunningHandler, &kOpenApplicationReady, &kOpenApplicationReadyDynamicReconfigurationRunningDrWaitPlugCnf, &Impl::StartDynReconfTimer, &Impl::StopDynReconfTimer);
IoArHandlerMain::Transition IoArHandlerMain::DynamicReconfigurationRunningHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -157,7 +157,7 @@ IoArHandlerMain::Transition IoArHandlerMain::DynamicReconfigurationRunningHandle
}

// State DrPlugPrmSequence
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrPlugPrmSequence("DrPlugPrmSequence", &DrPlugPrmSequenceHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrPlugPrmSequence("Open::ApplicationReady::DynamicReconfigurationRunning::DrPlugPrmSequence", &DrPlugPrmSequenceHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::DrPlugPrmSequenceHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -178,7 +178,7 @@ IoArHandlerMain::Transition IoArHandlerMain::DrPlugPrmSequenceHandler(ImplPtr im
}

// State DrWaitApplicationReadyCnfPlugSubmodule
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitApplicationReadyCnfPlugSubmodule("DrWaitApplicationReadyCnfPlugSubmodule", &DrWaitApplicationReadyCnfPlugSubmoduleHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitApplicationReadyCnfPlugSubmodule("Open::ApplicationReady::DynamicReconfigurationRunning::DrWaitApplicationReadyCnfPlugSubmodule", &DrWaitApplicationReadyCnfPlugSubmoduleHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::DrWaitApplicationReadyCnfPlugSubmoduleHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -199,7 +199,7 @@ IoArHandlerMain::Transition IoArHandlerMain::DrWaitApplicationReadyCnfPlugSubmod
}

// State DrWaitApplicationReadyPlugSubmodule
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitApplicationReadyPlugSubmodule("DrWaitApplicationReadyPlugSubmodule", &DrWaitApplicationReadyPlugSubmoduleHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, &Impl::StartWaitApplicationReadyTimer, &Impl::StopWaitApplicationReadyTimer);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitApplicationReadyPlugSubmodule("Open::ApplicationReady::DynamicReconfigurationRunning::DrWaitApplicationReadyPlugSubmodule", &DrWaitApplicationReadyPlugSubmoduleHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, &Impl::StartWaitApplicationReadyTimer, &Impl::StopWaitApplicationReadyTimer);
IoArHandlerMain::Transition IoArHandlerMain::DrWaitApplicationReadyPlugSubmoduleHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -223,7 +223,7 @@ IoArHandlerMain::Transition IoArHandlerMain::DrWaitApplicationReadyPlugSubmodule
}

// State DrWaitPlugCnf
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitPlugCnf("DrWaitPlugCnf", &DrWaitPlugCnfHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitPlugCnf("Open::ApplicationReady::DynamicReconfigurationRunning::DrWaitPlugCnf", &DrWaitPlugCnfHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::DrWaitPlugCnfHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -243,7 +243,7 @@ IoArHandlerMain::Transition IoArHandlerMain::DrWaitPlugCnfHandler(ImplPtr impl,
}

// State DrWaitPullCnf
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitPullCnf("DrWaitPullCnf", &DrWaitPullCnfHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyDynamicReconfigurationRunningDrWaitPullCnf("Open::ApplicationReady::DynamicReconfigurationRunning::DrWaitPullCnf", &DrWaitPullCnfHandler, &kOpenApplicationReadyDynamicReconfigurationRunning, nullptr, nullptr, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::DrWaitPullCnfHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -264,7 +264,7 @@ IoArHandlerMain::Transition IoArHandlerMain::DrWaitPullCnfHandler(ImplPtr impl,
}

// State Ready
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyReady("Ready", &ReadyHandler, &kOpenApplicationReady, nullptr, nullptr, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenApplicationReadyReady("Open::ApplicationReady::Ready", &ReadyHandler, &kOpenApplicationReady, nullptr, nullptr, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::ReadyHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand Down Expand Up @@ -293,7 +293,7 @@ IoArHandlerMain::Transition IoArHandlerMain::ReadyHandler(ImplPtr impl, Event ev
}

// State Parameterizing
const IoArHandlerMain::State IoArHandlerMain::kOpenParameterizing("Parameterizing", &ParameterizingHandler, &kOpen, nullptr, nullptr, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenParameterizing("Open::Parameterizing", &ParameterizingHandler, &kOpen, nullptr, nullptr, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::ParameterizingHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -318,7 +318,7 @@ IoArHandlerMain::Transition IoArHandlerMain::ParameterizingHandler(ImplPtr impl,
}

// State WaitApplicationReady
const IoArHandlerMain::State IoArHandlerMain::kOpenWaitApplicationReady("WaitApplicationReady", &WaitApplicationReadyHandler, &kOpen, nullptr, &Impl::StartWaitApplicationReadyTimer, &Impl::StopWaitApplicationReadyTimer);
const IoArHandlerMain::State IoArHandlerMain::kOpenWaitApplicationReady("Open::WaitApplicationReady", &WaitApplicationReadyHandler, &kOpen, nullptr, &Impl::StartWaitApplicationReadyTimer, &Impl::StopWaitApplicationReadyTimer);
IoArHandlerMain::Transition IoArHandlerMain::WaitApplicationReadyHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -342,7 +342,7 @@ IoArHandlerMain::Transition IoArHandlerMain::WaitApplicationReadyHandler(ImplPtr
}

// State WaitApplicationReadyCnf
const IoArHandlerMain::State IoArHandlerMain::kOpenWaitApplicationReadyCnf("WaitApplicationReadyCnf", &WaitApplicationReadyCnfHandler, &kOpen, nullptr, &Impl::SendApplicationReady, nullptr);
const IoArHandlerMain::State IoArHandlerMain::kOpenWaitApplicationReadyCnf("Open::WaitApplicationReadyCnf", &WaitApplicationReadyCnfHandler, &kOpen, nullptr, &Impl::SendApplicationReady, nullptr);
IoArHandlerMain::Transition IoArHandlerMain::WaitApplicationReadyCnfHandler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand Down
6 changes: 3 additions & 3 deletions test/generated/ScXmlTestInstance.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ScXmlTest::Transition ScXmlTest::State_1Handler(ImplPtr impl, Event event)
}

// State State_2
const ScXmlTest::HistoryState ScXmlTest::kState_1State_2("State_2", &State_2Handler, &kState_1, nullptr, nullptr, nullptr);
const ScXmlTest::HistoryState ScXmlTest::kState_1State_2("State_1::State_2", &State_2Handler, &kState_1, nullptr, nullptr, nullptr);
ScXmlTest::Transition ScXmlTest::State_2Handler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand Down Expand Up @@ -56,7 +56,7 @@ ScXmlTest::Transition ScXmlTest::State_2Handler(ImplPtr impl, Event event)
}

// State State_3
const ScXmlTest::State ScXmlTest::kState_1State_3("State_3", &State_3Handler, &kState_1, nullptr, &Impl::entry, &Impl::exit);
const ScXmlTest::State ScXmlTest::kState_1State_3("State_1::State_3", &State_3Handler, &kState_1, nullptr, &Impl::entry, &Impl::exit);
ScXmlTest::Transition ScXmlTest::State_3Handler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand All @@ -76,7 +76,7 @@ ScXmlTest::Transition ScXmlTest::State_3Handler(ImplPtr impl, Event event)
}

// State State_4
const ScXmlTest::State ScXmlTest::kState_1State_4("State_4", &State_4Handler, &kState_1, nullptr, nullptr, nullptr);
const ScXmlTest::State ScXmlTest::kState_1State_4("State_1::State_4", &State_4Handler, &kState_1, nullptr, nullptr, nullptr);
ScXmlTest::Transition ScXmlTest::State_4Handler(ImplPtr impl, Event event)
{
(void)impl; // impl parameter is unused when there is no guard function being called in here
Expand Down

0 comments on commit eb22058

Please sign in to comment.