diff options
Diffstat (limited to 'src/uscxml')
36 files changed, 631 insertions, 389 deletions
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<std::string>& 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<std::string> 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<std::string>(onExitElems[j])); } Arabica::XPath::NodeSet<std::string> 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<std::string>(invokeElems[j])); } Element<std::string> stateElem(statesToExit[i]); @@ -764,7 +764,7 @@ NodeSet<std::string> 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<std::string> 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<std::string> 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<std::string>& enab exitStates(enabledTransitions); - for (int i = 0; i < enabledTransitions.size(); i++) { + for (size_t i = 0; i < enabledTransitions.size(); i++) { Element<std::string> 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<std::string> states = getAllStates(); - for (int i = 0; i < states.size(); i++) { + for (size_t i = 0; i < states.size(); i++) { Arabica::DOM::Element<std::string> stateElem = Arabica::DOM::Element<std::string>(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<std::string> 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<std::string> invokeElem = Arabica::DOM::Element<std::string>(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<std::string> 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<std::string>(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<std::string> 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<std::string>(xincludes[j])); } } @@ -1910,7 +1910,7 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Element<std::string>& void InterpreterImpl::processParamChilds(const Arabica::DOM::Element<std::string>& element, std::multimap<std::string, Data>& params) { NodeSet<std::string> 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<std::string> paramElem = Element<std::string>(paramElems[i]); if (!HAS_ATTR(paramElem, "name")) { @@ -2421,7 +2421,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Element<std::string>& c iequals(TAGNAME(content), _nsInfo.xmlNSPrefix + "transition")) { // --- CONVENIENCE LOOP -------------------------- NodeList<std::string> executable = content.getChildNodes(); - for (int i = 0; i < executable.getLength(); i++) { + for (size_t i = 0; i < executable.getLength(); i++) { const Arabica::DOM::Node<std::string>& childNode = executable.item(i); if (childNode.getNodeType() != Node_base::ELEMENT_NODE) continue; @@ -2670,7 +2670,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Element<std::string>& c execContent.enterElement(content); if (execContent.processChildren()) { NodeList<std::string> 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<std::string>(executable.item(i)), rethrow); @@ -2689,7 +2689,7 @@ void InterpreterImpl::finalizeAndAutoForwardCurrentEvent() { invokeIter++) { if (iequals(invokeIter->first, _currEvent.invokeid)) { Arabica::XPath::NodeSet<std::string> 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<std::string> finalizeElem = Element<std::string>(finalizes[k]); executeContent(finalizeElem); } @@ -2729,13 +2729,13 @@ bool InterpreterImpl::parentIsScxmlState(const Arabica::DOM::Element<std::string bool InterpreterImpl::isInFinalState(const Arabica::DOM::Element<std::string>& state) { if (isCompound(state)) { Arabica::XPath::NodeSet<std::string> childs = getChildStates(state); - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { if (isFinal(Element<std::string>(childs[i])) && isMember(childs[i], _configuration)) return true; } } else if (isParallel(state)) { Arabica::XPath::NodeSet<std::string> childs = getChildStates(state); - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { if (!isInFinalState(Element<std::string>(childs[i]))) return false; } @@ -2745,7 +2745,7 @@ bool InterpreterImpl::isInFinalState(const Arabica::DOM::Element<std::string>& s } bool InterpreterImpl::isMember(const Arabica::DOM::Node<std::string>& node, const Arabica::XPath::NodeSet<std::string>& 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<std::string> InterpreterImpl::getChildStates(const Arabi Arabica::XPath::NodeSet<std::string> childs; Arabica::DOM::NodeList<std::string> 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<std::string>(childElems.item(i)))) { @@ -2768,7 +2768,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterImpl::getChildStates(const Arabi Arabica::XPath::NodeSet<std::string> InterpreterImpl::getChildStates(const Arabica::XPath::NodeSet<std::string>& states) { Arabica::XPath::NodeSet<std::string> 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<std::string> InterpreterImpl::getAncestorElement(const Arabic Arabica::DOM::Node<std::string> InterpreterImpl::findLCCA(const Arabica::XPath::NodeSet<std::string>& 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<std::string> InterpreterImpl::findLCCA(const Arabica::XPath:: Arabica::XPath::NodeSet<std::string> ancestors = getProperAncestors(states[0], Arabica::DOM::Node<std::string>()); Arabica::DOM::Node<std::string> ancestor; - for (int i = 0; i < ancestors.size(); i++) { + for (size_t i = 0; i < ancestors.size(); i++) { if (!isCompound(Element<std::string>(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<std::string> 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<std::string> targetElem(target[i]); if (!isInEmbeddedDocument(targetElem)) { _cachedStates[stateId] = targetElem; @@ -2955,7 +2955,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterImpl::getInitialStates(Arabica:: // first child state Arabica::XPath::NodeSet<std::string> initStates; NodeList<std::string> 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<std::string>(childs.item(i)))) { @@ -2981,12 +2981,12 @@ NodeSet<std::string> 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<std::string> state = Element<std::string>(reachable[i]); try { NodeSet<std::string> initials = getInitialStates(state); - for (int j = 0; j < initials.size(); j++) { + for (size_t j = 0; j < initials.size(); j++) { Element<std::string> initial = Element<std::string>(initials[j]); if (!InterpreterImpl::isMember(initial, reachable)) { reachable.push_back(initial); @@ -2998,14 +2998,14 @@ NodeSet<std::string> 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<std::string> state = Element<std::string>(reachable[i]); NodeSet<std::string> 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<std::string> transition = Element<std::string>(transitions[j]); try { NodeSet<std::string> targets = getTargetStates(transition); - for (int k = 0; k < targets.size(); k++) { + for (size_t k = 0; k < targets.size(); k++) { Element<std::string> target = Element<std::string>(targets[k]); if (!InterpreterImpl::isMember(target, reachable)) { reachable.push_back(target); @@ -3018,7 +3018,7 @@ NodeSet<std::string> 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<std::string> state = Element<std::string>(reachable[i]); if (InterpreterImpl::isAtomic(state)) { // iterate the states parents @@ -3054,7 +3054,7 @@ NodeSet<std::string> 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<std::string> 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<std::string> childElem = Element<std::string>(childs.item(i)); @@ -3377,7 +3377,7 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet<std::string>& config) { // The configuration contains exactly one child of the <scxml> element. NodeSet<std::string> scxmlChilds = getChildStates(_scxml); Node<std::string> 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<std::string>& 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<std::string>(config[i]))) { foundAtomicState = true; break; @@ -3406,7 +3406,7 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet<std::string>& 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<std::string>(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<std::string>& config) { // When the configuration contains an atomic state, it contains all of its <state> and <parallel> ancestors. - for (int i = 0; i < config.size(); i++) { + for (size_t i = 0; i < config.size(); i++) { if (isAtomic(Element<std::string>(config[i]))) { Node<std::string> parent = config[i]; while(((parent = parent.getParentNode()) && parent.getNodeType() == Node_base::ELEMENT_NODE)) { @@ -3433,13 +3433,13 @@ bool InterpreterImpl::isLegalConfiguration(const NodeSet<std::string>& config) { } // When the configuration contains a non-atomic <state>, 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<std::string> configElem(config[i]); if (!isAtomic(configElem) && !isParallel(configElem)) { Node<std::string> foundChildState; //std::cerr << config[i] << std::endl; NodeSet<std::string> 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<std::string>& config) { } // If the configuration contains a <parallel> 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<std::string>(config[i]))) { NodeSet<std::string> 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<std::string>(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<std::string>& e // remove modified states from cache Node<std::string> target = Arabica::DOM::Node<std::string>(event.getTarget()); NodeSet<std::string> 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<std::string> getBasicConfiguration() { tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); Arabica::XPath::NodeSet<std::string> basicConfig; - for (int i = 0; i < _configuration.size(); i++) { + for (size_t i = 0; i < _configuration.size(); i++) { if (isAtomic(Arabica::DOM::Element<std::string>(_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<std::set<Element<std::string> > > Complexity::getAllConfigurations(con bool isAtomic = true; NodeList<std::string> 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<std::string> childElem(children.item(i)); @@ -148,7 +148,7 @@ Complexity Complexity::calculateStateMachineComplexity(const Arabica::DOM::Eleme bool hasNestedData = false; Arabica::DOM::NodeList<std::string> 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<std::string> childElem = Element<std::string>(childElems.item(i)); @@ -161,7 +161,7 @@ Complexity Complexity::calculateStateMachineComplexity(const Arabica::DOM::Eleme } if (!hasNestedData && childElem.getLocalName() == "datamodel") { Arabica::DOM::NodeList<std::string> 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<std::string> childs = InterpreterImpl::getChildStates(root); - for (int i = 0; i < childs.size(); i++) { + for (size_t i = 0; i < childs.size(); i++) { complexity += calculateStateMachineComplexity(Element<std::string>(childs[i]), reachable); } if (hasFlatHistory) { @@ -189,7 +189,7 @@ Complexity Complexity::calculateStateMachineComplexity(const Arabica::DOM::Eleme // parallels are in all states -> multiply NodeSet<std::string> 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<std::string>(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<tthread::recursive_mutex> lock(_mutex); Arabica::XPath::NodeSet<std::string> basicConf = _interpreter.getBasicConfiguration(); - for (int i = 0; i < basicConf.size(); i++) { + for (size_t i = 0; i < basicConf.size(); i++) { Arabica::DOM::Element<std::string> element = Arabica::DOM::Element<std::string>(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<std::string> activeConf = _interpreter.getConfiguration(); - for (int i = 0; i < activeConf.size(); i++) { + for (size_t i = 0; i < activeConf.size(); i++) { Arabica::DOM::Element<std::string> element = Arabica::DOM::Element<std::string>(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<Breakpoint> getQualifiedTransBreakpoints(Interpreter interpreter, cons Arabica::DOM::Element<std::string> source(interpreter.getImpl()->getSourceState(transition)); Arabica::XPath::NodeSet<std::string> 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<std::string> 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> InterpreterIssue::forInterpreter(InterpreterImpl* in } - for (int i = 0; i < allStates.size(); i++) { + for (size_t i = 0; i < allStates.size(); i++) { Element<std::string> state = Element<std::string>(allStates[i]); if (InterpreterImpl::isMember(state, finals) && !HAS_ATTR(state, "id")) // id is not required for finals @@ -316,7 +316,7 @@ std::list<InterpreterIssue> InterpreterIssue::forInterpreter(InterpreterImpl* in issues.push_back(InterpreterIssue("Transition in history pseudo-state '" + stateId + "' has no target", transition, InterpreterIssue::USCXML_ISSUE_FATAL)); } else { NodeSet<std::string> targetStates = interpreter->getTargetStates(transition); - for (int j = 0; j < targetStates.size(); j++) { + for (size_t j = 0; j < targetStates.size(); j++) { Element<std::string> target = Element<std::string>(targetStates[j]); if (HAS_ATTR(state, "type") && ATTR(state, "type") == "deep") { if (!InterpreterImpl::isDescendant(target, state.getParentNode())) { @@ -345,7 +345,7 @@ std::list<InterpreterIssue> 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<std::string> transition = Element<std::string>(transitions[i]); // check for valid target @@ -365,15 +365,15 @@ std::list<InterpreterIssue> 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<std::string> state = Element<std::string>(allStates[i]); NodeSet<std::string> 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<std::string> transition = Element<std::string>(transitions[j]); - for (int k = 0; k < j; k++) { + for (size_t k = 0; k < j; k++) { Element<std::string> earlierTransition = Element<std::string>(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<std::string> history = Element<std::string>(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<std::string> state = Element<std::string>(withInitialAttr[i]); if (HAS_ATTR(state, "initial")) { @@ -461,7 +461,7 @@ NEXT_TRANSITION: // check for legal configuration of target sets { std::map<Element<std::string>, std::string > targetIdSets; - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { Element<std::string> transition = Element<std::string>(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<std::string> initial = Element<std::string>(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<std::string> state = Element<std::string>(allStates[i]); if (HAS_ATTR(state, "initial")) { @@ -508,7 +508,7 @@ NEXT_SET: NodeSet<std::string> 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<std::string> initial = Element<std::string>(initials[i]); NodeSet<std::string> 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<std::string> transition = Element<std::string>(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<std::string> invoke = Element<std::string>(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<std::string> send = Element<std::string>(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<std::string> block = Element<std::string>(allExecContentContainers[i]); NodeSet<std::string> 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<std::string> execContent = Element<std::string>(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<std::string> element = Element<std::string>(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<std::string> initial = Element<std::string>(initials[i]); if (initial.getParentNode() && initial.getParentNode().getNodeType() == Node_base::ELEMENT_NODE) { Element<std::string> 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<std::string> state = Element<std::string>(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<std::string> assign = Element<std::string>(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<std::string> content = Element<std::string>(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<std::string> param = Element<std::string>(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<std::string> script = Element<std::string>(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<std::string> send = Element<std::string>(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<std::string> cancel = Element<std::string>(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<std::string> invoke = Element<std::string>(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<std::string> donedata = Element<std::string>(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<std::string> script = Element<std::string>(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<std::string> condAttr = Element<std::string>(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<std::string> withExprAttr = Element<std::string>(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<std::string> foreach = Element<std::string>(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<std::string> send = Element<std::string>(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<std::string> invoke = Element<std::string>(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<std::string> cancel = Element<std::string>(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<std::string>& state, int32_t ch NodeSet<std::string> 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<std::string> childElem(childElems[i]); // remember histories we passed @@ -213,7 +213,7 @@ void SCXMLDotWriter::assembleGraph(const Element<std::string>& state, int32_t ch if (iequals(TAGNAME(childElem), "transition")) { _graph[nodeId].transitions.push_back(childElem); NodeSet<std::string> 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<std::stri break; case PORT_TRANSITION: nrOutPorts = dotState.transitions.size(); -// for (int i = 0; i < dotState.transitions.size(); i++) { +// for (size_t i = 0; i < dotState.transitions.size(); i++) { // outPorts.push_back(idForNode(dotState.transitions[i])); // } break; @@ -400,7 +400,7 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri // write history states NodeSet<std::string> histories = DOMUtils::filterChildElements(_xmlNSPrefix + "history", stateElem); - for (int i = 0; i < histories.size(); i++) { + for (size_t i = 0; i < histories.size(); i++) { os << " <tr><td port=\"" << portEscape(ATTR_CAST(histories[i], "id")) << "\" balign=\"left\" colspan=\"" << (nrOutPorts == 0 ? 1 : 2) << "\"><b>history: </b>" << ATTR_CAST(histories[i], "id") << "</td></tr>" << std::endl; } @@ -422,7 +422,7 @@ void SCXMLDotWriter::writeStateElement(std::ostream& os, const Element<std::stri // recurse into children and search others to draw NodeSet<std::string> 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<std::string> childElem(childElems[i]); if (InterpreterImpl::isState(Element<std::string>(childElem))) { writeStateElement(os, childElem); @@ -598,7 +598,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element<std::string>& elem, i std::list<struct ElemDetails> content; NodeList<std::string > 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<std::string> elem = Element<std::string>(childElems.item(i)); @@ -637,7 +637,7 @@ std::string SCXMLDotWriter::getDetailedLabel(const Element<std::string>& elem, i if (HAS_ATTR(elem, "expr")) details.name += " = " + ATTR(elem, "expr"); NodeList<std::string > 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<std::string>& elem, i if (HAS_ATTR(elem, "src")) details.name += ATTR(elem, "src"); NodeList<std::string > 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<std::string>& transition) Node<std::string> InterpreterDraft6::findLCPA(const Arabica::XPath::NodeSet<std::string>& states) { Arabica::XPath::NodeSet<std::string> ancestors = getProperAncestors(states[0], Node<std::string>()); Node<std::string> ancestor; - for (int i = 0; i < ancestors.size(); i++) { + for (size_t i = 0; i < ancestors.size(); i++) { if (!isParallel(Element<std::string>(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<std::string>& 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<std::string> t = ((Element<std::string>)enabledTransitions[i]); if (!isTargetless(t)) { Node<std::string> ancestor; @@ -156,7 +156,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e NodeSet<std::string> 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<std::string>& 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<std::string>& 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<std::string>& e } // remove statesToExit from _statesToInvoke std::list<Node<std::string> > 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<std::string>& 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<std::string> 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<std::string> historyElem = (Element<std::string>)histories[j]; std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow"); NodeSet<std::string> 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<std::string>(_configuration[k])) && isDescendant(_configuration[k], statesToExit[i])) historyNodes.push_back(_configuration[k]); @@ -225,7 +225,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& 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<std::string>& e } } - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { USCXML_MONITOR_CALLBACK3(beforeExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet<std::string> 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<std::string> onExitElem = (Element<std::string>)onExits[j]; executeContent(onExitElem); } @@ -246,7 +246,7 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e USCXML_MONITOR_CALLBACK3(afterExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet<std::string> 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<std::string> invokeElem = (Element<std::string>)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<std::string>& 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<std::string>& #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<std::string> transition = ((Element<std::string>)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<std::string>& #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<std::string>& 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::string>& 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<std::string>(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<std::string> 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<std::string>(ancestors[k]))) { NodeSet<std::string> 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<std::string>& #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<std::string> stateElem = (Element<std::string>)statesToEnter[i]; // extension for flattened interpreters @@ -397,7 +397,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>& // extension for flattened SCXML documents, we will need an explicit uninvoke element NodeSet<std::string> 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<std::string> uninvokeElem = (Element<std::string>)uninvokes[j]; cancelInvoke(uninvokeElem); } @@ -409,7 +409,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>& NodeSet<std::string> dataModelElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", stateElem); if(dataModelElems.size() > 0 && _dataModel) { Arabica::XPath::NodeSet<std::string> 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<std::string>(dataElems[j])); } @@ -425,7 +425,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>& if (isMember(stateElem, statesForDefaultEntry)) { // execute initial transition content for compound states Arabica::XPath::NodeSet<std::string> 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<std::string>(transitions[j])); } } @@ -435,7 +435,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>& if (isMember(stateElem, defaultHistoryContent)) { // execute history transition Arabica::XPath::NodeSet<std::string> 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<std::string>& Arabica::XPath::NodeSet<std::string> 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<std::string>(childs[j]))) { inFinalState = false; break; @@ -471,7 +471,7 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>& } } } - for (int i = 0; i < _configuration.size(); i++) { + for (size_t i = 0; i < _configuration.size(); i++) { Element<std::string> stateElem = (Element<std::string>)_configuration[i]; if (isFinal(stateElem) && parentIsScxmlState(stateElem)) { _topLevelFinalReached = true; @@ -494,39 +494,39 @@ void InterpreterDraft6::addStatesToEnter(const Element<std::string>& 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<std::string>(historyValue[i]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); NodeSet<std::string> 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<std::string> 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<std::string> targets = getTargetStates(Element<std::string>(transitions[i])); - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { addStatesToEnter(Element<std::string>(targets[j]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); // Modifications from chris nuernberger NodeSet<std::string> 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<std::string>& state, statesForDefaultEntry.push_back(state); NodeSet<std::string> tStates = getInitialStates(state); - for (int i = 0; i < tStates.size(); i++) { + for (size_t i = 0; i < tStates.size(); i++) { addStatesToEnter(Element<std::string>(tStates[i]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); } @@ -547,7 +547,7 @@ void InterpreterDraft6::addStatesToEnter(const Element<std::string>& state, } else if(isParallel(state)) { NodeSet<std::string> childStates = getChildStates(state); - for (int i = 0; i < childStates.size(); i++) { + for (size_t i = 0; i < childStates.size(); i++) { addStatesToEnter(Element<std::string>(childStates[i]), statesToEnter, statesForDefaultEntry, defaultHistoryContent); } } @@ -562,7 +562,7 @@ void InterpreterDraft6::handleDOMEvent(Arabica::DOM::Events::Event<std::string>& return; Node<std::string> target = Arabica::DOM::Node<std::string>(event.getTarget()); NodeSet<std::string> 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<std::string> transElem = Element<std::string>(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<std::string> InterpreterRC::removeConflictingTransitions if (!t1Preempted) { // remove transitionsToRemove from DOMUtils::filteredTransitions std::list<Node<std::string> > 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<std::string>& 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<std::string>& enabl // remove statesToExit from _statesToInvoke std::list<Node<std::string> > 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<std::string>& enabl statesToExit.sort(); - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { NodeSet<std::string> 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<std::string> historyElem = (Element<std::string>)histories[j]; std::string historyType = (historyElem.hasAttribute("type") ? historyElem.getAttribute("type") : "shallow"); NodeSet<std::string> 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<std::string>(_configuration[k])) && isDescendant(_configuration[k], statesToExit[i])) historyNodes.push_back(_configuration[k]); @@ -137,11 +137,11 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet<std::string>& enabl } } - for (int i = 0; i < statesToExit.size(); i++) { + for (size_t i = 0; i < statesToExit.size(); i++) { USCXML_MONITOR_CALLBACK3(beforeExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet<std::string> 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<std::string> onExitElem = (Element<std::string>)onExits[j]; executeContent(onExitElem); } @@ -149,7 +149,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet<std::string>& enabl USCXML_MONITOR_CALLBACK3(afterExitingState, Element<std::string>(statesToExit[i]), (i + 1 < statesToExit.size())) NodeSet<std::string> 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<std::string> invokeElem = (Element<std::string>)invokes[j]; if (HAS_ATTR(invokeElem, "persist") && stringIsTrue(ATTR(invokeElem, "persist"))) { } else { @@ -159,7 +159,7 @@ void InterpreterRC::exitStates(const Arabica::XPath::NodeSet<std::string>& 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<std::string> 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<std::string> 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<std::string>& 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<std::string> s = (Element<std::string>)statesToEnter[i]; USCXML_MONITOR_CALLBACK3(beforeEnteringState, s, i + 1 < statesToEnter.size()) @@ -257,7 +257,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab NodeSet<std::string> dataModelElems = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", s); if(dataModelElems.size() > 0 && _dataModel) { Arabica::XPath::NodeSet<std::string> 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<std::string>(dataElems[j])); } @@ -290,7 +290,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab // extension for flattened SCXML documents, we will need an explicit uninvoke element NodeSet<std::string> 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<std::string> uninvokeElem = (Element<std::string>)uninvokes[j]; cancelInvoke(uninvokeElem); } @@ -322,7 +322,7 @@ void InterpreterRC::enterStates(const Arabica::XPath::NodeSet<std::string>& enab if (isParallel(grandParent)) { Arabica::XPath::NodeSet<std::string> 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<std::string>(childs[j]))) { inFinalState = false; break; @@ -353,23 +353,23 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet<std::string>& std::map<std::string, Arabica::DOM::Node<std::string> >& 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<std::string> t(transitions[i]); NodeSet<std::string> targets = getTargetStates(t); - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { Element<std::string> s = Element<std::string>(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<std::string> t(transitions[i]); Element<std::string> ancestor = Element<std::string>(getTransitionDomain(t)); NodeSet<std::string> effectiveTargetStates = getEffectiveTargetStates(t); - for (int j = 0; j < effectiveTargetStates.size(); j++) { + for (size_t j = 0; j < effectiveTargetStates.size(); j++) { Element<std::string> s = Element<std::string>(effectiveTargetStates[j]); addAncestorStatesToEnter(s, ancestor, statesToEnter, statesForDefaultEntry, defaultHistoryContent); } @@ -402,7 +402,7 @@ Arabica::XPath::NodeSet<std::string> InterpreterRC::getEffectiveTargetStates(con targets = getTargetStates(transition); } - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { Element<std::string> s = Element<std::string>(targets[j]); if (isHistory(s)) { if (_historyValue.find(ATTR(s, "id")) != _historyValue.end()) { @@ -482,7 +482,7 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element<std:: std::string stateId = ATTR(state, "id"); if (_historyValue.find(stateId) != _historyValue.end()) { const Arabica::XPath::NodeSet<std::string>& historyValue = _historyValue[stateId]; - for (int i = 0; i < historyValue.size(); i++) { + for (size_t i = 0; i < historyValue.size(); i++) { const Element<std::string>& s = Element<std::string>(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<std:: defaultHistoryContent[ATTR_CAST(getParentState(state), "id")] = transitions[0]; } - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { NodeSet<std::string> targets = getTargetStates(Element<std::string>(transitions[i])); - for (int j = 0; j < targets.size(); j++) { + for (size_t j = 0; j < targets.size(); j++) { const Element<std::string>& s = Element<std::string>(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<std:: // test 579 - initial leads to history still fails NodeSet<std::string> targets = getEffectiveTargetStates(Element<std::string>(state)); - for (int i = 0; i < targets.size(); i++) { + for (size_t i = 0; i < targets.size(); i++) { const Element<std::string>& s = Element<std::string>(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<std::string>& s = Element<std::string>(targets[i]); addAncestorStatesToEnter(s, state, statesToEnter, statesForDefaultEntry, defaultHistoryContent); } @@ -545,10 +545,10 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element<std:: } else if(isParallel(state)) { NodeSet<std::string> childStates = getChildStates(state); - for (int i = 0; i < childStates.size(); i++) { + for (size_t i = 0; i < childStates.size(); i++) { const Element<std::string>& child = Element<std::string>(childStates[i]); - for (int j = 0; j < statesToEnter.size(); j++) { + for (size_t j = 0; j < statesToEnter.size(); j++) { const Node<std::string>& s = statesToEnter[j]; if (isDescendant(s, child)) { goto BREAK_LOOP; @@ -585,7 +585,7 @@ void InterpreterRC::addAncestorStatesToEnter(const Arabica::DOM::Element<std::st #endif NodeSet<std::string> ancestors = getProperAncestors(state, ancestor); - for (int i = 0; i < ancestors.size(); i++) { + for (size_t i = 0; i < ancestors.size(); i++) { const Node<std::string>& 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<std::st if (isParallel(Element<std::string>(anc))) { NodeSet<std::string> childStates = getChildStates(anc); - for (int j = 0; j < childStates.size(); j++) { + for (size_t j = 0; j < childStates.size(); j++) { const Element<std::string>& child = Element<std::string>(childStates[j]); - for (int k = 0; k < statesToEnter.size(); k++) { + for (size_t k = 0; k < statesToEnter.size(); k++) { const Node<std::string>& s = statesToEnter[k]; if (isDescendant(s, child)) { goto BREAK_LOOP; @@ -631,7 +631,7 @@ Arabica::DOM::Node<std::string> InterpreterRC::getTransitionDomain(const Arabica Node<std::string> source = getSourceState(transition); if (iequals(transitionType, "internal") && isCompound(Element<std::string>(source))) { - for (int i = 0; i < tStates.size(); i++) { + for (size_t i = 0; i < tStates.size(); i++) { const Node<std::string>& 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<std::string>& dom) { if (dom.hasAttributes()) { Arabica::DOM::NamedNodeMap<std::string> attributes = dom.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { + for (size_t i = 0; i < attributes.getLength(); i++) { Arabica::DOM::Node<std::string> attribute = attributes.item(i); // Interpreter::dump(attribute); @@ -96,7 +96,7 @@ Data::Data(const Arabica::DOM::Node<std::string>& dom) { if (dom.hasChildNodes()) { Arabica::DOM::NodeList<std::string> children = dom.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { + for (size_t i = 0; i < children.getLength(); i++) { Arabica::DOM::Node<std::string> 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<Data>::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<Data>::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<std::string> payloadElem = (Arabica::DOM::Element<std::string>)payload; Arabica::DOM::NodeList<std::string> 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<std::string> 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<InterpreterInfo*>(); 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<PlCompound> SWIDataModel::getSolutions(PlCompound compound) { std::list<PlCompound> 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<std::string>& 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<std::string, PlTerm> 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<std::string, PlTerm> 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<std::string> 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<std::string> 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<std::string>& 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<std::string> 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<std::string>& dataElem, XPathValue<std::string> 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<std::string>& key, const Element<std::string>& assignElem) { if (key.size() == 0) return; - for (int i = 0; i < key.size(); i++) { + for (size_t i = 0; i < key.size(); i++) { Node<std::string> node = key[i]; switch (node.getNodeType()) { case Node_base::ATTRIBUTE_NODE: { @@ -710,7 +710,7 @@ void XPathDataModel::assign(const NodeSet<std::string>& 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<std::string>(key[i]), value, assignElem); @@ -733,13 +733,13 @@ void XPathDataModel::assign(const Element<std::string>& 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<std::string> 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<std::string> 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<std::string>& key, Node<std::string> 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<std::string> 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<std::string>& key, Node<std::string> 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<std::string> importedNode = (value[i-1].getOwnerDocument() == _doc ? value[i-1].cloneNode(true) : _doc.importNode(value[i-1], true)); Node<std::string> nextSibling = element.getNextSibling(); if (nextSibling) { @@ -787,7 +787,7 @@ void XPathDataModel::assign(const Element<std::string>& 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<std::string> 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<std::string>& 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<std::string, Arabica::XPath::NodeSet<std::string> >::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<std::pair<std::string, std::string> > XPathFunctionResolver::validNa bool XPathFunctionIn::doEvaluate(const Node<std::string>& context, const ExecutionContext<std::string>& executionContext) const { - for (int i = 0; i < argCount(); i++) { + for (size_t i = 0; i < argCount(); i++) { XPathValue<std::string> 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<std::string>& node // process headers Arabica::XPath::NodeSet<std::string> 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<std::string> headerElem = Arabica::DOM::Element<std::string>(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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string>(histories[i]); } @@ -236,7 +236,7 @@ InterpreterState ChartToFSM::interpret() { // set invokeid for all invokers to parent state if none given NodeSet<std::string> 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<std::string> invokerElem = Element<std::string>(invokers[i]); invokerElem.setAttribute("parent", ATTR_CAST(invokerElem.getParentNode(), "id")); } @@ -255,7 +255,7 @@ InterpreterState ChartToFSM::interpret() { Arabica::XPath::NodeSet<std::string> 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<std::string> 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<std::string>(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<std::string> state = Element<std::string>(allStates[i]); // while we are iterating, determine deepest nested level @@ -471,7 +471,7 @@ static bool isSuperset(const GlobalTransition* t1, const GlobalTransition* t2) { NodeSet<std::string> t1Trans = t1->getTransitions(); NodeSet<std::string> 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<std::string>& 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<std::string> execContentElem(execContent[i]); int nrRaise = 0; NodeSet<std::string> 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<std::string> 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<std::string> 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<std::string> transition(allTransitions[i]); Arabica::DOM::Node<std::string> domain = getTransitionDomain(transition); if (domain) { @@ -615,14 +615,14 @@ void ChartToFSM::annotateDomain() { void ChartToFSM::annotateExitSet() { Arabica::XPath::NodeSet<std::string> 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<std::string> transition(allTransitions[i]); Arabica::DOM::Node<std::string> domain = getTransitionDomain(transition); Arabica::XPath::NodeSet<std::string> 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<std::string> 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<std::string> 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<std::string> transition(allTransitions[i]); NodeSet<std::string> 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<std::string> 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<std::string> 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<std::string> allTransitions = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true); Arabica::XPath::NodeSet<std::string> allStates = getAllStates(); - for (int i = 0; i < allTransitions.size(); i++) { + for (size_t i = 0; i < allTransitions.size(); i++) { Element<std::string> t1(allTransitions[i]); if (!isState(Element<std::string>(t1.getParentNode()))) continue; @@ -676,7 +676,7 @@ void ChartToFSM::annotateConflicts() { Arabica::DOM::Node<std::string> d1 = getTransitionDomain(t1); Arabica::XPath::NodeSet<std::string> exitSet1; - for (int k = 0; k < allStates.size(); k++) { + for (size_t k = 0; k < allStates.size(); k++) { Element<std::string> 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<std::string> d2 = getTransitionDomain(t2); Arabica::XPath::NodeSet<std::string> exitSet2; - for (int k = 0; k < allStates.size(); k++) { + for (size_t k = 0; k < allStates.size(); k++) { Element<std::string> state(allStates[k]); if (isDescendant(state, d2)) { exitSet2.push_back(state); @@ -764,13 +764,13 @@ void ChartToFSM::indexTransitions(const Arabica::DOM::Element<std::string>& root void ChartToFSM::indexTransitions(const Arabica::DOM::Element<std::string>& root) { // Post-order traversal of transitions Arabica::XPath::NodeSet<std::string> childStates = getChildStates(root); - for (int i = 0; i < childStates.size(); i++) { + for (size_t i = 0; i < childStates.size(); i++) { Element<std::string> childElem(childStates[i]); indexTransitions(childElem); } Arabica::XPath::NodeSet<std::string> 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<std::string>(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<GlobalTransition*> redundantMark(std::list<GlobalTransition*> 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<TransitionTreeNode*> transLeafs; - for (int i = 0; i < conf.size(); i++) { + for (size_t i = 0; i < conf.size(); i++) { DUMP_STATS(conf.size(), false); Element<std::string> confElem(conf[i]); @@ -1256,7 +1256,7 @@ TransitionTreeNode* ChartToFSM::buildTransTree(const Arabica::DOM::Element<std:: TransitionTreeNode* lastNode = NULL; - for (int i = 0; i < nested.size(); i++) { + for (size_t i = 0; i < nested.size(); i++) { Element<std::string> 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<std::string> 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<std::string>& 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<int>(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<int>(ATTR_CAST(alreadyEnteredStates_[i], "index"))); } for (std::map<std::string, Arabica::XPath::NodeSet<std::string> >::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<int>(ATTR_CAST(histIter->second[i], "index"))); } } @@ -1790,7 +1790,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet<std::string>& 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<int>(ATTR_CAST(transitionSet[i], "index"))); } @@ -1808,7 +1808,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet<std::string>& 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<std::string>& t Arabica::DOM::Element<std::string> withTarget; Arabica::DOM::Element<std::string> noneTarget; - for (int i = 0; i < transitionSet.size(); i++) { + for (size_t i = 0; i < transitionSet.size(); i++) { Arabica::DOM::Element<std::string> transElem = Arabica::DOM::Element<std::string>(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<std::string>& t // extract conditions and history targets std::list<std::string> conditions; - for (int i = 0; i < transitionSet.size(); i++) { + for (size_t i = 0; i < transitionSet.size(); i++) { Arabica::DOM::Element<std::string> transElem = Arabica::DOM::Element<std::string>(transitionSet[i]); // gather conditions while we are iterating anyway if (HAS_ATTR(transElem, "cond")) { @@ -1937,7 +1937,7 @@ GlobalTransition::GlobalTransition(const Arabica::XPath::NodeSet<std::string>& 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<std::string> GlobalTransition::getCommonEvents(const NodeSet<std::stri std::list<std::string> prefixes; std::list<std::string> longestPrefixes; - for (int i = 0; i < transitions.size(); i++) { + for (size_t i = 0; i < transitions.size(); i++) { // for every transition std::list<std::string> eventNames = tokenize(ATTR_CAST(transitions[i], "event")); @@ -1999,7 +1999,7 @@ std::list<std::string> GlobalTransition::getCommonEvents(const NodeSet<std::stri eventName = eventName.substr(0, eventName.size() - 1); bool isMatching = true; - for (int j = 0; j < transitions.size(); j++) { + for (size_t j = 0; j < transitions.size(); j++) { // check if token would activate all other transitions if (i == j) continue; diff --git a/src/uscxml/transform/ChartToFlatSCXML.cpp b/src/uscxml/transform/ChartToFlatSCXML.cpp index 984c287..ac91681 100644 --- a/src/uscxml/transform/ChartToFlatSCXML.cpp +++ b/src/uscxml/transform/ChartToFlatSCXML.cpp @@ -32,7 +32,7 @@ if (childs.size() > 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<std::string> imported = _flatDoc.importNode(childs[i], true); \ transientState.appendChild(imported); \ } \ @@ -64,7 +64,7 @@ void ChartToFlatSCXML::writeTo(std::ostream& stream) { // remove all debug attributes NodeSet<std::string> 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<std::string> 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<std::string> 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<std::string> imported = _flatDoc.importNode(datas[i], true); @@ -147,13 +147,13 @@ void ChartToFlatSCXML::createDocument() { NodeSet<std::string> 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<std::string> imported = _flatDoc.importNode(scripts[i], true); _scxml.appendChild(imported); } NodeSet<std::string> 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<std::string> imported = _flatDoc.importNode(comments[i], true); _scxml.appendChild(imported); } @@ -185,7 +185,7 @@ void ChartToFlatSCXML::createDocument() { { NodeSet<std::string> 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<std::string> ChartToFlatSCXML::globalTransitionToNode(GlobalTransition* glo if (transientStateChain.size() > 0) { Element<std::string> prevExitTransitionElem; - for (int i = 0; i < transientStateChain.size(); i++) { + for (size_t i = 0; i < transientStateChain.size(); i++) { Element<std::string> transientStateElem = Element<std::string>(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<std::string> 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<std::string> 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<std::string>& node) NodeSet<std::string> ifChilds = DOMUtils::filterChildType(Node_base::ELEMENT_NODE, elem, false); Element<std::string> lastConditional = elem; bool hadVisitedChild = false; - for (int j = 0; j < ifChilds.size(); j++) { + for (size_t j = 0; j < ifChilds.size(); j++) { Element<std::string> 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<std::string>& node) // iterate and remove unvisited children NodeList<std::string> children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { + for (size_t i = 0; i < children.getLength(); i++) { Node<std::string> 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<std::string>& transition, bool moreComing) { NodeSet<std::string> 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<std::string>(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<GlobalTransitio void ChartToPromela::writeTransition(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 += " "; } std::list<GlobalTransition*>::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<std::string> 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<std::string> 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<std::string> paramElem = Element<std::string>(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<std::string>& 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<std::string> 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<std::string> 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<std::string> 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<std::string>& 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<std::string> 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<std::string> 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<std::string> transitions = DOMUtils::filterChildElements("transition", es.container, true); std::set<std::string> 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<GlobalTransition*> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> contentElem = Element<std::string>(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<std::string> elem = Element<std::string>(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<std::string> elem = Element<std::string>(withExpr[i]); if (HAS_ATTR(elem, "expr")) { std::string code = ATTR(elem, "expr"); @@ -3313,7 +3313,7 @@ void ChartToPromela::initNodes() { { NodeSet<std::string> 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<std::string> elem = Element<std::string>(withLocation[i]); if (HAS_ATTR(elem, "location")) { std::string code = ATTR(elem, "location"); @@ -3327,9 +3327,9 @@ void ChartToPromela::initNodes() { NodeSet<std::string> 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<std::string> 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<std::string> elem = Text<std::string>(texts[j]); std::string code = elem.getNodeValue(); @@ -3342,7 +3342,7 @@ void ChartToPromela::initNodes() { } { NodeSet<std::string> 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<std::string> 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<std::string> 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<GlobalTransition*>::iterator transIter = stateIter->second->sortedOutgoing.begin(); transIter != stateIter->second->sortedOutgoing.end(); transIter++) { GlobalTransition* currTrans = *transIter; Arabica::XPath::NodeSet<std::string> members = currTrans->getTransitions(); - for (int i = 0; i < members.size(); i++) { + for (size_t i = 0; i < members.size(); i++) { Element<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> transition(_transitions[i]); - stream << "signal in_optimal_transition_set_" << ATTR(transition, "postFixOrder") << "_sig : std_logic;" - << std::endl; - } + std::list<TrieNode*> eventNames = _eventTrie.getWordsWithPrefix(""); + for (std::list<TrieNode*>::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<std::string> transition(_transitions[i]); std::string conflicts = ATTR(transition, "conflictBools"); + + VContainer nameMatchers = VOR; + if (HAS_ATTR(transition, "event")) { + std::list<std::string> eventDescs = tokenize(ATTR(transition, "event")); + for (std::list<std::string>::iterator descIter = eventDescs.begin(); descIter != eventDescs.end(); descIter++) { + std::list<TrieNode*> eventNames = _eventTrie.getWordsWithPrefix((*descIter) == "*" ? "" : *descIter); + for (std::list<TrieNode*>::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<std::string> 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<std::string> 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<std::string> 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 <scxml> } + VContainer tmp1 = VAND; + if (isCompound(Element<std::string>(_states[strTo<size_t>(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<std::string>(_states[strTo<size_t>(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<std::string>(_states[strTo<size_t>(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<std::string> state(_states[i]); // calculate event choices @@ -604,7 +731,7 @@ void ChartToVHDL::writeNextStateLogic(std::ostream & stream) { // will be written first std::vector< Element<std::string> > choices; std::string spntaneous_trans_sig = ""; - for (int j = 0; j < _transitions.size(); j++) { + for (size_t j = 0; j < _transitions.size(); j++) { Element<std::string> 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<std::string> > incommingTransitions; - for (int j = 0; j < _transitions.size(); j++) { + for (size_t j = 0; j < _transitions.size(); j++) { Element<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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 <DOM/Node.hpp> #include <XPath/XPath.hpp> #include <ostream> +#include <vector> 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<std::string>& activeStates, const Arabica::XPath::NodeSet<std::string>& alreadyEnteredStates, const std::map<std::string, Arabica::XPath::NodeSet<std::string> >& 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<std::string>& 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<std::string, Arabica::XPath::NodeSet<std::string> >::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<std::string> 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<TrieNode*> 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 += " "; } |