cmMakefile: Trivially constify some methods.

This commit is contained in:
Stephen Kelly 2014-01-22 15:00:29 +01:00
parent 9073318fc4
commit 01d7ceda5d
2 changed files with 51 additions and 51 deletions

View File

@ -179,7 +179,7 @@ unsigned int cmMakefile::GetCacheMinorVersion() const
return this->GetCacheManager()->GetCacheMinorVersion(); return this->GetCacheManager()->GetCacheMinorVersion();
} }
bool cmMakefile::NeedCacheCompatibility(int major, int minor) bool cmMakefile::NeedCacheCompatibility(int major, int minor) const
{ {
return this->GetCacheManager()->NeedCacheCompatibility(major, minor); return this->GetCacheManager()->NeedCacheCompatibility(major, minor);
} }
@ -260,7 +260,7 @@ void cmMakefile
// call print on all the classes in the makefile // call print on all the classes in the makefile
void cmMakefile::Print() void cmMakefile::Print() const
{ {
// print the class lists // print the class lists
std::cout << "classes:\n"; std::cout << "classes:\n";
@ -359,7 +359,7 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
{ {
cmOStringStream msg; cmOStringStream msg;
msg << lff.FilePath << "(" << lff.Line << "): "; msg << lff.FilePath << "(" << lff.Line << "): ";
@ -734,7 +734,7 @@ bool cmMakefile::ReadListFile(const char* filename_in,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefile::EnforceDirectoryLevelRules() void cmMakefile::EnforceDirectoryLevelRules() const
{ {
// Diagnose a violation of CMP0000 if necessary. // Diagnose a violation of CMP0000 if necessary.
if(this->CheckCMP0000) if(this->CheckCMP0000)
@ -2058,7 +2058,8 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name)
return &it->second; return &it->second;
} }
cmSourceFile *cmMakefile::LinearGetSourceFileWithOutput(const char *cname) cmSourceFile*
cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const
{ {
std::string name = cname; std::string name = cname;
std::string out; std::string out;
@ -2094,7 +2095,7 @@ cmSourceFile *cmMakefile::LinearGetSourceFileWithOutput(const char *cname)
return 0; return 0;
} }
cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const
{ {
std::string name = cname; std::string name = cname;
@ -2105,7 +2106,7 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname)
return LinearGetSourceFileWithOutput(cname); return LinearGetSourceFileWithOutput(cname);
} }
// Otherwise we use an efficient lookup map. // Otherwise we use an efficient lookup map.
OutputToSourceMap::iterator o = this->OutputToSource.find(name); OutputToSourceMap::const_iterator o = this->OutputToSource.find(name);
if (o != this->OutputToSource.end()) if (o != this->OutputToSource.end())
{ {
return (*o).second; return (*o).second;
@ -2376,7 +2377,7 @@ const char* cmMakefile::GetSONameFlag(const char* language) const
return GetDefinition(name.c_str()); return GetDefinition(name.c_str());
} }
bool cmMakefile::CanIWriteThisFile(const char* fileName) bool cmMakefile::CanIWriteThisFile(const char* fileName) const
{ {
if ( !this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES") ) if ( !this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES") )
{ {
@ -2518,7 +2519,7 @@ std::vector<std::string> cmMakefile
} }
const char *cmMakefile::ExpandVariablesInString(std::string& source) const char *cmMakefile::ExpandVariablesInString(std::string& source) const
{ {
return this->ExpandVariablesInString(source, false, false); return this->ExpandVariablesInString(source, false, false);
} }
@ -2530,7 +2531,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
const char* filename, const char* filename,
long line, long line,
bool removeEmpty, bool removeEmpty,
bool replaceAt) bool replaceAt) const
{ {
if ( source.empty() || source.find_first_of("$@\\") == source.npos) if ( source.empty() || source.find_first_of("$@\\") == source.npos)
{ {
@ -2865,7 +2866,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
bool cmMakefile::ExpandArguments( bool cmMakefile::ExpandArguments(
std::vector<cmListFileArgument> const& inArgs, std::vector<cmListFileArgument> const& inArgs,
std::vector<std::string>& outArgs) std::vector<std::string>& outArgs) const
{ {
std::vector<cmListFileArgument>::const_iterator i; std::vector<cmListFileArgument>::const_iterator i;
std::string value; std::string value;
@ -3009,7 +3010,7 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmSourceFile* cmMakefile::GetSource(const char* sourceName) cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
{ {
cmSourceFileLocation sfl(this, sourceName); cmSourceFileLocation sfl(this, sourceName);
for(std::vector<cmSourceFile*>::const_iterator for(std::vector<cmSourceFile*>::const_iterator
@ -3057,7 +3058,7 @@ void cmMakefile::EnableLanguage(std::vector<std::string> const & lang,
void cmMakefile::ExpandSourceListArguments( void cmMakefile::ExpandSourceListArguments(
std::vector<std::string> const& arguments, std::vector<std::string> const& arguments,
std::vector<std::string>& newargs, unsigned int /* start */) std::vector<std::string>& newargs, unsigned int /* start */) const
{ {
// now expand the args // now expand the args
unsigned int i; unsigned int i;
@ -3257,7 +3258,7 @@ cmCacheManager *cmMakefile::GetCacheManager() const
return this->GetCMakeInstance()->GetCacheManager(); return this->GetCMakeInstance()->GetCacheManager();
} }
void cmMakefile::DisplayStatus(const char* message, float s) void cmMakefile::DisplayStatus(const char* message, float s) const
{ {
cmake* cm = this->GetLocalGenerator()->GetGlobalGenerator() cmake* cm = this->GetLocalGenerator()->GetGlobalGenerator()
->GetCMakeInstance(); ->GetCMakeInstance();
@ -3270,7 +3271,7 @@ void cmMakefile::DisplayStatus(const char* message, float s)
cm->UpdateProgress(message, s); cm->UpdateProgress(message, s);
} }
std::string cmMakefile::GetModulesFile(const char* filename) std::string cmMakefile::GetModulesFile(const char* filename) const
{ {
std::string result; std::string result;
@ -3939,13 +3940,13 @@ void cmMakefile::AddCMakeDependFilesFromUser()
} }
} }
std::string cmMakefile::GetListFileStack() std::string cmMakefile::GetListFileStack() const
{ {
cmOStringStream tmp; cmOStringStream tmp;
size_t depth = this->ListFileStack.size(); size_t depth = this->ListFileStack.size();
if (depth > 0) if (depth > 0)
{ {
std::deque<cmStdString>::iterator it = this->ListFileStack.end(); std::deque<cmStdString>::const_iterator it = this->ListFileStack.end();
do do
{ {
if (depth != this->ListFileStack.size()) if (depth != this->ListFileStack.size())
@ -4091,7 +4092,7 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmMakefile::FindTargetToUse(const std::string& name, cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
bool excludeAliases) bool excludeAliases) const
{ {
// Look for an imported target. These take priority because they // Look for an imported target. These take priority because they
// are more local in scope and do not have to be globally unique. // are more local in scope and do not have to be globally unique.
@ -4115,7 +4116,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile::IsAlias(const std::string& name) bool cmMakefile::IsAlias(const std::string& name) const
{ {
if (this->AliasTargets.find(name) != this->AliasTargets.end()) if (this->AliasTargets.find(name) != this->AliasTargets.end())
return true; return true;
@ -4124,7 +4125,8 @@ bool cmMakefile::IsAlias(const std::string& name)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) cmGeneratorTarget*
cmMakefile::FindGeneratorTargetToUse(const char* name) const
{ {
if (cmTarget *t = this->FindTargetToUse(name)) if (cmTarget *t = this->FindTargetToUse(name))
{ {
@ -4135,7 +4137,7 @@ cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom) bool isCustom) const
{ {
if(this->IsAlias(name)) if(this->IsAlias(name))
{ {
@ -4226,7 +4228,8 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile::EnforceUniqueDir(const char* srcPath, const char* binPath) bool cmMakefile::EnforceUniqueDir(const char* srcPath,
const char* binPath) const
{ {
// Make sure the binary directory is unique. // Make sure the binary directory is unique.
cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();

View File

@ -76,7 +76,7 @@ public:
bool VariableUsed(const char* ) const; bool VariableUsed(const char* ) const;
/** Return whether compatibility features needed for a version of /** Return whether compatibility features needed for a version of
the cache or lower should be enabled. */ the cache or lower should be enabled. */
bool NeedCacheCompatibility(int major, int minor); bool NeedCacheCompatibility(int major, int minor) const;
/** /**
* Construct an empty makefile. * Construct an empty makefile.
@ -149,7 +149,7 @@ public:
* Help enforce global target name uniqueness. * Help enforce global target name uniqueness.
*/ */
bool EnforceUniqueName(std::string const& name, std::string& msg, bool EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom = false); bool isCustom = false) const;
/** /**
* Perform FinalPass, Library dependency analysis etc before output of the * Perform FinalPass, Library dependency analysis etc before output of the
@ -165,7 +165,7 @@ public:
/** /**
* Print the object state to std::cout. * Print the object state to std::cout.
*/ */
void Print(); void Print() const;
/** Add a custom command to the build. */ /** Add a custom command to the build. */
void AddCustomCommandToTarget(const char* target, void AddCustomCommandToTarget(const char* target,
@ -498,7 +498,7 @@ public:
{ {
this->ComplainFileRegularExpression = regex; this->ComplainFileRegularExpression = regex;
} }
const char* GetComplainRegularExpression() const char* GetComplainRegularExpression() const
{ {
return this->ComplainFileRegularExpression.c_str(); return this->ComplainFileRegularExpression.c_str();
} }
@ -532,9 +532,9 @@ public:
/** Find a target to use in place of the given name. The target /** Find a target to use in place of the given name. The target
returned may be imported or built within the project. */ returned may be imported or built within the project. */
cmTarget* FindTargetToUse(const std::string& name, cmTarget* FindTargetToUse(const std::string& name,
bool excludeAliases = false); bool excludeAliases = false) const;
bool IsAlias(const std::string& name); bool IsAlias(const std::string& name) const;
cmGeneratorTarget* FindGeneratorTargetToUse(const char* name); cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const;
/** /**
* Mark include directories as system directories. * Mark include directories as system directories.
@ -550,12 +550,12 @@ public:
*/ */
void ExpandSourceListArguments(std::vector<std::string> const& argsIn, void ExpandSourceListArguments(std::vector<std::string> const& argsIn,
std::vector<std::string>& argsOut, std::vector<std::string>& argsOut,
unsigned int startArgumentIndex); unsigned int startArgumentIndex) const;
/** Get a cmSourceFile pointer for a given source name, if the name is /** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then a null pointer is returned. * not found, then a null pointer is returned.
*/ */
cmSourceFile* GetSource(const char* sourceName); cmSourceFile* GetSource(const char* sourceName) const;
/** Get a cmSourceFile pointer for a given source name, if the name is /** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then create the source file and return it. generated * not found, then create the source file and return it. generated
@ -568,7 +568,7 @@ public:
/** /**
* Obtain a list of auxiliary source directories. * Obtain a list of auxiliary source directories.
*/ */
std::vector<std::string>& GetAuxSourceDirectories() const std::vector<std::string>& GetAuxSourceDirectories() const
{return this->AuxSourceDirectories;} {return this->AuxSourceDirectories;}
//@{ //@{
@ -613,13 +613,13 @@ public:
/** /**
* Get a list of preprocessor define flags. * Get a list of preprocessor define flags.
*/ */
const char* GetDefineFlags() const char* GetDefineFlags() const
{return this->DefineFlags.c_str();} {return this->DefineFlags.c_str();}
/** /**
* Make sure CMake can write this file * Make sure CMake can write this file
*/ */
bool CanIWriteThisFile(const char* fileName); bool CanIWriteThisFile(const char* fileName) const;
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
/** /**
@ -644,10 +644,7 @@ public:
{ this->ListFiles.push_back(file);} { this->ListFiles.push_back(file);}
void AddCMakeDependFilesFromUser(); void AddCMakeDependFilesFromUser();
/** std::string GetListFileStack() const;
* Get the list file stack as a string
*/
std::string GetListFileStack();
/** /**
* Get the current context backtrace. * Get the current context backtrace.
@ -669,14 +666,14 @@ public:
* entry in the this->Definitions map. Also \@var\@ is * entry in the this->Definitions map. Also \@var\@ is
* expanded to match autoconf style expansions. * expanded to match autoconf style expansions.
*/ */
const char *ExpandVariablesInString(std::string& source); const char *ExpandVariablesInString(std::string& source) const;
const char *ExpandVariablesInString(std::string& source, bool escapeQuotes, const char *ExpandVariablesInString(std::string& source, bool escapeQuotes,
bool noEscapes, bool noEscapes,
bool atOnly = false, bool atOnly = false,
const char* filename = 0, const char* filename = 0,
long line = -1, long line = -1,
bool removeEmpty = false, bool removeEmpty = false,
bool replaceAt = true); bool replaceAt = true) const;
/** /**
* Remove any remaining variables in the string. Anything with ${var} or * Remove any remaining variables in the string. Anything with ${var} or
@ -716,7 +713,7 @@ public:
/** /**
* Print a command's invocation * Print a command's invocation
*/ */
void PrintCommandTrace(const cmListFileFunction& lff); void PrintCommandTrace(const cmListFileFunction& lff) const;
/** /**
* Execute a single CMake command. Returns true if the command * Execute a single CMake command. Returns true if the command
@ -752,14 +749,14 @@ public:
#endif #endif
///! Display progress or status message. ///! Display progress or status message.
void DisplayStatus(const char*, float); void DisplayStatus(const char*, float) const;
/** /**
* Expand the given list file arguments into the full set after * Expand the given list file arguments into the full set after
* variable replacement and list expansion. * variable replacement and list expansion.
*/ */
bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs, bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
std::vector<std::string>& outArgs); std::vector<std::string>& outArgs) const;
/** /**
* Get the instance * Get the instance
*/ */
@ -776,7 +773,7 @@ public:
* Is there a source file that has the provided source file as an output? * Is there a source file that has the provided source file as an output?
* if so then return it * if so then return it
*/ */
cmSourceFile *GetSourceFileWithOutput(const char *outName); cmSourceFile *GetSourceFileWithOutput(const char *outName) const;
/** /**
* Add a macro to the list of macros. The arguments should be name of the * Add a macro to the list of macros. The arguments should be name of the
@ -800,7 +797,7 @@ public:
/** /**
* Return a location of a file in cmake or custom modules directory * Return a location of a file in cmake or custom modules directory
*/ */
std::string GetModulesFile(const char* name); std::string GetModulesFile(const char* name) const;
///! Set/Get a property of this directory ///! Set/Get a property of this directory
void SetProperty(const char *prop, const char *value); void SetProperty(const char *prop, const char *value);
@ -829,7 +826,7 @@ public:
void AddTestGenerator(cmTestGenerator* g) void AddTestGenerator(cmTestGenerator* g)
{ if(g) this->TestGenerators.push_back(g); } { if(g) this->TestGenerators.push_back(g); }
std::vector<cmTestGenerator*>& GetTestGenerators() const std::vector<cmTestGenerator*>& GetTestGenerators() const
{ return this->TestGenerators; } { return this->TestGenerators; }
// Define the properties // Define the properties
@ -869,7 +866,7 @@ public:
return this->CompileDefinitionsEntries; return this->CompileDefinitionsEntries;
} }
bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } bool IsGeneratingBuildSystem() const { return this->GeneratingBuildSystem; }
void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; }
void AddQtUiFileWithOptions(cmSourceFile *sf); void AddQtUiFileWithOptions(cmSourceFile *sf);
@ -950,7 +947,7 @@ private:
bool ParseDefineFlag(std::string const& definition, bool remove); bool ParseDefineFlag(std::string const& definition, bool remove);
bool EnforceUniqueDir(const char* srcPath, const char* binPath); bool EnforceUniqueDir(const char* srcPath, const char* binPath) const;
friend class cmMakeDepend; // make depend needs direct access friend class cmMakeDepend; // make depend needs direct access
// to the Sources array // to the Sources array
@ -973,7 +970,7 @@ private:
cmsys::RegularExpression cmDefineRegex; cmsys::RegularExpression cmDefineRegex;
cmsys::RegularExpression cmDefine01Regex; cmsys::RegularExpression cmDefine01Regex;
cmsys::RegularExpression cmAtVarRegex; mutable cmsys::RegularExpression cmAtVarRegex;
cmPropertyMap Properties; cmPropertyMap Properties;
@ -1028,7 +1025,7 @@ private:
bool CheckCMP0000; bool CheckCMP0000;
// Enforce rules about CMakeLists.txt files. // Enforce rules about CMakeLists.txt files.
void EnforceDirectoryLevelRules(); void EnforceDirectoryLevelRules() const;
bool GeneratingBuildSystem; bool GeneratingBuildSystem;
/** /**
@ -1037,7 +1034,7 @@ private:
* relative file paths. It is used as a fall back by * relative file paths. It is used as a fall back by
* GetSourceFileWithOutput(const char*). * GetSourceFileWithOutput(const char*).
*/ */
cmSourceFile *LinearGetSourceFileWithOutput(const char *cname); cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const;
// A map for fast output to input look up. // A map for fast output to input look up.
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)