Skip to content

Commit e051103

Browse files
Rijomkris-jusiak
authored andcommitted
Add special case for initial on_entry events that have no associated action. This ensures that composite states have in turn their on_entry actions executed.
See subsequent_anonymous_transitions_composite_without_action (now passes) and subsequent_anonymous_transitions_composite_with_action (always passed).
1 parent a4dcc73 commit e051103

3 files changed

Lines changed: 50 additions & 18 deletions

File tree

include/boost/sml.hpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,10 +1424,24 @@ struct sm_impl : aux::conditional_t<aux::is_empty<typename TSM::sm>::value, aux:
14241424
}
14251425
template <class TEvent, class TDeps, class TSubs, class... Ts,
14261426
__BOOST_SML_REQUIRES(!aux::is_base_of<get_generic_t<TEvent>, events_ids_t>::value &&
1427-
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value)>
1428-
bool process_internal_events(const TEvent &, TDeps &, TSubs &, Ts &&...) {
1427+
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value &&
1428+
!aux::is_same<get_event_t<TEvent>, initial>::value)>
1429+
bool process_internal_events(const TEvent&, TDeps &, TSubs &, Ts &&...) {
14291430
return false;
14301431
}
1432+
template <class TEvent, class TDeps, class TSubs, class... Ts,
1433+
__BOOST_SML_REQUIRES(!aux::is_base_of<get_generic_t<TEvent>, events_ids_t>::value &&
1434+
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value &&
1435+
aux::is_same<get_event_t<TEvent>, initial>::value)>
1436+
bool process_internal_events(const TEvent &event, TDeps &deps, TSubs &subs) {
1437+
policies::log_process_event<sm_t>(aux::type<logger_t>{}, deps, event);
1438+
#if BOOST_SML_DISABLE_EXCEPTIONS
1439+
return process_event_impl<get_event_mapping_t<get_generic_t<TEvent>, mappings>>(event, deps, subs, states_t{},
1440+
aux::make_index_sequence<regions>{});
1441+
#else
1442+
return process_event_except_imp<get_event_mapping_t<get_generic_t<TEvent>, mappings>>(event, deps, subs, has_exceptions{});
1443+
#endif
1444+
}
14311445
template <class TEvent, class TDeps, class TSubs,
14321446
__BOOST_SML_REQUIRES(aux::is_base_of<get_generic_t<TEvent>, events_ids_t>::value &&
14331447
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value)>

include/boost/sml/back/state_machine.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,29 @@ struct sm_impl : aux::conditional_t<aux::is_empty<typename TSM::sm>::value, aux:
114114

115115
template <class TEvent, class TDeps, class TSubs, class... Ts,
116116
__BOOST_SML_REQUIRES(!aux::is_base_of<get_generic_t<TEvent>, events_ids_t>::value &&
117-
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value)>
118-
bool process_internal_events(const TEvent &, TDeps &, TSubs &, Ts &&...) {
117+
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value &&
118+
!aux::is_same<get_event_t<TEvent>, initial>::value)>
119+
bool process_internal_events(const TEvent&, TDeps &, TSubs &, Ts &&...) {
119120
return false;
120121
}
121122

123+
// This version is used by initial events that are not associated with any actions.
124+
// Without this, composite classes will their initial events not have executed.
125+
template <class TEvent, class TDeps, class TSubs, class... Ts,
126+
__BOOST_SML_REQUIRES(!aux::is_base_of<get_generic_t<TEvent>, events_ids_t>::value &&
127+
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value &&
128+
aux::is_same<get_event_t<TEvent>, initial>::value)>
129+
bool process_internal_events(const TEvent &event, TDeps &deps, TSubs &subs) {
130+
policies::log_process_event<sm_t>(aux::type<logger_t>{}, deps, event);
131+
#if BOOST_SML_DISABLE_EXCEPTIONS // __pph__
132+
return process_event_impl<get_event_mapping_t<get_generic_t<TEvent>, mappings>>(event, deps, subs, states_t{},
133+
aux::make_index_sequence<regions>{});
134+
#else // __pph__
135+
return process_event_except_imp<get_event_mapping_t<get_generic_t<TEvent>, mappings>>(event, deps, subs, has_exceptions{});
136+
#endif // __pph__
137+
}
138+
139+
122140
template <class TEvent, class TDeps, class TSubs,
123141
__BOOST_SML_REQUIRES(aux::is_base_of<get_generic_t<TEvent>, events_ids_t>::value &&
124142
!aux::is_base_of<get_mapped_t<TEvent>, events_ids_t>::value)>

test/ft/transitions.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ test subsequent_anonymous_transitions_composite_with_action = []{
171171
V calls{};
172172
//
173173
// sub_sm
174-
// +--------------------------------+
175-
// | |
176-
// | +---+ +---+ evExit |
177-
// *+---> *+---> A +-------> B +----> X +----> X
178-
// | +---+ +---+ |
179-
// | |
180-
// +--------------------------------+
174+
// +----------------------------------+
175+
// | |
176+
// | +----+ +----+ evExit |
177+
// *+---> *+---> s1 +-------> s2 +----> X +----> X
178+
// | +----+ +----+ |
179+
// | |
180+
// +----------------------------------+
181181
//
182182

183183
struct sub_sm {
@@ -219,13 +219,13 @@ test subsequent_anonymous_transitions_composite_without_action = []{
219219

220220
//
221221
// sub_sm
222-
// +--------------------------------+
223-
// | |
224-
// | +---+ +---+ evExit |
225-
// *+---> *+---> A +-------> B +----> X +----> X
226-
// | +---+ +---+ |
227-
// | |
228-
// +--------------------------------+
222+
// +----------------------------------+
223+
// | |
224+
// | +----+ +----+ evExit |
225+
// *+---> *+---> s1 +-------> s2 +----> X +----> X
226+
// | +----+ +----+ |
227+
// | |
228+
// +----------------------------------+
229229
//
230230

231231
struct sub_sm {

0 commit comments

Comments
 (0)