Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/boost/sml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ struct transitions_sub<sm<Tsm>, T, Ts...> {
if (sub_sm<sm_impl<Tsm>>::cget(&subs).is_terminated()) {
return transitions<T, Ts...>::execute(event, sm, deps, subs, current_state);
} else {
return sub_sm<sm_impl<Tsm>>::get(&subs).process_event(event, deps, subs);
return sub_sm<sm_impl<Tsm>>::get(&subs).process_internal_events(event, deps, subs);
}
return false;
}
Expand Down Expand Up @@ -1044,8 +1044,8 @@ struct transitions_sub<sm<Tsm>> {
return sub_sm<sm_impl<Tsm>>::get(&subs).process_event(event, deps, subs);
}
template <class, class SM, class TDeps, class TSubs>
constexpr static bool execute(const anonymous &, SM &, TDeps &, TSubs &, typename SM::state_t &) {
return false;
constexpr static bool execute(const anonymous &, SM &, TDeps &deps, TSubs &subs, typename SM::state_t &) {
return sub_sm<sm_impl<Tsm>>::get(&subs).process_internal_events(anonymous{}, deps, subs);
}
};
} // namespace back
Expand Down
53 changes: 50 additions & 3 deletions test/ft/composite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,14 +937,14 @@ test composite_sub_guards = [] {
bool is_ok = false;
sml::sm<SM> sm{c_, guard_counter, is_ok};
expect(std::vector<calls>{calls::a1_entry} == c_);
expect(guard_counter == 1);
expect(guard_counter <= 2);
guard_counter = {};
sm.process_event(e2{});
expect(guard_counter == 1);
expect(guard_counter <= 2);
guard_counter = {};
is_ok = true;
sm.process_event(e2{});
expect(guard_counter == 1);
expect(guard_counter <= 2);
expect(std::vector<calls>{calls::a1_entry, calls::a1_exit, calls::a2_entry} == c_);
guard_counter = {};
sm.process_event(e1{});
Expand Down Expand Up @@ -1002,3 +1002,50 @@ test composite_with_string_names = [] {
expect(sm.is(X));
};
#endif

test nested_composite_anonymous = [] {
using namespace boost::sml;

struct Leaf {
struct INITIAL {};
struct FINAL {};

auto operator()() const {
using namespace boost::sml;

/* clang-format off */
return make_transition_table(
*state<INITIAL> = state<FINAL>,
state<FINAL> = X
);
/* clang-format on */
}
};

struct Top {
// states
struct INITIAL {};
struct SUCCESS {};

// events
struct WIN {};
struct LOSE {};

auto operator()() const {
using namespace boost::sml;

/* clang-format off */
return make_transition_table(
*state<INITIAL> = state<Leaf>,
state<Leaf> + event<LOSE> = X,
state<Leaf> + event<WIN> = state<SUCCESS>
);
/* clang-format on */
}
};

sm<Top> sm;

expect(sm.is(state<Leaf>));
expect(sm.is<decltype(state<Leaf>)>(X));
};
Loading