diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-04-11 10:30:26 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-04-13 19:12:14 (GMT) |
commit | 96f8c5f9a3bd60f553af054b43e06ce4864269e0 (patch) | |
tree | 638ea6d9f11c263287f4bd698f476edd12f2fde1 /Source/cmake.cxx | |
parent | 97e53ebb3cd728e6091f93cb7d4eac91ae417bdb (diff) | |
download | CMake-96f8c5f9a3bd60f553af054b43e06ce4864269e0.zip CMake-96f8c5f9a3bd60f553af054b43e06ce4864269e0.tar.gz CMake-96f8c5f9a3bd60f553af054b43e06ce4864269e0.tar.bz2 |
cmState: Move cmCommand-related methods from cmake class.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 88 |
1 files changed, 8 insertions, 80 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6518207..89d5fea 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -179,7 +179,6 @@ cmake::~cmake() delete this->GlobalGenerator; this->GlobalGenerator = 0; } - cmDeleteAll(this->Commands); cmDeleteAll(this->Generators); #ifdef CMAKE_BUILD_WITH_CMAKE delete this->VariableWatch; @@ -197,94 +196,33 @@ void cmake::InitializeProperties() void cmake::CleanupCommandsAndMacros() { this->InitializeProperties(); - for(RegisteredCommandsMap::iterator j = this->Commands.begin(); - j != this->Commands.end(); ) - { - if (j->second->IsA("cmMacroHelperCommand") || - j->second->IsA("cmFunctionHelperCommand")) - { - delete j->second; - this->Commands.erase(j++); - } - else - { - ++j; - } - } + this->State->RemoveUserDefinedCommands(); } bool cmake::CommandExists(const std::string& name) const { - return this->GetCommand(name) ? true : false; + return this->State->GetCommand(name) ? true : false; } cmCommand *cmake::GetCommand(const std::string& name) const { - cmCommand* command = 0; - std::string sName = cmSystemTools::LowerCase(name); - RegisteredCommandsMap::const_iterator pos = this->Commands.find(sName); - if (pos != this->Commands.end()) - { - command = (*pos).second; - } - return command; + return this->State->GetCommand(name); } void cmake::RenameCommand(const std::string& oldName, const std::string& newName) { - // if the command already exists, free the old one - std::string sOldName = cmSystemTools::LowerCase(oldName); - RegisteredCommandsMap::iterator pos = this->Commands.find(sOldName); - if ( pos == this->Commands.end() ) - { - return; - } - std::string sNewName = cmSystemTools::LowerCase(newName); - cmCommand* cmd = pos->second; - - pos = this->Commands.find(sNewName); - if (pos != this->Commands.end()) - { - delete pos->second; - this->Commands.erase(pos); - } - this->Commands.insert(std::make_pair(sNewName, cmd)); - pos = this->Commands.find(sOldName); - this->Commands.erase(pos); + this->State->RenameCommand(oldName, newName); } void cmake::AddCommand(cmCommand* command) { - std::string name = cmSystemTools::LowerCase(command->GetName()); - // if the command already exists, free the old one - RegisteredCommandsMap::iterator pos = this->Commands.find(name); - if (pos != this->Commands.end()) - { - delete pos->second; - this->Commands.erase(pos); - } - this->Commands.insert(std::make_pair(name, command)); + this->State->AddCommand(command); } - void cmake::RemoveUnscriptableCommands() { - std::vector<std::string> unscriptableCommands; - for (cmake::RegisteredCommandsMap::iterator - pos = this->Commands.begin(); - pos != this->Commands.end(); ) - { - if (!pos->second->IsScriptable()) - { - delete pos->second; - this->Commands.erase(pos++); - } - else - { - ++pos; - } - } + this->State->RemoveUnscriptableCommands(); } // Parse the args @@ -2301,18 +2239,8 @@ const char *cmake::GetProperty(const std::string& prop, } else if ( prop == "COMMANDS" ) { - cmake::RegisteredCommandsMap::iterator cmds - = this->Commands.begin(); - for (unsigned int cc=0 ; cmds != this->Commands.end(); ++ cmds ) - { - if ( cc > 0 ) - { - output += ";"; - } - output += cmds->first.c_str(); - cc++; - } - this->SetProperty("COMMANDS",output.c_str()); + std::vector<std::string> commands = this->State->GetCommandNames(); + this->SetProperty("COMMANDS", cmJoin(commands, ";").c_str()); } else if ( prop == "IN_TRY_COMPILE" ) { |