jp-embedded / scxmlcc

The SCXML state machine to C++ compiler
GNU General Public License v3.0
138 stars 34 forks source link

Add _event system variable if string events enabled #87

Closed sstiller closed 5 years ago

sstiller commented 5 years ago

Adding variable _event https://www.w3.org/TR/scxml/#SystemVariables with the contents name and data. https://www.w3.org/TR/scxml/#InternalStructureofEvents _event.name contains the event name as std::string _event.data is a boost::any (new dependency)

The support for _event currently only works for string events. _event.data could be added to the other version of dispatch() later.

_event.data is really great to update the data model in scxml or for guard conditions for transitions.

jp-embedded commented 5 years ago

Great addition ☺️

I would prefer to use std:any instead boost:any to have a dependency on c++17 instead of boost

sstiller commented 5 years ago

In my targets I can only use C++14 (too old compilers). Perhaps we can add a compiler switch.

jp-embedded commented 5 years ago

Yes, then both options are available. I think we should make the c++17 option the default because c++17 eventually will become more and more common. Also, we already have the c++17 dependency when using the --threadsafe option, where boost is a new one.

sstiller commented 5 years ago

Would you prefer

Or do you have another idea?

jp-embedded commented 5 years ago

I think I prefer a 'use boost instead c++17' option rather than using the ifdef, because its a matter of using/not using an external library more than enabling/disabling a feature that requires c++17

Also, it could end up with a lot of ifdefs with the other method because the threadsafe option has the same issue which also requires c++17 (this could also be implemented with boost as an alternative)

jp-embedded commented 5 years ago

Thanks a lot :-)