From d98fa23db3ded884479ac3ab44a57aa858ba5533 Mon Sep 17 00:00:00 2001 From: Jan Pedersen Date: Mon, 17 Sep 2018 16:45:11 +0200 Subject: [PATCH 1/4] reproduce issue --- src/test/all-tests.h | 6 ++++++ src/test/issue_69.scxml | 30 ++++++++++++++++++++++++++++++ src/test/test.cpp | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 src/test/issue_69.scxml diff --git a/src/test/all-tests.h b/src/test/all-tests.h index 233301c..e8c8bee 100644 --- a/src/test/all-tests.h +++ b/src/test/all-tests.h @@ -365,4 +365,10 @@ TEST(lcca_parallel, 0) EXPECT_EQ(typeid(sc_lcca_parallel::state_A1), typeid(*sc.cur_state[2])); } +TEST(issue_69, 0) +{ + sc_issue_69 sc; + sc.init(); +} + #endif diff --git a/src/test/issue_69.scxml b/src/test/issue_69.scxml new file mode 100644 index 0000000..fb0937e --- /dev/null +++ b/src/test/issue_69.scxml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/test.cpp b/src/test/test.cpp index 27e0d88..69db165 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -18,6 +18,8 @@ #include "conditional.h" #include "../examples/timer_switch.h" #include "lcca_parallel.h" +#include "issue_69.h" + #include #include #include From 9a54bcb2cbb493eb284717dcee9ed9bd55d9dfc2 Mon Sep 17 00:00:00 2001 From: Jan Pedersen Date: Thu, 27 Sep 2018 13:21:04 +0200 Subject: [PATCH 2/4] fix #69 --- src/cpp_output.cpp | 10 ++++++++++ src/test/all-tests.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/cpp_output.cpp b/src/cpp_output.cpp index 47324c1..e87f976 100644 --- a/src/cpp_output.cpp +++ b/src/cpp_output.cpp @@ -601,11 +601,21 @@ void cpp_output::gen_state_base() // collect events vector events; for (scxml_parser::state_list::const_iterator i_state = states.begin(); i_state != states.end(); ++i_state) { + + // Final state events if (i_state->get()->type && *i_state->get()->type == "final") { if (!i_state->get()->parent) continue; string event = "done.state." + i_state->get()->parent->id; events.push_back(event); } + + // If parallel have a final child, the parallel state must have a done event also + if (sc.using_final && sc.using_parallel && i_state->get()->type && *i_state->get()->type == "parallel") { + string event = "done.state." + i_state->get()->id; + events.push_back(event); + } + + // Transition events for (scxml_parser::transition_list::const_iterator i_trans = i_state->get()->transitions.begin(); i_trans != i_state->get()->transitions.end(); ++i_trans) { for(scxml_parser::slist::const_iterator i_event = i_trans->get()->event.begin(); i_event != i_trans->get()->event.end(); ++i_event) { events.push_back(*i_event); diff --git a/src/test/all-tests.h b/src/test/all-tests.h index e8c8bee..35bb9e2 100644 --- a/src/test/all-tests.h +++ b/src/test/all-tests.h @@ -365,6 +365,8 @@ TEST(lcca_parallel, 0) EXPECT_EQ(typeid(sc_lcca_parallel::state_A1), typeid(*sc.cur_state[2])); } +// This sc could not build because of a missing event in state +// Just test that this builds and can be instantiated. TEST(issue_69, 0) { sc_issue_69 sc; From 349bcdfd8101d7e861fdb5135275ceeb79c8348a Mon Sep 17 00:00:00 2001 From: Jan Pedersen Date: Thu, 27 Sep 2018 13:23:46 +0200 Subject: [PATCH 3/4] add new test to vs --- src/vc2013/test/test.vcxproj | 12 ++++++++++++ src/vc2013/test/test.vcxproj.filters | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/vc2013/test/test.vcxproj b/src/vc2013/test/test.vcxproj index c286a5a..de11ccc 100644 --- a/src/vc2013/test/test.vcxproj +++ b/src/vc2013/test/test.vcxproj @@ -324,6 +324,18 @@ $(OutDir)scxmlcc.exe %(RelativeDir)%(Filename).scxml scxmlcc %(FullPath) false + + Designer + Document + $(OutDir)scxmlcc.exe %(RelativeDir)%(Filename)%(Extension) + %(RelativeDir)%(Filename).h + $(OutDir)scxmlcc.exe %(RelativeDir)%(Filename)%(Extension) + %(RelativeDir)%(Filename).h + scxmlcc %(FullPath) + false + scxmlcc %(FullPath) + false + diff --git a/src/vc2013/test/test.vcxproj.filters b/src/vc2013/test/test.vcxproj.filters index 329c7b4..f30815c 100644 --- a/src/vc2013/test/test.vcxproj.filters +++ b/src/vc2013/test/test.vcxproj.filters @@ -71,5 +71,8 @@ Source Files + + Source Files + From 61dc4cff36915df884085852cb06ca93e52e90b2 Mon Sep 17 00:00:00 2001 From: Jan Pedersen Date: Thu, 27 Sep 2018 13:35:29 +0200 Subject: [PATCH 4/4] add test to cmake --- src/test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 629346f..adb254b 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -29,6 +29,7 @@ scxmlcc_generator( ${CMAKE_CURRENT_SOURCE_DIR}/event_list.scxml gen_src ) scxmlcc_generator( ${CMAKE_CURRENT_SOURCE_DIR}/event_tokens.scxml gen_src ) scxmlcc_generator( ${CMAKE_CURRENT_SOURCE_DIR}/conditional.scxml gen_src ) scxmlcc_generator( ${CMAKE_CURRENT_SOURCE_DIR}/lcca_parallel.scxml gen_src ) +scxmlcc_generator( ${CMAKE_CURRENT_SOURCE_DIR}/issue_69.scxml gen_src ) add_executable( test_scxml ${gen_src}