Browse Source

cmMakefile: Make FindSourceGroup const.

Return a pointer instead of a reference.  This allows making the accessor
const with the least impact.
Stephen Kelly 12 years ago
parent
commit
bf1e1bf1d0

+ 2 - 2
Source/cmExtraEclipseCDT4Generator.cxx

@@ -567,9 +567,9 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
             {
             // Add the file to the list of sources.
             std::string source = (*sfIt)->GetFullPath();
-            cmSourceGroup& sourceGroup =
+            cmSourceGroup* sourceGroup =
                        makefile->FindSourceGroup(source.c_str(), sourceGroups);
-            sourceGroup.AssignSource(*sfIt);
+            sourceGroup->AssignSource(*sfIt);
             }
 
           for(std::vector<cmSourceGroup>::iterator sgIt = sourceGroups.begin();

+ 4 - 4
Source/cmGlobalXCodeGenerator.cxx

@@ -2960,10 +2960,10 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
         cmSourceFile* sf = *s;
         // Add the file to the list of sources.
         std::string const& source = sf->GetFullPath();
-        cmSourceGroup& sourceGroup =
+        cmSourceGroup* sourceGroup =
           mf->FindSourceGroup(source.c_str(), sourceGroups);
         cmXCodeObject* pbxgroup =
-          this->CreateOrGetPBXGroup(cmtarget, &sourceGroup);
+          this->CreateOrGetPBXGroup(cmtarget, sourceGroup);
         cmStdString key = GetGroupMapKey(cmtarget, sf);
         this->GroupMap[key] = pbxgroup;
         }
@@ -2975,10 +2975,10 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
             oi = objs.begin(); oi != objs.end(); ++oi)
         {
         std::string const& source = *oi;
-        cmSourceGroup& sourceGroup =
+        cmSourceGroup* sourceGroup =
           mf->FindSourceGroup(source.c_str(), sourceGroups);
         cmXCodeObject* pbxgroup =
-          this->CreateOrGetPBXGroup(cmtarget, &sourceGroup);
+          this->CreateOrGetPBXGroup(cmtarget, sourceGroup);
         cmStdString key = GetGroupMapKeyFromPath(cmtarget, source);
         this->GroupMap[key] = pbxgroup;
         }

+ 2 - 2
Source/cmLocalVisualStudio6Generator.cxx

@@ -324,9 +324,9 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
     {
     // Add the file to the list of sources.
     std::string source = (*i)->GetFullPath();
-    cmSourceGroup& sourceGroup =
+    cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
-    sourceGroup.AssignSource(*i);
+    sourceGroup->AssignSource(*i);
     // while we are at it, if it is a .rule file then for visual studio 6 we
     // must generate it
     if ((*i)->GetPropertyAsBool("__CMAKE_RULE"))

+ 2 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -1392,9 +1392,9 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
       {
       this->ModuleDefinitionFile = (*i)->GetFullPath();
       }
-    cmSourceGroup& sourceGroup =
+    cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
-    sourceGroup.AssignSource(*i);
+    sourceGroup->AssignSource(*i);
     }
 
   // open the project

+ 5 - 5
Source/cmMakefile.cxx

@@ -2775,9 +2775,9 @@ cmMakefile::GetConfigurations(std::vector<std::string>& configs,
  * non-inherited SOURCE_GROUP commands will have precedence over
  * inherited ones.
  */
-cmSourceGroup&
+cmSourceGroup*
 cmMakefile::FindSourceGroup(const char* source,
-                            std::vector<cmSourceGroup> &groups)
+                            std::vector<cmSourceGroup> &groups) const
 {
   // First search for a group that lists the file explicitly.
   for(std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
@@ -2786,7 +2786,7 @@ cmMakefile::FindSourceGroup(const char* source,
     cmSourceGroup *result = sg->MatchChildrenFiles(source);
     if(result)
       {
-      return *result;
+      return result;
       }
     }
 
@@ -2797,13 +2797,13 @@ cmMakefile::FindSourceGroup(const char* source,
     cmSourceGroup *result = sg->MatchChildrenRegex(source);
     if(result)
       {
-      return *result;
+      return result;
       }
     }
 
 
   // Shouldn't get here, but just in case, return the default group.
-  return groups.front();
+  return &groups.front();
 }
 #endif
 

+ 2 - 2
Source/cmMakefile.h

@@ -706,8 +706,8 @@ public:
   /**
    * find what source group this source is in
    */
-  cmSourceGroup& FindSourceGroup(const char* source,
-                                 std::vector<cmSourceGroup> &groups);
+  cmSourceGroup* FindSourceGroup(const char* source,
+                                 std::vector<cmSourceGroup> &groups) const;
 #endif
 
   /**

+ 4 - 4
Source/cmVisualStudio10TargetGenerator.cxx

@@ -708,9 +708,9 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
     {
     cmSourceFile* sf = *s;
     std::string const& source = sf->GetFullPath();
-    cmSourceGroup& sourceGroup =
+    cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
-    groupsUsed.insert(&sourceGroup);
+    groupsUsed.insert(sourceGroup);
     }
 
   this->AddMissingSourceGroups(groupsUsed, sourceGroups);
@@ -901,9 +901,9 @@ WriteGroupSources(const char* name,
     {
     cmSourceFile* sf = s->SourceFile;
     std::string const& source = sf->GetFullPath();
-    cmSourceGroup& sourceGroup =
+    cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
-    const char* filter = sourceGroup.GetFullName();
+    const char* filter = sourceGroup->GetFullName();
     this->WriteString("<", 2);
     std::string path = this->ConvertPath(source, s->RelativePath);
     this->ConvertToWindowsSlash(path);