Constify some APIs in generators.

This commit is contained in:
Stephen Kelly 2014-03-12 23:50:42 +01:00
parent dcfcd23ed5
commit c725bb3cbd
8 changed files with 36 additions and 32 deletions

View File

@ -470,7 +470,7 @@ cmGlobalVisualStudio10Generator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::PathTooLong( void cmGlobalVisualStudio10Generator::PathTooLong(
cmTarget* target, cmSourceFile* sf, std::string const& sfRel) cmTarget* target, cmSourceFile const* sf, std::string const& sfRel)
{ {
size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) + size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) +
1 + sfRel.length()); 1 + sfRel.length());

View File

@ -87,7 +87,7 @@ public:
/** Generate an <output>.rule file path for a given command output. */ /** Generate an <output>.rule file path for a given command output. */
virtual std::string GenerateRuleFile(std::string const& output) const; virtual std::string GenerateRuleFile(std::string const& output) const;
void PathTooLong(cmTarget* target, cmSourceFile* sf, void PathTooLong(cmTarget* target, cmSourceFile const* sf,
std::string const& sfRel); std::string const& sfRel);
virtual const char* GetToolsVersion() { return "4.0"; } virtual const char* GetToolsVersion() { return "4.0"; }
@ -112,7 +112,7 @@ private:
LongestSourcePath(): Length(0), Target(0), SourceFile(0) {} LongestSourcePath(): Length(0), Target(0), SourceFile(0) {}
size_t Length; size_t Length;
cmTarget* Target; cmTarget* Target;
cmSourceFile* SourceFile; cmSourceFile const* SourceFile;
std::string SourceRel; std::string SourceRel;
}; };
LongestSourcePath LongestSource; LongestSourcePath LongestSource;

View File

@ -423,7 +423,8 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) void cmMakefileTargetGenerator
::WriteObjectRuleFiles(cmSourceFile const& source)
{ {
// Identify the language of the source file. // Identify the language of the source file.
const std::string& lang = const std::string& lang =
@ -498,7 +499,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmMakefileTargetGenerator cmMakefileTargetGenerator
::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) ::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source)
{ {
const char* srcfmt = source.GetProperty("Fortran_FORMAT"); const char* srcfmt = source.GetProperty("Fortran_FORMAT");
cmLocalGenerator::FortranFormat format = cmLocalGenerator::FortranFormat format =
@ -529,7 +530,7 @@ void
cmMakefileTargetGenerator cmMakefileTargetGenerator
::WriteObjectBuildFile(std::string &obj, ::WriteObjectBuildFile(std::string &obj,
const std::string& lang, const std::string& lang,
cmSourceFile& source, cmSourceFile const& source,
std::vector<std::string>& depends) std::vector<std::string>& depends)
{ {
this->LocalGenerator->AppendRuleDepend(depends, this->LocalGenerator->AppendRuleDepend(depends,
@ -1194,7 +1195,7 @@ cmMakefileTargetGenerator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefileTargetGenerator void cmMakefileTargetGenerator
::WriteObjectDependRules(cmSourceFile& source, ::WriteObjectDependRules(cmSourceFile const& source,
std::vector<std::string>& depends) std::vector<std::string>& depends)
{ {
// Create the list of dependencies known at cmake time. These are // Create the list of dependencies known at cmake time. These are

View File

@ -89,16 +89,16 @@ protected:
friend struct MacOSXContentGeneratorType; friend struct MacOSXContentGeneratorType;
// write the rules for an object // write the rules for an object
void WriteObjectRuleFiles(cmSourceFile& source); void WriteObjectRuleFiles(cmSourceFile const& source);
// write the build rule for an object // write the build rule for an object
void WriteObjectBuildFile(std::string &obj, void WriteObjectBuildFile(std::string &obj,
const std::string& lang, const std::string& lang,
cmSourceFile& source, cmSourceFile const& source,
std::vector<std::string>& depends); std::vector<std::string>& depends);
// write the depend.make file for an object // write the depend.make file for an object
void WriteObjectDependRules(cmSourceFile& source, void WriteObjectDependRules(cmSourceFile const& source,
std::vector<std::string>& depends); std::vector<std::string>& depends);
// write the build rule for a custom command // write the build rule for a custom command
@ -126,7 +126,8 @@ protected:
// Return the a string with -F flags on apple // Return the a string with -F flags on apple
std::string GetFrameworkFlags(std::string const& l); std::string GetFrameworkFlags(std::string const& l);
void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); void AppendFortranFormatFlags(std::string& flags,
cmSourceFile const& source);
// append intertarget dependencies // append intertarget dependencies
void AppendTargetDepends(std::vector<std::string>& depends); void AppendTargetDepends(std::vector<std::string>& depends);

View File

@ -126,7 +126,7 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
// Refactor it. // Refactor it.
std::string std::string
cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
const std::string& language) const std::string& language)
{ {
// TODO: Fortran support. // TODO: Fortran support.
@ -211,7 +211,7 @@ bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang)
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). // void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
std::string std::string
cmNinjaTargetGenerator:: cmNinjaTargetGenerator::
ComputeDefines(cmSourceFile *source, const std::string& language) ComputeDefines(cmSourceFile const* source, const std::string& language)
{ {
std::set<std::string> defines; std::set<std::string> defines;
@ -269,14 +269,14 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
std::string std::string
cmNinjaTargetGenerator cmNinjaTargetGenerator
::GetSourceFilePath(cmSourceFile* source) const ::GetSourceFilePath(cmSourceFile const* source) const
{ {
return ConvertToNinjaPath(source->GetFullPath().c_str()); return ConvertToNinjaPath(source->GetFullPath().c_str());
} }
std::string std::string
cmNinjaTargetGenerator cmNinjaTargetGenerator
::GetObjectFilePath(cmSourceFile* source) const ::GetObjectFilePath(cmSourceFile const* source) const
{ {
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if(!path.empty()) if(!path.empty())
@ -536,7 +536,7 @@ cmNinjaTargetGenerator
void void
cmNinjaTargetGenerator cmNinjaTargetGenerator
::WriteObjectBuildStatement(cmSourceFile* source) ::WriteObjectBuildStatement(cmSourceFile const* source)
{ {
std::string comment; std::string comment;
const std::string language = source->GetLanguage(); const std::string language = source->GetLanguage();

View File

@ -79,10 +79,10 @@ protected:
* @note Generally it is the value of the variable whose name is computed * @note Generally it is the value of the variable whose name is computed
* by LanguageFlagsVarName(). * by LanguageFlagsVarName().
*/ */
std::string ComputeFlagsForObject(cmSourceFile *source, std::string ComputeFlagsForObject(cmSourceFile const* source,
const std::string& language); const std::string& language);
std::string ComputeDefines(cmSourceFile *source, std::string ComputeDefines(cmSourceFile const* source,
const std::string& language); const std::string& language);
std::string ConvertToNinjaPath(const char *path) const { std::string ConvertToNinjaPath(const char *path) const {
@ -96,10 +96,10 @@ protected:
cmNinjaDeps ComputeLinkDeps() const; cmNinjaDeps ComputeLinkDeps() const;
/// @return the source file path for the given @a source. /// @return the source file path for the given @a source.
std::string GetSourceFilePath(cmSourceFile* source) const; std::string GetSourceFilePath(cmSourceFile const* source) const;
/// @return the object file path for the given @a source. /// @return the object file path for the given @a source.
std::string GetObjectFilePath(cmSourceFile* source) const; std::string GetObjectFilePath(cmSourceFile const* source) const;
/// @return the file path where the target named @a name is generated. /// @return the file path where the target named @a name is generated.
std::string GetTargetFilePath(const std::string& name) const; std::string GetTargetFilePath(const std::string& name) const;
@ -110,7 +110,7 @@ protected:
void WriteLanguageRules(const std::string& language); void WriteLanguageRules(const std::string& language);
void WriteCompileRule(const std::string& language); void WriteCompileRule(const std::string& language);
void WriteObjectBuildStatements(); void WriteObjectBuildStatements();
void WriteObjectBuildStatement(cmSourceFile* source); void WriteObjectBuildStatement(cmSourceFile const* source);
void WriteCustomCommandBuildStatement(cmCustomCommand *cc); void WriteCustomCommandBuildStatement(cmCustomCommand *cc);
cmNinjaDeps GetObjects() const cmNinjaDeps GetObjects() const

View File

@ -562,7 +562,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) void cmVisualStudio10TargetGenerator
::WriteCustomCommand(cmSourceFile const* sf)
{ {
if(this->SourcesVisited.insert(sf).second) if(this->SourcesVisited.insert(sf).second)
{ {
@ -585,7 +586,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf)
} }
void void
cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
cmCustomCommand const & cmCustomCommand const &
command) command)
{ {
@ -928,7 +929,7 @@ WriteGroupSources(const char* name,
} }
void cmVisualStudio10TargetGenerator::WriteSource( void cmVisualStudio10TargetGenerator::WriteSource(
const char* tool, cmSourceFile* sf, const char* end) const char* tool, cmSourceFile const* sf, const char* end)
{ {
// Visual Studio tools append relative paths to the current dir, as in: // Visual Studio tools append relative paths to the current dir, as in:
// //
@ -1091,9 +1092,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
} }
bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmSourceFile* source) cmSourceFile const* source)
{ {
cmSourceFile& sf = *source; cmSourceFile const& sf = *source;
std::string objectName; std::string objectName;
if(this->GeneratorTarget->HasExplicitObjectName(&sf)) if(this->GeneratorTarget->HasExplicitObjectName(&sf))

View File

@ -45,7 +45,7 @@ public:
private: private:
struct ToolSource struct ToolSource
{ {
cmSourceFile* SourceFile; cmSourceFile const* SourceFile;
bool RelativePath; bool RelativePath;
}; };
struct ToolSources: public std::vector<ToolSource> {}; struct ToolSources: public std::vector<ToolSource> {};
@ -55,7 +55,8 @@ private:
void WriteString(const char* line, int indentLevel); void WriteString(const char* line, int indentLevel);
void WriteProjectConfigurations(); void WriteProjectConfigurations();
void WriteProjectConfigurationValues(); void WriteProjectConfigurationValues();
void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0); 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&);
void WriteAllSources(); void WriteAllSources();
void WriteDotNetReferences(); void WriteDotNetReferences();
@ -77,13 +78,13 @@ private:
std::vector<std::string> const & includes); std::vector<std::string> const & includes);
void OutputIncludes(std::vector<std::string> const & includes); void OutputIncludes(std::vector<std::string> const & includes);
void OutputLinkIncremental(std::string const& configName); void OutputLinkIncremental(std::string const& configName);
void WriteCustomRule(cmSourceFile* source, void WriteCustomRule(cmSourceFile const* source,
cmCustomCommand const & command); cmCustomCommand const & command);
void WriteCustomCommands(); void WriteCustomCommands();
void WriteCustomCommand(cmSourceFile* sf); void WriteCustomCommand(cmSourceFile const* sf);
void WriteGroups(); void WriteGroups();
void WriteProjectReferences(); void WriteProjectReferences();
bool OutputSourceSpecificFlags(cmSourceFile* source); bool OutputSourceSpecificFlags(cmSourceFile const* source);
void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
void WriteLibOptions(std::string const& config); void WriteLibOptions(std::string const& config);
void WriteEvents(std::string const& configName); void WriteEvents(std::string const& configName);
@ -111,7 +112,7 @@ private:
cmGlobalVisualStudio10Generator* GlobalGenerator; cmGlobalVisualStudio10Generator* GlobalGenerator;
cmGeneratedFileStream* BuildFileStream; cmGeneratedFileStream* BuildFileStream;
cmLocalVisualStudio7Generator* LocalGenerator; cmLocalVisualStudio7Generator* LocalGenerator;
std::set<cmSourceFile*> SourcesVisited; std::set<cmSourceFile const*> SourcesVisited;
typedef std::map<std::string, ToolSources> ToolSourceMap; typedef std::map<std::string, ToolSources> ToolSourceMap;
ToolSourceMap Tools; ToolSourceMap Tools;