Port cmCommand consumers to cmState.

This commit is contained in:
Stephen Kelly 2015-04-11 12:52:14 +02:00 committed by Brad King
parent 96f8c5f9a3
commit 0aec491328
11 changed files with 18 additions and 37 deletions

View File

@ -198,7 +198,7 @@ int main (int argc, char const* const* argv)
"Read CPack config file: " << cpackConfigFile << std::endl);
cmake cminst;
cminst.RemoveUnscriptableCommands();
cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg;
cmgg.SetCMakeInstance(&cminst);
cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator());

View File

@ -214,7 +214,7 @@ void cmCTestScriptHandler::AddCTestCommand(cmCTestCommand* command)
cmCTestCommand* newCom = command;
newCom->CTest = this->CTest;
newCom->CTestScriptHandler = this;
this->CMake->AddCommand(newCom);
this->CMake->GetState()->AddCommand(newCom);
}
int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
@ -353,7 +353,7 @@ void cmCTestScriptHandler::CreateCMake()
// remove all cmake commands which are not scriptable, since they can't be
// used in ctest scripts
this->CMake->RemoveUnscriptableCommands();
this->CMake->GetState()->RemoveUnscriptableCommands();
// add any ctest specific commands, probably should have common superclass
// for ctest commands to clean this up. If a couple more commands are

View File

@ -1585,25 +1585,25 @@ void cmCTestTestHandler::GetListOfTests()
// Add handler for ADD_TEST
cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
newCom1->TestHandler = this;
cm.AddCommand(newCom1);
cm.GetState()->AddCommand(newCom1);
// Add handler for SUBDIRS
cmCTestSubdirCommand* newCom2 =
new cmCTestSubdirCommand;
newCom2->TestHandler = this;
cm.AddCommand(newCom2);
cm.GetState()->AddCommand(newCom2);
// Add handler for ADD_SUBDIRECTORY
cmCTestAddSubdirectoryCommand* newCom3 =
new cmCTestAddSubdirectoryCommand;
newCom3->TestHandler = this;
cm.AddCommand(newCom3);
cm.GetState()->AddCommand(newCom3);
// Add handler for SET_SOURCE_FILES_PROPERTIES
cmCTestSetTestsPropertiesCommand* newCom4
= new cmCTestSetTestsPropertiesCommand;
newCom4->TestHandler = this;
cm.AddCommand(newCom4);
cm.GetState()->AddCommand(newCom4);
const char* testFilename;
if( cmSystemTools::FileExists("CTestTestfile.cmake") )

View File

@ -164,7 +164,7 @@ int CCONV cmIsOn(void *arg, const char* name)
int CCONV cmCommandExists(void *arg, const char* name)
{
cmMakefile *mf = static_cast<cmMakefile *>(arg);
return static_cast<int>(mf->CommandExists(name));
return static_cast<int>(mf->GetState()->GetCommand(name) ? 1 : 0);
}
void CCONV cmAddDefineFlag(void *arg, const char* definition)

View File

@ -481,8 +481,10 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
// does a command exist
if (this->IsKeyword("COMMAND", *arg) && argP1 != newArgs.end())
{
cmCommand* command =
this->Makefile.GetState()->GetCommand(argP1->c_str());
this->HandlePredicate(
this->Makefile.CommandExists(argP1->c_str()),
command ? true : false,
reducible, arg, newArgs, argP1, argP2);
}
// does a policy exist

View File

@ -193,9 +193,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
}
std::string newName = "_" + this->Args[0];
mf.GetCMakeInstance()->RenameCommand(this->Args[0],
newName);
mf.AddCommand(f);
mf.GetState()->RenameCommand(this->Args[0], newName);
mf.GetState()->AddCommand(f);
// remove the function blocker now that the function is defined
mf.RemoveFunctionBlocker(this, lff);

View File

@ -273,7 +273,7 @@ bool cmLoadCommandCommand
// create a function blocker and set it up
cmLoadedCommand *f = new cmLoadedCommand();
(*initFunction)(&f->info);
this->Makefile->AddCommand(f);
this->Makefile->GetState()->AddCommand(f);
return true;
}
this->SetError("Attempt to load command failed. "

View File

@ -232,9 +232,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
f->Functions = this->Functions;
mf.RecordPolicies(f->Policies);
std::string newName = "_" + this->Args[0];
mf.GetCMakeInstance()->RenameCommand(this->Args[0],
newName);
mf.AddCommand(f);
mf.GetState()->RenameCommand(this->Args[0], newName);
mf.GetState()->AddCommand(f);
// remove the function blocker now that the macro is defined
mf.RemoveFunctionBlocker(this, lff);

View File

@ -244,12 +244,6 @@ void cmMakefile::Print() const
#endif
}
bool cmMakefile::CommandExists(const char* name) const
{
return this->GetCMakeInstance()->CommandExists(name);
}
//----------------------------------------------------------------------------
void cmMakefile::IssueMessage(cmake::MessageType t,
std::string const& text) const
@ -340,7 +334,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
static_cast<void>(stack_manager);
// Lookup the command prototype.
if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name))
if(cmCommand* proto = this->GetState()->GetCommand(name))
{
// Clone the prototype.
cmsys::auto_ptr<cmCommand> pcmd(proto->Clone());
@ -718,11 +712,6 @@ void cmMakefile::EnforceDirectoryLevelRules() const
}
}
void cmMakefile::AddCommand(cmCommand* wg)
{
this->GetCMakeInstance()->AddCommand(wg);
}
// Set the make file
void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
{

View File

@ -746,14 +746,6 @@ public:
bool ExecuteCommand(const cmListFileFunction& lff,
cmExecutionStatus &status);
/** Check if a command exists. */
bool CommandExists(const char* name) const;
/**
* Add a command to this cmake instance
*/
void AddCommand(cmCommand* );
///! Enable support for named language, if nil then all languages are
///enabled.
void EnableLanguage(std::vector<std::string>const& languages, bool optional);

View File

@ -1758,7 +1758,7 @@ void cmake::AddDefaultCommands()
for(std::vector<cmCommand*>::iterator i = commands.begin();
i != commands.end(); ++i)
{
this->AddCommand(*i);
this->State->AddCommand(*i);
}
}