From cf19f11b8d2bd6d9566c7528fbed40af06928abf Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Wed, 24 Feb 2016 11:50:32 +0100 Subject: Some more refactoring and VHDL transformation --- apps/uscxml-browser.cpp | 2 +- apps/uscxml-transform.cpp | 2 +- src/bindings/swig/csharp/uscxml.i | 12 +- src/bindings/swig/java/uscxml.i | 14 +- src/uscxml/Interpreter.cpp | 96 +++++----- src/uscxml/Interpreter.h | 2 +- src/uscxml/URL.cpp | 2 +- src/uscxml/UUID.cpp | 2 +- src/uscxml/debug/Complexity.cpp | 10 +- src/uscxml/debug/DebugSession.cpp | 4 +- src/uscxml/debug/Debugger.cpp | 2 +- src/uscxml/debug/InterpreterIssue.cpp | 70 +++---- src/uscxml/debug/SCXMLDotWriter.cpp | 18 +- src/uscxml/interpreter/InterpreterDraft6.cpp | 94 ++++----- src/uscxml/interpreter/InterpreterRC.cpp | 68 +++---- src/uscxml/messages/Data.cpp | 8 +- src/uscxml/messages/Data.h | 4 +- src/uscxml/messages/Event.cpp | 6 +- src/uscxml/messages/InvokeRequest.cpp | 2 +- src/uscxml/messages/SendRequest.cpp | 2 +- src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp | 2 +- .../plugins/datamodel/prolog/swi/SWIDataModel.cpp | 18 +- .../plugins/datamodel/promela/PromelaDataModel.cpp | 2 +- .../plugins/datamodel/promela/PromelaParser.cpp | 4 +- .../plugins/datamodel/xpath/XPathDataModel.cpp | 34 ++-- .../plugins/element/respond/RespondElement.cpp | 2 +- src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp | 8 +- .../plugins/invoker/ffmpeg/FFMPEGInvoker.cpp | 2 +- src/uscxml/transform/ChartToFSM.cpp | 86 ++++----- src/uscxml/transform/ChartToFlatSCXML.cpp | 16 +- src/uscxml/transform/ChartToMinimalSCXML.cpp | 12 +- src/uscxml/transform/ChartToPromela.cpp | 92 ++++----- src/uscxml/transform/ChartToTex.cpp | 4 +- src/uscxml/transform/ChartToVHDL.cpp | 213 ++++++++++++++++----- src/uscxml/transform/ChartToVHDL.h | 115 +++++++++++ src/uscxml/transform/FlatStateIdentifier.h | 8 +- src/uscxml/util/MD5.hpp | 2 +- src/uscxml/util/SHA1.hpp | 2 +- src/uscxml/util/String.cpp | 6 +- src/uscxml/util/Trie.cpp | 2 +- test/src/test-arabica-events.cpp | 2 +- test/src/test-arabica-namespaces.cpp | 10 +- test/src/test-base64.cpp | 2 +- test/src/test-c-machine.cpp | 8 +- test/src/test-datamodel.cpp | 4 +- test/src/test-ffmpeg.cpp | 2 +- test/src/test-lifecycle.cpp | 2 +- test/src/test-sockets.cpp | 4 +- test/src/test-stress.cpp | 2 +- test/src/test-vxml-mmi-socket.cpp | 2 +- test/src/test-w3c.cpp | 2 +- test/w3c/run_generated_test.cmake | 28 ++- 52 files changed, 687 insertions(+), 431 deletions(-) diff --git a/apps/uscxml-browser.cpp b/apps/uscxml-browser.cpp index 2f416bb..2185aa9 100644 --- a/apps/uscxml-browser.cpp +++ b/apps/uscxml-browser.cpp @@ -27,7 +27,7 @@ #ifdef HAS_EXECINFO_H void printBacktrace(void** array, int size) { char** messages = backtrace_symbols(array, size); - for (int i = 0; i < size && messages != NULL; ++i) { + for (size_t i = 0; i < size && messages != NULL; ++i) { std::cerr << "\t" << messages[i] << std::endl; } std::cerr << std::endl; diff --git a/apps/uscxml-transform.cpp b/apps/uscxml-transform.cpp index 3ef7a83..2dc4d74 100644 --- a/apps/uscxml-transform.cpp +++ b/apps/uscxml-transform.cpp @@ -50,7 +50,7 @@ class VerboseMonitor : public uscxml::InterpreterMonitor { void printConfig(const Arabica::XPath::NodeSet& config) { std::string seperator; std::cerr << "Config: {"; - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { std::cerr << seperator << ATTR_CAST(config[i], "id"); seperator = ", "; } diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i index 18b8cb8..fbc5f20 100644 --- a/src/bindings/swig/csharp/uscxml.i +++ b/src/bindings/swig/csharp/uscxml.i @@ -236,7 +236,7 @@ using System.Runtime.InteropServices; Dictionary ioProcs = new Dictionary(); StringVector keys = getIOProcessorKeys(); IOProcMap ioProcMap = getIOProcessorsNative(); - for (int i = 0; i < keys.Count; i++) { + for (size_t i = 0; i < keys.Count; i++) { ioProcs[keys[i]] = ioProcMap[keys[i]]; } return ioProcs; @@ -246,7 +246,7 @@ using System.Runtime.InteropServices; Dictionary invokers = new Dictionary(); StringVector keys = getInvokerKeys(); InvokerMap invokerMap = getInvokersNative(); - for (int i = 0; i < keys.Count; i++) { + for (size_t i = 0; i < keys.Count; i++) { invokers[keys[i]] = invokerMap[keys[i]]; } return invokers; @@ -288,7 +288,7 @@ using System.Runtime.InteropServices; Dictionary compound = new Dictionary(); DataMap dataMap = getCompoundNative(); StringVector dataMapKeys = getCompoundKeys(); - for (int i = 0; i < dataMapKeys.Count; i++) { + for (size_t i = 0; i < dataMapKeys.Count; i++) { compound[dataMapKeys[i]] = dataMap[dataMapKeys[i]]; } return compound; @@ -305,7 +305,7 @@ using System.Runtime.InteropServices; public List getArray() { List arr = new List(); DataList dataList = getArrayNative(); - for (int i = 0; i < dataList.size(); i++) { + for (size_t i = 0; i < dataList.size(); i++) { arr.Add(dataList.get(i)); } return arr; @@ -345,7 +345,7 @@ using System.Runtime.InteropServices; foreach (KeyValuePair entry in paramMap) { DataList dataList = entry.Value; List paramList = new List(); - for (int i = 0; i < dataList.size(); i++) { + for (size_t i = 0; i < dataList.size(); i++) { Data data = dataList.get(i); paramList.Add(data); } @@ -370,7 +370,7 @@ using System.Runtime.InteropServices; Dictionary nameList = new Dictionary(); DataMap nameListMap = getNameListNative(); StringVector nameListMapKeys = getNameListKeys(); - for (int i = 0; i < nameListMapKeys.Count; i++) { + for (size_t i = 0; i < nameListMapKeys.Count; i++) { nameList[nameListMapKeys[i]] = nameListMap[nameListMapKeys[i]]; } return nameList; diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index 031b9c0..23f6401 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -239,7 +239,7 @@ import java.net.URL; Map ioProcs = new HashMap(); StringVector keys = getIOProcessorKeys(); IOProcMap ioProcMap = getIOProcessorsNative(); - for (int i = 0; i < keys.size(); i++) { + for (size_t i = 0; i < keys.size(); i++) { ioProcs.put(keys.get(i), ioProcMap.get(keys.get(i))); } return ioProcs; @@ -249,7 +249,7 @@ import java.net.URL; Map invokers = new HashMap(); StringVector keys = getInvokerKeys(); InvokerMap invokerMap = getInvokersNative(); - for (int i = 0; i < keys.size(); i++) { + for (size_t i = 0; i < keys.size(); i++) { invokers.put(keys.get(i), invokerMap.get(keys.get(i))); } return invokers; @@ -301,7 +301,7 @@ import java.util.LinkedList; Map compound = new HashMap(); DataMap dataMap = getCompoundNative(); StringVector dataMapKeys = getCompoundKeys(); - for (int i = 0; i < dataMapKeys.size(); i++) { + for (size_t i = 0; i < dataMapKeys.size(); i++) { compound.put(dataMapKeys.get(i), dataMap.get(dataMapKeys.get(i))); } return compound; @@ -318,7 +318,7 @@ import java.util.LinkedList; public List getArray() { List array = new LinkedList(); DataList dataList = getArrayNative(); - for (int i = 0; i < dataList.size(); i++) { + for (size_t i = 0; i < dataList.size(); i++) { array.add(dataList.get(i)); } return array; @@ -357,11 +357,11 @@ import java.util.LinkedList; ParamMap paramMap = getParamMap(); StringVector paramMapKeys = getParamMapKeys(); - for (int i = 0; i < paramMapKeys.size(); i++) { + for (size_t i = 0; i < paramMapKeys.size(); i++) { String key = paramMapKeys.get(i); DataList dataList = paramMap.get(key); - for (int j = 0; j < dataList.size(); j++) { + for (size_t j = 0; j < dataList.size(); j++) { Data data = dataList.get(j); if (!params.containsKey(key)) params.put(key, new LinkedList()); @@ -388,7 +388,7 @@ import java.util.LinkedList; StringVector nameMapKeys = getNameListKeys(); DataMap nameMap = getNameListNative(); - for (int i = 0; i < nameMapKeys.size(); i++) { + for (size_t i = 0; i < nameMapKeys.size(); i++) { namelist.put(nameMapKeys.get(i), nameMap.get(nameMapKeys.get(i))); } return namelist; diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 7353104..27b3f08 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -399,7 +399,7 @@ void StateTransitionMonitor::beforeMicroStep(uscxml::Interpreter interpreter) { void StateTransitionMonitor::printNodeSet(const Arabica::XPath::NodeSet& config) { std::string seperator; - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { std::cerr << seperator << ATTR_CAST(config[i], "id"); seperator = ", "; } @@ -681,14 +681,14 @@ void InterpreterImpl::exitInterpreter() { statesToExit.forward(false); statesToExit.sort(); - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { Arabica::XPath::NodeSet onExitElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onexit", statesToExit[i]); - for (int j = 0; j < onExitElems.size(); j++) { + for (size_t j = 0; j < onExitElems.size(); j++) { executeContent(Element(onExitElems[j])); } Arabica::XPath::NodeSet invokeElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]); // TODO: we ought to cancel all remaining invokers just to be sure with the persist extension - for (int j = 0; j < invokeElems.size(); j++) { + for (size_t j = 0; j < invokeElems.size(); j++) { cancelInvoke(Element(invokeElems[j])); } Element stateElem(statesToExit[i]); @@ -764,7 +764,7 @@ NodeSet InterpreterImpl::getDocumentInitialTransitions() { // fetch per draft initialStates = getInitialStates(); assert(initialStates.size() > 0); - for (int i = 0; i < initialStates.size(); i++) { + for (size_t i = 0; i < initialStates.size(); i++) { Element initialElem = _document.createElementNS(_nsInfo.nsURL, "initial"); _nsInfo.setPrefix(initialElem); @@ -804,14 +804,14 @@ InterpreterState InterpreterImpl::step(int waitForMS) { assert(initialTransitions.size() > 0); #if VERBOSE std::cerr << _name << ": initialTransitions: " << std::endl; - for (int i = 0; i < initialTransitions.size(); i++) { + for (size_t i = 0; i < initialTransitions.size(); i++) { std::cerr << initialTransitions[i] << std::endl; } std::cerr << std::endl; #endif // this is not mentionend in the standard, though it makes sense - for (int i = 0; i < initialTransitions.size(); i++) { + for (size_t i = 0; i < initialTransitions.size(); i++) { Element transition(initialTransitions[i]); USCXML_MONITOR_CALLBACK3(beforeTakingTransition, transition, (i + 1 < enabledTransitions.size())) executeContent(transition); @@ -1004,7 +1004,7 @@ void InterpreterImpl::microstep(const Arabica::XPath::NodeSet& enab exitStates(enabledTransitions); - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { Element transition(enabledTransitions[i]); USCXML_MONITOR_CALLBACK3(beforeTakingTransition, transition, (i + 1 < enabledTransitions.size())) @@ -1149,7 +1149,7 @@ LOOP: #if VERBOSE std::cerr << "Enabled eventless transitions: " << std::endl; - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { std::cerr << enabledTransitions[i] << std::endl << "----" << std::endl; } std::cerr << std::endl; @@ -1193,7 +1193,7 @@ NEXT_ATOMIC: #if 0 std::cerr << "Enabled transitions for '" << event << "': " << std::endl; - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { std::cerr << enabledTransitions[i] << std::endl << "----" << std::endl; } std::cerr << std::endl; @@ -1203,7 +1203,7 @@ NEXT_ATOMIC: #if 0 std::cerr << "Non-conflicting transitions for '" << event << "': " << std::endl; - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { std::cerr << enabledTransitions[i] << std::endl << "----" << std::endl; } std::cerr << std::endl; @@ -1247,7 +1247,7 @@ NEXT_ATOMIC: #if 0 std::cerr << "Enabled eventless transitions: " << std::endl; - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { std::cerr << enabledTransitions[i] << std::endl << "----" << std::endl; } std::cerr << std::endl; @@ -1463,7 +1463,7 @@ void InterpreterImpl::setupDOM() { // make sure every state has an id - not required per spec, but needed for us Arabica::XPath::NodeSet states = getAllStates(); - for (int i = 0; i < states.size(); i++) { + for (size_t i = 0; i < states.size(); i++) { Arabica::DOM::Element stateElem = Arabica::DOM::Element(states[i]); if (!stateElem.hasAttribute("id")) { stateElem.setAttribute("id", UUID::getUUID()); @@ -1473,7 +1473,7 @@ void InterpreterImpl::setupDOM() { // make sure every invoke has an idlocation or id - actually required! Arabica::XPath::NodeSet invokes = _xpath.evaluate("//" + _nsInfo.xpathPrefix + "invoke", _scxml).asNodeSet(); - for (int i = 0; i < invokes.size(); i++) { + for (size_t i = 0; i < invokes.size(); i++) { Arabica::DOM::Element invokeElem = Arabica::DOM::Element(invokes[i]); if (!invokeElem.hasAttribute("id") && !invokeElem.hasAttribute("idlocation")) { invokeElem.setAttribute("id", UUID::getUUID()); @@ -1508,7 +1508,7 @@ void InterpreterImpl::resolveXIncludes() { includeChain.push_back(_sourceURL); Arabica::XPath::NodeSet xincludes = _xpath.evaluate("//" + xIncludeNS + "include", _document.getDocumentElement()).asNodeSet(); - for (int i = 0; i < xincludes.size(); i++) { + for (size_t i = 0; i < xincludes.size(); i++) { // recursively resolve includes resolveXIncludes(includeChain, mergedNs, xIncludeNS, URL::asBaseURL(_sourceURL), Element(xincludes[i])); } @@ -1629,10 +1629,10 @@ TRY_WITH_FALLBACK: { } REMOVE_AND_RECURSE: xinclude.getParentNode().removeChild(xinclude); - for (int i = 0; i < newNodes.size(); i++) { + for (size_t i = 0; i < newNodes.size(); i++) { _baseURL[newNodes[i]] = URL::asBaseURL(src); Arabica::XPath::NodeSet xincludes = DOMUtils::filterChildElements(xIncludeNS + "include", newNodes[i], true); - for (int j = 0; j < xincludes.size(); j++) { + for (size_t j = 0; j < xincludes.size(); j++) { resolveXIncludes(includeChain, mergedNS, xIncludeNS, URL::asBaseURL(src), Element(xincludes[j])); } } @@ -1910,7 +1910,7 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Element& void InterpreterImpl::processParamChilds(const Arabica::DOM::Element& element, std::multimap& params) { NodeSet paramElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", element); - for (int i = 0; i < paramElems.size(); i++) { + for (size_t i = 0; i < paramElems.size(); i++) { try { Element paramElem = Element(paramElems[i]); if (!HAS_ATTR(paramElem, "name")) { @@ -2421,7 +2421,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Element& c iequals(TAGNAME(content), _nsInfo.xmlNSPrefix + "transition")) { // --- CONVENIENCE LOOP -------------------------- NodeList executable = content.getChildNodes(); - for (int i = 0; i < executable.getLength(); i++) { + for (size_t i = 0; i < executable.getLength(); i++) { const Arabica::DOM::Node& childNode = executable.item(i); if (childNode.getNodeType() != Node_base::ELEMENT_NODE) continue; @@ -2670,7 +2670,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Element& c execContent.enterElement(content); if (execContent.processChildren()) { NodeList executable = content.getChildNodes(); - for (int i = 0; i < executable.getLength(); i++) { + for (size_t i = 0; i < executable.getLength(); i++) { if (executable.item(i).getNodeType() != Node_base::ELEMENT_NODE) continue; executeContent(Element(executable.item(i)), rethrow); @@ -2689,7 +2689,7 @@ void InterpreterImpl::finalizeAndAutoForwardCurrentEvent() { invokeIter++) { if (iequals(invokeIter->first, _currEvent.invokeid)) { Arabica::XPath::NodeSet finalizes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "finalize", invokeIter->second.getElement()); - for (int k = 0; k < finalizes.size(); k++) { + for (size_t k = 0; k < finalizes.size(); k++) { Element finalizeElem = Element(finalizes[k]); executeContent(finalizeElem); } @@ -2729,13 +2729,13 @@ bool InterpreterImpl::parentIsScxmlState(const Arabica::DOM::Element& state) { if (isCompound(state)) { Arabica::XPath::NodeSet childs = getChildStates(state); - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { if (isFinal(Element(childs[i])) && isMember(childs[i], _configuration)) return true; } } else if (isParallel(state)) { Arabica::XPath::NodeSet childs = getChildStates(state); - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { if (!isInFinalState(Element(childs[i]))) return false; } @@ -2745,7 +2745,7 @@ bool InterpreterImpl::isInFinalState(const Arabica::DOM::Element& s } bool InterpreterImpl::isMember(const Arabica::DOM::Node& node, const Arabica::XPath::NodeSet& set) { - for (int i = 0; i < set.size(); i++) { + for (size_t i = 0; i < set.size(); i++) { if (set[i] == node) return true; } @@ -2756,7 +2756,7 @@ Arabica::XPath::NodeSet InterpreterImpl::getChildStates(const Arabi Arabica::XPath::NodeSet childs; Arabica::DOM::NodeList childElems = state.getChildNodes(); - for (int i = 0; i < childElems.getLength(); i++) { + for (size_t i = 0; i < childElems.getLength(); i++) { if (childElems.item(i).getNodeType() != Node_base::ELEMENT_NODE) continue; if (isState(Element(childElems.item(i)))) { @@ -2768,7 +2768,7 @@ Arabica::XPath::NodeSet InterpreterImpl::getChildStates(const Arabi Arabica::XPath::NodeSet InterpreterImpl::getChildStates(const Arabica::XPath::NodeSet& states) { Arabica::XPath::NodeSet childs; - for (int i = 0; i < states.size(); i++) { + for (size_t i = 0; i < states.size(); i++) { childs.push_back(getChildStates(states[i])); } return childs; @@ -2806,7 +2806,7 @@ Arabica::DOM::Node InterpreterImpl::getAncestorElement(const Arabic Arabica::DOM::Node InterpreterImpl::findLCCA(const Arabica::XPath::NodeSet& states) { #if VERBOSE_FIND_LCCA std::cerr << "findLCCA: "; - for (int i = 0; i < states.size(); i++) { + for (size_t i = 0; i < states.size(); i++) { std::cerr << ATTR_CAST(states[i], "id") << ", "; } std::cerr << std::endl << std::flush; @@ -2815,10 +2815,10 @@ Arabica::DOM::Node InterpreterImpl::findLCCA(const Arabica::XPath:: Arabica::XPath::NodeSet ancestors = getProperAncestors(states[0], Arabica::DOM::Node()); Arabica::DOM::Node ancestor; - for (int i = 0; i < ancestors.size(); i++) { + for (size_t i = 0; i < ancestors.size(); i++) { if (!isCompound(Element(ancestors[i]))) continue; - for (int j = 0; j < states.size(); j++) { + for (size_t j = 0; j < states.size(); j++) { #if VERBOSE_FIND_LCCA std::cerr << "Checking " << ATTR_CAST(states[j], "id") << " and " << ATTR_CAST(ancestors[i], "id") << std::endl; @@ -2884,7 +2884,7 @@ Arabica::DOM::Element InterpreterImpl::getState(const std::string& } FOUND: if (target.size() > 0) { - for (int i = 0; i < target.size(); i++) { + for (size_t i = 0; i < target.size(); i++) { Element targetElem(target[i]); if (!isInEmbeddedDocument(targetElem)) { _cachedStates[stateId] = targetElem; @@ -2955,7 +2955,7 @@ Arabica::XPath::NodeSet InterpreterImpl::getInitialStates(Arabica:: // first child state Arabica::XPath::NodeSet initStates; NodeList childs = state.getChildNodes(); - for (int i = 0; i < childs.getLength(); i++) { + for (size_t i = 0; i < childs.getLength(); i++) { if (childs.item(i).getNodeType() != Node_base::ELEMENT_NODE) continue; if (isState(Element(childs.item(i)))) { @@ -2981,12 +2981,12 @@ NodeSet InterpreterImpl::getReachableStates() { hasChanges = false; // reachable per initial attribute or document order - size will increase as we append new states - for (int i = 0; i < reachable.size(); i++) { + for (size_t i = 0; i < reachable.size(); i++) { // get the state's initial states Element state = Element(reachable[i]); try { NodeSet initials = getInitialStates(state); - for (int j = 0; j < initials.size(); j++) { + for (size_t j = 0; j < initials.size(); j++) { Element initial = Element(initials[j]); if (!InterpreterImpl::isMember(initial, reachable)) { reachable.push_back(initial); @@ -2998,14 +2998,14 @@ NodeSet InterpreterImpl::getReachableStates() { } // reachable per target attribute in transitions - for (int i = 0; i < reachable.size(); i++) { + for (size_t i = 0; i < reachable.size(); i++) { Element state = Element(reachable[i]); NodeSet transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false); - for (int j = 0; j < transitions.size(); j++) { + for (size_t j = 0; j < transitions.size(); j++) { Element transition = Element(transitions[j]); try { NodeSet targets = getTargetStates(transition); - for (int k = 0; k < targets.size(); k++) { + for (size_t k = 0; k < targets.size(); k++) { Element target = Element(targets[k]); if (!InterpreterImpl::isMember(target, reachable)) { reachable.push_back(target); @@ -3018,7 +3018,7 @@ NodeSet InterpreterImpl::getReachableStates() { } // reachable via a reachable child state - for (int i = 0; i < reachable.size(); i++) { + for (size_t i = 0; i < reachable.size(); i++) { Element state = Element(reachable[i]); if (InterpreterImpl::isAtomic(state)) { // iterate the states parents @@ -3054,7 +3054,7 @@ NodeSet InterpreterImpl::getTargetStates(const Arabica::DOM::Elemen // if we are called with a state, process all its transitions if (isState(transition) || (transition.getNodeType() == Node_base::ELEMENT_NODE && iequals(_nsInfo.xmlNSPrefix + "initial", TAGNAME(transition)))) { NodeList childs = transition.getChildNodes(); - for (int i = 0; i < childs.getLength(); i++) { + for (size_t i = 0; i < childs.getLength(); i++) { if (childs.item(i).getNodeType() != Node_base::ELEMENT_NODE) continue; Element childElem = Element(childs.item(i)); @@ -3377,7 +3377,7 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet& config) { // The configuration contains exactly one child of the element. NodeSet scxmlChilds = getChildStates(_scxml); Node foundScxmlChild; - for (int i = 0; i < scxmlChilds.size(); i++) { + for (size_t i = 0; i < scxmlChilds.size(); i++) { if (isMember(scxmlChilds[i], config)) { if (foundScxmlChild) { LOG(ERROR) << "Invalid configuration: Multiple childs of scxml root are active '" << ATTR_CAST(foundScxmlChild, "id") << "' and '" << ATTR_CAST(scxmlChilds[i], "id") << "'"; @@ -3394,7 +3394,7 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet& config) { // The configuration contains one or more atomic states. bool foundAtomicState = false; - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { if (isAtomic(Element(config[i]))) { foundAtomicState = true; break; @@ -3406,7 +3406,7 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet& config) { } // the configuration contains no history pseudo-states - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { if (isHistory(Element(config[i]))) { LOG(ERROR) << "Invalid configuration: history state " << ATTR_CAST(config[i], "id") << " is active"; return false; @@ -3416,7 +3416,7 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet& config) { // When the configuration contains an atomic state, it contains all of its and ancestors. - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { if (isAtomic(Element(config[i]))) { Node parent = config[i]; while(((parent = parent.getParentNode()) && parent.getNodeType() == Node_base::ELEMENT_NODE)) { @@ -3433,13 +3433,13 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet& config) { } // When the configuration contains a non-atomic , it contains one and only one of the state's children - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { Element configElem(config[i]); if (!isAtomic(configElem) && !isParallel(configElem)) { Node foundChildState; //std::cerr << config[i] << std::endl; NodeSet childs = getChildStates(config[i]); - for (int j = 0; j < childs.size(); j++) { + for (size_t j = 0; j < childs.size(); j++) { //std::cerr << childs[j] << std::endl; if (isMember(childs[j], config)) { if (foundChildState) { @@ -3458,10 +3458,10 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet& config) { } // If the configuration contains a state, it contains all of its children - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { if (isParallel(Element(config[i]))) { NodeSet childs = getChildStates(config[i]); - for (int j = 0; j < childs.size(); j++) { + for (size_t j = 0; j < childs.size(); j++) { if (!isMember(childs[j], config) && !isHistory(Element(childs[j]))) { LOG(ERROR) << "Invalid configuration: Not all children of parallel '" << ATTR_CAST(config[i], "id") << "' are active i.e. '" << ATTR_CAST(childs[j], "id") << "' is not"; return false; @@ -3488,7 +3488,7 @@ bool InterpreterImpl::isInState(const std::string& stateId) { return false; } else { - for (int i = 0; i < _configuration.size(); i++) { + for (size_t i = 0; i < _configuration.size(); i++) { if (HAS_ATTR_CAST(_configuration[i], "id") && iequals(ATTR_CAST(_configuration[i], "id"), stateId)) { return true; @@ -3522,7 +3522,7 @@ void InterpreterImpl::handleDOMEvent(Arabica::DOM::Events::Event& e // remove modified states from cache Node target = Arabica::DOM::Node(event.getTarget()); NodeSet childs = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "state", target); - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { if (HAS_ATTR_CAST(childs[i], "id")) { _cachedStates.erase(ATTR_CAST(childs[i], "id")); } diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index c3395d0..f27d93e 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -284,7 +284,7 @@ public: Arabica::XPath::NodeSet getBasicConfiguration() { tthread::lock_guard lock(_mutex); Arabica::XPath::NodeSet basicConfig; - for (int i = 0; i < _configuration.size(); i++) { + for (size_t i = 0; i < _configuration.size(); i++) { if (isAtomic(Arabica::DOM::Element(_configuration[i]))) basicConfig.push_back(_configuration[i]); } diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp index 67a6e37..8b02d53 100644 --- a/src/uscxml/URL.cpp +++ b/src/uscxml/URL.cpp @@ -61,7 +61,7 @@ void URL::dump() { std::cout << "[path]" << path(); std::cout << "[file]" << file() << std::endl; std::cout << "[segmts " << pathComponents().size() << "]: "; - for (int i = 0; i < pathComponents().size(); i++) { + for (size_t i = 0; i < pathComponents().size(); i++) { std::cout << pathComponents()[i] << ", "; } std::cout << std::endl << std::endl; diff --git a/src/uscxml/UUID.cpp b/src/uscxml/UUID.cpp index ae103ed..34e3e75 100644 --- a/src/uscxml/UUID.cpp +++ b/src/uscxml/UUID.cpp @@ -38,7 +38,7 @@ bool UUID::isUUID(const std::string& uuid) { if (uuid[8] != '-' || uuid[13] != '-' || uuid[18] != '-' || uuid[23] != '-') return false; - for (int i = 0; i < 36; i++) { + for (size_t i = 0; i < 36; i++) { if (i == 8 || i == 13 || i == 18 || i ==23) continue; diff --git a/src/uscxml/debug/Complexity.cpp b/src/uscxml/debug/Complexity.cpp index a7f9f93..232260c 100644 --- a/src/uscxml/debug/Complexity.cpp +++ b/src/uscxml/debug/Complexity.cpp @@ -35,7 +35,7 @@ std::list > > Complexity::getAllConfigurations(con bool isAtomic = true; NodeList children = root.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { + for (size_t i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() != Node_base::ELEMENT_NODE) continue; Element childElem(children.item(i)); @@ -148,7 +148,7 @@ Complexity Complexity::calculateStateMachineComplexity(const Arabica::DOM::Eleme bool hasNestedData = false; Arabica::DOM::NodeList childElems = root.getChildNodes(); - for (int i = 0; i < childElems.getLength(); i++) { + for (size_t i = 0; i < childElems.getLength(); i++) { if (childElems.item(i).getNodeType() != Node_base::ELEMENT_NODE) continue; Element childElem = Element(childElems.item(i)); @@ -161,7 +161,7 @@ Complexity Complexity::calculateStateMachineComplexity(const Arabica::DOM::Eleme } if (!hasNestedData && childElem.getLocalName() == "datamodel") { Arabica::DOM::NodeList dataElemChilds = childElem.getChildNodes(); - for (int j = 0; j < dataElemChilds.getLength(); j++) { + for (size_t j = 0; j < dataElemChilds.getLength(); j++) { if (dataElemChilds.item(j).getLocalName() == "data") hasNestedData = true; } @@ -176,7 +176,7 @@ Complexity Complexity::calculateStateMachineComplexity(const Arabica::DOM::Eleme } else if (InterpreterImpl::isCompound(root) || TAGNAME(root) == "scxml") { // compounds can be in any of the child state -> add NodeSet childs = InterpreterImpl::getChildStates(root); - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { complexity += calculateStateMachineComplexity(Element(childs[i]), reachable); } if (hasFlatHistory) { @@ -189,7 +189,7 @@ Complexity Complexity::calculateStateMachineComplexity(const Arabica::DOM::Eleme // parallels are in all states -> multiply NodeSet childs = InterpreterImpl::getChildStates(root); complexity.value = 1; - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { complexity *= calculateStateMachineComplexity(Element(childs[i]), reachable); } if (hasDeepHistory) { diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp index 4d8fda5..6e81563 100644 --- a/src/uscxml/debug/DebugSession.cpp +++ b/src/uscxml/debug/DebugSession.cpp @@ -72,7 +72,7 @@ void DebugSession::breakExecution(Data replyData) { tthread::lock_guard lock(_mutex); Arabica::XPath::NodeSet basicConf = _interpreter.getBasicConfiguration(); - for (int i = 0; i < basicConf.size(); i++) { + for (size_t i = 0; i < basicConf.size(); i++) { Arabica::DOM::Element element = Arabica::DOM::Element(basicConf[i]); if (element.hasAttribute("id")) { replyData.compound["basicStates"].array.push_back(Data(element.getAttribute("id"), Data::VERBATIM)); @@ -80,7 +80,7 @@ void DebugSession::breakExecution(Data replyData) { } Arabica::XPath::NodeSet activeConf = _interpreter.getConfiguration(); - for (int i = 0; i < activeConf.size(); i++) { + for (size_t i = 0; i < activeConf.size(); i++) { Arabica::DOM::Element element = Arabica::DOM::Element(activeConf[i]); if (element.hasAttribute("id")) { replyData.compound["activeStates"].array.push_back(Data(element.getAttribute("id"), Data::VERBATIM)); diff --git a/src/uscxml/debug/Debugger.cpp b/src/uscxml/debug/Debugger.cpp index 1a7d977..f8b13fe 100644 --- a/src/uscxml/debug/Debugger.cpp +++ b/src/uscxml/debug/Debugger.cpp @@ -70,7 +70,7 @@ std::list getQualifiedTransBreakpoints(Interpreter interpreter, cons Arabica::DOM::Element source(interpreter.getImpl()->getSourceState(transition)); Arabica::XPath::NodeSet targets = interpreter.getImpl()->getTargetStates(transition); - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { Arabica::DOM::Element target(targets[j]); Breakpoint bp = breakpointTemplate; // copy base as template diff --git a/src/uscxml/debug/InterpreterIssue.cpp b/src/uscxml/debug/InterpreterIssue.cpp index 1fcfc00..1bb14f6 100644 --- a/src/uscxml/debug/InterpreterIssue.cpp +++ b/src/uscxml/debug/InterpreterIssue.cpp @@ -278,7 +278,7 @@ std::list InterpreterIssue::forInterpreter(InterpreterImpl* in } - for (int i = 0; i < allStates.size(); i++) { + for (size_t i = 0; i < allStates.size(); i++) { Element state = Element(allStates[i]); if (InterpreterImpl::isMember(state, finals) && !HAS_ATTR(state, "id")) // id is not required for finals @@ -316,7 +316,7 @@ std::list InterpreterIssue::forInterpreter(InterpreterImpl* in issues.push_back(InterpreterIssue("Transition in history pseudo-state '" + stateId + "' has no target", transition, InterpreterIssue::USCXML_ISSUE_FATAL)); } else { NodeSet targetStates = interpreter->getTargetStates(transition); - for (int j = 0; j < targetStates.size(); j++) { + for (size_t j = 0; j < targetStates.size(); j++) { Element target = Element(targetStates[j]); if (HAS_ATTR(state, "type") && ATTR(state, "type") == "deep") { if (!InterpreterImpl::isDescendant(target, state.getParentNode())) { @@ -345,7 +345,7 @@ std::list InterpreterIssue::forInterpreter(InterpreterImpl* in seenStates[ATTR(state, "id")] = state; } - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { Element transition = Element(transitions[i]); // check for valid target @@ -365,15 +365,15 @@ std::list InterpreterIssue::forInterpreter(InterpreterImpl* in } // check for redundancy of transition - for (int i = 0; i < allStates.size(); i++) { + for (size_t i = 0; i < allStates.size(); i++) { Element state = Element(allStates[i]); NodeSet transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state, false); transitions.to_document_order(); - for (int j = 1; j < transitions.size(); j++) { + for (size_t j = 1; j < transitions.size(); j++) { Element transition = Element(transitions[j]); - for (int k = 0; k < j; k++) { + for (size_t k = 0; k < j; k++) { Element earlierTransition = Element(transitions[k]); // will the earlier transition always be enabled when the later is? @@ -410,7 +410,7 @@ NEXT_TRANSITION: // check for useless history elements { - for (int i = 0; i < histories.size(); i++) { + for (size_t i = 0; i < histories.size(); i++) { Element history = Element(histories[i]); if (!history.getParentNode() || history.getParentNode().getNodeType() != Node_base::ELEMENT_NODE) continue; // syntax check will have catched this @@ -433,7 +433,7 @@ NEXT_TRANSITION: withInitialAttr.push_back(allStates); withInitialAttr.push_back(_scxml); - for (int i = 0; i < withInitialAttr.size(); i++) { + for (size_t i = 0; i < withInitialAttr.size(); i++) { Element state = Element(withInitialAttr[i]); if (HAS_ATTR(state, "initial")) { @@ -461,7 +461,7 @@ NEXT_TRANSITION: // check for legal configuration of target sets { std::map, std::string > targetIdSets; - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { Element transition = Element(transitions[i]); if (HAS_ATTR(transition, "target")) { @@ -469,7 +469,7 @@ NEXT_TRANSITION: } } - for (int i = 0; i < initials.size(); i++) { + for (size_t i = 0; i < initials.size(); i++) { Element initial = Element(initials[i]); if (HAS_ATTR(initial, "target")) { @@ -477,7 +477,7 @@ NEXT_TRANSITION: } } - for (int i = 0; i < allStates.size(); i++) { + for (size_t i = 0; i < allStates.size(); i++) { Element state = Element(allStates[i]); if (HAS_ATTR(state, "initial")) { @@ -508,7 +508,7 @@ NEXT_SET: NodeSet initTrans; // initTrans.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", histories, true)); - for (int i = 0; i < initials.size(); i++) { + for (size_t i = 0; i < initials.size(); i++) { Element initial = Element(initials[i]); NodeSet initTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", initial, true); if (initTransitions.size() != 1) { @@ -518,7 +518,7 @@ NEXT_SET: } - for (int i = 0; i < initTrans.size(); i++) { + for (size_t i = 0; i < initTrans.size(); i++) { Element transition = Element(initTrans[i]); /* In a conformant SCXML document, this transition must not contain 'cond' or 'event' attributes, and must specify a non-null 'target' @@ -557,7 +557,7 @@ NEXT_SET: // check that all invokers exists { - for (int i = 0; i < invokes.size(); i++) { + for (size_t i = 0; i < invokes.size(); i++) { Element invoke = Element(invokes[i]); if (HAS_ATTR(invoke, "type") && !_factory->hasInvoker(ATTR(invoke, "type"))) { // unknown at factory - adhoc extension? @@ -580,7 +580,7 @@ NEXT_SET: // check that all io processors exists { - for (int i = 0; i < sends.size(); i++) { + for (size_t i = 0; i < sends.size(); i++) { Element send = Element(sends[i]); if (HAS_ATTR(send, "type") && !_factory->hasIOProcessor(ATTR(send, "type"))) { if (interpreter->_ioProcessors.find(ATTR(send, "type")) != interpreter->_ioProcessors.end()) @@ -600,10 +600,10 @@ NEXT_SET: allExecContentContainers.push_back(transitions); allExecContentContainers.push_back(finalizes); - for (int i = 0; i < allExecContentContainers.size(); i++) { + for (size_t i = 0; i < allExecContentContainers.size(); i++) { Element block = Element(allExecContentContainers[i]); NodeSet execContents = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, block); - for (int j = 0; j < execContents.size(); j++) { + for (size_t j = 0; j < execContents.size(); j++) { Element execContent = Element(execContents[j]); // SCXML specific executable content, always available if (InterpreterImpl::isMember(execContent, allExecContents)) { @@ -619,7 +619,7 @@ NEXT_SET: // check that all SCXML elements have valid parents and required attributes { - for (int i = 0; i < allElements.size(); i++) { + for (size_t i = 0; i < allElements.size(); i++) { Element element = Element(allElements[i]); std::string localName = LOCALNAME(element); @@ -655,7 +655,7 @@ NEXT_SET: // check attribute constraints { - for (int i = 0; i < initials.size(); i++) { + for (size_t i = 0; i < initials.size(); i++) { Element initial = Element(initials[i]); if (initial.getParentNode() && initial.getParentNode().getNodeType() == Node_base::ELEMENT_NODE) { Element state(initial.getParentNode()); @@ -667,42 +667,42 @@ NEXT_SET: } } } - for (int i = 0; i < allStates.size(); i++) { + for (size_t i = 0; i < allStates.size(); i++) { Element state = Element(allStates[i]); if (InterpreterImpl::isAtomic(state) && HAS_ATTR(state, "initial")) { issues.push_back(InterpreterIssue("Atomic state cannot have initial attribute ", state, InterpreterIssue::USCXML_ISSUE_WARNING)); } } - for (int i = 0; i < assigns.size(); i++) { + for (size_t i = 0; i < assigns.size(); i++) { Element assign = Element(assigns[i]); if (HAS_ATTR(assign, "expr") && assign.getChildNodes().getLength() > 0) { issues.push_back(InterpreterIssue("Assign element cannot have expr attribute and children", assign, InterpreterIssue::USCXML_ISSUE_WARNING)); } } - for (int i = 0; i < contents.size(); i++) { + for (size_t i = 0; i < contents.size(); i++) { Element content = Element(contents[i]); if (HAS_ATTR(content, "expr") && content.getChildNodes().getLength() > 0) { issues.push_back(InterpreterIssue("Content element cannot have expr attribute and children", content, InterpreterIssue::USCXML_ISSUE_WARNING)); } } - for (int i = 0; i < params.size(); i++) { + for (size_t i = 0; i < params.size(); i++) { Element param = Element(params[i]); if (HAS_ATTR(param, "expr") && HAS_ATTR(param, "location")) { issues.push_back(InterpreterIssue("Param element cannot have both expr and location attribute", param, InterpreterIssue::USCXML_ISSUE_WARNING)); } } - for (int i = 0; i < scripts.size(); i++) { + for (size_t i = 0; i < scripts.size(); i++) { Element script = Element(scripts[i]); if (HAS_ATTR(script, "src") && script.getChildNodes().getLength() > 0) { issues.push_back(InterpreterIssue("Script element cannot have src attribute and children", script, InterpreterIssue::USCXML_ISSUE_WARNING)); } } - for (int i = 0; i < sends.size(); i++) { + for (size_t i = 0; i < sends.size(); i++) { Element send = Element(sends[i]); if (HAS_ATTR(send, "event") && HAS_ATTR(send, "eventexpr")) { issues.push_back(InterpreterIssue("Send element cannot have both event and eventexpr attribute", send, InterpreterIssue::USCXML_ISSUE_WARNING)); @@ -735,14 +735,14 @@ NEXT_SET: } } - for (int i = 0; i < cancels.size(); i++) { + for (size_t i = 0; i < cancels.size(); i++) { Element cancel = Element(cancels[i]); if (HAS_ATTR(cancel, "sendid") && HAS_ATTR(cancel, "sendidexpr")) { issues.push_back(InterpreterIssue("Cancel element cannot have both sendid and eventexpr sendidexpr", cancel, InterpreterIssue::USCXML_ISSUE_WARNING)); } } - for (int i = 0; i < invokes.size(); i++) { + for (size_t i = 0; i < invokes.size(); i++) { Element invoke = Element(invokes[i]); if (HAS_ATTR(invoke, "type") && HAS_ATTR(invoke, "typeexpr")) { issues.push_back(InterpreterIssue("Invoke element cannot have both type and typeexpr attribute", invoke, InterpreterIssue::USCXML_ISSUE_WARNING)); @@ -761,7 +761,7 @@ NEXT_SET: } } - for (int i = 0; i < doneDatas.size(); i++) { + for (size_t i = 0; i < doneDatas.size(); i++) { Element donedata = Element(doneDatas[i]); if (DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", donedata, false).size() > 0 && DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", donedata, false).size() > 0) { @@ -798,7 +798,7 @@ NEXT_SET: // test all scripts for valid syntax { - for (int i = 0; i < scripts.size(); i++) { + for (size_t i = 0; i < scripts.size(); i++) { Element script = Element(scripts[i]); if (script.hasChildNodes()) { @@ -823,7 +823,7 @@ NEXT_SET: withCondAttrs.push_back(ifs); withCondAttrs.push_back(elseIfs); - for (int i = 0; i < withCondAttrs.size(); i++) { + for (size_t i = 0; i < withCondAttrs.size(); i++) { Element condAttr = Element(withCondAttrs[i]); if (HAS_ATTR(condAttr, "cond")) { if (!_dataModel.isValidSyntax(ATTR(condAttr, "cond"))) { @@ -842,7 +842,7 @@ NEXT_SET: withExprAttrs.push_back(contents); withExprAttrs.push_back(params); - for (int i = 0; i < withExprAttrs.size(); i++) { + for (size_t i = 0; i < withExprAttrs.size(); i++) { Element withExprAttr = Element(withExprAttrs[i]); if (HAS_ATTR(withExprAttr, "expr")) { if (InterpreterImpl::isMember(withExprAttr, datas) || InterpreterImpl::isMember(withExprAttr, assigns)) { @@ -861,7 +861,7 @@ NEXT_SET: } { - for (int i = 0; i < foreachs.size(); i++) { + for (size_t i = 0; i < foreachs.size(); i++) { Element foreach = Element(foreachs[i]); if (HAS_ATTR(foreach, "array")) { if (!_dataModel.isValidSyntax(ATTR(foreach, "array"))) { @@ -882,7 +882,7 @@ NEXT_SET: } { - for (int i = 0; i < sends.size(); i++) { + for (size_t i = 0; i < sends.size(); i++) { Element send = Element(sends[i]); if (HAS_ATTR(send, "eventexpr")) { if (!_dataModel.isValidSyntax(ATTR(send, "eventexpr"))) { @@ -914,7 +914,7 @@ NEXT_SET: } { - for (int i = 0; i < invokes.size(); i++) { + for (size_t i = 0; i < invokes.size(); i++) { Element invoke = Element(invokes[i]); if (HAS_ATTR(invoke, "typeexpr")) { if (!_dataModel.isValidSyntax(ATTR(invoke, "typeexpr"))) { @@ -938,7 +938,7 @@ NEXT_SET: } { - for (int i = 0; i < cancels.size(); i++) { + for (size_t i = 0; i < cancels.size(); i++) { Element cancel = Element(cancels[i]); if (HAS_ATTR(cancel, "sendidexpr")) { if (!_dataModel.isValidSyntax(ATTR(cancel, "sendidexpr"))) { diff --git a/src/uscxml/debug/SCXMLDotWriter.cpp b/src/uscxml/debug/SCXMLDotWriter.cpp index a6ec0b6..56de37a 100644 --- a/src/uscxml/debug/SCXMLDotWriter.cpp +++ b/src/uscxml/debug/SCXMLDotWriter.cpp @@ -99,7 +99,7 @@ void SCXMLDotWriter::beforeTakingTransition(Interpreter interpreter, std::string SCXMLDotWriter::getPrefix() { std::string prefix = ""; - for (int i = 0; i < _indentation; i++) + for (size_t i = 0; i < _indentation; i++) prefix += " "; return prefix; } @@ -200,7 +200,7 @@ void SCXMLDotWriter::assembleGraph(const Element& state, int32_t ch NodeSet childElems = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, state); - for (int i = 0; i < childElems.size(); i++) { + for (size_t i = 0; i < childElems.size(); i++) { Element childElem(childElems[i]); // remember histories we passed @@ -213,7 +213,7 @@ void SCXMLDotWriter::assembleGraph(const Element& state, int32_t ch if (iequals(TAGNAME(childElem), "transition")) { _graph[nodeId].transitions.push_back(childElem); NodeSet targetStates = _interpreter.getImpl()->getTargetStates(childElem); - for (int j = 0; j < targetStates.size(); j++) { + for (size_t j = 0; j < targetStates.size(); j++) { std::string remoteNodeId = idForNode(targetStates[j]); _graph[nodeId].targets.insert(std::make_pair(remoteNodeId, childElem)); @@ -348,7 +348,7 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element histories = DOMUtils::filterChildElements(_xmlNSPrefix + "history", stateElem); - for (int i = 0; i < histories.size(); i++) { + for (size_t i = 0; i < histories.size(); i++) { os << " history: " << ATTR_CAST(histories[i], "id") << "" << std::endl; } @@ -422,7 +422,7 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element childElems = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, stateElem); - for (int i = 0; i < childElems.size(); i++) { + for (size_t i = 0; i < childElems.size(); i++) { Element childElem(childElems[i]); if (InterpreterImpl::isState(Element(childElem))) { writeStateElement(os, childElem); @@ -598,7 +598,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element& elem, i std::list content; NodeList childElems = elem.getChildNodes(); - for (int i = 0; i < childElems.getLength(); i++) { + for (size_t i = 0; i < childElems.getLength(); i++) { if (childElems.item(i).getNodeType() != Node_base::ELEMENT_NODE) continue; Element elem = Element(childElems.item(i)); @@ -637,7 +637,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element& elem, i if (HAS_ATTR(elem, "expr")) details.name += " = " + ATTR(elem, "expr"); NodeList grandChildElems = elem.getChildNodes(); - for (int j = 0; j < grandChildElems.getLength(); j++) { + for (size_t j = 0; j < grandChildElems.getLength(); j++) { if (grandChildElems.item(j).getNodeType() == Node_base::TEXT_NODE) { details.name += dotEscape(grandChildElems.item(j).getNodeValue()); } @@ -700,7 +700,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element& elem, i if (HAS_ATTR(elem, "src")) details.name += ATTR(elem, "src"); NodeList grandChildElems = childElems.item(i).getChildNodes(); - for (int j = 0; j < grandChildElems.getLength(); j++) { + for (size_t j = 0; j < grandChildElems.getLength(); j++) { if (grandChildElems.item(j).getNodeType() == Node_base::TEXT_NODE) { details.name += dotEscape(grandChildElems.item(j).getNodeValue()); } diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index a8bf97b..6084641 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -119,10 +119,10 @@ bool InterpreterDraft6::isWithinParallel(const Element& transition) Node InterpreterDraft6::findLCPA(const Arabica::XPath::NodeSet& states) { Arabica::XPath::NodeSet ancestors = getProperAncestors(states[0], Node()); Node ancestor; - for (int i = 0; i < ancestors.size(); i++) { + for (size_t i = 0; i < ancestors.size(); i++) { if (!isParallel(Element(ancestors[i]))) continue; - for (int j = 0; j < states.size(); j++) { + for (size_t j = 0; j < states.size(); j++) { if (!isDescendant(states[j], ancestors[i]) && (states[j] != ancestors[i])) goto NEXT_ANCESTOR; } @@ -141,13 +141,13 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e #if VERBOSE std::cout << _name << ": Enabled exit transitions: " << std::endl; - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { std::cout << enabledTransitions[i] << std::endl; } std::cout << std::endl; #endif - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { Element t = ((Element)enabledTransitions[i]); if (!isTargetless(t)) { Node ancestor; @@ -156,7 +156,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e NodeSet tStates = getTargetStates(t); bool isInternal = (HAS_ATTR(t, "type") && iequals(ATTR(t, "type"), "internal")); // external is default bool allDescendants = true; - for (int j = 0; j < tStates.size(); j++) { + for (size_t j = 0; j < tStates.size(); j++) { if (!isDescendant(tStates[j], source)) { allDescendants = false; break; @@ -170,7 +170,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e tmpStates.insert(tmpStates.end(), tStates.begin(), tStates.end()); #if 0 std::cout << _name << ": tmpStates: "; - for (int i = 0; i < tmpStates.size(); i++) { + for (size_t i = 0; i < tmpStates.size(); i++) { std::cout << ATTR(tmpStates[i], "id") << ", "; } std::cout << std::endl; @@ -180,7 +180,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e #if 0 std::cout << _name << ": Ancestor: " << ATTR(ancestor, "id") << std::endl;; #endif - for (int j = 0; j < _configuration.size(); j++) { + for (size_t j = 0; j < _configuration.size(); j++) { if (isDescendant(_configuration[j], ancestor)) statesToExit.push_back(_configuration[j]); } @@ -188,7 +188,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e } // remove statesToExit from _statesToInvoke std::list > tmp; - for (int i = 0; i < _statesToInvoke.size(); i++) { + for (size_t i = 0; i < _statesToInvoke.size(); i++) { if (!isMember(_statesToInvoke[i], statesToExit)) { tmp.push_back(_statesToInvoke[i]); } @@ -201,19 +201,19 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e #if 0 std::cout << _name << ": States to exit: "; - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { std::cout << LOCALNAME(statesToExit[i]) << ":" << ATTR(statesToExit[i], "id") << ", "; } std::cout << std::endl; #endif - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { NodeSet histories = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", statesToExit[i]); - for (int j = 0; j < histories.size(); j++) { + for (size_t j = 0; j < histories.size(); j++) { Element historyElem = (Element)histories[j]; std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow"); NodeSet historyNodes; - for (int k = 0; k < _configuration.size(); k++) { + for (size_t k = 0; k < _configuration.size(); k++) { if (iequals(historyType, "deep")) { if (isAtomic(Element(_configuration[k])) && isDescendant(_configuration[k], statesToExit[i])) historyNodes.push_back(_configuration[k]); @@ -225,7 +225,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e _historyValue[historyElem.getAttribute("id")] = historyNodes; #if VERBOSE std::cout << _name << ": History node " << ATTR(historyElem, "id") << " contains: "; - for (int i = 0; i < historyNodes.size(); i++) { + for (size_t i = 0; i < historyNodes.size(); i++) { std::cout << ATTR_CAST(historyNodes[i], "id") << ", "; } std::cout << std::endl; @@ -234,11 +234,11 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e } } - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { USCXML_MONITOR_CALLBACK3(beforeExitingState, Element(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet onExits = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onExit", statesToExit[i]); - for (int j = 0; j < onExits.size(); j++) { + for (size_t j = 0; j < onExits.size(); j++) { Element onExitElem = (Element)onExits[j]; executeContent(onExitElem); } @@ -246,7 +246,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e USCXML_MONITOR_CALLBACK3(afterExitingState, Element(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]); - for (int j = 0; j < invokes.size(); j++) { + for (size_t j = 0; j < invokes.size(); j++) { Element invokeElem = (Element)invokes[j]; if (HAS_ATTR(invokeElem, "persist") && stringIsTrue(ATTR(invokeElem, "persist"))) { // extension for flattened SCXML documents, we will need an explicit uninvoke element @@ -257,7 +257,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet& e // remove statesToExit[i] from _configuration - test409 tmp.clear(); - for (int j = 0; j < _configuration.size(); j++) { + for (size_t j = 0; j < _configuration.size(); j++) { if (_configuration[j] != statesToExit[i]) { tmp.push_back(_configuration[j]); } @@ -275,13 +275,13 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& #if VERBOSE std::cout << _name << ": Enabled enter transitions: " << std::endl; - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { std::cout << "\t" << enabledTransitions[i] << std::endl; } std::cout << std::endl; #endif - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { Element transition = ((Element)enabledTransitions[i]); if (!isTargetless(transition)) { std::string transitionType = (iequals(transition.getAttribute("type"), "internal") ? "internal" : "external"); @@ -289,7 +289,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& #if VERBOSE std::cout << _name << ": Target States: "; - for (int i = 0; i < tStates.size(); i++) { + for (size_t i = 0; i < tStates.size(); i++) { std::cout << ATTR_CAST(tStates[i], "id") << ", "; } std::cout << std::endl; @@ -303,7 +303,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& assert(source); bool allDescendants = true; - for (int j = 0; j < tStates.size(); j++) { + for (size_t j = 0; j < tStates.size(); j++) { if (!isDescendant(tStates[j], source)) { allDescendants = false; break; @@ -325,36 +325,36 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& std::cout << _name << ": Ancestor: " << ATTR_CAST(ancestor, "id") << std::endl; #endif - for (int j = 0; j < tStates.size(); j++) { + for (size_t j = 0; j < tStates.size(); j++) { addStatesToEnter(Element(tStates[j]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); } #if VERBOSE std::cout << _name << ": States to enter: "; - for (int i = 0; i < statesToEnter.size(); i++) { + for (size_t i = 0; i < statesToEnter.size(); i++) { std::cout << LOCALNAME(statesToEnter[i]) << ":" << ATTR_CAST(statesToEnter[i], "id") << ", "; } std::cout << std::endl; #endif - for (int j = 0; j < tStates.size(); j++) { + for (size_t j = 0; j < tStates.size(); j++) { NodeSet ancestors = getProperAncestors(tStates[j], ancestor); #if VERBOSE std::cout << _name << ": Proper Ancestors of " << ATTR_CAST(tStates[j], "id") << " and " << ATTR_CAST(ancestor, "id") << ": "; - for (int i = 0; i < ancestors.size(); i++) { + for (size_t i = 0; i < ancestors.size(); i++) { std::cout << ATTR_CAST(ancestors[i], "id") << ", "; } std::cout << std::endl; #endif - for (int k = 0; k < ancestors.size(); k++) { + for (size_t k = 0; k < ancestors.size(); k++) { statesToEnter.push_back(ancestors[k]); if(isParallel(Element(ancestors[k]))) { NodeSet childs = getChildStates(ancestors[k]); - for (int l = 0; l < childs.size(); l++) { + for (size_t l = 0; l < childs.size(); l++) { bool someIsDescendant = false; - for (int m = 0; m < statesToEnter.size(); m++) { + for (size_t m = 0; m < statesToEnter.size(); m++) { if (isDescendant(statesToEnter[m], childs[l])) { someIsDescendant = true; break; @@ -373,13 +373,13 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& #if VERBOSE std::cout << _name << ": States to enter: "; - for (int i = 0; i < statesToEnter.size(); i++) { + for (size_t i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR_CAST(statesToEnter[i], "id") << ", "; } std::cout << std::endl; #endif - for (int i = 0; i < statesToEnter.size(); i++) { + for (size_t i = 0; i < statesToEnter.size(); i++) { Element stateElem = (Element)statesToEnter[i]; // extension for flattened interpreters @@ -397,7 +397,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& // extension for flattened SCXML documents, we will need an explicit uninvoke element NodeSet uninvokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", statesToEnter[i]); - for (int j = 0; j < uninvokes.size(); j++) { + for (size_t j = 0; j < uninvokes.size(); j++) { Element uninvokeElem = (Element)uninvokes[j]; cancelInvoke(uninvokeElem); } @@ -409,7 +409,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& NodeSet dataModelElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", stateElem); if(dataModelElems.size() > 0 && _dataModel) { Arabica::XPath::NodeSet dataElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", dataModelElems[0]); - for (int j = 0; j < dataElems.size(); j++) { + for (size_t j = 0; j < dataElems.size(); j++) { if (dataElems[j].getNodeType() == Node_base::ELEMENT_NODE) initializeData(Element(dataElems[j])); } @@ -425,7 +425,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& if (isMember(stateElem, statesForDefaultEntry)) { // execute initial transition content for compound states Arabica::XPath::NodeSet transitions = _xpath.evaluate("" + _nsInfo.xpathPrefix + "initial/" + _nsInfo.xpathPrefix + "transition", stateElem).asNodeSet(); - for (int j = 0; j < transitions.size(); j++) { + for (size_t j = 0; j < transitions.size(); j++) { executeContent(Element(transitions[j])); } } @@ -435,7 +435,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& if (isMember(stateElem, defaultHistoryContent)) { // execute history transition Arabica::XPath::NodeSet transitions = _xpath.evaluate("" + _nsInfo.xpathPrefix + "history/" + _nsInfo.xpathPrefix + "transition", stateElem).asNodeSet(); - for (int j = 0; j < transitions.size(); j++) { + for (size_t j = 0; j < transitions.size(); j++) { executeContent(transitions[j]); } } @@ -459,7 +459,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& Arabica::XPath::NodeSet childs = getChildStates(grandParent); bool inFinalState = true; - for (int j = 0; j < childs.size(); j++) { + for (size_t j = 0; j < childs.size(); j++) { if (!isInFinalState(Element(childs[j]))) { inFinalState = false; break; @@ -471,7 +471,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet& } } } - for (int i = 0; i < _configuration.size(); i++) { + for (size_t i = 0; i < _configuration.size(); i++) { Element stateElem = (Element)_configuration[i]; if (isFinal(stateElem) && parentIsScxmlState(stateElem)) { _topLevelFinalReached = true; @@ -494,39 +494,39 @@ void InterpreterDraft6::addStatesToEnter(const Element& state, #if VERBOSE std::cout << "History State " << ATTR(state, "id") << ": "; - for (int i = 0; i < historyValue.size(); i++) { + for (size_t i = 0; i < historyValue.size(); i++) { std::cout << ATTR_CAST(historyValue[i], "id") << ", "; } std::cout << std::endl; #endif - for (int i = 0; i < historyValue.size(); i++) { + for (size_t i = 0; i < historyValue.size(); i++) { addStatesToEnter(Element(historyValue[i]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); NodeSet ancestors = getProperAncestors(historyValue[i], state); #if VERBOSE std::cout << "Proper Ancestors: "; - for (int i = 0; i < ancestors.size(); i++) { - std::cout << ATTR_CAST(ancestors[i], "id") << ", "; + for (size_t j = 0; j < ancestors.size(); j++) { + std::cout << ATTR_CAST(ancestors[j], "id") << ", "; } std::cout << std::endl; #endif - for (int j = 0; j < ancestors.size(); j++) { + for (size_t j = 0; j < ancestors.size(); j++) { statesToEnter.push_back(ancestors[j]); } } } else { defaultHistoryContent.push_back(getParentState(state)); NodeSet transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", state); - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { NodeSet targets = getTargetStates(Element(transitions[i])); - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { addStatesToEnter(Element(targets[j]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); // Modifications from chris nuernberger NodeSet ancestors = getProperAncestors(targets[j], state); - for (int k = 0; k < ancestors.size(); k++) { + for (size_t k = 0; k < ancestors.size(); k++) { statesToEnter.push_back(ancestors[k]); } } @@ -538,7 +538,7 @@ void InterpreterDraft6::addStatesToEnter(const Element& state, statesForDefaultEntry.push_back(state); NodeSet tStates = getInitialStates(state); - for (int i = 0; i < tStates.size(); i++) { + for (size_t i = 0; i < tStates.size(); i++) { addStatesToEnter(Element(tStates[i]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); } @@ -547,7 +547,7 @@ void InterpreterDraft6::addStatesToEnter(const Element& state, } else if(isParallel(state)) { NodeSet childStates = getChildStates(state); - for (int i = 0; i < childStates.size(); i++) { + for (size_t i = 0; i < childStates.size(); i++) { addStatesToEnter(Element(childStates[i]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); } } @@ -562,7 +562,7 @@ void InterpreterDraft6::handleDOMEvent(Arabica::DOM::Events::Event& return; Node target = Arabica::DOM::Node(event.getTarget()); NodeSet transitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", target, true); - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { const Element transElem = Element(transitions[i]); if (_transWithinParallel.find(transElem) != _transWithinParallel.end()) _transWithinParallel.erase(transElem); diff --git a/src/uscxml/interpreter/InterpreterRC.cpp b/src/uscxml/interpreter/InterpreterRC.cpp index d959e3d..b594c18 100644 --- a/src/uscxml/interpreter/InterpreterRC.cpp +++ b/src/uscxml/interpreter/InterpreterRC.cpp @@ -39,7 +39,7 @@ using namespace Arabica::DOM; size_t padding = 0; std::string getPadding() { std::string pad = ""; - for (int i = 0; i < padding; i++) { + for (size_t i = 0; i < padding; i++) { pad += " "; } return pad; @@ -68,7 +68,7 @@ Arabica::XPath::NodeSet InterpreterRC::removeConflictingTransitions if (!t1Preempted) { // remove transitionsToRemove from DOMUtils::filteredTransitions std::list > tmp; - for (int i = 0; i < filteredTransitions.size(); i++) { + for (size_t i = 0; i < filteredTransitions.size(); i++) { if (!isMember(filteredTransitions[i], transitionsToRemove)) { tmp.push_back(filteredTransitions[i]); } @@ -98,7 +98,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet& enabl #if VERBOSE_STATE_SELECTION std::cout << "exitStates: "; - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { std::cout << ATTR_CAST(statesToExit[i], "id") << " "; } std::cout << std::endl; @@ -106,7 +106,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet& enabl // remove statesToExit from _statesToInvoke std::list > tmp; - for (int i = 0; i < _statesToInvoke.size(); i++) { + for (size_t i = 0; i < _statesToInvoke.size(); i++) { if (!isMember(_statesToInvoke[i], statesToExit)) { tmp.push_back(_statesToInvoke[i]); } @@ -118,13 +118,13 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet& enabl statesToExit.sort(); - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { NodeSet histories = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", statesToExit[i]); - for (int j = 0; j < histories.size(); j++) { + for (size_t j = 0; j < histories.size(); j++) { Element historyElem = (Element)histories[j]; std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow"); NodeSet historyNodes; - for (int k = 0; k < _configuration.size(); k++) { + for (size_t k = 0; k < _configuration.size(); k++) { if (iequals(historyType, "deep")) { if (isAtomic(Element(_configuration[k])) && isDescendant(_configuration[k], statesToExit[i])) historyNodes.push_back(_configuration[k]); @@ -137,11 +137,11 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet& enabl } } - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { USCXML_MONITOR_CALLBACK3(beforeExitingState, Element(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet onExits = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onExit", statesToExit[i]); - for (int j = 0; j < onExits.size(); j++) { + for (size_t j = 0; j < onExits.size(); j++) { Element onExitElem = (Element)onExits[j]; executeContent(onExitElem); } @@ -149,7 +149,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet& enabl USCXML_MONITOR_CALLBACK3(afterExitingState, Element(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToExit[i]); - for (int j = 0; j < invokes.size(); j++) { + for (size_t j = 0; j < invokes.size(); j++) { Element invokeElem = (Element)invokes[j]; if (HAS_ATTR(invokeElem, "persist") && stringIsTrue(ATTR(invokeElem, "persist"))) { } else { @@ -159,7 +159,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet& enabl // remove statesToExit[i] from _configuration - test409 tmp.clear(); - for (int j = 0; j < _configuration.size(); j++) { + for (size_t j = 0; j < _configuration.size(); j++) { if (_configuration[j] != statesToExit[i]) { tmp.push_back(_configuration[j]); } @@ -199,7 +199,7 @@ Arabica::XPath::NodeSet InterpreterRC::computeExitSet(const Arabica } #if VERBOSE std::cout << "computeExitSet: "; - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { std::cout << ATTR_CAST(statesToExit[i], "id") << " "; } std::cout << std::endl; @@ -220,7 +220,7 @@ Arabica::XPath::NodeSet InterpreterRC::computeExitSet(const Arabica #if 0 std::cerr << "Exit set for transition '" << transition << "': " << std::endl; - for (int i = 0; i < exitSet.size(); i++) { + for (size_t i = 0; i < exitSet.size(); i++) { std::cerr << ATTR_CAST(exitSet[i], "id") << std::endl << "----" << std::endl; } std::cerr << std::endl; @@ -239,13 +239,13 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet& enab #if VERBOSE_STATE_SELECTION std::cout << "enterStates: "; - for (int i = 0; i < statesToEnter.size(); i++) { + for (size_t i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR_CAST(statesToEnter[i], "id") << " "; } std::cout << std::endl; #endif - for (int i = 0; i < statesToEnter.size(); i++) { + for (size_t i = 0; i < statesToEnter.size(); i++) { Element s = (Element)statesToEnter[i]; USCXML_MONITOR_CALLBACK3(beforeEnteringState, s, i + 1 < statesToEnter.size()) @@ -257,7 +257,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet& enab NodeSet dataModelElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", s); if(dataModelElems.size() > 0 && _dataModel) { Arabica::XPath::NodeSet dataElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", dataModelElems[0]); - for (int j = 0; j < dataElems.size(); j++) { + for (size_t j = 0; j < dataElems.size(); j++) { if (dataElems[j].getNodeType() == Node_base::ELEMENT_NODE) initializeData(Element(dataElems[j])); } @@ -290,7 +290,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet& enab // extension for flattened SCXML documents, we will need an explicit uninvoke element NodeSet uninvokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", s); - for (int j = 0; j < uninvokes.size(); j++) { + for (size_t j = 0; j < uninvokes.size(); j++) { Element uninvokeElem = (Element)uninvokes[j]; cancelInvoke(uninvokeElem); } @@ -322,7 +322,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet& enab if (isParallel(grandParent)) { Arabica::XPath::NodeSet childs = getChildStates(grandParent); bool inFinalState = true; - for (int j = 0; j < childs.size(); j++) { + for (size_t j = 0; j < childs.size(); j++) { if (!isInFinalState(Element(childs[j]))) { inFinalState = false; break; @@ -353,23 +353,23 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet& std::map >& defaultHistoryContent) { // add all descendants in a dedicated first step - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { Element t(transitions[i]); NodeSet targets = getTargetStates(t); - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { Element s = Element(targets[j]); addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry, defaultHistoryContent); } } // only now add the ancestors - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { Element t(transitions[i]); Element ancestor = Element(getTransitionDomain(t)); NodeSet effectiveTargetStates = getEffectiveTargetStates(t); - for (int j = 0; j < effectiveTargetStates.size(); j++) { + for (size_t j = 0; j < effectiveTargetStates.size(); j++) { Element s = Element(effectiveTargetStates[j]); addAncestorStatesToEnter(s, ancestor, statesToEnter, statesForDefaultEntry, defaultHistoryContent); } @@ -402,7 +402,7 @@ Arabica::XPath::NodeSet InterpreterRC::getEffectiveTargetStates(con targets = getTargetStates(transition); } - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { Element s = Element(targets[j]); if (isHistory(s)) { if (_historyValue.find(ATTR(s, "id")) != _historyValue.end()) { @@ -482,7 +482,7 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element& historyValue = _historyValue[stateId]; - for (int i = 0; i < historyValue.size(); i++) { + for (size_t i = 0; i < historyValue.size(); i++) { const Element& s = Element(historyValue[i]); addDescendantStatesToEnter(s,statesToEnter,statesForDefaultEntry, defaultHistoryContent); addAncestorStatesToEnter(s, getParentState(s), statesToEnter, statesForDefaultEntry, defaultHistoryContent); @@ -496,9 +496,9 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element targets = getTargetStates(Element(transitions[i])); - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { const Element& s = Element(targets[i]); addDescendantStatesToEnter(s,statesToEnter,statesForDefaultEntry, defaultHistoryContent); addAncestorStatesToEnter(s, getParentState(s), statesToEnter, statesForDefaultEntry, defaultHistoryContent); @@ -532,12 +532,12 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element targets = getEffectiveTargetStates(Element(state)); - for (int i = 0; i < targets.size(); i++) { + for (size_t i = 0; i < targets.size(); i++) { const Element& s = Element(targets[i]); addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry, defaultHistoryContent); } - for (int i = 0; i < targets.size(); i++) { + for (size_t i = 0; i < targets.size(); i++) { const Element& s = Element(targets[i]); addAncestorStatesToEnter(s, state, statesToEnter, statesForDefaultEntry, defaultHistoryContent); } @@ -545,10 +545,10 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element childStates = getChildStates(state); - for (int i = 0; i < childStates.size(); i++) { + for (size_t i = 0; i < childStates.size(); i++) { const Element& child = Element(childStates[i]); - for (int j = 0; j < statesToEnter.size(); j++) { + for (size_t j = 0; j < statesToEnter.size(); j++) { const Node& s = statesToEnter[j]; if (isDescendant(s, child)) { goto BREAK_LOOP; @@ -585,7 +585,7 @@ void InterpreterRC::addAncestorStatesToEnter(const Arabica::DOM::Element ancestors = getProperAncestors(state, ancestor); - for (int i = 0; i < ancestors.size(); i++) { + for (size_t i = 0; i < ancestors.size(); i++) { const Node& anc = ancestors[i]; #if VERBOSE_STATE_SELECTION std::cout << getPadding() << "adding: " << ATTR_CAST(anc, "id") << std::endl; @@ -595,9 +595,9 @@ void InterpreterRC::addAncestorStatesToEnter(const Arabica::DOM::Element(anc))) { NodeSet childStates = getChildStates(anc); - for (int j = 0; j < childStates.size(); j++) { + for (size_t j = 0; j < childStates.size(); j++) { const Element& child = Element(childStates[j]); - for (int k = 0; k < statesToEnter.size(); k++) { + for (size_t k = 0; k < statesToEnter.size(); k++) { const Node& s = statesToEnter[k]; if (isDescendant(s, child)) { goto BREAK_LOOP; @@ -631,7 +631,7 @@ Arabica::DOM::Node InterpreterRC::getTransitionDomain(const Arabica Node source = getSourceState(transition); if (iequals(transitionType, "internal") && isCompound(Element(source))) { - for (int i = 0; i < tStates.size(); i++) { + for (size_t i = 0; i < tStates.size(); i++) { const Node& s = tStates[i]; if (!isDescendant(s, source)) goto BREAK_LOOP; diff --git a/src/uscxml/messages/Data.cpp b/src/uscxml/messages/Data.cpp index 53d4571..b555ed8 100644 --- a/src/uscxml/messages/Data.cpp +++ b/src/uscxml/messages/Data.cpp @@ -83,7 +83,7 @@ Data::Data(const Arabica::DOM::Node& dom) { if (dom.hasAttributes()) { Arabica::DOM::NamedNodeMap attributes = dom.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { + for (size_t i = 0; i < attributes.getLength(); i++) { Arabica::DOM::Node attribute = attributes.item(i); // Interpreter::dump(attribute); @@ -96,7 +96,7 @@ Data::Data(const Arabica::DOM::Node& dom) { if (dom.hasChildNodes()) { Arabica::DOM::NodeList children = dom.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { + for (size_t i = 0; i < children.getLength(); i++) { Arabica::DOM::Node child = children.item(i); // Interpreter::dump(child); std::string key; @@ -307,7 +307,7 @@ std::ostream& operator<< (std::ostream& os, const Data& data) { std::string Data::toJSON(const Data& data) { std::stringstream os; std::string indent; - for (int i = 0; i < _dataIndentation; i++) { + for (size_t i = 0; i < _dataIndentation; i++) { indent += " "; } if (false) { @@ -352,7 +352,7 @@ std::string Data::toJSON(const Data& data) { // empty string is handled below if (data.type == Data::VERBATIM) { os << "\""; - for (int i = 0; i < data.atom.size(); i++) { + for (size_t i = 0; i < data.atom.size(); i++) { // escape string if (false) { } else if (data.atom[i] == '"') { diff --git a/src/uscxml/messages/Data.h b/src/uscxml/messages/Data.h index f4d220f..c2e7dcf 100644 --- a/src/uscxml/messages/Data.h +++ b/src/uscxml/messages/Data.h @@ -116,7 +116,7 @@ public: array.push_back(Data("", Data::VERBATIM)); } std::list::iterator arrayIter = array.begin(); - for (int i = 0; i < index; i++, arrayIter++) {} + for (size_t i = 0; i < index; i++, arrayIter++) {} return *arrayIter; } @@ -134,7 +134,7 @@ public: const Data item(const size_t index) const { if (array.size() > index) { std::list::const_iterator arrayIter = array.begin(); - for (int i = 0; i < index; i++, arrayIter++) {} + for (size_t i = 0; i < index; i++, arrayIter++) {} return *arrayIter; } Data data; diff --git a/src/uscxml/messages/Event.cpp b/src/uscxml/messages/Event.cpp index 072c1b9..f247542 100644 --- a/src/uscxml/messages/Event.cpp +++ b/src/uscxml/messages/Event.cpp @@ -100,12 +100,12 @@ Event Event::fromXML(const std::string& xmlString) { Arabica::DOM::Element payloadElem = (Arabica::DOM::Element)payload; Arabica::DOM::NodeList properties = payloadElem.getElementsByTagName("scxml:property"); if (properties.getLength() > 0) { - for (int i = 0; i < properties.getLength(); i++) { + for (size_t i = 0; i < properties.getLength(); i++) { if (HAS_ATTR_CAST(properties.item(i), "name")) { std::string key = ATTR_CAST(properties.item(i), "name"); std::string value; Arabica::DOM::NodeList childs = properties.item(i).getChildNodes(); - for (int j = 0; j < childs.getLength(); j++) { + for (size_t j = 0; j < childs.getLength(); j++) { if (childs.item(j).getNodeType() == Arabica::DOM::Node_base::TEXT_NODE) { value = childs.item(j).getNodeValue(); break; @@ -123,7 +123,7 @@ Event Event::fromXML(const std::string& xmlString) { std::ostream& operator<< (std::ostream& os, const Event& event) { std::string indent; - for (int i = 0; i < _dataIndentation; i++) { + for (size_t i = 0; i < _dataIndentation; i++) { indent += " "; } diff --git a/src/uscxml/messages/InvokeRequest.cpp b/src/uscxml/messages/InvokeRequest.cpp index 26d40ce..e56a6ff 100644 --- a/src/uscxml/messages/InvokeRequest.cpp +++ b/src/uscxml/messages/InvokeRequest.cpp @@ -48,7 +48,7 @@ InvokeRequest InvokeRequest::fromXML(const std::string& xmlString) { std::ostream& operator<< (std::ostream& os, const InvokeRequest& invokeReq) { std::string indent; - for (int i = 0; i < _dataIndentation; i++) { + for (size_t i = 0; i < _dataIndentation; i++) { indent += " "; } diff --git a/src/uscxml/messages/SendRequest.cpp b/src/uscxml/messages/SendRequest.cpp index 497182c..4759d29 100644 --- a/src/uscxml/messages/SendRequest.cpp +++ b/src/uscxml/messages/SendRequest.cpp @@ -89,7 +89,7 @@ SendRequest SendRequest::fromXML(const std::string& xmlString) { std::ostream& operator<< (std::ostream& os, const SendRequest& sendReq) { std::string indent; - for (int i = 0; i < _dataIndentation; i++) { + for (size_t i = 0; i < _dataIndentation; i++) { indent += " "; } diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp index c23b483..63314e1 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp @@ -127,7 +127,7 @@ static int luaInFunction(lua_State * l) { InterpreterInfo* interpreter = ref.cast(); int stackSize = lua_gettop(l); - for (int i = 0; i < stackSize; i++) { + for (size_t i = 0; i < stackSize; i++) { if (!lua_isstring(l, -1 - i)) continue; std::string stateName = lua_tostring(l, -1 - i); diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp index 9a59a20..2ec9fea 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp @@ -308,7 +308,7 @@ void SWIDataModel::setEvent(const Event& event) { paramArray << paramIter->first << "(["; std::string termSep = ""; - for (int j = 0; paramIter != lastValueIter; j++) { + for (size_t j = 0; paramIter != lastValueIter; j++) { paramArray << termSep << "'" << paramIter->second << "'"; termSep = ", "; paramIter++; @@ -405,7 +405,7 @@ std::list SWIDataModel::getSolutions(PlCompound compound) { std::list solutions; PlTermv termv(compound.arity()); - for (int i = 0; i < compound.arity(); i++) { + for (size_t i = 0; i < compound.arity(); i++) { termv[i] = compound[i + 1]; } PlQuery query(compound.name(), termv); @@ -425,7 +425,7 @@ Data SWIDataModel::getStringAsData(const std::string& content) { Data data; PlTermv termv(compound.arity()); - for (int i = 0; i < compound.arity(); i++) { + for (size_t i = 0; i < compound.arity(); i++) { termv[i] = compound[i + 1]; } PlQuery query(compound.name(), termv); @@ -460,7 +460,7 @@ Data SWIDataModel::termAsData(PlTerm term) { switch (term.type()) { case PL_TERM: - for (int i = 1; i <= term.arity(); i++) { // arguments start at 1 + for (size_t i = 1; i <= term.arity(); i++) { // arguments start at 1 data.compound[term.name()] = termAsData(term[i]); } break; @@ -618,7 +618,7 @@ uint32_t SWIDataModel::getLength(const std::string& expr) { try { PlCompound compound(expr.c_str()); PlTermv termv(compound.arity()); - for (int i = 0; i < compound.arity(); i++) { + for (size_t i = 0; i < compound.arity(); i++) { termv[i] = compound[i + 1]; } PlQuery query(compound.name(), termv); @@ -639,7 +639,7 @@ void SWIDataModel::setForeach(const std::string& item, PlCompound compound(array.c_str()); PlCompound orig(array.c_str()); PlTermv termv(compound.arity()); - for (int i = 0; i < compound.arity(); i++) { + for (size_t i = 0; i < compound.arity(); i++) { termv[i] = compound[i + 1]; } { @@ -686,7 +686,7 @@ bool SWIDataModel::evalAsBool(const Arabica::DOM::Element& node, co try { PlCompound compound(expr.c_str()); PlTermv termv(compound.arity()); - for (int i = 0; i < compound.arity(); i++) { + for (size_t i = 0; i < compound.arity(); i++) { termv[i] = compound[i + 1]; } PlQuery query(compound.name(), termv); @@ -708,7 +708,7 @@ std::string SWIDataModel::evalAsString(const std::string& expr) { PlCompound orig(expr.c_str()); PlTermv termv(compound.arity()); - for (int i = 0; i < compound.arity(); i++) { + for (size_t i = 0; i < compound.arity(); i++) { termv[i] = compound[i + 1]; } PlQuery query(compound.name(), termv); @@ -760,7 +760,7 @@ std::map SWIDataModel::resolveAtoms(PlTerm& term, PlTerm& o case PL_INTEGER: break; case PL_TERM: - for (int i = 1; i <= orig.arity(); i++) { + for (size_t i = 1; i <= orig.arity(); i++) { PlTerm newTerm = term[i]; PlTerm newOrig = orig[i]; std::map result = resolveAtoms(newTerm, newOrig); diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp index 02df56d..d65e9c7 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp @@ -391,7 +391,7 @@ void PromelaDataModel::evaluateDecl(void* ast) { int size = dataToInt(evaluateExpr(*opIterAsgn++)); variable.compound["size"] = size; - for (int i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { variable.compound["value"].array.push_back(Data(0, Data::INTERPRETED)); } diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp index c07fca2..3467598 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp +++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp @@ -42,7 +42,7 @@ void promela_error (void* yylloc_param, uscxml::PromelaParser* ctx, void* yyscan excEvent.data.compound["col"] = uscxml::Data(yylloc->first_column, uscxml::Data::VERBATIM); std::stringstream ssUnderline; - for (int i = 0; i < yylloc->first_column; i++) + for (size_t i = 0; i < yylloc->first_column; i++) ssUnderline << " "; ssUnderline << "^"; excEvent.data.compound["sourcemark"] = uscxml::Data(ssUnderline.str(), uscxml::Data::VERBATIM); @@ -197,7 +197,7 @@ void PromelaParserNode::push(PromelaParserNode* node) { void PromelaParserNode::dump(int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } std::cout << padding << typeToDesc(type) << ": " << value; diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp index 3bb22cc..282e8c6 100644 --- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp +++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp @@ -269,7 +269,7 @@ Data XPathDataModel::getStringAsData(const std::string& content) { break; case NODE_SET: NodeSet ns = result.asNodeSet(); - for (int i = 0; i < ns.size(); i++) { + for (size_t i = 0; i < ns.size(); i++) { ss.str(""); ss << i; std::string idx = ss.str(); @@ -321,7 +321,7 @@ void XPathDataModel::setForeach(const std::string& item, #if 0 std::cout << "Array Size: " << arrayResult.asNodeSet().size() << std::endl; - for (int i = 0; i < arrayResult.asNodeSet().size(); i++) { + for (size_t i = 0; i < arrayResult.asNodeSet().size(); i++) { std::cout << arrayResult.asNodeSet()[i] << std::endl; } #endif @@ -367,7 +367,7 @@ void XPathDataModel::setForeach(const std::string& item, #if 0 std::cout << _datamodel << std::endl << std::endl; std::cout << "Index: " << indexResult.asNodeSet().size() << std::endl; - for (int i = 0; i < indexResult.asNodeSet().size(); i++) { + for (size_t i = 0; i < indexResult.asNodeSet().size(); i++) { std::cout << indexResult.asNodeSet()[i] << std::endl; } std::cout << std::endl; @@ -438,7 +438,7 @@ std::string XPathDataModel::evalAsString(const std::string& expr) { case NODE_SET: { NodeSet nodeSet = result.asNodeSet(); std::stringstream ss; - for (int i = 0; i < nodeSet.size(); i++) { + for (size_t i = 0; i < nodeSet.size(); i++) { ss << nodeSet[i]; if (nodeSet[i].getNodeType() != Node_base::TEXT_NODE) { ss << std::endl; @@ -477,7 +477,7 @@ void XPathDataModel::assign(const Element& assignElem, #if 0 if (key.type() == NODE_SET) { try { - for (int i = 0; i < key.asNodeSet().size(); i++) { + for (size_t i = 0; i < key.asNodeSet().size(); i++) { Node node = key.asNodeSet()[i]; if (node == _varResolver.resolveVariable("", "_ioprocessors").asNodeSet()[0]) ERROR_EXECUTION_THROW("Cannot assign _ioProcessors"); @@ -561,7 +561,7 @@ void XPathDataModel::init(const Element& dataElem, XPathValue expr = _xpath.evaluate_expr(ATTR(dataElem, "expr"), _doc); switch (expr.type()) { case NODE_SET: { - for (int i = 0; i < expr.asNodeSet().size(); i++) { + for (size_t i = 0; i < expr.asNodeSet().size(); i++) { container.appendChild(expr.asNodeSet()[i].cloneNode(true)); nodeSet.push_back(expr.asNodeSet()[i].cloneNode(true)); } @@ -654,7 +654,7 @@ void XPathDataModel::assign(const NodeSet& key, const Element& assignElem) { if (key.size() == 0) return; - for (int i = 0; i < key.size(); i++) { + for (size_t i = 0; i < key.size(); i++) { Node node = key[i]; switch (node.getNodeType()) { case Node_base::ATTRIBUTE_NODE: { @@ -710,7 +710,7 @@ void XPathDataModel::assign(const NodeSet& key, if (value.size() == 0 || !value[0]) return; - for (int i = 0; i < key.size(); i++) { + for (size_t i = 0; i < key.size(); i++) { switch (key[i].getNodeType()) case Node_base::ELEMENT_NODE: { assign(Element(key[i]), value, assignElem); @@ -733,13 +733,13 @@ void XPathDataModel::assign(const Element& key, if (false) { } else if (assignElem && HAS_ATTR(assignElem, "type") && iequals(ATTR(assignElem, "type"), "firstchild")) { // firstchild: Insert the value specified by 'expr' before all of the children at 'location'. - for (int i = value.size(); i; i--) { + for (size_t i = value.size(); i; i--) { Node importedNode = (value[i-1].getOwnerDocument() == _doc ? value[i-1].cloneNode(true) : _doc.importNode(value[i-1], true)); element.insertBefore(importedNode, element.getFirstChild()); } } else if (assignElem && HAS_ATTR(assignElem, "type") && iequals(ATTR(assignElem, "type"), "lastchild")) { // lastchild: Insert the value specified by 'expr' after all of the children at 'location'. - for (int i = 0; i < value.size(); i++) { + for (size_t i = 0; i < value.size(); i++) { Node importedNode = (value[i].getOwnerDocument() == _doc ? value[i].cloneNode(true) : _doc.importNode(value[i], true)); element.appendChild(importedNode); } @@ -749,7 +749,7 @@ void XPathDataModel::assign(const Element& key, Node parent = element.getParentNode(); if (!parent) ERROR_EXECUTION_THROW("Node has no parent"); - for (int i = 0; i < value.size(); i++) { + for (size_t i = 0; i < value.size(); i++) { Node importedNode = (value[i].getOwnerDocument() == _doc ? value[i].cloneNode(true) : _doc.importNode(value[i], true)); parent.insertBefore(importedNode, element); } @@ -759,7 +759,7 @@ void XPathDataModel::assign(const Element& key, Node parent = element.getParentNode(); if (!parent) ERROR_EXECUTION_THROW("Node has no parent"); - for (int i = value.size(); i; i--) { + for (size_t i = value.size(); i; i--) { Node importedNode = (value[i-1].getOwnerDocument() == _doc ? value[i-1].cloneNode(true) : _doc.importNode(value[i-1], true)); Node nextSibling = element.getNextSibling(); if (nextSibling) { @@ -787,7 +787,7 @@ void XPathDataModel::assign(const Element& key, // replacechildren: Replace all the children at 'location' with the value specified by 'expr'. while(element.hasChildNodes()) element.removeChild(element.getChildNodes().item(0)); - for (int i = 0; i < value.size(); i++) { + for (size_t i = 0; i < value.size(); i++) { Node importedNode = element.getOwnerDocument().importNode(value[i], true); element.appendChild(importedNode); } @@ -803,7 +803,7 @@ NodeSetVariableResolver::resolveVariable(const std::string& namepaceUri, } #if VERBOSE std::cout << std::endl << "Getting " << name << ":" << std::endl; - for (int i = 0; i < n->second.size(); i++) { + for (size_t i = 0; i < n->second.size(); i++) { std::cout << n->second[i].getNodeType() << " | " << n->second[i] << std::endl; } std::cout << std::endl; @@ -814,7 +814,7 @@ NodeSetVariableResolver::resolveVariable(const std::string& namepaceUri, void NodeSetVariableResolver::setVariable(const std::string& name, const NodeSet& value) { #if VERBOSE std::cout << std::endl << "Setting " << name << ":" << std::endl; - for (int i = 0; i < value.size(); i++) { + for (size_t i = 0; i < value.size(); i++) { std::cout << value[i].getNodeType() << " | " << value[i] << std::endl; } std::cout << std::endl; @@ -824,7 +824,7 @@ void NodeSetVariableResolver::setVariable(const std::string& name, const NodeSet std::map >::iterator varIter = _variables.begin(); while (varIter != _variables.end()) { std::cout << varIter->first << ":" << std::endl; - for (int i = 0; i < varIter->second.size(); i++) { + for (size_t i = 0; i < varIter->second.size(); i++) { std::cout << varIter->second[i].getNodeType() << " | " << varIter->second[i] << std::endl; } varIter++; @@ -861,7 +861,7 @@ std::vector > XPathFunctionResolver::validNa bool XPathFunctionIn::doEvaluate(const Node& context, const ExecutionContext& executionContext) const { - for (int i = 0; i < argCount(); i++) { + for (size_t i = 0; i < argCount(); i++) { XPathValue stateName = arg(i, context, executionContext); if (stateName.type() == STRING) { if (_interpreter->isInState(stateName.asString())) { diff --git a/src/uscxml/plugins/element/respond/RespondElement.cpp b/src/uscxml/plugins/element/respond/RespondElement.cpp index 65babd7..032f74e 100644 --- a/src/uscxml/plugins/element/respond/RespondElement.cpp +++ b/src/uscxml/plugins/element/respond/RespondElement.cpp @@ -144,7 +144,7 @@ void RespondElement::enterElement(const Arabica::DOM::Element& node // process headers Arabica::XPath::NodeSet headers = DOMUtils::filterChildElements(_interpreter->getNameSpaceInfo().getXMLPrefixForNS(getNamespace()) + "header", node); - for (int i = 0; i < headers.size(); i++) { + for (size_t i = 0; i < headers.size(); i++) { Arabica::DOM::Element headerElem = Arabica::DOM::Element(headers[i]); std::string name; diff --git a/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp b/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp index 5833e2b..3aaeddf 100644 --- a/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp +++ b/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp @@ -96,12 +96,12 @@ OpenALPlayer::~OpenALPlayer() { if (alIsSource(_alId)) { throw std::runtime_error("openal source id still valid"); } - for (int i = 0; i < _nrBuffers; i++) { + for (size_t i = 0; i < _nrBuffers; i++) { assert(alIsBuffer(_bufferIds[i])); free(_buffers[i]); } alDeleteBuffers(_nrBuffers, _bufferIds); - for (int i = 0; i < _nrBuffers; i++) { + for (size_t i = 0; i < _nrBuffers; i++) { // assert(!alIsBuffer(_bufferIds[i])); } free(_buffers); @@ -134,7 +134,7 @@ void OpenALPlayer::init() { _buffers = (char**)malloc(_nrBuffers * sizeof(char*)); _bufferIds = (ALuint*)malloc(_nrBuffers * sizeof(ALuint)); - for (int i = 0; i < _nrBuffers; i++) { + for (size_t i = 0; i < _nrBuffers; i++) { _buffers[i] = 0; //(char*)malloc(_bufferSize); } @@ -384,7 +384,7 @@ void OpenALPlayer::updateBuffers() { alSourceUnqueueBuffers(_alId, processed, bufferIds); checkOpenALError(__LINE__); - for (int id = 0; id < processed; id++) { + for (size_t id = 0; id < processed; id++) { int bufferIdx = bufferIndex(bufferIds[id]); // refill the buffer with data from the callback diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp index 5e2d8eb..f67e58f 100644 --- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp +++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp @@ -95,7 +95,7 @@ void FFMPEGInvoker::invoke(const InvokeRequest& req) { Event::getParam(req.params, "threads", nrThreads); _isRunning = true; - for (int i = 0; i < nrThreads; i++) { + for (size_t i = 0; i < nrThreads; i++) { _threads.insert(new tthread::thread(FFMPEGInvoker::run, this)); } } diff --git a/src/uscxml/transform/ChartToFSM.cpp b/src/uscxml/transform/ChartToFSM.cpp index da53c1f..aa9dda8 100644 --- a/src/uscxml/transform/ChartToFSM.cpp +++ b/src/uscxml/transform/ChartToFSM.cpp @@ -73,7 +73,7 @@ if (now - _lastTimeStamp > 1000 || disregardTime) { \ {\ std::cout << std::endl;\ std::cout << "** " << transitions.size() << " ** " << where << std::endl;\ - for (int m = 0; m < transitions.size(); m++) {\ + for (size_t m = 0; m < transitions.size(); m++) {\ std::cout << transitions[m] << std::endl;\ }\ } @@ -88,7 +88,7 @@ using namespace Arabica::XPath; #define DETAIL_EXEC_CONTENT(field, actPtr) \ std::cerr << " " << #field << " / " << TAGNAME_CAST(actPtr->field) << " ("; \ NodeSet contents = filterChildType(Node_base::ELEMENT_NODE, actPtr->field, true); \ -for (int i = 0; i < contents.size(); i++) { \ +for (size_t i = 0; i < contents.size(); i++) { \ std::cerr << " " << TAGNAME_CAST(contents[i]); \ } \ std::cerr << ")"; @@ -148,7 +148,7 @@ ChartToFSM::~ChartToFSM() { // tear down caches Arabica::XPath::NodeSet allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true); - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { _transParents.erase(allTransitions[i]); } } @@ -215,14 +215,14 @@ InterpreterState ChartToFSM::interpret() { { Arabica::XPath::NodeSet allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true); indexedTransitions.reserve(allTransitions.size()); - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { _transParents[allTransitions[i]] = InterpreterImpl::getParentState(allTransitions[i]); } } // identify all history elements NodeSet histories = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "history", _scxml, true); - for (int i = 0; i < histories.size(); i++) { + for (size_t i = 0; i < histories.size(); i++) { _historyTargets[ATTR_CAST(histories[i], "id")] = Element(histories[i]); } @@ -236,7 +236,7 @@ InterpreterState ChartToFSM::interpret() { // set invokeid for all invokers to parent state if none given NodeSet invokers = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true); - for (int i = 0; i < invokers.size(); i++) { + for (size_t i = 0; i < invokers.size(); i++) { Element invokerElem = Element(invokers[i]); invokerElem.setAttribute("parent", ATTR_CAST(invokerElem.getParentNode(), "id")); } @@ -255,7 +255,7 @@ InterpreterState ChartToFSM::interpret() { Arabica::XPath::NodeSet initialStates; initialStates = getInitialStates(); assert(initialStates.size() > 0); - for (int i = 0; i < initialStates.size(); i++) { + for (size_t i = 0; i < initialStates.size(); i++) { Element initialElem = _document.createElementNS(_nsInfo.nsURL, "initial"); _nsInfo.setPrefix(initialElem); initialElem.setAttribute("generated", "true"); @@ -275,19 +275,19 @@ InterpreterState ChartToFSM::interpret() { indexTransitions(); // add initial transitions as least prior - for (int i = 0; i < initialTransitions.size() ; i++) { + for (size_t i = 0; i < initialTransitions.size() ; i++) { indexedTransitions.push_back(Element(initialTransitions[i])); } // set index attribute for transitions - for (int i = 0; i < indexedTransitions.size(); i++) { + for (size_t i = 0; i < indexedTransitions.size(); i++) { // std::cerr << toStr(i) << ":" << (HAS_ATTR(indexedTransitions[i], "line_start") ? ATTR(indexedTransitions[i], "line_start") : ""); // std::cerr << "\t" << DOMUtils::xPathForNode(indexedTransitions[i]) << std::endl; indexedTransitions[i].setAttribute("index", toStr(i)); } // int lastTransIndex = indexedTransitions.size(); -// for (int i = 0; i < initialTransitions.size() ; i++, lastTransIndex++) { +// for (size_t i = 0; i < initialTransitions.size() ; i++, lastTransIndex++) { // indexedTransitions[i].setAttribute("index", toStr(indexedTransitions.size() - 1 - i)); // } @@ -296,7 +296,7 @@ InterpreterState ChartToFSM::interpret() { allStates.to_document_order(); indexedStates.resize(allStates.size()); - for (int i = 0; i < allStates.size(); i++) { + for (size_t i = 0; i < allStates.size(); i++) { Element state = Element(allStates[i]); // while we are iterating, determine deepest nested level @@ -471,7 +471,7 @@ static bool isSuperset(const GlobalTransition* t1, const GlobalTransition* t2) { NodeSet t1Trans = t1->getTransitions(); NodeSet t2Trans = t2->getTransitions(); - for (int i = 0; i < t1Trans.size(); i++) { + for (size_t i = 0; i < t1Trans.size(); i++) { if (!InterpreterImpl::isMember(t1Trans[i], t2Trans)) { isSuperset = false; } @@ -566,12 +566,12 @@ void ChartToFSM::annotateRaiseAndSend(const Arabica::DOM::Element& execContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true)); execContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onentry", _scxml, true)); execContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "onexit", _scxml, true)); - for (int i = 0; i < execContent.size(); i++) { + for (size_t i = 0; i < execContent.size(); i++) { Element execContentElem(execContent[i]); int nrRaise = 0; NodeSet raise = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "raise", execContent[i], true); - for (int j = 0; j < raise.size(); j++) { + for (size_t j = 0; j < raise.size(); j++) { if (hasForeachInBetween(execContent[i], raise[j])) { execContentElem.setAttribute("raise", "-1"); goto DONE_COUNT_RAISE; @@ -585,7 +585,7 @@ DONE_COUNT_RAISE: int nrSend = 0; NodeSet sends = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", execContent[i], true); - for (int j = 0; j < sends.size(); j++) { + for (size_t j = 0; j < sends.size(); j++) { if (hasForeachInBetween(execContent[i], sends[j])) { execContentElem.setAttribute("send", "-1"); goto DONE_COUNT_SEND; @@ -602,7 +602,7 @@ DONE_COUNT_SEND: void ChartToFSM::annotateDomain() { Arabica::XPath::NodeSet allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true); - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { Element transition(allTransitions[i]); Arabica::DOM::Node domain = getTransitionDomain(transition); if (domain) { @@ -615,14 +615,14 @@ void ChartToFSM::annotateDomain() { void ChartToFSM::annotateExitSet() { Arabica::XPath::NodeSet allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true); - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { Element transition(allTransitions[i]); Arabica::DOM::Node domain = getTransitionDomain(transition); Arabica::XPath::NodeSet allStates = getAllStates(); std::ostringstream exitSetStr; std::string seperator = ""; - for (int j = 0; j < allStates.size(); j++) { + for (size_t j = 0; j < allStates.size(); j++) { Element state(allStates[j]); if (state.getParentNode() == domain) { exitSetStr << seperator << (HAS_ATTR(state, "id") ? ATTR(state, "id") : DOMUtils::xPathForNode(state)); @@ -635,7 +635,7 @@ void ChartToFSM::annotateExitSet() { void ChartToFSM::annotateEntrySet() { Arabica::XPath::NodeSet allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true); - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { Element transition(allTransitions[i]); NodeSet tmpTransitions; @@ -649,12 +649,12 @@ void ChartToFSM::annotateEntrySet() { std::ostringstream entrySetStr; std::string seperator = ""; - for (int j = 0; j < tmpStatesToEnter.size(); j++) { + for (size_t j = 0; j < tmpStatesToEnter.size(); j++) { Element state(tmpStatesToEnter[j]); entrySetStr << seperator << (HAS_ATTR(state, "id") ? ATTR(state, "id") : DOMUtils::xPathForNode(state)); seperator = ", "; } - for (int j = 0; j < tmpStatesForDefaultEntry.size(); j++) { + for (size_t j = 0; j < tmpStatesForDefaultEntry.size(); j++) { Element state(tmpStatesForDefaultEntry[j]); entrySetStr << seperator << (HAS_ATTR(state, "id") ? ATTR(state, "id") : DOMUtils::xPathForNode(state)); seperator = ", "; @@ -668,7 +668,7 @@ void ChartToFSM::annotateConflicts() { Arabica::XPath::NodeSet allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true); Arabica::XPath::NodeSet allStates = getAllStates(); - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { Element t1(allTransitions[i]); if (!isState(Element(t1.getParentNode()))) continue; @@ -676,7 +676,7 @@ void ChartToFSM::annotateConflicts() { Arabica::DOM::Node d1 = getTransitionDomain(t1); Arabica::XPath::NodeSet exitSet1; - for (int k = 0; k < allStates.size(); k++) { + for (size_t k = 0; k < allStates.size(); k++) { Element state(allStates[k]); if (isDescendant(state, d1)) { exitSet1.push_back(state); @@ -686,7 +686,7 @@ void ChartToFSM::annotateConflicts() { std::ostringstream preemptionStr; std::string seperator = ""; - for (int j = 0; j < allTransitions.size(); j++) { + for (size_t j = 0; j < allTransitions.size(); j++) { if ( i == j) continue; @@ -697,7 +697,7 @@ void ChartToFSM::annotateConflicts() { Arabica::DOM::Node d2 = getTransitionDomain(t2); Arabica::XPath::NodeSet exitSet2; - for (int k = 0; k < allStates.size(); k++) { + for (size_t k = 0; k < allStates.size(); k++) { Element state(allStates[k]); if (isDescendant(state, d2)) { exitSet2.push_back(state); @@ -764,13 +764,13 @@ void ChartToFSM::indexTransitions(const Arabica::DOM::Element& root void ChartToFSM::indexTransitions(const Arabica::DOM::Element& root) { // Post-order traversal of transitions Arabica::XPath::NodeSet childStates = getChildStates(root); - for (int i = 0; i < childStates.size(); i++) { + for (size_t i = 0; i < childStates.size(); i++) { Element childElem(childStates[i]); indexTransitions(childElem); } Arabica::XPath::NodeSet levelTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", root); - for (int i = 0; i < levelTransitions.size(); i++) { + for (size_t i = 0; i < levelTransitions.size(); i++) { // push into index starting with least prior indexedTransitions.push_back(Element(levelTransitions[i])); } @@ -813,7 +813,7 @@ bool hasUnconditionalSuperset(GlobalTransition* first, GlobalTransition* second) // return false; if (isSuperset(second, first)) { - for (int i = 0; i < firstTransitions.size(); i++) { + for (size_t i = 0; i < firstTransitions.size(); i++) { if (!InterpreterImpl::isMember(firstTransitions[i], secondTransitions)) { if (HAS_ATTR_CAST(firstTransitions[i], "cond")) { return false; // second can't be removed @@ -996,7 +996,7 @@ std::list redundantMark(std::list list) { void TransitionTreeNode::dump(int indent) { std::string padding; - for (int i = 0; i + 1 < indent; i++) { + for (size_t i = 0; i + 1 < indent; i++) { padding += "| "; } if (indent > 0) @@ -1052,7 +1052,7 @@ void ChartToFSM::getPotentialTransitionsForConfFromTree(const Arabica::XPath::No // recursion start std::set transLeafs; - for (int i = 0; i < conf.size(); i++) { + for (size_t i = 0; i < conf.size(); i++) { DUMP_STATS(conf.size(), false); Element confElem(conf[i]); @@ -1256,7 +1256,7 @@ TransitionTreeNode* ChartToFSM::buildTransTree(const Arabica::DOM::Element nestedElem(nested[i]); if (TAGNAME(nestedElem) == _nsInfo.xmlNSPrefix + "transition") { TransitionTreeNode* transNode = new TransitionTreeNode(); @@ -1300,7 +1300,7 @@ void ChartToFSM::getPotentialTransitionsForConfFromPowerSet(const Arabica::XPath { std::string seperator = ""; - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { std::cerr << seperator << ATTR_CAST(allTransitions[i], "index"); seperator=", "; } @@ -1344,7 +1344,7 @@ void ChartToFSM::getPotentialTransitionsForConfFromPowerSet(const Arabica::XPath NodeSet transitions; // std::cerr << globalState->stateId << " [" << nrElements << "]: " << std::endl; - for (int i = 1; i <= k; i++) { + for (size_t i = 1; i <= k; i++) { // std::cerr << stack[i] - 1 << ", "; transitions.push_back(allTransitions[stack[i] - 1]); } @@ -1742,16 +1742,16 @@ GlobalState::GlobalState(const Arabica::XPath::NodeSet& activeState activeIndex = -1; // take references - for (int i = 0; i < activeStates_.size(); i++) { + for (size_t i = 0; i < activeStates_.size(); i++) { activeStatesRefs.insert(strTo(ATTR_CAST(activeStates_[i], "index"))); } - for (int i = 0; i < alreadyEnteredStates_.size(); i++) { + for (size_t i = 0; i < alreadyEnteredStates_.size(); i++) { alreadyEnteredStatesRefs.insert(strTo(ATTR_CAST(alreadyEnteredStates_[i], "index"))); } for (std::map >::const_iterator histIter = historyStates_.begin(); histIter != historyStates_.end(); histIter++) { - for (int i = 0; i < histIter->second.size(); i++) { + for (size_t i = 0; i < histIter->second.size(); i++) { historyStatesRefs[histIter->first].insert(strTo(ATTR_CAST(histIter->second[i], "index"))); } } @@ -1790,7 +1790,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet& t eventsChainSent = 0; historyBase = NULL; - for (int i = 0; i < transitionSet.size(); i++) { + for (size_t i = 0; i < transitionSet.size(); i++) { transitionRefs.insert(strTo(ATTR_CAST(transitionSet[i], "index"))); } @@ -1808,7 +1808,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet& t #if 0 std::cerr << "################" << std::endl; - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { std::cerr << transitions[i] << std::endl; } std::cerr << "################" << std::endl; @@ -1833,7 +1833,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet& t Arabica::DOM::Element withTarget; Arabica::DOM::Element noneTarget; - for (int i = 0; i < transitionSet.size(); i++) { + for (size_t i = 0; i < transitionSet.size(); i++) { Arabica::DOM::Element transElem = Arabica::DOM::Element(transitionSet[i]); if (HAS_ATTR(transElem, "eventexpr")) { ERROR_EXECUTION_THROW("Cannot flatten document with eventexpr attributes"); @@ -1909,7 +1909,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet& t // extract conditions and history targets std::list conditions; - for (int i = 0; i < transitionSet.size(); i++) { + for (size_t i = 0; i < transitionSet.size(); i++) { Arabica::DOM::Element transElem = Arabica::DOM::Element(transitionSet[i]); // gather conditions while we are iterating anyway if (HAS_ATTR(transElem, "cond")) { @@ -1937,7 +1937,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet& t members += seperator + ATTR(refTrans, "priority"); } else { members += seperator; - for (int i = 0; i < ATTR(refTrans, "priority").size(); i++) { + for (size_t i = 0; i < ATTR(refTrans, "priority").size(); i++) { members += " "; } } @@ -1982,7 +1982,7 @@ std::list GlobalTransition::getCommonEvents(const NodeSet prefixes; std::list longestPrefixes; - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { // for every transition std::list eventNames = tokenize(ATTR_CAST(transitions[i], "event")); @@ -1999,7 +1999,7 @@ std::list GlobalTransition::getCommonEvents(const NodeSet 0) { \ pendingComments.clear(); \ if (stateId.length() > 0) \ transientState.setAttribute("id", stateId); \ - for (int i = 0; i < childs.size(); i++) { \ + for (size_t i = 0; i < childs.size(); i++) { \ Node imported = _flatDoc.importNode(childs[i], true); \ transientState.appendChild(imported); \ } \ @@ -64,7 +64,7 @@ void ChartToFlatSCXML::writeTo(std::ostream& stream) { // remove all debug attributes NodeSet elementNodes = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true); - for (int i = 0; i < elementNodes.size(); i++) { + for (size_t i = 0; i < elementNodes.size(); i++) { Element element(elementNodes[i]); if (!envVarIsTrue("USCXML_ANNOTATE_GLOBAL_TRANS_SENDS") && HAS_ATTR(element, "send")) element.removeAttribute("send"); @@ -94,7 +94,7 @@ void ChartToFlatSCXML::createDocument() { { NodeSet allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true); size_t nrElements = 0; - for (int i = 0; i < allElements.size(); i++) { + for (size_t i = 0; i < allElements.size(); i++) { if (!isInEmbeddedDocument(allElements[i])) nrElements++; } @@ -138,7 +138,7 @@ void ChartToFlatSCXML::createDocument() { // with early binding, copy all datamodel elements into scxml element datas = _xpath.evaluate("//" + _nsInfo.xpathPrefix + "datamodel", _origSCXML).asNodeSet(); } - for (int i = 0; i < datas.size(); i++) { + for (size_t i = 0; i < datas.size(); i++) { if (isInEmbeddedDocument(datas[i])) continue; // nested document Node imported = _flatDoc.importNode(datas[i], true); @@ -147,13 +147,13 @@ void ChartToFlatSCXML::createDocument() { NodeSet scripts = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _origSCXML); - for (int i = 0; i < scripts.size(); i++) { + for (size_t i = 0; i < scripts.size(); i++) { Node imported = _flatDoc.importNode(scripts[i], true); _scxml.appendChild(imported); } NodeSet comments = DOMUtils::filterChildType(Node_base::COMMENT_NODE, _origSCXML); - for (int i = 0; i < comments.size(); i++) { + for (size_t i = 0; i < comments.size(); i++) { Node imported = _flatDoc.importNode(comments[i], true); _scxml.appendChild(imported); } @@ -185,7 +185,7 @@ void ChartToFlatSCXML::createDocument() { { NodeSet allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true); size_t nrElements = 0; - for (int i = 0; i < allElements.size(); i++) { + for (size_t i = 0; i < allElements.size(); i++) { if (!isInEmbeddedDocument(allElements[i])) nrElements++; } @@ -385,7 +385,7 @@ Node ChartToFlatSCXML::globalTransitionToNode(GlobalTransition* glo if (transientStateChain.size() > 0) { Element prevExitTransitionElem; - for (int i = 0; i < transientStateChain.size(); i++) { + for (size_t i = 0; i < transientStateChain.size(); i++) { Element transientStateElem = Element(transientStateChain[i]); transientStateElem.setAttribute("id", transientStateElem.getAttribute("id") + "-via-" + toStr(_lastTransientStateId++)); diff --git a/src/uscxml/transform/ChartToMinimalSCXML.cpp b/src/uscxml/transform/ChartToMinimalSCXML.cpp index f052b09..80db707 100644 --- a/src/uscxml/transform/ChartToMinimalSCXML.cpp +++ b/src/uscxml/transform/ChartToMinimalSCXML.cpp @@ -51,7 +51,7 @@ void ChartToMinimalSCXML::writeTo(std::ostream& stream) { { NodeSet allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true); size_t nrElements = 0; - for (int i = 0; i < allElements.size(); i++) { + for (size_t i = 0; i < allElements.size(); i++) { if (!isInEmbeddedDocument(allElements[i])) nrElements++; } @@ -76,7 +76,7 @@ void ChartToMinimalSCXML::writeTo(std::ostream& stream) { while(topMostDatamodel.hasChildNodes()) topMostDatamodel.removeChild(topMostDatamodel.getFirstChild()); - for (int i = 0; i < datas.size(); i++) { + for (size_t i = 0; i < datas.size(); i++) { if (!isInEmbeddedDocument(datas[i])) { topMostDatamodel.appendChild(datas[i]); } @@ -120,7 +120,7 @@ void ChartToMinimalSCXML::writeTo(std::ostream& stream) { { NodeSet allElements = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, _scxml, true); size_t nrElements = 0; - for (int i = 0; i < allElements.size(); i++) { + for (size_t i = 0; i < allElements.size(); i++) { if (!isInEmbeddedDocument(allElements[i])) nrElements++; } @@ -153,7 +153,7 @@ void ChartToMinimalSCXML::removeUnvisited(Arabica::DOM::Node& node) NodeSet ifChilds = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, elem, false); Element lastConditional = elem; bool hadVisitedChild = false; - for (int j = 0; j < ifChilds.size(); j++) { + for (size_t j = 0; j < ifChilds.size(); j++) { Element ifChildElem(ifChilds[j]); if (TAGNAME(ifChildElem) == _nsInfo.xmlNSPrefix + "else" || TAGNAME(ifChildElem) == _nsInfo.xmlNSPrefix + "elseif") { if (!hadVisitedChild && HAS_ATTR(lastConditional, "cond")) { @@ -193,7 +193,7 @@ void ChartToMinimalSCXML::removeUnvisited(Arabica::DOM::Node& node) // iterate and remove unvisited children NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { + for (size_t i = 0; i < children.getLength(); i++) { Node child(children.item(i)); removeUnvisited(child); } @@ -225,7 +225,7 @@ void ChartToMinimalSCXML::beforeUninvoking(Interpreter interpreter, const Arabic void ChartToMinimalSCXML::beforeTakingTransition(Interpreter interpreter, const Arabica::DOM::Element& transition, bool moreComing) { NodeSet targets = getTargetStates(transition); // we need this for history pseudo states - for (int i = 0; i < targets.size(); i++) { + for (size_t i = 0; i < targets.size(); i++) { markAsVisited(Arabica::DOM::Element(targets[i])); } markAsVisited(transition); diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp index 747fb34..b0c3c79 100644 --- a/src/uscxml/transform/ChartToPromela.cpp +++ b/src/uscxml/transform/ChartToPromela.cpp @@ -52,7 +52,7 @@ } #define INDENT_MIN(stream, start, cols) \ -for (int indentIndex = start; indentIndex < cols; indentIndex++) \ +for (size_t indentIndex = start; indentIndex < cols; indentIndex++) \ stream << " "; #define DIFF_MAPS(base, compare, result) \ @@ -392,7 +392,7 @@ std::string PromelaCodeAnalyzer::getTypeReset(const std::string& var, const Prom while(typeIter != type.types.end()) { const PromelaTypedef& innerType = typeIter->second; if (innerType.arraySize > 0) { - for (int i = 0; i < innerType.arraySize; i++) { + for (size_t i = 0; i < innerType.arraySize; i++) { assignment << padding << var << "." << typeIter->first << "[" << i << "] = 0;" << std::endl; } } else if (innerType.types.size() > 0) { @@ -413,7 +413,7 @@ std::string PromelaCodeAnalyzer::getTypeAssignment(const std::string& varTo, con while(typeIter != type.types.end()) { const PromelaTypedef& innerType = typeIter->second; if (innerType.arraySize > 0) { - for (int i = 0; i < innerType.arraySize; i++) { + for (size_t i = 0; i < innerType.arraySize; i++) { assignment << padding << varTo << "." << typeIter->first << "[" << i << "] = " << varFrom << "." << typeIter->first << "[" << i << "];" << std::endl; } } else if (innerType.types.size() > 0) { @@ -597,7 +597,7 @@ void ChartToPromela::writeStates(std::ostream& stream) { stateIter++; } -// for (int i = 0; i < _globalConf.size(); i++) { +// for (size_t i = 0; i < _globalConf.size(); i++) { // stream << "#define " << "s" << i << " " << i; // stream << " /* from \"" << ATTR_CAST(_globalStates[i], "id") << "\" */" << std::endl; // } @@ -856,7 +856,7 @@ std::string ChartToPromela::conditionalizeForHist(const std::set::const_iterator histIter; @@ -1222,7 +1222,7 @@ void ChartToPromela::writeTransition(std::ostream& stream, GlobalTransition* tra void ChartToPromela::writeHistoryAssignments(std::ostream& stream, GlobalTransition* transition, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -1464,7 +1464,7 @@ void HistoryTransitionClass::merge(const HistoryTransitionClass& other) { void ChartToPromela::writeTransitionClosure(std::ostream& stream, GlobalTransition* transition, GlobalState* state, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -1489,7 +1489,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica: return; std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -1513,7 +1513,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica: } } else if(TAGNAME(nodeElem) == "script") { NodeSet scriptText = DOMUtils::filterChildType(Node_base::TEXT_NODE, node, true); - for (int i = 0; i < scriptText.size(); i++) { + for (size_t i = 0; i < scriptText.size(); i++) { stream << ADAPT_SRC(beautifyIndentation(scriptText[i].getNodeValue(), indent)) << std::endl; } @@ -1657,7 +1657,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica: NodeSet sendContents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", nodeElem); std::string sendNameList = ATTR(nodeElem, "namelist"); if (sendParams.size() > 0) { - for (int i = 0; i < sendParams.size(); i++) { + for (size_t i = 0; i < sendParams.size(); i++) { Element paramElem = Element(sendParams[i]); typeAssignSS << padding << " tmpE.data." << ATTR(paramElem, "name") << " = " << ADAPT_SRC(ATTR(paramElem, "expr")) << ";" << std::endl; } @@ -1842,11 +1842,11 @@ PromelaInlines::PromelaInlines(const Arabica::DOM::Node& node) { PromelaInline* predecessor = NULL; // iterate all nodes at given level - for (int i = 0; i < levelNodes.size(); i++) { + for (size_t i = 0; i < levelNodes.size(); i++) { // get all comments NodeSet comments = DOMUtils::filterChildType(Node_base::COMMENT_NODE, levelNodes[i]); - for (int j = 0; j < comments.size(); j++) { + for (size_t j = 0; j < comments.size(); j++) { PromelaInline* tmp = new PromelaInline(comments[j]); if (tmp->type == PromelaInline::PROMELA_NIL) { delete tmp; @@ -1904,7 +1904,7 @@ void ChartToPromela::writeIfBlock(std::ostream& stream, const Arabica::XPath::No return; std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -1957,7 +1957,7 @@ void ChartToPromela::writeIfBlock(std::ostream& stream, const Arabica::XPath::No stream << "{" << std::endl; Arabica::XPath::NodeSet cdrCondChain; - for (int i = 1; i < condChain.size(); i++) { + for (size_t i = 1; i < condChain.size(); i++) { cdrCondChain.push_back(condChain[i]); } writeIfBlock(stream, cdrCondChain, indent + 1); @@ -1972,7 +1972,7 @@ void ChartToPromela::writeIfBlock(std::ostream& stream, const Arabica::XPath::No std::string ChartToPromela::beautifyIndentation(const std::string& code, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2096,7 +2096,7 @@ void ChartToPromela::writeDeclarations(std::ostream& stream) { // automatic types PromelaCodeAnalyzer::PromelaTypedef allTypes = _analyzer->getTypes(); - for (int i = 0; i < datas.size(); i++) { + for (size_t i = 0; i < datas.size(); i++) { Node data = datas[i]; if (isInEmbeddedDocument(data)) @@ -2177,7 +2177,7 @@ void ChartToPromela::writeEventSources(std::ostream& stream) { void ChartToPromela::writeStartInvoker(std::ostream& stream, const Arabica::DOM::Node& node, ChartToPromela* invoker, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2193,7 +2193,7 @@ void ChartToPromela::writeStartInvoker(std::ostream& stream, const Arabica::DOM: // set from params NodeSet invokeParams = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", node); - for (int i = 0; i < invokeParams.size(); i++) { + for (size_t i = 0; i < invokeParams.size(); i++) { std::string identifier = ATTR_CAST(invokeParams[i], "name"); std::string expression = ATTR_CAST(invokeParams[i], "expr"); if (invoker->_dataModelVars.find(identifier) != invoker->_dataModelVars.end()) { @@ -2225,7 +2225,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) { NodeSet scripts = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, false); if (scripts.size() > 0) { stream << std::endl << "/* global scripts */" << std::endl; - for (int i = 0; i < scripts.size(); i++) { + for (size_t i = 0; i < scripts.size(); i++) { writeExecutableContent(stream, scripts[i], 1); } stream << std::endl; @@ -2339,7 +2339,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) { NodeSet transitions = DOMUtils::filterChildElements("transition", es.container, true); std::set eventNames; - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { if (!HAS_ATTR_CAST(transitions[i], "event")) continue; if (HAS_ATTR_CAST(transitions[i], "cond") && ATTR_CAST(transitions[i], "cond").find("_event.") != std::string::npos) @@ -2492,7 +2492,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) { void ChartToPromela::writeRescheduleProcess(std::ostream& stream, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2536,7 +2536,7 @@ void ChartToPromela::writeRescheduleProcess(std::ostream& stream, int indent) { void ChartToPromela::writeDetermineShortestDelay(std::ostream& stream, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2557,7 +2557,7 @@ void ChartToPromela::writeDetermineShortestDelay(std::ostream& stream, int inden void ChartToPromela::writeInsertWithDelay(std::ostream& stream, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2651,7 +2651,7 @@ void ChartToPromela::writeInsertWithDelay(std::ostream& stream, int indent) { void ChartToPromela::writeAdvanceTime(std::ostream& stream, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2739,7 +2739,7 @@ void ChartToPromela::writeCancelEvents(std::ostream& stream, int indent) { void ChartToPromela::writeScheduleMachines(std::ostream& stream, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2814,7 +2814,7 @@ void ChartToPromela::writeEventDispatching(std::ostream& stream) { void ChartToPromela::writeDispatchingBlock(std::ostream& stream, std::list transitions, int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } @@ -2976,7 +2976,7 @@ void ChartToPromela::initNodes() { // get all states NodeSet states = getAllStates(); - for (int i = 0; i < states.size(); i++) { + for (size_t i = 0; i < states.size(); i++) { if (InterpreterImpl::isInEmbeddedDocument(states[i])) continue; Element stateElem(states[i]); @@ -2992,7 +2992,7 @@ void ChartToPromela::initNodes() { invokes.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", _scxml, true)); // make sure all invokers have an id! - for (int i = 0; i < invokes.size(); i++) { + for (size_t i = 0; i < invokes.size(); i++) { if (!HAS_ATTR_CAST(invokes[i], "id")) { Element invokeElem(invokes[i]); invokeElem.setAttribute("id", "INV_" + UUID::getUUID().substr(0,5)); @@ -3008,7 +3008,7 @@ void ChartToPromela::initNodes() { // are there nestes SCXML invokers? { NodeSet invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true); - for (int i = 0; i < invokes.size(); i++) { + for (size_t i = 0; i < invokes.size(); i++) { if (!HAS_ATTR_CAST(invokes[i], "type") || ATTR_CAST(invokes[i], "type") == "scxml" || ATTR_CAST(invokes[i], "type") == "http://www.w3.org/TR/scxml/#SCXMLEventProcessor" || @@ -3075,7 +3075,7 @@ void ChartToPromela::initNodes() { histStatesMembers.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", histIter->second.getParentNode(), isDeep)); histStatesMembers.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "final", histIter->second.getParentNode(), isDeep)); - for (int i = 0; i < histStatesMembers.size(); i++) { + for (size_t i = 0; i < histStatesMembers.size(); i++) { _historyMembers[histIter->first].insert(std::make_pair(ATTR_CAST(histStatesMembers[i], "id"), i)); } histIter++; @@ -3087,7 +3087,7 @@ void ChartToPromela::initNodes() { internalEventNames.push_back(_xpath.evaluate("//" + _nsInfo.xpathPrefix + "raise", _scxml).asNodeSet()); internalEventNames.push_back(_xpath.evaluate("//" + _nsInfo.xpathPrefix + "send", _scxml).asNodeSet()); - for (int i = 0; i < internalEventNames.size(); i++) { + for (size_t i = 0; i < internalEventNames.size(); i++) { if (HAS_ATTR_CAST(internalEventNames[i], "event")) { std::string eventNames = ATTR_CAST(internalEventNames[i], "event"); std::list events = tokenize(eventNames); @@ -3113,7 +3113,7 @@ void ChartToPromela::initNodes() { asgn.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true)); asgn.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true)); - for (int i = 0; i < asgn.size(); i++) { + for (size_t i = 0; i < asgn.size(); i++) { if (isInEmbeddedDocument(asgn[i])) continue; @@ -3139,7 +3139,7 @@ void ChartToPromela::initNodes() { } else { NodeSet textChilds = DOMUtils::filterChildType(Node_base::TEXT_NODE, asgnElem); if (textChilds.size() > 0) { - for (int j = 0; j < textChilds.size(); j++) { + for (size_t j = 0; j < textChilds.size(); j++) { value += textChilds[j].getNodeValue(); } } @@ -3180,7 +3180,7 @@ void ChartToPromela::initNodes() { _analyzer->addCode("_event.invokeid", this); } - for (int i = 0; i < sends.size(); i++) { + for (size_t i = 0; i < sends.size(); i++) { if (HAS_ATTR_CAST(sends[i], "idlocation")) { _analyzer->addCode("_event.sendid", this); } @@ -3191,7 +3191,7 @@ void ChartToPromela::initNodes() { } // do we need delays? - for (int i = 0; i < sends.size(); i++) { + for (size_t i = 0; i < sends.size(); i++) { if (HAS_ATTR_CAST(sends[i], "delay") || HAS_ATTR_CAST(sends[i], "delayexpr")) { _analyzer->addCode("_event.delay", this); #if NEW_DELAY_RESHUFFLE @@ -3208,9 +3208,9 @@ void ChartToPromela::initNodes() { withContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true)); withContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "raise", _scxml, true)); - for (int i = 0; i < withContent.size(); i++) { + for (size_t i = 0; i < withContent.size(); i++) { NodeSet content = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", withContent[i], true); - for (int j = 0; j < content.size(); j++) { + for (size_t j = 0; j < content.size(); j++) { Element contentElem(content[j]); std::string content = spaceNormalize(contentElem.getFirstChild().getNodeValue()); if (!isNumeric(content.c_str(), 10)) @@ -3243,7 +3243,7 @@ void ChartToPromela::initNodes() { } if (json.array.size() > 0) { - for (int i = 0; i < json.array.size(); i++) { + for (size_t i = 0; i < json.array.size(); i++) { std::string expr = dataToAssignments("_event", json.item(i)); _analyzer->addCode(expr, this); } @@ -3266,7 +3266,7 @@ void ChartToPromela::initNodes() { } NodeSet contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true); - for (int i = 0; i < contents.size(); i++) { + for (size_t i = 0; i < contents.size(); i++) { Element contentElem = Element(contents[i]); if (contentElem.hasChildNodes() && contentElem.getFirstChild().getNodeType() == Node_base::TEXT_NODE && contentElem.getChildNodes().getLength() == 1) { std::string content = contentElem.getFirstChild().getNodeValue(); @@ -3283,7 +3283,7 @@ void ChartToPromela::initNodes() { withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true)); withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "if", _scxml, true)); withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "elseif", _scxml, true)); - for (int i = 0; i < withCond.size(); i++) { + for (size_t i = 0; i < withCond.size(); i++) { Element elem = Element(withCond[i]); if (HAS_ATTR(elem, "cond")) { std::string code = ATTR(elem, "cond"); @@ -3300,7 +3300,7 @@ void ChartToPromela::initNodes() { withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true)); withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true)); withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", _scxml, true)); - for (int i = 0; i < withExpr.size(); i++) { + for (size_t i = 0; i < withExpr.size(); i++) { Element elem = Element(withExpr[i]); if (HAS_ATTR(elem, "expr")) { std::string code = ATTR(elem, "expr"); @@ -3313,7 +3313,7 @@ void ChartToPromela::initNodes() { { NodeSet withLocation; withLocation.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true)); - for (int i = 0; i < withLocation.size(); i++) { + for (size_t i = 0; i < withLocation.size(); i++) { Element elem = Element(withLocation[i]); if (HAS_ATTR(elem, "location")) { std::string code = ATTR(elem, "location"); @@ -3327,9 +3327,9 @@ void ChartToPromela::initNodes() { NodeSet withText; withText.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, true)); // withText.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true)); - for (int i = 0; i < withText.size(); i++) { + for (size_t i = 0; i < withText.size(); i++) { NodeSet texts = DOMUtils::filterChildType(Node_base::TEXT_NODE, withText[i], true); - for (int j = 0; j < texts.size(); j++) { + for (size_t j = 0; j < texts.size(); j++) { if (texts[j].getNodeValue().size() > 0) { Text elem = Text(texts[j]); std::string code = elem.getNodeValue(); @@ -3342,7 +3342,7 @@ void ChartToPromela::initNodes() { } { NodeSet foreachs = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "foreach", _scxml, true); - for (int i = 0; i < foreachs.size(); i++) { + for (size_t i = 0; i < foreachs.size(); i++) { if (HAS_ATTR_CAST(foreachs[i], "index")) { allCode.insert(ATTR_CAST(foreachs[i], "index")); } else { @@ -3362,7 +3362,7 @@ void ChartToPromela::initNodes() { NodeSet withNamelist; withNamelist.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true)); withNamelist.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true)); - for (int i = 0; i < withNamelist.size(); i++) { + for (size_t i = 0; i < withNamelist.size(); i++) { if (HAS_ATTR_CAST(withNamelist[i], "namelist")) { std::string namelist = ATTR_CAST(withNamelist[i], "namelist"); std::list names = tokenize(namelist); diff --git a/src/uscxml/transform/ChartToTex.cpp b/src/uscxml/transform/ChartToTex.cpp index f38740a..9d30be5 100644 --- a/src/uscxml/transform/ChartToTex.cpp +++ b/src/uscxml/transform/ChartToTex.cpp @@ -109,7 +109,7 @@ void ChartToTex::writeTex(std::ostream& stream) { for (std::list::iterator transIter = stateIter->second->sortedOutgoing.begin(); transIter != stateIter->second->sortedOutgoing.end(); transIter++) { GlobalTransition* currTrans = *transIter; Arabica::XPath::NodeSet members = currTrans->getTransitions(); - for (int i = 0; i < members.size(); i++) { + for (size_t i = 0; i < members.size(); i++) { Element transElem(members[i]); if (HAS_ATTR(transElem, "priority")) { origTransitions.insert(ATTR(transElem, "priority")); @@ -149,7 +149,7 @@ void ChartToTex::writeTex(std::ostream& stream) { if (members.size() > 0) { stream << "$\\{ "; seperator = ""; - for (int i = 0; i < members.size(); i++) { + for (size_t i = 0; i < members.size(); i++) { Element transElem(members[i]); if (HAS_ATTR(transElem, "priority")) { stream << seperator << "t_{" << ATTR(transElem, "priority") << "}"; diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp index 52f1a5c..7a139fa 100644 --- a/src/uscxml/transform/ChartToVHDL.cpp +++ b/src/uscxml/transform/ChartToVHDL.cpp @@ -78,7 +78,7 @@ void ChartToVHDL::checkDocument() { std::stringstream ss; if (unsupported.size() > 0) { - for (int i = 0; i < unsupported.size(); i++) { + for (size_t i = 0; i < unsupported.size(); i++) { ss << " " << DOMUtils::xPathForNode(unsupported[i]) << " unsupported" << std::endl; } throw std::runtime_error("Unsupported elements found:\n" + ss.str()); @@ -88,7 +88,7 @@ void ChartToVHDL::checkDocument() { elements.insert(_nsInfo.xmlNSPrefix + "transition"); unsupported = DOMUtils::inDocumentOrder(elements, _scxml); - for (int i = 0; i < unsupported.size(); i++) { + for (size_t i = 0; i < unsupported.size(); i++) { Element transition(unsupported[i]); if (HAS_ATTR(transition, "cond")) { ERROR_PLATFORM_THROW("transition with conditions not supported!"); @@ -122,14 +122,9 @@ void ChartToVHDL::writeTo(std::ostream& stream) { // checkDocument(); findEvents(); -// _eventTrie.dump(); - writeTypes(stream); writeFiFo(stream); - writeOptimalTransitionSetSelection(stream); - writeExitSet(stream); - writeEntrySet(stream); writeFSM(stream); } @@ -169,10 +164,16 @@ void ChartToVHDL::writeFSM(std::ostream & stream) { writeModuleInstantiation(stream); // write fsm architecture - writeNextStateLogic(stream); +// writeNextStateLogic(stream); + + writeOptimalTransitionSetSelection(stream); + writeExitSet(stream); + writeEntrySet(stream); + // writeOutputLogic(stream); writeErrorHandler(stream); + stream << std::endl; stream << "end behavioral; " << std::endl; stream << "-- END FSM Logic" << std::endl; @@ -226,15 +227,15 @@ void ChartToVHDL::writeTypes(std::ostream & stream) { stream << std::endl; stream << "package machine" << _md5 << " is" << std::endl; // create state type - stream << " type state_type is std_logic_vector( "; + stream << " subtype state_type is std_logic_vector( "; stream << _states.size() - 1; - stream << " downto 0)" << std::endl; + stream << " downto 0);" << std::endl; //TODO complete // create event type stream << " type event_type is ("; seperator = ""; -// for (int i = 0; i < _events.size(); i++) { +// for (size_t i = 0; i < _events.size(); i++) { // stream << seperator; // stream << _events[i]; // seperator = ", "; @@ -358,16 +359,32 @@ void ChartToVHDL::writeSignals(std::ostream & stream) { stream << "-- system signals" << std::endl; stream << "signal stall : std_logic;" << std::endl; stream << "-- state signals" << std::endl; - stream << "signal next_state : state_type;" << std::endl; - stream << "signal current_state : state_type;" << std::endl; +// stream << "signal next_state : state_type;" << std::endl; +// stream << "signal current_state : state_type;" << std::endl; - for (int i = 0; i < _states.size(); i++) { + for (size_t i = 0; i < _states.size(); i++) { Element state(_states[i]); - stream << "signal " << ATTR(state, "id") << "_curr : current_state(" - << toStr(i) << ");" << std::endl; - stream << "signal " << ATTR(state, "id") << "_next : next_state(" - << toStr(i) << ");" << std::endl; + stream << "signal " << DOMUtils::idForNode(state) << "_curr : std_logic;" << std::endl; + stream << "signal " << DOMUtils::idForNode(state) << "_next : std_logic;" << std::endl; } + for (size_t i = 0; i < _states.size(); i++) { + Element state(_states[i]); + stream << "signal in_exit_set_" << ATTR(state, "documentOrder") << "_sig : std_logic;" << std::endl; + stream << "signal in_complete_entry_set_up_" << ATTR(state, "documentOrder") << "_sig : std_logic;" << std::endl; + stream << "signal in_complete_entry_set_" << ATTR(state, "documentOrder") << "_sig : std_logic;" << std::endl; + stream << "signal state_active_" << ATTR(state, "documentOrder") << "_sig : std_logic;" << std::endl; + stream << "signal default_completion_" << ATTR(state, "documentOrder") << "_sig : std_logic;" << std::endl; + } + + stream << "-- transition signals" << std::endl; + stream << "signal spontaneous_en : std_logic;" << std::endl; + + for (size_t i = 0; i < _transitions.size(); i++) { + Element transition(_transitions[i]); + stream << "signal in_optimal_transition_set_" << ATTR(transition, "postFixOrder") << "_sig : std_logic;" + << std::endl; + } + stream << std::endl; stream << "-- event signals" << std::endl; stream << "signal int_event_write_en : std_logic;" << std::endl; @@ -379,14 +396,13 @@ void ChartToVHDL::writeSignals(std::ostream & stream) { stream << "signal next_event : event_type;" << std::endl; stream << "signal event_consumed : std_logic;" << std::endl; stream << std::endl; - stream << "-- transition signals" << std::endl; - stream << "signal transition_spntaneous_en : std_logic;" << std::endl; - for (int i = 0; i < _transitions.size(); i++) { - Element transition(_transitions[i]); - stream << "signal in_optimal_transition_set_" << ATTR(transition, "postFixOrder") << "_sig : std_logic;" - << std::endl; - } + std::list eventNames = _eventTrie.getWordsWithPrefix(""); + for (std::list::iterator eventIter = eventNames.begin(); eventIter != eventNames.end(); eventIter++) { + stream << "signal event_" << eventNameEscape((*eventIter)->value) << "_sig : std_logic;" << std::endl; + } + // _eventTrie.dump(); + stream << std::endl; stream << "-- error signals" << std::endl; @@ -421,7 +437,7 @@ void ChartToVHDL::writeModuleInstantiation(std::ostream & stream) { stream << "next_event <= int_event_output; " << std::endl; stream << "int_event_write_en <= next_event_en_i; " << std::endl; stream << "int_event_input <= next_event_i; " << std::endl; - stream << "int_event_read_en <= not transition_spontanous_en and not stall; " << std::endl; + stream << "int_event_read_en <= not spontaneous_en and not stall; " << std::endl; stream << std::endl; // instantiate event fifo @@ -466,8 +482,44 @@ void ChartToVHDL::writeOptimalTransitionSetSelection(std::ostream & stream) { Element transition(_transitions[i]); std::string conflicts = ATTR(transition, "conflictBools"); + + VContainer nameMatchers = VOR; + if (HAS_ATTR(transition, "event")) { + std::list eventDescs = tokenize(ATTR(transition, "event")); + for (std::list::iterator descIter = eventDescs.begin(); descIter != eventDescs.end(); descIter++) { + std::list eventNames = _eventTrie.getWordsWithPrefix((*descIter) == "*" ? "" : *descIter); + for (std::list::iterator eventIter = eventNames.begin(); eventIter != eventNames.end(); eventIter++) { + *nameMatchers += VLINE("event_" + eventNameEscape((*eventIter)->value) + "_sig"); + } + } + } else { + *nameMatchers += VLINE("'1'"); + } + + VContainer conflicters = VOR; + for (size_t j = 0; j < i; j++) { + if (conflicts[j] == '1') { + *conflicters += VLINE("in_optimal_transition_set_" + toStr(j) + "_sig"); + } + } + + VBranch* tree = (VASSIGN , + VLINE("in_optimal_transition_set_" + ATTR(transition, "postFixOrder") + "_sig") , + (VAND , + (HAS_ATTR(transition, "event") + ? ( VNOT , VLINE("spontaneous_en") ) + : ( VNOP , VLINE("spontaneous_en") ) ) , + VLINE("state_active_" + ATTR(transition, "source") + "_sig"), + nameMatchers, + (VNOT , conflicters) ) ); + + tree->print(stream); + stream << ";" << std::endl; + + +#if 0 stream << "in_optimal_transition_set_" << ATTR(transition, "postFixOrder") << "_sig " - << "<= " << (HAS_ATTR(transition, "event") ? "(not spontaneous_sig)" : "spontaneous_sig") << " and " << std::endl + << "<= " << (HAS_ATTR(transition, "event") ? "(not spontaneous_en)" : "spontaneous_en") << " and " << std::endl << " state_active_" << ATTR(transition, "source") << "_sig and not ( '0' " << std::endl; for (size_t j = 0; j < i; j++) { if (conflicts[j] == '1') { @@ -490,8 +542,8 @@ void ChartToVHDL::writeOptimalTransitionSetSelection(std::ostream & stream) { } stream << ";" << std::endl; +#endif } - } void ChartToVHDL::writeExitSet(std::ostream & stream) { @@ -504,8 +556,27 @@ void ChartToVHDL::writeExitSet(std::ostream & stream) { std::string children = ATTR(state, "childBools"); std::string parent = ATTR(state, "parent"); + VContainer exitsetters = VOR; + for (size_t j = 0; j < _transitions.size(); j++) { + Element transition(_transitions[j]); + std::string exitSet = ATTR(transition, "exitSetBools"); + if (exitSet[i] == '1') { + *exitsetters += VLINE("in_optimal_transition_set_" + toStr(j) + "_sig "); + } + } + + VBranch* tree = (VASSIGN , + VLINE("in_exit_set_" + toStr(i) + "_sig"), + (VAND, + VLINE("state_active_" + toStr(i) + "_sig"), + exitsetters )); + + tree->print(stream); + stream << ";" << std::endl; + +#if 0 stream << "in_exit_set_" << toStr(i) << "_sig " - << "<= state_active_ " << toStr(i) << "_sig and ('0'" << std::endl; + << "<= state_active_" << toStr(i) << "_sig and ('0'" << std::endl; for (size_t j = 0; j < _transitions.size(); j++) { Element transition(_transitions[j]); std::string exitSet = ATTR(transition, "exitSetBools"); @@ -516,7 +587,7 @@ void ChartToVHDL::writeExitSet(std::ostream & stream) { stream << ")"; stream << ";" << std::endl; - +#endif } } @@ -530,6 +601,33 @@ void ChartToVHDL::writeEntrySet(std::ostream & stream) { std::string children = ATTR(state, "childBools"); std::string parent = ATTR(state, "parent"); + VContainer optimalEntrysetters = VOR; + for (size_t j = 0; j < _transitions.size(); j++) { + Element transition(_transitions[j]); + std::string targetSet = ATTR(transition, "targetBools"); + if (targetSet[i] == '1') { + *optimalEntrysetters += VLINE("in_optimal_transition_set_" + toStr(j) + "_sig"); + } + } + + VContainer completeEntrysetters = VOR; + if (isCompound(state)) { + for (size_t j = 0; j < _states.size(); j++) { + if (children[j] != '1') + continue; + *completeEntrysetters += VLINE("in_complete_entry_set_up_" + toStr(j) + "_sig"); + } + } + + VBranch* tree = (VASSIGN , + VLINE("in_complete_entry_set_up_" + toStr(i) + "_sig"), + optimalEntrysetters, + completeEntrysetters); + + tree->print(stream); + stream << ";" << std::endl; + +#if 0 stream << "in_complete_entry_set_up_" << toStr(i) << "_sig <= ('0'" << std::endl; for (size_t j = 0; j < _transitions.size(); j++) { @@ -550,7 +648,7 @@ void ChartToVHDL::writeEntrySet(std::ostream & stream) { } stream << ");" << std::endl; - +#endif } for (size_t i = 0; i < _states.size(); i++) { @@ -564,6 +662,35 @@ void ChartToVHDL::writeEntrySet(std::ostream & stream) { continue; // TODO: FixMe } + VContainer tmp1 = VAND; + if (isCompound(Element(_states[strTo(parent)]))) { + *tmp1 += VLINE("default_completion_" + toStr(parent) + "_sig"); + + for (size_t j = 0; j < _states.size(); j++) { + if (children[j] != '1') + continue; + *tmp1 += ( VAND, + ( VNOT, + ( VAND, + VLINE("is_active" + toStr(j) + "_sig"), + ( VNOT, + VLINE("in_exit_set_" + toStr(j) + "_sig") ) ) ) ); + + } + + } + + if (isParallel(Element(_states[strTo(parent)]))) { + *tmp1 += VLINE("in_complete_entry_set_" + toStr(parent) + "_sig"); + } + + VBranch* tree = (VASSIGN , + VLINE("in_complete_entry_set_" + toStr(i) + "_sig"), tmp1); + + tree->print(stream); + stream << ";" << std::endl; + +#if 0 stream << "in_complete_entry_set_" << toStr(i) << "_sig <= (in_complete_entry_set_up_" << toStr(i) << "_sig or (" << std::endl; if (isParallel(Element(_states[strTo(parent)]))) { @@ -580,7 +707,7 @@ void ChartToVHDL::writeEntrySet(std::ostream & stream) { } stream << ");" << std::endl; - +#endif } } @@ -595,7 +722,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { stream << "begin" << std::endl; std::stringstream nextStateBuffer; - for (int i = 0; i < _states.size(); i++) { + for (size_t i = 0; i < _states.size(); i++) { Element state(_states[i]); // calculate event choices @@ -604,7 +731,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { // will be written first std::vector< Element > choices; std::string spntaneous_trans_sig = ""; - for (int j = 0; j < _transitions.size(); j++) { + for (size_t j = 0; j < _transitions.size(); j++) { Element transition(_transitions[j]); if (ATTR_CAST(transition.getParentNode(), "id") == ATTR(state, "id")) { choices.push_back(transition); @@ -618,7 +745,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { // calculate incomming transitions (for later use) std::vector< Element > incommingTransitions; - for (int j = 0; j < _transitions.size(); j++) { + for (size_t j = 0; j < _transitions.size(); j++) { Element transition(_transitions[j]); if (ATTR_CAST(transition, "target") == ATTR(state, "id")) { incommingTransitions.push_back(transition); @@ -630,7 +757,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { stream << " if ( " << ATTR(state, "id") << " = '1' ) then" << std::endl; stream << " if ( transition_spntaneous_en = '1' ) then" << std::endl; // enable spntaneous transition (if any) and disable all other - for (int j = 0; j < choices.size(); j++) { + for (size_t j = 0; j < choices.size(); j++) { Element transition(choices[j]); if (ATTR(transition, "id") == spntaneous_trans_sig) { stream << " " << ATTR(transition, "id") << "_sig <= '1';" << std::endl; @@ -646,7 +773,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { // FIXME hopefully there is just one transition per state and event at a time stream << " case next_event is" << std::endl; bool hasWildcardTransition = false; - for (int j = 0; j < choices.size(); j++) { + for (size_t j = 0; j < choices.size(); j++) { Element transition(choices[j]); std::string eventName = ATTR(transition, "event"); if (eventName == CONST_EVENT_ANY) { @@ -655,7 +782,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { } stream << " when " << eventName << " =>" << std::endl; // activate transition and deactivete others - for (int k = 0; k < choices.size(); k++) { + for (size_t k = 0; k < choices.size(); k++) { Element tmp_t(choices[k]); if (ATTR(tmp_t, "event") == ATTR(transition, "event")) { stream << " " << ATTR(tmp_t, "id") << "_sig <= '1';" << std::endl; @@ -667,7 +794,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { if (!hasWildcardTransition) { // if there is no others we create one for deactivating everything stream << " when others =>" << std::endl; - for (int j = 0; j < choices.size(); j++) { + for (size_t j = 0; j < choices.size(); j++) { Element tmp_t(choices[j]); stream << " " << ATTR(tmp_t, "id") << "_sig <= '0';" << std::endl; } @@ -679,7 +806,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { stream << " else" << std::endl; // no enabled event ? disable all transitions (looks like we have to wait) - for (int j = 0; j < choices.size(); j++) { + for (size_t j = 0; j < choices.size(); j++) { Element transition(choices[j]); stream << " " << ATTR(transition, "id") << "_sig <= '0';" << std::endl; } @@ -690,14 +817,14 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { // write next state calculation in buffer for later use nextStateBuffer << ATTR(state, "id") << "_next <= ( ( '0'"; std::string seperator = " or "; - for (int j = 0; j < incommingTransitions.size(); j++) { + for (size_t j = 0; j < incommingTransitions.size(); j++) { nextStateBuffer << seperator << ATTR(incommingTransitions[j], "id") << "_sig"; } nextStateBuffer << " ) or "; nextStateBuffer << "( ( not ( '0'"; seperator = " or "; - for (int j = 0; j < choices.size(); j++) { + for (size_t j = 0; j < choices.size(); j++) { nextStateBuffer << seperator << ATTR(choices[j], "id") << "_sig"; } @@ -729,7 +856,7 @@ void ChartToVHDL::writeOutputLogic(std::ostream & stream) { stream << "begin" << std::endl; stream << " case current_state is" << std::endl; - for (int i = 0; i < _states.size(); i++) { + for (size_t i = 0; i < _states.size(); i++) { //TODO // if end state set completed and result // on entry events generated here diff --git a/src/uscxml/transform/ChartToVHDL.h b/src/uscxml/transform/ChartToVHDL.h index c2dec15..933faa4 100644 --- a/src/uscxml/transform/ChartToVHDL.h +++ b/src/uscxml/transform/ChartToVHDL.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace uscxml { @@ -41,6 +42,120 @@ public: void writeTo(std::ostream& stream); + + struct VNode { + virtual void print(std::ostream& stream, const std::string padding = "") = 0; + virtual ~VNode() {}; + }; + struct VBranch : VNode { + std::vector< VNode* > v; + virtual ~VBranch(){ + for(unsigned i = 0; i < v.size(); i++) + delete v[i]; + } + + VBranch& operator +=(VNode* p ) { + v.push_back(p); + return *this; + } + }; + + struct VPointer{ + VNode* ptr; + + operator VNode*() { + return ptr; + } + + VPointer& operator /( VNode* p ){ + ptr = p; + return *this; + } + }; + + struct VContainer { + VBranch* ptr; + + operator VBranch*() { + return ptr; + } + VContainer& operator /( VBranch* p ){ + ptr = p; + return *this; + } + VContainer& operator , ( VPointer p ) { + if(ptr) ptr->v.push_back(p.ptr); + return *this; + } + VContainer& operator , ( VContainer c ) { + if(ptr) ptr->v.push_back(c.ptr); + return *this; + } + }; + + struct VLine : VNode { + VLine(const std::string& name) : name(name) {} + virtual void print(std::ostream& stream, const std::string padding = "") { + stream << " " << name; + } + + std::string name; + }; + + struct VAssign : VBranch { + virtual void print(std::ostream& stream, const std::string padding = "") { + v[0]->print(stream, padding); + stream << padding << " <="; + v[1]->print(stream, padding + " "); + } + }; + + struct VAnd : VBranch { + virtual void print(std::ostream& stream, const std::string padding = "") { + stream << std::endl << padding << "( '1' "; + for(unsigned i = 0; i < v.size(); i++) { + stream << std::endl << padding << " and"; + v[i]->print(stream, padding + " "); + } + stream << padding << ")" << std::endl; + } + }; + + struct VOr : VBranch { + virtual void print(std::ostream& stream, const std::string padding = "") { + stream << std::endl << padding << "( '0' "; + for(unsigned i = 0; i < v.size(); i++) { + stream << std::endl << padding << " or"; + v[i]->print(stream, padding + " "); + } + stream << std::endl << padding << ")" << std::endl; + } + }; + + struct VNot : VBranch { + virtual void print(std::ostream& stream, const std::string padding = "") { + stream << " ( not"; + v[0]->print(stream, padding + " "); + stream << " )"; + } + }; + + struct VNop : VBranch { + virtual void print(std::ostream& stream, const std::string padding = "") { + v[0]->print(stream, padding); + } + }; + + +#define VLINE VPointer()/new VLine +#define VASSIGN VContainer()/new VAssign +#define VOR VContainer()/new VOr +#define VAND VContainer()/new VAnd +#define VNOT VContainer()/new VNot +#define VNOP VContainer()/new VNop + + + protected: ChartToVHDL(const Interpreter& other); diff --git a/src/uscxml/transform/FlatStateIdentifier.h b/src/uscxml/transform/FlatStateIdentifier.h index 99ae084..2d62651 100644 --- a/src/uscxml/transform/FlatStateIdentifier.h +++ b/src/uscxml/transform/FlatStateIdentifier.h @@ -49,14 +49,14 @@ public: FlatStateIdentifier(const Arabica::XPath::NodeSet& activeStates, const Arabica::XPath::NodeSet& alreadyEnteredStates, const std::map >& historyStates) { - for (int i = 0; i < activeStates.size(); i++) { + for (size_t i = 0; i < activeStates.size(); i++) { active.push_back(ATTR_CAST(activeStates[i], "id")); } - for (int i = 0; i < alreadyEnteredStates.size(); i++) { + for (size_t i = 0; i < alreadyEnteredStates.size(); i++) { const Arabica::DOM::NodeList& children = alreadyEnteredStates[i].getChildNodes(); bool isRelevant = false; - for (int j = 0; j < children.getLength(); j++) { + for (size_t j = 0; j < children.getLength(); j++) { if (children.item(j).getNodeType() != Arabica::DOM::Node_base::ELEMENT_NODE) continue; if (iequals(LOCALNAME_CAST(children.item(j)), "data") || iequals(LOCALNAME_CAST(children.item(j)), "datamodel")) { @@ -70,7 +70,7 @@ public: std::map >::const_iterator histIter; for (histIter = historyStates.begin(); histIter != historyStates.end(); histIter++) { - for (int i = 0; i < histIter->second.size(); i++) { + for (size_t i = 0; i < histIter->second.size(); i++) { histories[histIter->first].push_back(ATTR_CAST(histIter->second[i], "id")); } } diff --git a/src/uscxml/util/MD5.hpp b/src/uscxml/util/MD5.hpp index 4dae3b3..b566dc4 100644 --- a/src/uscxml/util/MD5.hpp +++ b/src/uscxml/util/MD5.hpp @@ -43,7 +43,7 @@ namespace uscxml { std::ostringstream ss; ss << std::hex << std::uppercase << std::setfill( '0' ); - for (int i = 0; i < 16; i++) { + for (size_t i = 0; i < 16; i++) { ss << std::setw( 2 ) << (int)digest[i]; } diff --git a/src/uscxml/util/SHA1.hpp b/src/uscxml/util/SHA1.hpp index 61df5db..97d88d9 100644 --- a/src/uscxml/util/SHA1.hpp +++ b/src/uscxml/util/SHA1.hpp @@ -40,7 +40,7 @@ namespace uscxml { } else { std::ostringstream ss; ss << std::hex << std::uppercase << std::setfill( '0' ); - for (int i = 0; i < 5; i++) { + for (size_t i = 0; i < 5; i++) { ss << std::setw( 2 ) << sha.Message_Digest[i]; } diff --git a/src/uscxml/util/String.cpp b/src/uscxml/util/String.cpp index dc5a765..6d43301 100644 --- a/src/uscxml/util/String.cpp +++ b/src/uscxml/util/String.cpp @@ -30,7 +30,7 @@ std::list tokenize(const std::string& line, const char sep, bool tr // appr. 3x faster than stringstream size_t start = 0; - for (int i = 0; i < line.size(); i++) { + for (size_t i = 0; i < line.size(); i++) { if (line[i] == sep || (trimWhiteSpace && ISWHITESPACE(line[i]))) { if (i > 0 && start < i) { tokens.push_back(line.substr(start, i - start)); @@ -55,7 +55,7 @@ std::string spaceNormalize(const std::string& text) { std::string seperator; size_t start = 0; - for (int i = 0; i < text.size(); i++) { + for (size_t i = 0; i < text.size(); i++) { if (isspace(text[i])) { if (i > 0 && start < i) { content << seperator << text.substr(start, i - start); @@ -99,7 +99,7 @@ bool nameMatch(const std::string& eventDescs, const std::string& eventName) { size_t start = 0; std::string eventDesc; - for (int i = 0; i < eventDescs.size(); i++) { + for (size_t i = 0; i < eventDescs.size(); i++) { if (isspace(eventDescs[i])) { if (i > 0 && start < i - 1) { eventDesc = eventDescs.substr(start, i - start); diff --git a/src/uscxml/util/Trie.cpp b/src/uscxml/util/Trie.cpp index 8934c73..8e3aff3 100644 --- a/src/uscxml/util/Trie.cpp +++ b/src/uscxml/util/Trie.cpp @@ -148,7 +148,7 @@ std::list Trie::getChildsWithWords(TrieNode* node) { void TrieNode::dump(int indent) { std::string padding; - for (int i = 0; i < indent; i++) { + for (size_t i = 0; i < indent; i++) { padding += " "; } diff --git a/test/src/test-arabica-events.cpp b/test/src/test-arabica-events.cpp index 0cd45ee..bcec093 100644 --- a/test/src/test-arabica-events.cpp +++ b/test/src/test-arabica-events.cpp @@ -56,7 +56,7 @@ int main(int argc, char** argv) { Arabica::XPath::XPath xpath; Arabica::XPath::NodeSet divs = xpath.evaluate("//div", doc).asNodeSet(); - for (int i = 0; i < divs.size(); i++) { + for (size_t i = 0; i < divs.size(); i++) { Element divElem = Element(divs[i]); divElem.setAttribute("foo", "true"); divElem.setAttribute("foo", "false"); diff --git a/test/src/test-arabica-namespaces.cpp b/test/src/test-arabica-namespaces.cpp index ced9578..5d5d90d 100644 --- a/test/src/test-arabica-namespaces.cpp +++ b/test/src/test-arabica-namespaces.cpp @@ -67,7 +67,7 @@ void insertBar(std::pair, NameSpaceInfo>& parsed) { Document document = parsed.first; Node root = document.getDocumentElement(); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { Element bar = document.createElementNS(nsInfo.nsURL, "bar"); // if (nsInfo.nsToPrefix.find(nsInfo.nsURL) != nsInfo.nsToPrefix.end()) nsInfo.setPrefix(bar); @@ -80,7 +80,7 @@ void insertBaz(std::pair, NameSpaceInfo>& parsed) { Document document = parsed.first; Node root = document.getDocumentElement(); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { Element baz = document.createElementNS(nsInfo.nsURL, "baz"); nsInfo.setPrefix(baz); root.appendChild(baz); @@ -102,7 +102,7 @@ static void validateRootFoo(std::pair, NameSpaceInfo>& par NodeSet foosXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "foo", root).asNodeSet(); assert(foosXPath.size() == 3); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { assert(foosFiltered[i] == foosXPath[i]); assert(TAGNAME_CAST(foosFiltered[i]) == nsInfo.xmlNSPrefix + "foo"); assert(LOCALNAME_CAST(foosFiltered[i]) == "foo"); @@ -124,7 +124,7 @@ static void validateRootFooBar(std::pair, NameSpaceInfo>& NodeSet barsXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "bar", root).asNodeSet(); assert(barsXPath.size() == 3); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { assert(barsFiltered[i] == barsXPath[i]); assert(TAGNAME_CAST(barsFiltered[i]) == nsInfo.xmlNSPrefix + "bar"); assert(LOCALNAME_CAST(barsFiltered[i]) == "bar"); @@ -149,7 +149,7 @@ static void validateRootFooBarBaz(std::pair, NameSpaceInfo NodeSet bazsXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "baz", root).asNodeSet(); assert(bazsXPath.size() == 3); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { assert(bazsFiltered[i] == bazsXPath[i]); assert(TAGNAME_CAST(bazsFiltered[i]) == nsInfo.xmlNSPrefix + "baz"); assert(LOCALNAME_CAST(bazsFiltered[i]) == "baz"); diff --git a/test/src/test-base64.cpp b/test/src/test-base64.cpp index 1267b7b..4981a26 100644 --- a/test/src/test-base64.cpp +++ b/test/src/test-base64.cpp @@ -9,7 +9,7 @@ int main(int argc, char** argv) { std::string base64C; char buffer[SOURCE_LEN]; - for (int i = 0; i < SOURCE_LEN; i++) { + for (size_t i = 0; i < SOURCE_LEN; i++) { buffer[i] = (char)55; } diff --git a/test/src/test-c-machine.cpp b/test/src/test-c-machine.cpp index 815993e..f78e970 100644 --- a/test/src/test-c-machine.cpp +++ b/test/src/test-c-machine.cpp @@ -242,7 +242,7 @@ public: } bool isInState(const std::string& stateId) { - for (int i = 0 ; i < ctx.machine->nr_states; i++) { + for (size_t i = 0 ; i < ctx.machine->nr_states; i++) { if (ctx.machine->states[i].name != NULL && BIT_HAS(i, ctx.config) && stateId == ctx.machine->states[i].name) return true; } @@ -797,7 +797,7 @@ public: std::string seperator; size_t start = 0; - for (int i = 0; i < text.size(); i++) { + for (size_t i = 0; i < text.size(); i++) { if (isspace(text[i])) { if (i > 0 && start < i) { content << seperator << text.substr(start, i - start); @@ -823,7 +823,7 @@ public: size_t start = 0; std::string eventDesc; - for (int i = 0; i < eventDescs.size(); i++) { + for (size_t i = 0; i < eventDescs.size(); i++) { if (isspace(eventDescs[i])) { if (i > 0 && start < i - 1) { eventDesc = eventDescs.substr(start, i - start); @@ -960,7 +960,7 @@ int main(int argc, char** argv) { rootMachine.dataModel.timer.elapsed = 0; #endif size_t passIdx = 0; - for (int i = 0; i < rootMachine.ctx.machine->nr_states; i++) { + for (size_t i = 0; i < rootMachine.ctx.machine->nr_states; i++) { if (rootMachine.ctx.machine->states[i].name && strcmp(rootMachine.ctx.machine->states[i].name, "pass") == 0) { passIdx = i; break; diff --git a/test/src/test-datamodel.cpp b/test/src/test-datamodel.cpp index 12f74e6..0c02ae8 100644 --- a/test/src/test-datamodel.cpp +++ b/test/src/test-datamodel.cpp @@ -38,7 +38,7 @@ int main(int argc, char** argv) { { char* testData = (char*)malloc(1024); - for (int i = 0; i < 1024; i++) { + for (size_t i = 0; i < 1024; i++) { testData[i] = (char)i; } @@ -46,7 +46,7 @@ int main(int argc, char** argv) { Blob blob = data.getBinary(); char* otherData = blob.getData(); - for (int i = 0; i < 1024; i++) { + for (size_t i = 0; i < 1024; i++) { assert(testData[i] == otherData[i]); } diff --git a/test/src/test-ffmpeg.cpp b/test/src/test-ffmpeg.cpp index a8660e5..1c99aa5 100644 --- a/test/src/test-ffmpeg.cpp +++ b/test/src/test-ffmpeg.cpp @@ -339,7 +339,7 @@ int main(int argc, char **argv) { if (frame) frame->pts = 0; - for (int i = 0; i < 125; i++) { + for (size_t i = 0; i < 125; i++) { write_video_frame(oc, video_st); frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base); } diff --git a/test/src/test-lifecycle.cpp b/test/src/test-lifecycle.cpp index eeaad96..e61d6db 100644 --- a/test/src/test-lifecycle.cpp +++ b/test/src/test-lifecycle.cpp @@ -28,7 +28,7 @@ bool testIssue56(); #ifdef HAS_EXECINFO_H void printBacktrace(void** array, int size) { char** messages = backtrace_symbols(array, size); - for (int i = 0; i < size && messages != NULL; ++i) { + for (size_t i = 0; i < size && messages != NULL; ++i) { std::cerr << "\t" << messages[i] << std::endl; } std::cerr << std::endl; diff --git a/test/src/test-sockets.cpp b/test/src/test-sockets.cpp index 16234ee..89e6885 100644 --- a/test/src/test-sockets.cpp +++ b/test/src/test-sockets.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) { int iterations = 1000; std::stringstream contentSS; - for (int i = 0; i < iterations; i++) { + for (size_t i = 0; i < iterations; i++) { contentSS << toStr(i); contentSS << "tadaa!"; } @@ -99,7 +99,7 @@ int main(int argc, char** argv) { client.connect("127.0.0.1", 1235); int iterations = 1000; - for (int i = 0; i < iterations; i++) { + for (size_t i = 0; i < iterations; i++) { client.write(toStr(i)); client.write("\0", 1); } diff --git a/test/src/test-stress.cpp b/test/src/test-stress.cpp index 220399a..0099f9b 100644 --- a/test/src/test-stress.cpp +++ b/test/src/test-stress.cpp @@ -30,7 +30,7 @@ int lastTransitionAt; #ifdef HAS_EXECINFO_H void printBacktrace(void** array, int size) { char** messages = backtrace_symbols(array, size); - for (int i = 0; i < size && messages != NULL; ++i) { + for (size_t i = 0; i < size && messages != NULL; ++i) { std::cerr << "\t" << messages[i] << std::endl; } std::cerr << std::endl; diff --git a/test/src/test-vxml-mmi-socket.cpp b/test/src/test-vxml-mmi-socket.cpp index 4db7109..b89a65a 100644 --- a/test/src/test-vxml-mmi-socket.cpp +++ b/test/src/test-vxml-mmi-socket.cpp @@ -135,7 +135,7 @@ int main(int argc, char** argv) { std::stringstream newCtxReqXMLSS; newCtxReqXMLSS << newCtxReqXML; - for (int i = 0; i < 100000; i++) { + for (size_t i = 0; i < 100000; i++) { std::string index = toStr(i); client.write(index.c_str(), index.size() + 1); // client.write(newCtxReqXMLSS.str().data(), newCtxReqXMLSS.str().size()); diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp index 669db30..baa963b 100644 --- a/test/src/test-w3c.cpp +++ b/test/src/test-w3c.cpp @@ -180,7 +180,7 @@ int main(int argc, char** argv) { Arabica::DOM::Element root = document.getDocumentElement(); Arabica::XPath::NodeSet sends = DOMUtils::filterChildElements(interpreter.getNameSpaceInfo().xmlNSPrefix + "send", root, true); - for (int i = 0; i < sends.size(); i++) { + for (size_t i = 0; i < sends.size(); i++) { Arabica::DOM::Element send = Arabica::DOM::Element(sends[i]); if (HAS_ATTR(send, "delay")) { NumAttr delay(ATTR(send, "delay")); diff --git a/test/w3c/run_generated_test.cmake b/test/w3c/run_generated_test.cmake index 334fffb..802acf1 100644 --- a/test/w3c/run_generated_test.cmake +++ b/test/w3c/run_generated_test.cmake @@ -6,22 +6,36 @@ include("${CMAKE_MODULE_PATH}/FileInformation.cmake") get_filename_component(TEST_FILE_NAME ${TESTFILE} NAME) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTDIR}) -message(STATUS "${USCXML_TRANSFORM_BIN} -t${TARGETLANG} -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.machine.c") -execute_process(COMMAND time -p ${USCXML_TRANSFORM_BIN} -t${TARGETLANG} -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.machine.c RESULT_VARIABLE CMD_RESULT) -if(CMD_RESULT) - message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}: ${CMD_RESULT}") -endif() -message(STATUS "time for transforming to c machine") # message(FATAL_ERROR "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}") if (${TARGETLANG} STREQUAL "vhdl") + find_program(GHDL ghdl) - message(STATUS ${OUTDIR}/${TEST_FILE_NAME}) + execute_process(COMMAND time -p ${USCXML_TRANSFORM_BIN} -t${TARGETLANG} -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.machine.vhdl RESULT_VARIABLE CMD_RESULT) + if(CMD_RESULT) + message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}: ${CMD_RESULT}") + endif() + message(STATUS "time for transforming to VHDL machine") + message(STATUS "${GHDL} -a ${OUTDIR}/${TEST_FILE_NAME}.machine.vhdl") + execute_process( + COMMAND time -p ${GHDL} -a ${OUTDIR}/${TEST_FILE_NAME}.machine.vhdl + WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT) + if(CMD_RESULT) + message(FATAL_ERROR "Error running ghdl ${GHDL}: ${CMD_RESULT}") + endif() + message(STATUS "time for transforming to binary") elseif (${TARGETLANG} STREQUAL "c") + message(STATUS "${USCXML_TRANSFORM_BIN} -t${TARGETLANG} -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.machine.c") + execute_process(COMMAND time -p ${USCXML_TRANSFORM_BIN} -t${TARGETLANG} -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.machine.c RESULT_VARIABLE CMD_RESULT) + if(CMD_RESULT) + message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}: ${CMD_RESULT}") + endif() + message(STATUS "time for transforming to c machine") + # set(COMPILE_CMD_OBJ # "-c" "${OUTDIR}/${TEST_FILE_NAME}.machine.c" # "-o" "${OUTDIR}/${TEST_FILE_NAME}.machine.c.o" -- cgit v0.12