Permalink
Browse files

Merge pull request #70 from jp-embedded/issue-69

Fix #69
  • Loading branch information...
jp-embedded committed Sep 28, 2018
2 parents 23e8d68 + 61dc4cf commit b4edd16039bb6cf5efaf463eed7d079493e33df4
View
@@ -601,11 +601,21 @@ void cpp_output::gen_state_base()
// collect events
vector<string> 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);
View
@@ -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}
View
@@ -365,4 +365,12 @@ 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;
sc.init();
}
#endif
View
@@ -0,0 +1,30 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" binding="early" initial="P1">
<parallel id="P1">
<state id="P1S1">
<onentry/>
<onexit/>
<state id="P1S11">
<onentry/>
<transition type="external" event="ev" target="P1S11"/>
</state>
</state>
<state id="P1S2">
<onentry/>
<state id="P1S21">
<onentry/>
<onexit/>
<transition type="external" event="ev" target="Final"/>
</state>
<onexit/>
<final id="Final">
</final>
</state>
<onentry/>
<transition type="external" event="ev2" target="S1">
</transition>
<onexit/>
</parallel>
<state id="S1">
<onentry/>
</state>
</scxml>
View
@@ -18,6 +18,8 @@
#include "conditional.h"
#include "../examples/timer_switch.h"
#include "lcca_parallel.h"
#include "issue_69.h"
#include <gtest/gtest.h>
#include <thread>
#include <chrono>
@@ -324,6 +324,18 @@ $(OutDir)scxmlcc.exe %(RelativeDir)%(Filename).scxml</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">scxmlcc %(FullPath)</Message>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
</CustomBuild>
<CustomBuild Include="..\..\test\issue_69.scxml">
<SubType>Designer</SubType>
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)scxmlcc.exe %(RelativeDir)%(Filename)%(Extension)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(RelativeDir)%(Filename).h</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)scxmlcc.exe %(RelativeDir)%(Filename)%(Extension)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(RelativeDir)%(Filename).h</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">scxmlcc %(FullPath)</Message>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">scxmlcc %(FullPath)</Message>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
@@ -71,5 +71,8 @@
<CustomBuild Include="..\..\test\lcca_parallel.scxml">
<Filter>Source Files</Filter>
</CustomBuild>
<CustomBuild Include="..\..\test\issue_69.scxml">
<Filter>Source Files</Filter>
</CustomBuild>
</ItemGroup>
</Project>

0 comments on commit b4edd16

Please sign in to comment.