cmGeneratorTarget: Constify cmSourceFile* in containers.

Some of them will be used with other APIs which require value_type
to be cmSourceFile const*.
This commit is contained in:
Stephen Kelly 2014-03-12 23:06:05 +01:00
parent c725bb3cbd
commit 9ad804ac7b
13 changed files with 84 additions and 75 deletions

View File

@ -97,7 +97,7 @@ struct DoAccept
template<>
struct DoAccept<true>
{
static void Do(std::vector<cmSourceFile*>& files, cmSourceFile* f)
static void Do(std::vector<cmSourceFile const*>& files, cmSourceFile* f)
{
files.push_back(f);
}
@ -120,7 +120,7 @@ struct DoAccept<true>
};
//----------------------------------------------------------------------------
template<typename Tag, typename DataType = std::vector<cmSourceFile*> >
template<typename Tag, typename DataType = std::vector<cmSourceFile const*> >
struct TagVisitor
{
DataType& Data;
@ -306,7 +306,8 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
//----------------------------------------------------------------------------
void
cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &data) const
cmGeneratorTarget
::GetObjectSources(std::vector<cmSourceFile const*> &data) const
{
IMPLEMENT_VISIT(ObjectSources);
if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY)
@ -342,34 +343,39 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& data) const
void cmGeneratorTarget
::GetIDLSources(std::vector<cmSourceFile const*>& data) const
{
IMPLEMENT_VISIT(IDLSources);
}
//----------------------------------------------------------------------------
void
cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& data) const
cmGeneratorTarget
::GetHeaderSources(std::vector<cmSourceFile const*>& data) const
{
IMPLEMENT_VISIT(HeaderSources);
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& data) const
void cmGeneratorTarget
::GetExtraSources(std::vector<cmSourceFile const*>& data) const
{
IMPLEMENT_VISIT(ExtraSources);
}
//----------------------------------------------------------------------------
void
cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& data) const
cmGeneratorTarget
::GetCustomCommands(std::vector<cmSourceFile const*>& data) const
{
IMPLEMENT_VISIT(CustomCommands);
}
//----------------------------------------------------------------------------
void
cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& data) const
cmGeneratorTarget
::GetExternalObjects(std::vector<cmSourceFile const*>& data) const
{
IMPLEMENT_VISIT(ExternalObjects);
}
@ -384,7 +390,8 @@ cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const
void cmGeneratorTarget
::GetResxSources(std::vector<cmSourceFile const*>& srcs) const
{
ResxData data;
IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
@ -570,7 +577,7 @@ cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const
cmTarget* objLib = *ti;
cmGeneratorTarget* ogt =
this->GlobalGenerator->GetGeneratorTarget(objLib);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = ogt->ObjectSources.begin();
si != ogt->ObjectSources.end(); ++si)
{

View File

@ -32,19 +32,19 @@ public:
bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
void GetObjectSources(std::vector<cmSourceFile*> &) const;
void GetObjectSources(std::vector<cmSourceFile const*> &) const;
const std::string& GetObjectName(cmSourceFile const* file);
void AddObject(cmSourceFile const* sf, std::string const&name);
bool HasExplicitObjectName(cmSourceFile const* file) const;
void AddExplicitObjectName(cmSourceFile const* sf);
void GetResxSources(std::vector<cmSourceFile*>&) const;
void GetIDLSources(std::vector<cmSourceFile*>&) const;
void GetExternalObjects(std::vector<cmSourceFile*>&) const;
void GetHeaderSources(std::vector<cmSourceFile*>&) const;
void GetExtraSources(std::vector<cmSourceFile*>&) const;
void GetCustomCommands(std::vector<cmSourceFile*>&) const;
void GetResxSources(std::vector<cmSourceFile const*>&) const;
void GetIDLSources(std::vector<cmSourceFile const*>&) const;
void GetExternalObjects(std::vector<cmSourceFile const*>&) const;
void GetHeaderSources(std::vector<cmSourceFile const*>&) const;
void GetExtraSources(std::vector<cmSourceFile const*>&) const;
void GetCustomCommands(std::vector<cmSourceFile const*>&) const;
void GetExpectedResxHeaders(std::set<std::string>&) const;
cmTarget* Target;
@ -117,7 +117,7 @@ public:
struct ResxData {
mutable std::set<std::string> ExpectedResxHeaders;
mutable std::vector<cmSourceFile*> ResxSources;
mutable std::vector<cmSourceFile const*> ResxSources;
};
private:
friend class cmTargetTraceDependencies;
@ -127,7 +127,7 @@ private:
std::map<cmSourceFile const*, std::string> Objects;
std::set<cmSourceFile const*> ExplicitObjectName;
mutable std::vector<cmSourceFile*> ObjectSources;
mutable std::vector<cmSourceFile const*> ObjectSources;
std::vector<cmTarget*> ObjectLibraries;
mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;

View File

@ -634,14 +634,14 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const
// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl.
void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
{
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources);
// Compute the name of each object file.
for(std::vector<cmSourceFile*>::iterator
for(std::vector<cmSourceFile const*>::iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
cmSourceFile* sf = *si;
cmSourceFile const* sf = *si;
std::string objectName = gt->LocalGenerator
->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
gt->AddObject(sf, objectName);

View File

@ -108,14 +108,14 @@ void
cmGlobalUnixMakefileGenerator3
::ComputeTargetObjects(cmGeneratorTarget* gt) const
{
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources);
// Compute the name of each object file.
for(std::vector<cmSourceFile*>::iterator
for(std::vector<cmSourceFile const*>::iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
cmSourceFile* sf = *si;
cmSourceFile const* sf = *si;
std::string objectName = gt->LocalGenerator
->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
gt->AddObject(sf, objectName);

View File

@ -129,13 +129,13 @@ cmGlobalVisualStudioGenerator
// Count the number of object files with each name. Note that
// windows file names are not case sensitive.
std::map<std::string, int> counts;
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
cmSourceFile* sf = *si;
cmSourceFile const* sf = *si;
std::string objectNameLower = cmSystemTools::LowerCase(
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
objectNameLower += ".obj";
@ -144,11 +144,11 @@ cmGlobalVisualStudioGenerator
// For all source files producing duplicate names we need unique
// object name computation.
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
cmSourceFile* sf = *si;
cmSourceFile const* sf = *si;
std::string objectName =
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
objectName += ".obj";

View File

@ -3944,13 +3944,13 @@ cmGlobalXCodeGenerator
// to avoid exact duplicate file names. Note that Mac file names are not
// typically case sensitive, hence the LowerCase.
std::map<std::string, int> counts;
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
cmSourceFile* sf = *si;
cmSourceFile const* sf = *si;
std::string objectName =
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
objectName += ".o";

View File

@ -185,7 +185,7 @@ GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
{
continue;
}
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources);
// Compute full path to object file directory for this target.
std::string dir_max;
@ -194,11 +194,11 @@ GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
dir_max += this->GetTargetDirectory(*gt->Target);
dir_max += "/";
// Compute the name of each object file.
for(std::vector<cmSourceFile*>::iterator
for(std::vector<cmSourceFile const*>::iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
cmSourceFile* sf = *si;
cmSourceFile const* sf = *si;
bool hasSourceExtension = true;
std::string objectName = this->GetObjectFileNameWithoutTarget(*sf,
dir_max,

View File

@ -153,9 +153,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
// First generate the object rule files. Save a list of all object
// files for this target.
std::vector<cmSourceFile*> customCommands;
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{
@ -176,27 +176,27 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
}
}
}
std::vector<cmSourceFile*> headerSources;
std::vector<cmSourceFile const*> headerSources;
this->GeneratorTarget->GetHeaderSources(headerSources);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources,
this->MacOSXContentGenerator);
std::vector<cmSourceFile*> extraSources;
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources,
this->MacOSXContentGenerator);
std::vector<cmSourceFile*> externalObjects;
std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
this->ExternalObjects.push_back((*si)->GetFullPath());
}
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si)
{
// Generate this object file's rule file.

View File

@ -480,36 +480,36 @@ cmNinjaTargetGenerator
<< this->GetTargetName()
<< "\n\n";
std::vector<cmSourceFile*> customCommands;
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{
cmCustomCommand const* cc = (*si)->GetCustomCommand();
this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
}
std::vector<cmSourceFile*> headerSources;
std::vector<cmSourceFile const*> headerSources;
this->GeneratorTarget->GetHeaderSources(headerSources);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources,
this->MacOSXContentGenerator);
std::vector<cmSourceFile*> extraSources;
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources,
this->MacOSXContentGenerator);
std::vector<cmSourceFile*> externalObjects;
std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
this->Objects.push_back(this->GetSourceFilePath(*si));
}
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si)
{
this->WriteObjectBuildStatement(*si);
@ -570,9 +570,9 @@ cmNinjaTargetGenerator
}
// Add order-only dependencies on custom command outputs.
std::vector<cmSourceFile*> customCommands;
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{

View File

@ -190,13 +190,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
//----------------------------------------------------------------------------
void
cmOSXBundleGenerator::
GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
MacOSXContentGeneratorType* generator)
GenerateMacOSXContentStatements(
std::vector<cmSourceFile const*> const& sources,
MacOSXContentGeneratorType* generator)
{
if (this->MustSkip())
return;
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = sources.begin(); si != sources.end(); ++si)
{
cmGeneratorTarget::SourceFileFlags tsFlags =

View File

@ -49,7 +49,7 @@ public:
};
void GenerateMacOSXContentStatements(
std::vector<cmSourceFile*> const& sources,
std::vector<cmSourceFile const*> const& sources,
MacOSXContentGeneratorType* generator);
std::string InitMacOSXContentDirectory(const char* pkgloc);

View File

@ -377,12 +377,12 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
{
std::vector<cmSourceFile*> resxObjs;
std::vector<cmSourceFile const*> resxObjs;
this->GeneratorTarget->GetResxSources(resxObjs);
if(!resxObjs.empty())
{
this->WriteString("<ItemGroup>\n", 1);
for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin();
for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
oi != resxObjs.end(); ++oi)
{
std::string obj = (*oi)->GetFullPath();
@ -551,9 +551,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
void cmVisualStudio10TargetGenerator::WriteCustomCommands()
{
this->SourcesVisited.clear();
std::vector<cmSourceFile*> customCommands;
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{
@ -746,12 +746,12 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups);
}
std::vector<cmSourceFile*> resxObjs;
std::vector<cmSourceFile const*> resxObjs;
this->GeneratorTarget->GetResxSources(resxObjs);
if(!resxObjs.empty())
{
this->WriteString("<ItemGroup>\n", 1);
for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin();
for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
oi != resxObjs.end(); ++oi)
{
std::string obj = (*oi)->GetFullPath();
@ -902,7 +902,7 @@ WriteGroupSources(const char* name,
for(ToolSources::const_iterator s = sources.begin();
s != sources.end(); ++s)
{
cmSourceFile* sf = s->SourceFile;
cmSourceFile const* sf = s->SourceFile;
std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
@ -985,9 +985,9 @@ void cmVisualStudio10TargetGenerator::WriteSource(
}
void cmVisualStudio10TargetGenerator::WriteSources(
const char* tool, std::vector<cmSourceFile*> const& sources)
const char* tool, std::vector<cmSourceFile const*> const& sources)
{
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = sources.begin(); si != sources.end(); ++si)
{
this->WriteSource(tool, *si);
@ -1002,16 +1002,16 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
}
this->WriteString("<ItemGroup>\n", 1);
std::vector<cmSourceFile*> headerSources;
std::vector<cmSourceFile const*> headerSources;
this->GeneratorTarget->GetHeaderSources(headerSources);
this->WriteSources("ClInclude", headerSources);
std::vector<cmSourceFile*> idlSources;
std::vector<cmSourceFile const*> idlSources;
this->GeneratorTarget->GetIDLSources(idlSources);
this->WriteSources("Midl", idlSources);
std::vector<cmSourceFile*> objectSources;
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources);
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
@ -1050,7 +1050,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
}
}
std::vector<cmSourceFile*> externalObjects;
std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects);
if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
{
@ -1062,7 +1062,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
{
// If an object file is generated in this target, then vs10 will use
// it in the build, and we have to list it as None instead of Object.
for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
@ -1072,7 +1072,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
}
}
std::vector<cmSourceFile*> extraSources;
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources);
this->WriteSources("None", extraSources);

View File

@ -57,7 +57,8 @@ private:
void WriteProjectConfigurationValues();
void WriteSource(const char* tool, cmSourceFile const* sf,
const char* end = 0);
void WriteSources(const char* tool, std::vector<cmSourceFile*> const&);
void WriteSources(const char* tool,
std::vector<cmSourceFile const*> const&);
void WriteAllSources();
void WriteDotNetReferences();
void WriteEmbeddedResourceGroup();