Closed sstiller closed 5 years ago
I would really prefer to have these includes embedded in the scxml file to make them self contained and not depend on specific parameters
An example of what I had in mind regarding this:
<scxml initial="hello" version="0.9" xmlns="http://www.w3.org/2005/07/scxml">
<script>
#include "someheader.h"
bool some_helper_func() { ... }
</script>
<state id="hello">
<transition target="world"></transition>
</state>
<state id="world"></state>
</scxml>
This would give the greatest flexibility.
This might be pushing the standard a bit, depending on how you define 'load time' in a compiled SM:
The SCXML Processor must evaluate any
<script>
element that is a child of<scxml>
at document load time. It must evaluate all other<script>
elements as part of normal executable content evaluation.
Another way could be the 'Qt' way: https://doc.qt.io/qt-5.11/qtscxml-mediaplayer-qml-cppdatamodel-mediaplayer-cppdatamodel-scxml.html, but this is much more strict.
You are right, it would be great do add the #include
into the scxml.
I don't like the Qt version, your example is much more obvious.
My interpretation of 'document load time' fits this. For a compiled SM, the 'document load time' is at the time in which it was compiled :)
It's nice if you want to use something from different libraries in
<script>
or add user defined data types to the data model. This PR may close #63