[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevplatform] /: remove FOREACH_ARRAY, just use Qt's foreach and be done with it...
From:       Milian Wolff <mail () milianw ! de>
Date:       2013-12-07 17:39:23
Message-ID: E1VpLqd-0005FR-F8 () scm ! kde ! org
[Download RAW message or body]

Git commit cec794b517f1415c696735ddb0144118e9996c7b by Milian Wolff.
Committed on 07/12/2013 at 17:39.
Pushed by mwolff into branch 'master'.

remove FOREACH_ARRAY, just use Qt's foreach and be done with it...

M  +2    -2    language/duchain/declaration.cpp
M  +1    -1    language/duchain/declarationid.cpp
M  +1    -1    language/duchain/duchain.cpp
M  +1    -1    language/duchain/duchainutils.cpp
M  +10   -10   language/duchain/ducontext.cpp
M  +2    -2    language/duchain/functiondefinition.cpp
M  +4    -4    language/duchain/topducontext.cpp
M  +0    -7    util/kdevvarlengtharray.h

http://commits.kde.org/kdevplatform/cec794b517f1415c696735ddb0144118e9996c7b


diff --git a/language/duchain/declaration.cpp \
b/language/duchain/declaration.cpp index caff045..3bb298f 100644
--- a/language/duchain/declaration.cpp
+++ b/language/duchain/declaration.cpp
@@ -726,7 +726,7 @@ QMap<IndexedString, QList<RangeInRevision> > \
Declaration::uses() const  
   KDevVarLengthArray<IndexedTopDUContext> useContexts = \
DUChain::uses()->uses(id());  
-  FOREACH_ARRAY(const IndexedTopDUContext& indexedContext, useContexts) {
+  foreach(const IndexedTopDUContext& indexedContext, useContexts) {
     TopDUContext* context = indexedContext.data();
     if(context) {
       QMap<RangeInRevision, bool>& ranges(tempUses[context->url()]);
@@ -792,7 +792,7 @@ QMap<IndexedString, QList<SimpleRange> > \
Declaration::usesCurrentRevision() cons  
   KDevVarLengthArray<IndexedTopDUContext> useContexts = \
DUChain::uses()->uses(id());  
-  FOREACH_ARRAY(const IndexedTopDUContext& indexedContext, useContexts) {
+  foreach(const IndexedTopDUContext& indexedContext, useContexts) {
     TopDUContext* context = indexedContext.data();
     if(context) {
       QMap<SimpleRange, bool>& ranges(tempUses[context->url()]);
diff --git a/language/duchain/declarationid.cpp \
b/language/duchain/declarationid.cpp index 1fdde3d..8e71701 100644
--- a/language/duchain/declarationid.cpp
+++ b/language/duchain/declarationid.cpp
@@ -112,7 +112,7 @@ KDevVarLengthArray<Declaration*> \
DeclarationId::getDeclarations(const TopDUConte  
   if(!ret.isEmpty() && m_specialization.index()) {
     KDevVarLengthArray<Declaration*> newRet;
-    FOREACH_ARRAY(Declaration* decl, ret) {
+    foreach(Declaration* decl, ret) {
         Declaration* specialized = decl->specialize(m_specialization, top \
? top : decl->topContext());  if(specialized)
           newRet.append(specialized);
diff --git a/language/duchain/duchain.cpp b/language/duchain/duchain.cpp
index 7cb9d73..622f128 100644
--- a/language/duchain/duchain.cpp
+++ b/language/duchain/duchain.cpp
@@ -520,7 +520,7 @@ public:
       
       //Process the indices in a separate step after copying them from the \
                array, so we don't need m_environmentListInfo.mutex locked,
       //and can call loadInformation(..) safely, which else might lead to \
                a deadlock.
-      FOREACH_ARRAY(uint topContextIndex, topContextIndices) {
+      foreach(uint topContextIndex, topContextIndices) {
         KSharedPtr< ParsingEnvironmentFile > p = \
ParsingEnvironmentFilePointer(loadInformation(topContextIndex));  if(p) {
          ret << p;
diff --git a/language/duchain/duchainutils.cpp \
b/language/duchain/duchainutils.cpp index 823decf..eb20a7a 100644
--- a/language/duchain/duchainutils.cpp
+++ b/language/duchain/duchainutils.cpp
@@ -486,7 +486,7 @@ QList<Declaration*> DUChainUtils::getInheriters(const \
Declaration* decl, uint& m  return ret;
 
   if(decl->internalContext() && decl->internalContext()->type() == \
                DUContext::Class)
-    FOREACH_ARRAY(const IndexedDUContext& importer, \
decl->internalContext()->indexedImporters()) { +    foreach(const \
IndexedDUContext& importer, decl->internalContext()->indexedImporters()) {  \
  DUContext* imp = importer.data();
       
diff --git a/language/duchain/ducontext.cpp \
b/language/duchain/ducontext.cpp index 6390d25..3e5ab93 100644
--- a/language/duchain/ducontext.cpp
+++ b/language/duchain/ducontext.cpp
@@ -733,7 +733,7 @@ bool DUContext::findDeclarationsInternal( const \
SearchItem::PtrList & baseIdenti  if( d->m_importedContextsSize() != 0 ) {
     ///Step 2: Give identifiers that are not marked as explicitly-global \
to imported contexts(explicitly global ones are treatead in TopDUContext)  \
                SearchItem::PtrList nonGlobalIdentifiers;
-    FOREACH_ARRAY( const SearchItem::Ptr& identifier, aliasedIdentifiers )
+    foreach( const SearchItem::Ptr& identifier, aliasedIdentifiers )
       if( !identifier->isExplicitlyGlobal )
         nonGlobalIdentifiers << identifier;
 
@@ -795,7 +795,7 @@ QList< QualifiedIdentifier > \
DUContext::fullyApplyAliases(const QualifiedIdentif  }
   
   QList<QualifiedIdentifier> ret;
-  FOREACH_ARRAY(const SearchItem::Ptr& item, identifiers)
+  foreach(const SearchItem::Ptr& item, identifiers)
     ret += item->toList();
   
   return ret;
@@ -909,7 +909,7 @@ QVector<DUContext*> DUContext::importers() const
   if(owner()) {
     //Add indirect importers to the list
     KDevVarLengthArray<IndexedDUContext> indirect = \
                Importers::self().importers(owner()->id());
-    FOREACH_ARRAY(const IndexedDUContext& ctx, indirect) {
+    foreach(const IndexedDUContext& ctx, indirect) {
       ret << ctx.context();
     }
   }
@@ -1052,7 +1052,7 @@ void DUContext::deleteLocalDeclarations()
   TopDUContext* top = topContext();
   //If we are deleting something that is not stored to disk, we need to \
create + delete the declarations,  //so their destructor unregisters from \
                the persistent symbol table and from \
                TopDUContextDynamicData
-  FOREACH_ARRAY(const LocalIndexedDeclaration& decl, declarations)
+  foreach(const LocalIndexedDeclaration& decl, declarations)
     if(decl.isLoaded(top) || !top->deleting() || !top->isOnDisk())
       delete decl.data(top);
 }
@@ -1233,7 +1233,7 @@ void DUContext::applyAliases(const \
SearchItem::PtrList& baseIdentifiers, SearchI  return;
   }
 
-  FOREACH_ARRAY( const SearchItem::Ptr& identifier, baseIdentifiers ) {
+  foreach( const SearchItem::Ptr& identifier, baseIdentifiers ) {
     bool addUnmodified = true;
 
     if( !identifier->isExplicitlyGlobal ) {
@@ -1241,7 +1241,7 @@ void DUContext::applyAliases(const \
SearchItem::PtrList& baseIdentifiers, SearchI  if( !imports.isEmpty() )
       {
         //We have namespace-imports.
-        FOREACH_ARRAY( Declaration* importDecl, imports )
+        foreach( Declaration* importDecl, imports )
         {
           //Search for the identifier with the import-identifier prepended
           if(dynamic_cast<NamespaceAliasDeclaration*>(importDecl))
@@ -1262,7 +1262,7 @@ void DUContext::applyAliases(const \
SearchItem::PtrList& baseIdentifiers, SearchI  if(!aliases.isEmpty()) {
           //The first part of the identifier has been found as a \
                namespace-alias.
           //In c++, we only need the first alias. However, just to be \
                correct, follow them all for now.
-          FOREACH_ARRAY( Declaration* aliasDecl, aliases )
+          foreach( Declaration* aliasDecl, aliases )
           {
             if(!dynamic_cast<NamespaceAliasDeclaration*>(aliasDecl))
               continue;
@@ -1475,7 +1475,7 @@ void DUContext::cleanIfNotEncountered(const \
QSet<DUChainBase*>& encountered)  declarationsCopy = \
d_func_dynamic()->m_localDeclarationsList();  }
 
-  FOREACH_ARRAY(const LocalIndexedDeclaration& indexedDec, \
declarationsCopy) +  foreach(const LocalIndexedDeclaration& indexedDec, \
declarationsCopy)  {
     Declaration* dec = indexedDec.data(topContext());
     if (dec && !encountered.contains(dec) && (!dec->isAutoDeclaration() || \
!dec->hasUses())) @@ -1485,7 +1485,7 @@ void \
DUContext::cleanIfNotEncountered(const QSet<DUChainBase*>& encountered)  \
//Copy since the array may change during the iteration  \
KDevVarLengthArray<LocalIndexedDUContext, 10> childrenCopy = \
d_func_dynamic()->m_childContextsList();  
-  FOREACH_ARRAY(const LocalIndexedDUContext& childContext, childrenCopy)
+  foreach(const LocalIndexedDUContext& childContext, childrenCopy)
     if (!encountered.contains(childContext.data(topContext())))
       delete childContext.data(topContext());
 }
@@ -1642,7 +1642,7 @@ void \
DUContext::SearchItem::addToEachNode(SearchItem::Ptr other) {  
 void DUContext::SearchItem::addToEachNode(SearchItem::PtrList other) {
   int added = 0;
-  FOREACH_ARRAY(const SearchItem::Ptr& o, other) {
+  foreach(const SearchItem::Ptr& o, other) {
     if(!o->isExplicitlyGlobal) {
       next.append(o);
       ++added;
diff --git a/language/duchain/functiondefinition.cpp \
b/language/duchain/functiondefinition.cpp index c30c2e3..d588772 100644
--- a/language/duchain/functiondefinition.cpp
+++ b/language/duchain/functiondefinition.cpp
@@ -49,7 +49,7 @@ Declaration* FunctionDefinition::declaration(const \
TopDUContext* topContext) con  
   KDevVarLengthArray<Declaration*> declarations = \
d_func()->m_declaration.getDeclarations(topContext ? topContext : \
this->topContext());  
-  FOREACH_ARRAY(Declaration* decl, declarations) {
+  foreach(Declaration* decl, declarations) {
     if(!dynamic_cast<FunctionDefinition*>(decl))
       return decl;
   }
@@ -81,7 +81,7 @@ FunctionDefinition* FunctionDefinition::definition(const \
Declaration* decl)  {
   ENSURE_CHAIN_READ_LOCKED
   KDevVarLengthArray<IndexedDeclaration> allDefinitions = \
                DUChain::definitions()->definitions(decl->id());
-  FOREACH_ARRAY(const IndexedDeclaration& decl, allDefinitions) {
+  foreach(const IndexedDeclaration& decl, allDefinitions) {
     if(decl.data()) ///@todo Find better ways of deciding which definition \
to use  return dynamic_cast<FunctionDefinition*>(decl.data());
   }
diff --git a/language/duchain/topducontext.cpp \
b/language/duchain/topducontext.cpp index 98eb207..f5efaf0 100644
--- a/language/duchain/topducontext.cpp
+++ b/language/duchain/topducontext.cpp
@@ -797,7 +797,7 @@ bool TopDUContext::findDeclarationsInternal(const \
SearchItem::PtrList& identifie  ENSURE_CAN_READ
 
 #ifdef DEBUG_SEARCH
-  FOREACH_ARRAY(const SearchItem::Ptr& idTree, identifiers)
+  foreach(const SearchItem::Ptr& idTree, identifiers)
       foreach(const QualifiedIdentifier &id, idTree->toList())
         kDebug() << "searching item" << id.toString();
 #endif
@@ -914,7 +914,7 @@ bool TopDUContext::applyAliases( const \
QualifiedIdentifier& previous, const Sear  return false;
           }else{
             //Create an identifiers where namespace-alias part is replaced \
                with the alias target
-            FOREACH_ARRAY(const SearchItem::Ptr& item, identifier->next)
+            foreach(const SearchItem::Ptr& item, identifier->next)
               if(!applyAliases(importIdentifier, item, accept, position, \
canBeNamespace, &info, recursionDepth+1))  return false;
           }
@@ -928,7 +928,7 @@ bool TopDUContext::applyAliases( const \
                QualifiedIdentifier& previous, const Sear
       if(!accept(id)) //We're at the end of a qualified identifier, accept \
it  return false;
     } else {
-      FOREACH_ARRAY(const SearchItem::Ptr& next, identifier->next)
+      foreach(const SearchItem::Ptr& next, identifier->next)
         if(!applyAliases(id, next, accept, position, canBeNamespace, 0, \
recursionDepth+1))  return false;
     }
@@ -999,7 +999,7 @@ void TopDUContext::applyAliases( const \
SearchItem::PtrList& identifiers, Accepto  {
   QualifiedIdentifier emptyId;
   
-  FOREACH_ARRAY(const SearchItem::Ptr& item, identifiers)
+  foreach(const SearchItem::Ptr& item, identifiers)
     applyAliases(emptyId, item, acceptor, position, canBeNamespace, 0, 0);
 }
 
diff --git a/util/kdevvarlengtharray.h b/util/kdevvarlengtharray.h
index 2b23b45..39cd873 100644
--- a/util/kdevvarlengtharray.h
+++ b/util/kdevvarlengtharray.h
@@ -23,13 +23,6 @@
 
 #include <QtCore/QVarLengthArray>
 
-///Foreach macro that also works with QVarLengthArray or \
                KDevVarLengthArray
-///@warning Unlike the Qt foreach macro, this does not temporarily copy \
                the array, which means its size must not be changed during \
                the iteration.
-#define FOREACH_ARRAY(item, container) \
-        for(int a__ = 0, mustDo__ = 1; a__ < container.size(); ++a__) \
-            if((mustDo__ == 0 || mustDo__ == 1) && (mustDo__ = 2)) \
-                for(item(container[a__]); mustDo__; mustDo__ = 0)
-
 /**
  * Extended QVarLengthArray with additional convenience API.
  */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic