summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/uscxml/transform/ChartToC.cpp329
-rw-r--r--src/uscxml/transform/ChartToC.h3
-rw-r--r--src/uscxml/transform/ChartToVHDL.cpp3
-rw-r--r--test/src/test-c-machine.machine.c445
-rw-r--r--test/w3c/run_generated_test.cmake58
6 files changed, 322 insertions, 518 deletions
diff --git a/README.md b/README.md
index 6e29edd..b8f668c 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@ for SCXML documents and currently implements the following features:
* [Flattened SCXML documents](https://github.com/tklab-tud/uscxml/blob/master/src/uscxml/transform/ChartToFlatSCXML.cpp) in which only a single state is ever active
* Resulting documents require slight adaptations to a compliant interpreter for donedata, the <tt>In</tt> predicate and invokers.
* Semantic equivalence is shown via IRP tests.
- * [C native code](https://github.com/tklab-tud/uscxml/blob/master/src/uscxml/transform/ChartToC.cpp) for easy embedding of SCXML state-charts in C and C++ programs
+ * [ANSI C native code](https://github.com/tklab-tud/uscxml/blob/master/src/uscxml/transform/ChartToC.cpp) for easy embedding of SCXML state-charts in C and C++ programs
* No invokers are implemented at the moment and only a single SCXML state-chart can be given in a given document.
* [PROMELA programs](https://github.com/tklab-tud/uscxml/blob/master/src/uscxml/transform/ChartToPromela.cpp) for model-checking via linear temporal logic with the SPIN model-checker.
* Only defined for the <tt>promela</tt> and <tt>null</tt> datamodel.
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index eb462a1..a105f93 100644
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -48,7 +48,7 @@ ChartToC::ChartToC(const Interpreter& other) : TransformerImpl() {
cloneFrom(other.getImpl());
}
-void ChartToC::setHistoryResponsibility() {
+void ChartToC::setHistoryCompletion() {
std::set<std::string> elements;
elements.insert(_nsInfo.xmlNSPrefix + "history");
Arabica::XPath::NodeSet<std::string> histories = inPostFixOrder(elements, _scxml);
@@ -73,7 +73,7 @@ void ChartToC::setHistoryResponsibility() {
continue;
if (isDescendant(_states[j], history.getParentNode()) && isHistory(Element<std::string>(_states[j]))) {
- history.setAttribute("hasNestedHistory", "true");
+ history.setAttribute("hasHistoryChild", "yes");
}
if (isMember(_states[j], covered))
@@ -91,18 +91,15 @@ void ChartToC::setHistoryResponsibility() {
}
perParentcovered.push_back(completion);
- std::string respBools;
- std::string respBoolsIdx;
+ std::string completionBools;
for (size_t j = 0; j < _states.size(); j++) {
if (isMember(_states[j], completion)) {
- respBools += "1";
- respBoolsIdx += " " + toStr(j);
+ completionBools += "1";
} else {
- respBools += "0";
+ completionBools += "0";
}
}
- history.setAttribute("respBools", respBools);
- history.setAttribute("respBoolsIdx", respBoolsIdx);
+ history.setAttribute("completionBools", completionBools);
}
}
@@ -172,6 +169,57 @@ void ChartToC::resortStates(Arabica::DOM::Node<std::string>& node) {
}
+void ChartToC::setStateCompletion() {
+ setHistoryCompletion();
+
+ for (size_t i = 0; i < _states.size(); i++) {
+ Element<std::string> state(_states[i]);
+
+ if (isHistory(state)) {
+ // we already did in setHistoryCompletion
+ continue;
+ }
+
+ NodeSet<std::string> completion;
+
+ if (isParallel(state)) {
+ completion = getChildStates(state);
+
+ } else if (state.hasAttribute("initial")) {
+ completion = getStates(tokenizeIdRefs(state.getAttribute("initial")));
+
+ } else {
+ NodeSet<std::string> initElems = filterChildElements(_nsInfo.xmlNSPrefix + "initial", state);
+ if(initElems.size() > 0 && !iequals(ATTR_CAST(initElems[0], "generated"), "true")) {
+ // initial element is first child
+ completion.push_back(initElems[0]);
+ } else {
+ // first child state
+ Arabica::XPath::NodeSet<std::string> initStates;
+ NodeList<std::string> childs = state.getChildNodes();
+ for (size_t i = 0; i < childs.getLength(); i++) {
+ if (childs.item(i).getNodeType() != Node_base::ELEMENT_NODE)
+ continue;
+ if (isState(Element<std::string>(childs.item(i)))) {
+ completion.push_back(childs.item(i));
+ break;
+ }
+ }
+ }
+ }
+
+ std::string completionBools;
+ for (size_t j = 0; j < _states.size(); j++) {
+ if (isMember(_states[j], completion)) {
+ completionBools += "1";
+ } else {
+ completionBools += "0";
+ }
+ }
+ state.setAttribute("completionBools", completionBools);
+ }
+}
+
void ChartToC::prepare() {
_binding = (HAS_ATTR(_scxml, "binding") && iequals(ATTR(_scxml, "binding"), "late") ? LATE : EARLY);
_name = (HAS_ATTR(_scxml, "name") ? ATTR(_scxml, "name") : "");
@@ -189,28 +237,118 @@ void ChartToC::prepare() {
elements.insert(_nsInfo.xmlNSPrefix + "parallel");
_states = inDocumentOrder(elements, _scxml);
+ // set states' document order and parent attribute
for (size_t i = 0; i < _states.size(); i++) {
Element<std::string> state(_states[i]);
state.setAttribute("documentOrder", toStr(i));
+ if (state.getParentNode().getNodeType() == Node_base::ELEMENT_NODE &&
+ HAS_ATTR_CAST(state.getParentNode(), "documentOrder")) {
+ state.setAttribute("parent", ATTR_CAST(state.getParentNode(), "documentOrder"));
+ }
+
+ // set the states' children and whether it has a history
+ std::string childBools;
+ bool hasHistoryChild = false;
+ for (size_t j = 0; j < _states.size(); j++) {
+ if (_states[j].getParentNode() == state) {
+ if (isHistory(Element<std::string>(_states[j]))) {
+ hasHistoryChild = true;
+ }
+ childBools += "1";
+ } else {
+ childBools += "0";
+ }
+ }
+ state.setAttribute("childBools", childBools);
+ if (hasHistoryChild) {
+ state.setAttribute("hasHistoryChild", "yes");
+ }
+
+ // ancestors
+ std::string ancBools;
+ for (size_t j = 0; j < _states.size(); j++) {
+ if (isDescendant(state, _states[j])) {
+ ancBools += "1";
+ } else {
+ ancBools += "0";
+ }
+ }
+ state.setAttribute("ancBools", ancBools);
+
}
+ // set transitions' document order and source attribute
elements.clear();
elements.insert(_nsInfo.xmlNSPrefix + "transition");
_transitions = inDocumentOrder(elements, _scxml);
for (size_t i = 0; i < _transitions.size(); i++) {
Element<std::string> transition(_transitions[i]);
transition.setAttribute("documentOrder", toStr(i));
+ if (transition.getParentNode().getNodeType() == Node_base::ELEMENT_NODE &&
+ HAS_ATTR_CAST(transition.getParentNode(), "documentOrder")) {
+ transition.setAttribute("source", ATTR_CAST(transition.getParentNode(), "documentOrder"));
+ }
}
+ // set transitions' postfix order attribute
_transitions = inPostFixOrder(elements, _scxml);
for (size_t i = 0; i < _transitions.size(); i++) {
Element<std::string> transition(_transitions[i]);
transition.setAttribute("postFixOrder", toStr(i));
+
+ // and exit set
+ std::string exitSetBools;
+ NodeSet<std::string> exitSet = computeExitSet(transition);
+ for (unsigned int j = 0; j < _states.size(); j++) {
+ Element<std::string> state(_states[j]);
+ if (isMember(state, exitSet)) {
+ exitSetBools += "1";
+ } else {
+ exitSetBools += "0";
+ }
+ }
+ transition.setAttribute("exitSetBools", exitSetBools);
+
+ // and conflicts
+ std::string conflictBools;
+ for (unsigned int j = 0; j < _transitions.size(); j++) {
+ Element<std::string> t2(_transitions[j]);
+ if (hasIntersection(computeExitSet(transition), computeExitSet(t2)) ||
+ (getSourceState(transition) == getSourceState(t2)) ||
+ (isDescendant(getSourceState(transition), getSourceState(t2))) ||
+ (isDescendant(getSourceState(t2), getSourceState(transition)))) {
+ conflictBools += "1";
+ } else {
+ conflictBools += "0";
+ }
+ }
+ transition.setAttribute("conflictBools", conflictBools);
+
+ // and target
+ if (HAS_ATTR(transition, "target")) {
+ std::list<std::string> targets = tokenize(ATTR(transition, "target"));
+
+ std::string targetBools;
+ for (size_t j = 0; j < _states.size(); j++) {
+ Element<std::string> state(_states[j]);
+
+ if (HAS_ATTR(state, "id") &&
+ std::find(targets.begin(), targets.end(), escape(ATTR(state, "id"))) != targets.end()) {
+ targetBools += "1";
+ } else {
+ targetBools += "0";
+ }
+ }
+ transition.setAttribute("targetBools", targetBools);
+
+ }
}
// leave transitions in postfix order
- // set the responsibility of history elements
- setHistoryResponsibility();
+
+
+ // set the completion of states and responsibility of history elements
+ setStateCompletion();
// how many bits do we need to represent the state array?
std::string seperator;
@@ -1081,6 +1219,7 @@ void ChartToC::writeStates(std::ostream& stream) {
stream << "static const scxml_state scxml_states[" << toStr(_states.size()) << "] = {" << std::endl;
for (size_t i = 0; i < _states.size(); i++) {
Element<std::string> state(_states[i]);
+
stream << " { /* state number " << toStr(i) << " */" << std::endl;
// name
@@ -1109,97 +1248,25 @@ void ChartToC::writeStates(std::ostream& stream) {
stream << "," << std::endl;
// children
- bool hasHistoryChild = false;
- std::string childBools;
- std::string childBoolsIdx;
- for (size_t j = 0; j < _states.size(); j++) {
- if (_states[j].getParentNode() == state) {
- if (isHistory(Element<std::string>(_states[j]))) {
- hasHistoryChild = true;
- }
- childBools += "1";
- childBoolsIdx += " " + toStr(j);
- } else {
- childBools += "0";
- }
- }
stream << " /* children */ { ";
- writeCharArrayInitList(stream, childBools);
- stream << " /* " << childBools << "," << childBoolsIdx << " */";
- stream << " }," << std::endl;
+ writeCharArrayInitList(stream, ATTR(state, "childBools"));
+ stream << " /* " << ATTR(state, "childBools") << " */ }," << std::endl;
// default completion
- std::string descBools;
- std::string descBoolsIdx;
-
- NodeSet<std::string> completion;
- if (isHistory(state)) {
- // we already precalculated everything
- descBools = ATTR(state, "respBools");
- descBoolsIdx = ATTR(state, "respBoolsIdx");
- hasHistoryChild = HAS_ATTR(state, "hasNestedHistory");
- goto WRITE_COMPLETION;
- }
- if (isParallel(state)) {
- completion = getChildStates(state);
- } else if (state.hasAttribute("initial")) {
- completion = getStates(tokenizeIdRefs(state.getAttribute("initial")));
- } else {
- NodeSet<std::string> initElems = filterChildElements(_nsInfo.xmlNSPrefix + "initial", state);
- if(initElems.size() > 0 && !iequals(ATTR_CAST(initElems[0], "generated"), "true")) {
- // initial element is first child
- completion.push_back(initElems[0]);
- } else {
- // first child state
- Arabica::XPath::NodeSet<std::string> initStates;
- NodeList<std::string> childs = state.getChildNodes();
- for (size_t i = 0; i < childs.getLength(); i++) {
- if (childs.item(i).getNodeType() != Node_base::ELEMENT_NODE)
- continue;
- if (isState(Element<std::string>(childs.item(i)))) {
- completion.push_back(childs.item(i));
- break;
- }
- }
- }
- }
-
- for (size_t j = 0; j < _states.size(); j++) {
- if (isMember(_states[j], completion)) {
- descBools += "1";
- descBoolsIdx += " " + toStr(j);
- } else {
- descBools += "0";
- }
- }
-WRITE_COMPLETION:
-
stream << " /* completion */ { ";
- writeCharArrayInitList(stream, descBools);
- stream << " /* " << descBools << "," << descBoolsIdx << " */";
- stream << " }, \t" << std::endl;
+ writeCharArrayInitList(stream, ATTR(state, "completionBools"));
+ stream << " /* " << ATTR(state, "completionBools") << " */ }, \t" << std::endl;
- // ancestors
- std::string ancBools;
- std::string ancBoolsIdx;
- for (size_t j = 0; j < _states.size(); j++) {
- if (isDescendant(state, _states[j])) {
- ancBools += "1";
- ancBoolsIdx += " " + toStr(j);
- } else {
- ancBools += "0";
- }
- }
stream << " /* ancestors */ { ";
- writeCharArrayInitList(stream, ancBools);
- stream << " /* " << ancBools << "," << ancBoolsIdx << " */";
- stream << " }," << std::endl;
+ writeCharArrayInitList(stream, ATTR(state, "ancBools"));
+ stream << " /* " << ATTR(state, "ancBools") << " */ }," << std::endl;
stream << " /* data */ ";
stream << (HAS_ATTR(state, "dataIndex") ? "&scxml_elem_datas[" + escape(ATTR(state, "dataIndex")) + "]" : "NULL");
stream << "," << std::endl;
stream << " /* type */ ";
+
if (false) {
} else if (iequals(TAGNAME(state), "initial")) {
stream << "SCXML_STATE_INITIAL";
@@ -1220,7 +1287,7 @@ WRITE_COMPLETION:
} else { // <scxml>
stream << "SCXML_STATE_COMPOUND";
}
- if (hasHistoryChild) {
+ if (HAS_ATTR(state, "hasHistoryChild")) {
stream << " | SCXML_STATE_HAS_HISTORY";
}
@@ -1240,25 +1307,10 @@ void ChartToC::writeTransitions(std::ostream& stream) {
elements.insert(_nsInfo.xmlNSPrefix + "transition");
NodeSet<std::string> transDocOrder = inDocumentOrder(elements, _scxml);
- std::stringstream transDocOrderSS;
- std::string seperator = "";
- for (size_t i = 0; i < transDocOrder.size(); i++) {
- Element<std::string> transition(_transitions[i]);
- transition.setAttribute("documentOrder", toStr(i));
- transDocOrderSS << seperator << ATTR(transition, "postFixOrder");
- seperator = ", ";
- }
-
-#if 0
- stream << "static const " << _transDataType << " scxml_transitions_doc_order[" << toStr(_transitions.size()) << "] = {" << std::endl;
- stream << " " << transDocOrderSS;
- stream << std::endl << "};" << std::endl;
- stream << std::endl;
-#endif
-
stream << "static const scxml_transition scxml_transitions[" << toStr(_transitions.size()) << "] = {" << std::endl;
for (size_t i = 0; i < _transitions.size(); i++) {
Element<std::string> transition(_transitions[i]);
+
stream << " { /* transition number " << ATTR(transition, "documentOrder") << " with priority " << toStr(i) << std::endl;
stream << " target: " << ATTR(transition, "target") << std::endl;
stream << " */" << std::endl;
@@ -1281,27 +1333,10 @@ void ChartToC::writeTransitions(std::ostream& stream) {
// targets
stream << " /* target */ ";
- if (HAS_ATTR(transition, "target")) {
- std::list<std::string> targets = tokenize(ATTR(transition, "target"));
-
- std::string targetBools;
- std::string targetBoolsIdx;
- for (size_t j = 0; j < _states.size(); j++) {
- Element<std::string> state(_states[j]);
-
- if (HAS_ATTR(state, "id") &&
- std::find(targets.begin(), targets.end(), escape(ATTR(state, "id"))) != targets.end()) {
- targetBools += "1";
- targetBoolsIdx += " " + toStr(j);
- } else {
- targetBools += "0";
- }
- }
-
+ if (HAS_ATTR(transition, "targetBools")) {
stream << "{ ";
- writeCharArrayInitList(stream, targetBools);
- stream << " /* " << targetBools << "," << targetBoolsIdx << " */";
- stream << " }";
+ writeCharArrayInitList(stream, ATTR(transition, "targetBools"));
+ stream << " /* " << ATTR(transition, "targetBools") << " */ }";
} else {
stream << "{ NULL }";
@@ -1318,8 +1353,7 @@ void ChartToC::writeTransitions(std::ostream& stream) {
// on transition handlers
stream << " /* ontrans */ ";
- if (filterChildType(Arabica::DOM::Node_base::ELEMENT_NODE, transition).size() > 0 /* &&
- !iequals(TAGNAME_CAST(transition.getParentNode()), "initial") */) {
+ if (filterChildType(Arabica::DOM::Node_base::ELEMENT_NODE, transition).size() > 0) {
stream << DOMUtils::idForNode(transition) + "_on_trans";
} else {
stream << "NULL";
@@ -1360,43 +1394,14 @@ void ChartToC::writeTransitions(std::ostream& stream) {
stream << "," << std::endl;
// conflicts
- std::string conflictBools;
- std::string conflictBoolsIdx;
- for (unsigned int j = 0; j < _transitions.size(); j++) {
- Element<std::string> t2(_transitions[j]);
- if (hasIntersection(computeExitSet(transition), computeExitSet(t2)) ||
- (getSourceState(transition) == getSourceState(t2)) ||
- (isDescendant(getSourceState(transition), getSourceState(t2))) ||
- (isDescendant(getSourceState(t2), getSourceState(transition)))) {
- conflictBools += "1";
- conflictBoolsIdx += " " + toStr(j);
- } else {
- conflictBools += "0";
- }
- }
stream << " /* conflicts */ { ";
- writeCharArrayInitList(stream, conflictBools);
- stream << " /* " << conflictBools << "," << conflictBoolsIdx << " */";
- stream << " }, " << std::endl;
+ writeCharArrayInitList(stream, ATTR(transition, "conflictBools"));
+ stream << " /* " << ATTR(transition, "conflictBools") << " */ }, " << std::endl;
// exit set
- std::string exitSetBools;
- std::string exitSetBoolsIdx;
- NodeSet<std::string> exitSet = computeExitSet(transition);
- for (unsigned int j = 0; j < _states.size(); j++) {
- Element<std::string> state(_states[j]);
- if (isMember(state, exitSet)) {
- exitSetBools += "1";
- exitSetBoolsIdx += " " + toStr(j);
- } else {
- exitSetBools += "0";
- }
- }
stream << " /* exit set */ { ";
- writeCharArrayInitList(stream, exitSetBools);
- stream << " /* " << exitSetBools << "," << exitSetBoolsIdx << " */";
-
- stream << " }" << std::endl;
+ writeCharArrayInitList(stream, ATTR(transition, "exitSetBools"));
+ stream << " /* " << ATTR(transition, "exitSetBools") << " */ }" << std::endl;
stream << " }" << (i + 1 < _transitions.size() ? ",": "") << std::endl;
}
diff --git a/src/uscxml/transform/ChartToC.h b/src/uscxml/transform/ChartToC.h
index 20713ca..039e8a4 100644
--- a/src/uscxml/transform/ChartToC.h
+++ b/src/uscxml/transform/ChartToC.h
@@ -72,7 +72,8 @@ protected:
Arabica::XPath::NodeSet<std::string> computeExitSet(const Arabica::DOM::Element<std::string>& transition);
void resortStates(Arabica::DOM::Node<std::string>& node);
- void setHistoryResponsibility();
+ void setHistoryCompletion();
+ void setStateCompletion();
void prepare();
Interpreter interpreter;
diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp
index bcff51f..d5bbac3 100644
--- a/src/uscxml/transform/ChartToVHDL.cpp
+++ b/src/uscxml/transform/ChartToVHDL.cpp
@@ -116,8 +116,7 @@ void ChartToVHDL::findEvents() {
void ChartToVHDL::writeTo(std::ostream& stream) {
// same preparations as the C transformation
-// annotateElementSets();
-
+ prepare();
// checkDocument();
findEvents();
diff --git a/test/src/test-c-machine.machine.c b/test/src/test-c-machine.machine.c
index cb3cf34..ebacc5f 100644
--- a/test/src/test-c-machine.machine.c
+++ b/test/src/test-c-machine.machine.c
@@ -25,8 +25,8 @@
#define SCXML_ERR_UNSUPPORTED 8
#define SCXML_MACHINE_NAME ""
-#define SCXML_NUMBER_STATES 14
-#define SCXML_NUMBER_TRANSITIONS 10
+#define SCXML_NUMBER_STATES 9
+#define SCXML_NUMBER_TRANSITIONS 6
#define SCXML_TRANS_SPONTANEOUS 0x01
#define SCXML_TRANS_TARGETLESS 0x02
@@ -113,7 +113,7 @@ struct scxml_transition {
const char* condition;
const exec_content_t on_transition;
const uint8_t type;
- const char conflicts[2];
+ const char conflicts[1];
const char exit_set[2];
};
@@ -204,27 +204,16 @@ static const scxml_elem_data scxml_elem_datas[2] = {
{ NULL, NULL, NULL, NULL }
};
-static const scxml_elem_send scxml_elem_sends[1] = {
- {
- /* event */ "timeout",
- /* eventexpr */ NULL,
- /* target */ NULL,
- /* targetexpr */ NULL,
- /* type */ NULL,
- /* typeexpr */ NULL,
- /* id */ NULL,
- /* idlocation */ NULL,
- /* delay */ "2s",
- /* delayexpr */ NULL,
- /* namelist */ NULL,
- /* content */ NULL,
- /* contentexpr */ NULL,
- /* params */ NULL
- }
+static const scxml_elem_param scxml_elem_params[2] = {
+ /* name, expr, location */
+ { "Var1", "1", NULL },
+ { NULL, NULL, NULL }
};
-static const scxml_elem_donedata scxml_elem_donedatas[1] = {
+static const scxml_elem_donedata scxml_elem_donedatas[3] = {
/* source, content, contentexpr, params */
+ { 3, NULL, NULL, &scxml_elem_params[0] },
+ { 6, "foo", NULL, NULL },
{ 0, NULL, NULL, NULL }
};
@@ -232,81 +221,6 @@ static int global_script(const scxml_ctx* ctx, const scxml_state* state, const v
return SCXML_ERR_OK;
}
-static int s0_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_assign != NULL) {
- if ((ctx->exec_content_assign(ctx, "Var1", "Var1 + 1")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static int s0_on_entry(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- s0_on_entry_0(ctx, state, event);
- return SCXML_ERR_OK;
-}
-
-static int s011_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_raise != NULL) {
- if unlikely((ctx->exec_content_raise(ctx, "entering.s011")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static int s011_on_entry(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- s011_on_entry_0(ctx, state, event);
- return SCXML_ERR_OK;
-}
-
-static int s012_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_raise != NULL) {
- if unlikely((ctx->exec_content_raise(ctx, "entering.s012")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static int s012_on_entry(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- s012_on_entry_0(ctx, state, event);
- return SCXML_ERR_OK;
-}
-
-static int s021_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_raise != NULL) {
- if unlikely((ctx->exec_content_raise(ctx, "entering.s021")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static int s021_on_entry(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- s021_on_entry_0(ctx, state, event);
- return SCXML_ERR_OK;
-}
-
-static int s022_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_raise != NULL) {
- if unlikely((ctx->exec_content_raise(ctx, "entering.s022")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static int s022_on_entry(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- s022_on_entry_0(ctx, state, event);
- return SCXML_ERR_OK;
-}
-
static int pass_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
int err = SCXML_ERR_OK;
if likely(ctx->exec_content_log != NULL) {
@@ -337,314 +251,197 @@ static int fail_on_entry(const scxml_ctx* ctx, const scxml_state* state, const v
return SCXML_ERR_OK;
}
-static int s0_transition0_on_trans(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_send != NULL) {
- if ((ctx->exec_content_send(ctx, &scxml_elem_sends[0])) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static const scxml_state scxml_states[14] = {
+static const scxml_state scxml_states[9] = {
{ /* state number 0 */
/* name */ NULL,
/* parent */ 0,
/* onentry */ NULL,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x02, 0x3c /* 01000000001111, 1 10 11 12 13 */ },
- /* completion */ { 0x40, 0x00 /* 00000010000000, 6 */ },
- /* ancestors */ { 0x00, 0x00 /* 00000000000000, */ },
+ /* children */ { 0x92, 0x01 /* 010010011, 1 4 7 8 */ },
+ /* completion */ { 0x02, 0x00 /* 010000000, 1 */ },
+ /* ancestors */ { 0x00, 0x00 /* 000000000, */ },
/* data */ &scxml_elem_datas[0],
/* type */ SCXML_STATE_COMPOUND,
},
{ /* state number 1 */
/* name */ "s0",
/* parent */ 0,
- /* onentry */ s0_on_entry,
+ /* onentry */ NULL,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x9c, 0x00 /* 00111001000000, 2 3 4 7 */ },
- /* completion */ { 0x10, 0x00 /* 00001000000000, 4 */ },
- /* ancestors */ { 0x01, 0x00 /* 10000000000000, 0 */ },
+ /* children */ { 0x0c, 0x00 /* 001100000, 2 3 */ },
+ /* completion */ { 0x04, 0x00 /* 001000000, 2 */ },
+ /* ancestors */ { 0x01, 0x00 /* 100000000, 0 */ },
/* data */ NULL,
- /* type */ SCXML_STATE_COMPOUND | SCXML_STATE_HAS_HISTORY,
+ /* type */ SCXML_STATE_COMPOUND,
},
{ /* state number 2 */
- /* name */ "s0HistDeep",
+ /* name */ "s01",
/* parent */ 1,
/* onentry */ NULL,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0xf0, 0x03 /* 00001111110000, 4 5 6 7 8 9 */ },
- /* ancestors */ { 0x03, 0x00 /* 11000000000000, 0 1 */ },
+ /* children */ { 0x00, 0x00 /* 000000000, */ },
+ /* completion */ { 0x00, 0x00 /* 000000000, */ },
+ /* ancestors */ { 0x03, 0x00 /* 110000000, 0 1 */ },
/* data */ NULL,
- /* type */ SCXML_STATE_HISTORY_DEEP | SCXML_STATE_HAS_HISTORY,
+ /* type */ SCXML_STATE_ATOMIC,
},
{ /* state number 3 */
- /* name */ "s0HistShallow",
+ /* name */ "s02",
/* parent */ 1,
/* onentry */ NULL,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x90, 0x00 /* 00001001000000, 4 7 */ },
- /* ancestors */ { 0x03, 0x00 /* 11000000000000, 0 1 */ },
+ /* children */ { 0x00, 0x00 /* 000000000, */ },
+ /* completion */ { 0x00, 0x00 /* 000000000, */ },
+ /* ancestors */ { 0x03, 0x00 /* 110000000, 0 1 */ },
/* data */ NULL,
- /* type */ SCXML_STATE_HISTORY_SHALLOW | SCXML_STATE_HAS_HISTORY,
+ /* type */ SCXML_STATE_FINAL,
},
{ /* state number 4 */
- /* name */ "s01",
- /* parent */ 1,
+ /* name */ "s1",
+ /* parent */ 0,
/* onentry */ NULL,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x60, 0x00 /* 00000110000000, 5 6 */ },
- /* completion */ { 0x20, 0x00 /* 00000100000000, 5 */ },
- /* ancestors */ { 0x03, 0x00 /* 11000000000000, 0 1 */ },
+ /* children */ { 0x60, 0x00 /* 000001100, 5 6 */ },
+ /* completion */ { 0x20, 0x00 /* 000001000, 5 */ },
+ /* ancestors */ { 0x01, 0x00 /* 100000000, 0 */ },
/* data */ NULL,
/* type */ SCXML_STATE_COMPOUND,
},
{ /* state number 5 */
- /* name */ "s011",
+ /* name */ "s11",
/* parent */ 4,
- /* onentry */ s011_on_entry,
+ /* onentry */ NULL,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x13, 0x00 /* 11001000000000, 0 1 4 */ },
+ /* children */ { 0x00, 0x00 /* 000000000, */ },
+ /* completion */ { 0x00, 0x00 /* 000000000, */ },
+ /* ancestors */ { 0x11, 0x00 /* 100010000, 0 4 */ },
/* data */ NULL,
/* type */ SCXML_STATE_ATOMIC,
},
{ /* state number 6 */
- /* name */ "s012",
+ /* name */ "s12",
/* parent */ 4,
- /* onentry */ s012_on_entry,
- /* onexit */ NULL,
- /* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x13, 0x00 /* 11001000000000, 0 1 4 */ },
- /* data */ NULL,
- /* type */ SCXML_STATE_ATOMIC,
- },
- { /* state number 7 */
- /* name */ "s02",
- /* parent */ 1,
- /* onentry */ NULL,
- /* onexit */ NULL,
- /* invoke */ NULL,
- /* children */ { 0x00, 0x03 /* 00000000110000, 8 9 */ },
- /* completion */ { 0x00, 0x01 /* 00000000100000, 8 */ },
- /* ancestors */ { 0x03, 0x00 /* 11000000000000, 0 1 */ },
- /* data */ NULL,
- /* type */ SCXML_STATE_COMPOUND,
- },
- { /* state number 8 */
- /* name */ "s021",
- /* parent */ 7,
- /* onentry */ s021_on_entry,
- /* onexit */ NULL,
- /* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x83, 0x00 /* 11000001000000, 0 1 7 */ },
- /* data */ NULL,
- /* type */ SCXML_STATE_ATOMIC,
- },
- { /* state number 9 */
- /* name */ "s022",
- /* parent */ 7,
- /* onentry */ s022_on_entry,
- /* onexit */ NULL,
- /* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x83, 0x00 /* 11000001000000, 0 1 7 */ },
- /* data */ NULL,
- /* type */ SCXML_STATE_ATOMIC,
- },
- { /* state number 10 */
- /* name */ "s1",
- /* parent */ 0,
- /* onentry */ NULL,
- /* onexit */ NULL,
- /* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x01, 0x00 /* 10000000000000, 0 */ },
- /* data */ NULL,
- /* type */ SCXML_STATE_ATOMIC,
- },
- { /* state number 11 */
- /* name */ "s2",
- /* parent */ 0,
/* onentry */ NULL,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x01, 0x00 /* 10000000000000, 0 */ },
+ /* children */ { 0x00, 0x00 /* 000000000, */ },
+ /* completion */ { 0x00, 0x00 /* 000000000, */ },
+ /* ancestors */ { 0x11, 0x00 /* 100010000, 0 4 */ },
/* data */ NULL,
- /* type */ SCXML_STATE_ATOMIC,
+ /* type */ SCXML_STATE_FINAL,
},
- { /* state number 12 */
+ { /* state number 7 */
/* name */ "pass",
/* parent */ 0,
/* onentry */ pass_on_entry,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x01, 0x00 /* 10000000000000, 0 */ },
+ /* children */ { 0x00, 0x00 /* 000000000, */ },
+ /* completion */ { 0x00, 0x00 /* 000000000, */ },
+ /* ancestors */ { 0x01, 0x00 /* 100000000, 0 */ },
/* data */ NULL,
/* type */ SCXML_STATE_FINAL,
},
- { /* state number 13 */
+ { /* state number 8 */
/* name */ "fail",
/* parent */ 0,
/* onentry */ fail_on_entry,
/* onexit */ NULL,
/* invoke */ NULL,
- /* children */ { 0x00, 0x00 /* 00000000000000, */ },
- /* completion */ { 0x00, 0x00 /* 00000000000000, */ },
- /* ancestors */ { 0x01, 0x00 /* 10000000000000, 0 */ },
+ /* children */ { 0x00, 0x00 /* 000000000, */ },
+ /* completion */ { 0x00, 0x00 /* 000000000, */ },
+ /* ancestors */ { 0x01, 0x00 /* 100000000, 0 */ },
/* data */ NULL,
/* type */ SCXML_STATE_FINAL,
}
};
-static const scxml_transition scxml_transitions[10] = {
+static const scxml_transition scxml_transitions[6] = {
{ /* transition number 0 with priority 0
- target: s022
+ target: s02
*/
/* source */ 2,
- /* target */ { 0x00, 0x02 /* 00000000010000, 9 */ },
+ /* target */ { 0x08, 0x00 /* 000100000, 3 */ },
/* event */ NULL,
/* condition */ NULL,
/* ontrans */ NULL,
- /* type */ SCXML_TRANS_SPONTANEOUS | SCXML_TRANS_HISTORY,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
+ /* type */ SCXML_TRANS_SPONTANEOUS,
+ /* conflicts */ { 0x37 /* 111011, 0 1 2 4 5 */ },
+ /* exit set */ { 0x0c, 0x00 /* 001100000, 2 3 */ }
},
{ /* transition number 1 with priority 1
- target: s02
- */
- /* source */ 3,
- /* target */ { 0x80, 0x00 /* 00000001000000, 7 */ },
- /* event */ NULL,
- /* condition */ NULL,
- /* ontrans */ NULL,
- /* type */ SCXML_TRANS_SPONTANEOUS | SCXML_TRANS_HISTORY,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
- },
- { /* transition number 2 with priority 2
target: s1
*/
/* source */ 1,
- /* target */ { 0x00, 0x04 /* 00000000001000, 10 */ },
- /* event */ "entering.s012",
- /* condition */ "Var1==1",
- /* ontrans */ s0_transition0_on_trans,
- /* type */ 0,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
- },
- { /* transition number 3 with priority 3
- target: s2
- */
- /* source */ 1,
- /* target */ { 0x00, 0x08 /* 00000000000100, 11 */ },
- /* event */ "entering.s012",
- /* condition */ "Var1==2",
+ /* target */ { 0x10, 0x00 /* 000010000, 4 */ },
+ /* event */ "done.state.s0",
+ /* condition */ "_event.data['Var1']==1",
/* ontrans */ NULL,
/* type */ 0,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
+ /* conflicts */ { 0x3f /* 111111, 0 1 2 3 4 5 */ },
+ /* exit set */ { 0xfe, 0x01 /* 011111111, 1 2 3 4 5 6 7 8 */ }
},
- { /* transition number 4 with priority 4
+ { /* transition number 2 with priority 2
target: fail
*/
/* source */ 1,
- /* target */ { 0x00, 0x20 /* 00000000000001, 13 */ },
- /* event */ "entering",
- /* condition */ "Var1==2",
+ /* target */ { 0x00, 0x01 /* 000000001, 8 */ },
+ /* event */ "done.state.s0",
+ /* condition */ NULL,
/* ontrans */ NULL,
/* type */ 0,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
+ /* conflicts */ { 0x3f /* 111111, 0 1 2 3 4 5 */ },
+ /* exit set */ { 0xfe, 0x01 /* 011111111, 1 2 3 4 5 6 7 8 */ }
},
- { /* transition number 5 with priority 5
- target: pass
+ { /* transition number 3 with priority 3
+ target: s12
*/
- /* source */ 1,
- /* target */ { 0x00, 0x10 /* 00000000000010, 12 */ },
- /* event */ "entering.s011",
- /* condition */ "Var1==3",
+ /* source */ 5,
+ /* target */ { 0x40, 0x00 /* 000000100, 6 */ },
+ /* event */ NULL,
+ /* condition */ NULL,
/* ontrans */ NULL,
- /* type */ 0,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
+ /* type */ SCXML_TRANS_SPONTANEOUS,
+ /* conflicts */ { 0x3e /* 011111, 1 2 3 4 5 */ },
+ /* exit set */ { 0x60, 0x00 /* 000001100, 5 6 */ }
},
- { /* transition number 6 with priority 6
- target: fail
+ { /* transition number 4 with priority 4
+ target: pass
*/
- /* source */ 1,
- /* target */ { 0x00, 0x20 /* 00000000000001, 13 */ },
- /* event */ "entering",
- /* condition */ "Var1==3",
+ /* source */ 4,
+ /* target */ { 0x80, 0x00 /* 000000010, 7 */ },
+ /* event */ "done.state.s1",
+ /* condition */ "_event.data == 'foo'",
/* ontrans */ NULL,
/* type */ 0,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
+ /* conflicts */ { 0x3f /* 111111, 0 1 2 3 4 5 */ },
+ /* exit set */ { 0xfe, 0x01 /* 011111111, 1 2 3 4 5 6 7 8 */ }
},
- { /* transition number 7 with priority 7
+ { /* transition number 5 with priority 5
target: fail
*/
- /* source */ 1,
- /* target */ { 0x00, 0x20 /* 00000000000001, 13 */ },
- /* event */ "timeout",
+ /* source */ 4,
+ /* target */ { 0x00, 0x01 /* 000000001, 8 */ },
+ /* event */ "done.state.s1",
/* condition */ NULL,
/* ontrans */ NULL,
/* type */ 0,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
- },
- { /* transition number 8 with priority 8
- target: s0HistDeep
- */
- /* source */ 10,
- /* target */ { 0x04, 0x00 /* 00100000000000, 2 */ },
- /* event */ NULL,
- /* condition */ NULL,
- /* ontrans */ NULL,
- /* type */ SCXML_TRANS_SPONTANEOUS,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
- },
- { /* transition number 9 with priority 9
- target: s0HistShallow
- */
- /* source */ 11,
- /* target */ { 0x08, 0x00 /* 00010000000000, 3 */ },
- /* event */ NULL,
- /* condition */ NULL,
- /* ontrans */ NULL,
- /* type */ SCXML_TRANS_SPONTANEOUS,
- /* conflicts */ { 0xff, 0x03 /* 1111111111, 0 1 2 3 4 5 6 7 8 9 */ },
- /* exit set */ { 0xfe, 0x3f /* 01111111111111, 1 2 3 4 5 6 7 8 9 10 11 12 13 */ }
+ /* conflicts */ { 0x3f /* 111111, 0 1 2 3 4 5 */ },
+ /* exit set */ { 0xfe, 0x01 /* 011111111, 1 2 3 4 5 6 7 8 */ }
}
};
#ifdef SCXML_VERBOSE
static void printStateNames(const char* a) {
+ size_t i;
const char* seperator = "";
- for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (i = 0; i < SCXML_NUMBER_STATES; i++) {
if (BIT_HAS(i, a)) {
printf("%s%s", seperator, (scxml_states[i].name != NULL ? scxml_states[i].name : "UNK"));
seperator = ", ";
@@ -654,8 +451,9 @@ static void printStateNames(const char* a) {
}
static void printBitsetIndices(const char* a, size_t length) {
+ size_t i;
const char* seperator = "";
- for (size_t i = 0; i < length; i++) {
+ for (i = 0; i < length; i++) {
if (BIT_HAS(i, a)) {
printf("%s%lu", seperator, i);
seperator = ", ";
@@ -668,17 +466,17 @@ static void printBitsetIndices(const char* a, size_t length) {
static int bit_has_and(const char* a, const char* b, size_t i) {
do {
if (a[i - 1] & b[i - 1])
- return true;
+ return 1;
} while(--i);
- return false;
+ return 0;
}
static int bit_has_any(const char* a, size_t i) {
do {
if (a[i - 1] > 0)
- return true;
+ return 1;
} while(--i);
- return false;
+ return 0;
}
static void bit_or(char* dest, const char* mask, size_t i) {
@@ -717,11 +515,12 @@ int scxml_step(scxml_ctx* ctx) {
if (ctx->flags & SCXML_CTX_TOP_LEVEL_FINAL)
return SCXML_ERR_DONE;
+ size_t i, j, k;
int err = SCXML_ERR_OK;
- char conflicts[2] = {0, 0};
+ char conflicts[1] = {0};
char target_set[2] = {0, 0};
char exit_set[2] = {0, 0};
- char trans_set[2] = {0, 0};
+ char trans_set[1] = {0};
char entry_set[2] = {0, 0};
char tmp_states[2] = {0, 0};
@@ -744,7 +543,7 @@ int scxml_step(scxml_ctx* ctx) {
}
SELECT_TRANSITIONS:
- for (size_t i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
+ for (i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
// never select history or initial transitions automatically
if unlikely(scxml_transitions[i].type & (SCXML_TRANS_HISTORY | SCXML_TRANS_INITIAL))
continue;
@@ -759,7 +558,7 @@ SELECT_TRANSITIONS:
ctx->flags |= SCXML_CTX_TRANSITION_FOUND;
// transitions that are pre-empted
- bit_or(conflicts, scxml_transitions[i].conflicts, 2);
+ bit_or(conflicts, scxml_transitions[i].conflicts, 1);
// states that are directly targeted (resolve as entry-set later)
bit_or(target_set, scxml_transitions[i].target, 2);
@@ -797,7 +596,7 @@ SELECT_TRANSITIONS:
#endif
// REMEMBER_HISTORY:
- for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (i = 0; i < SCXML_NUMBER_STATES; i++) {
if unlikely(SCXML_STATE_MASK(scxml_states[i].type) == SCXML_STATE_HISTORY_SHALLOW ||
SCXML_STATE_MASK(scxml_states[i].type) == SCXML_STATE_HISTORY_DEEP) {
// a history state whose parent is about to be exited
@@ -821,14 +620,14 @@ ESTABLISH_ENTRY_SET:
bit_copy(entry_set, target_set, 2);
// iterate for ancestors
- for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (i = 0; i < SCXML_NUMBER_STATES; i++) {
if (BIT_HAS(i, entry_set)) {
bit_or(entry_set, scxml_states[i].ancestors, 2);
}
}
// iterate for descendants
- for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (i = 0; i < SCXML_NUMBER_STATES; i++) {
if (BIT_HAS(i, entry_set)) {
switch (SCXML_STATE_MASK(scxml_states[i].type)) {
case SCXML_STATE_PARALLEL: {
@@ -840,12 +639,12 @@ ESTABLISH_ENTRY_SET:
if (!bit_has_and(scxml_states[i].completion, ctx->history, 2) &&
!BIT_HAS(scxml_states[i].parent, ctx->config)) {
// nothing set for history, look for a default transition
- for (size_t j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
+ for (j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
if unlikely(scxml_transitions[j].source == i) {
bit_or(entry_set, scxml_transitions[j].target, 2);
if(SCXML_STATE_MASK(scxml_states[i].type) == SCXML_STATE_HISTORY_DEEP &&
!bit_has_and(scxml_transitions[j].target, scxml_states[i].children, 2)) {
- for (size_t k = i + 1; k < SCXML_NUMBER_STATES; k++) {
+ for (k = i + 1; k < SCXML_NUMBER_STATES; k++) {
if (BIT_HAS(k, scxml_transitions[j].target)) {
bit_or(entry_set, scxml_states[k].ancestors, 2);
break;
@@ -863,11 +662,11 @@ ESTABLISH_ENTRY_SET:
bit_or(entry_set, tmp_states, 2);
if (scxml_states[i].type == (SCXML_STATE_HAS_HISTORY | SCXML_STATE_HISTORY_DEEP)) {
// a deep history state with nested histories -> more completion
- for (size_t j = i + 1; j < SCXML_NUMBER_STATES; j++) {
+ for (j = i + 1; j < SCXML_NUMBER_STATES; j++) {
if (BIT_HAS(j, scxml_states[i].completion) &&
BIT_HAS(j, entry_set) &&
(scxml_states[j].type & SCXML_STATE_HAS_HISTORY)) {
- for (size_t k = j + 1; k < SCXML_NUMBER_STATES; k++) {
+ for (k = j + 1; k < SCXML_NUMBER_STATES; k++) {
// add nested history to entry_set
if ((SCXML_STATE_MASK(scxml_states[k].type) == SCXML_STATE_HISTORY_DEEP ||
SCXML_STATE_MASK(scxml_states[k].type) == SCXML_STATE_HISTORY_SHALLOW) &&
@@ -883,12 +682,12 @@ ESTABLISH_ENTRY_SET:
break;
}
case SCXML_STATE_INITIAL: {
- for (size_t j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
+ for (j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
if (scxml_transitions[j].source == i) {
BIT_SET_AT(j, trans_set);
BIT_CLEAR(i, entry_set);
bit_or(entry_set, scxml_transitions[j].target, 2);
- for (size_t k = i + 1; k < SCXML_NUMBER_STATES; k++) {
+ for (k = i + 1; k < SCXML_NUMBER_STATES; k++) {
if (BIT_HAS(k, scxml_transitions[j].target)) {
bit_or(entry_set, scxml_states[k].ancestors, 2);
}
@@ -905,7 +704,7 @@ ESTABLISH_ENTRY_SET:
bit_or(entry_set, scxml_states[i].completion, 2);
if (!bit_has_and(scxml_states[i].completion, scxml_states[i].children, 2)) {
// deep completion
- for (size_t j = i + 1; j < SCXML_NUMBER_STATES; j++) {
+ for (j = i + 1; j < SCXML_NUMBER_STATES; j++) {
if (BIT_HAS(j, scxml_states[i].completion)) {
bit_or(entry_set, scxml_states[j].ancestors, 2);
break; // completion of compound is single state
@@ -921,11 +720,11 @@ ESTABLISH_ENTRY_SET:
#ifdef SCXML_VERBOSE
printf("Transitions: ");
- printBitsetIndices(trans_set, sizeof(char) * 8 * 2);
+ printBitsetIndices(trans_set, sizeof(char) * 8 * 1);
#endif
// EXIT_STATES:
- size_t i = SCXML_NUMBER_STATES;
+ i = SCXML_NUMBER_STATES;
while(i-- > 0) {
if (BIT_HAS(i, exit_set) && BIT_HAS(i, ctx->config)) {
// call all on exit handlers
@@ -938,7 +737,7 @@ ESTABLISH_ENTRY_SET:
}
// TAKE_TRANSITIONS:
- for (size_t i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
+ for (i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
if (BIT_HAS(i, trans_set) && (scxml_transitions[i].type & (SCXML_TRANS_HISTORY | SCXML_TRANS_INITIAL)) == 0) {
// call executable content in transition
if (scxml_transitions[i].on_transition != NULL) {
@@ -956,7 +755,7 @@ ESTABLISH_ENTRY_SET:
#endif
// ENTER_STATES:
- for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (i = 0; i < SCXML_NUMBER_STATES; i++) {
if (BIT_HAS(i, entry_set) && !BIT_HAS(i, ctx->config)) {
// these are no proper states
if unlikely(SCXML_STATE_MASK(scxml_states[i].type) == SCXML_STATE_HISTORY_DEEP ||
@@ -980,7 +779,7 @@ ESTABLISH_ENTRY_SET:
}
// take history and initial transitions
- for (size_t j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
+ for (j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
if unlikely(BIT_HAS(j, trans_set) &&
(scxml_transitions[j].type & (SCXML_TRANS_HISTORY | SCXML_TRANS_INITIAL)) &&
scxml_states[scxml_transitions[j].source].parent == i) {
@@ -1016,11 +815,11 @@ ESTABLISH_ENTRY_SET:
* 3. Iterate all active final states and remove their ancestors
* 4. If a state remains, not all children of a parallel are final
*/
- for (size_t j = 0; j < SCXML_NUMBER_STATES; j++) {
+ for (j = 0; j < SCXML_NUMBER_STATES; j++) {
if unlikely(SCXML_STATE_MASK(scxml_states[j].type) == SCXML_STATE_PARALLEL &&
BIT_HAS(j, scxml_states[i].ancestors)) {
bit_and_not(tmp_states, tmp_states, 2);
- for (size_t k = 0; k < SCXML_NUMBER_STATES; k++) {
+ for (k = 0; k < SCXML_NUMBER_STATES; k++) {
if unlikely(BIT_HAS(j, scxml_states[k].ancestors) && BIT_HAS(k, ctx->config)) {
if (SCXML_STATE_MASK(scxml_states[k].type) == SCXML_STATE_FINAL) {
bit_and_not(tmp_states, scxml_states[k].ancestors, 2);
diff --git a/test/w3c/run_generated_test.cmake b/test/w3c/run_generated_test.cmake
index 868e111..334fffb 100644
--- a/test/w3c/run_generated_test.cmake
+++ b/test/w3c/run_generated_test.cmake
@@ -22,35 +22,35 @@ if (${TARGETLANG} STREQUAL "vhdl")
elseif (${TARGETLANG} STREQUAL "c")
- set(COMPILE_CMD_OBJ
- "-c" "${OUTDIR}/${TEST_FILE_NAME}.machine.c"
- "-o" "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o"
- "-Ofast" "-ansi" "-m16")
-
- message(STATUS "${CC_BIN} ${COMPILE_CMD_OBJ}")
- execute_process(
- COMMAND time -p ${CC_BIN} ${COMPILE_CMD_OBJ}
- WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT)
- if(CMD_RESULT)
- message(FATAL_ERROR "Error running gcc ${CC_BIN}: ${CMD_RESULT}")
- endif()
- file (SIZE "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o" BINARY_SIZE)
- message("Size of compiled unit optimized for speed: ${BINARY_SIZE}")
-
- set(COMPILE_CMD_OBJ
- "-c" "${OUTDIR}/${TEST_FILE_NAME}.machine.c"
- "-o" "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o"
- "-Os" "-ansi" "-m16")
-
- message(STATUS "${CC_BIN} ${COMPILE_CMD_OBJ}")
- execute_process(
- COMMAND time -p ${CC_BIN} ${COMPILE_CMD_OBJ}
- WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT)
- if(CMD_RESULT)
- message(FATAL_ERROR "Error running gcc ${CC_BIN}: ${CMD_RESULT}")
- endif()
- file (SIZE "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o" BINARY_SIZE)
- message("Size of compiled unit optimized for size: ${BINARY_SIZE}")
+ # set(COMPILE_CMD_OBJ
+ # "-c" "${OUTDIR}/${TEST_FILE_NAME}.machine.c"
+ # "-o" "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o"
+ # "-Ofast" "-ansi" "-m16")
+ #
+ # message(STATUS "${CC_BIN} ${COMPILE_CMD_OBJ}")
+ # execute_process(
+ # COMMAND time -p ${CC_BIN} ${COMPILE_CMD_OBJ}
+ # WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT)
+ # if(CMD_RESULT)
+ # message(FATAL_ERROR "Error running gcc ${CC_BIN}: ${CMD_RESULT}")
+ # endif()
+ # file (SIZE "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o" BINARY_SIZE)
+ # message("Size of compiled unit optimized for speed: ${BINARY_SIZE}")
+ #
+ # set(COMPILE_CMD_OBJ
+ # "-c" "${OUTDIR}/${TEST_FILE_NAME}.machine.c"
+ # "-o" "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o"
+ # "-Os" "-ansi" "-m16")
+ #
+ # message(STATUS "${CC_BIN} ${COMPILE_CMD_OBJ}")
+ # execute_process(
+ # COMMAND time -p ${CC_BIN} ${COMPILE_CMD_OBJ}
+ # WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT)
+ # if(CMD_RESULT)
+ # message(FATAL_ERROR "Error running gcc ${CC_BIN}: ${CMD_RESULT}")
+ # endif()
+ # file (SIZE "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o" BINARY_SIZE)
+ # message("Size of compiled unit optimized for size: ${BINARY_SIZE}")
set(COMPILE_CMD_BIN
"-o" "${OUTDIR}/${TEST_FILE_NAME}"