summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2017-05-10 19:33:06 (GMT)
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2017-05-11 17:49:06 (GMT)
commita44dab461ffe269618f008f16e249d9101c5bd88 (patch)
tree404a5531a43d1636402586275cccff23fea76def /Source
parentc734c8501b5e8865b8a2e92a8834644becb181e4 (diff)
downloadCMake-a44dab461ffe269618f008f16e249d9101c5bd88.zip
CMake-a44dab461ffe269618f008f16e249d9101c5bd88.tar.gz
CMake-a44dab461ffe269618f008f16e249d9101c5bd88.tar.bz2
cmState: introduce method for adding scripted commands
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFunctionCommand.cxx6
-rw-r--r--Source/cmLoadCommandCommand.cxx2
-rw-r--r--Source/cmMacroCommand.cxx5
-rw-r--r--Source/cmState.cxx6
-rw-r--r--Source/cmState.h1
5 files changed, 10 insertions, 10 deletions
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index dccc29f..642b029 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -149,11 +149,7 @@ bool cmFunctionFunctionBlocker::IsFunctionBlocked(
f->Functions = this->Functions;
f->FilePath = this->GetStartingContext().FilePath;
mf.RecordPolicies(f->Policies);
-
- std::string newName = "_" + this->Args[0];
- mf.GetState()->RenameCommand(this->Args[0], newName);
- mf.GetState()->AddCommand(f);
-
+ mf.GetState()->AddScriptedCommand(this->Args[0], f);
// remove the function blocker now that the function is defined
mf.RemoveFunctionBlocker(this, lff);
return true;
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 5cf1853..8bd212c 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -246,7 +246,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// create a function blocker and set it up
cmLoadedCommand* f = new cmLoadedCommand();
(*initFunction)(&f->info);
- this->Makefile->GetState()->AddCommand(f);
+ this->Makefile->GetState()->AddScriptedCommand(args[0], f);
return true;
}
this->SetError("Attempt to load command failed. "
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 507b579..f386a22 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -184,10 +184,7 @@ bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
f->Functions = this->Functions;
f->FilePath = this->GetStartingContext().FilePath;
mf.RecordPolicies(f->Policies);
- std::string newName = "_" + this->Args[0];
- mf.GetState()->RenameCommand(this->Args[0], newName);
- mf.GetState()->AddCommand(f);
-
+ mf.GetState()->AddScriptedCommand(this->Args[0], f);
// remove the function blocker now that the macro is defined
mf.RemoveFunctionBlocker(this, lff);
return true;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 510501b..6de4c9f 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -433,6 +433,12 @@ void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
this->AddBuiltinCommand(name, new cmUnexpectedCommand(name, error));
}
+void cmState::AddScriptedCommand(std::string const& name, cmCommand* command)
+{
+ this->RenameCommand(name, "_" + name);
+ this->AddCommand(command);
+}
+
cmCommand* cmState::GetCommand(std::string const& name) const
{
cmCommand* command = CM_NULLPTR;
diff --git a/Source/cmState.h b/Source/cmState.h
index 603fe5d..895561e 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -126,6 +126,7 @@ public:
void AddDisallowedCommand(std::string const& name, cmCommand* command,
cmPolicies::PolicyID policy, const char* message);
void AddUnexpectedCommand(std::string const& name, const char* error);
+ void AddScriptedCommand(std::string const& name, cmCommand* command);
void RenameCommand(std::string const& oldName, std::string const& newName);
void RemoveUserDefinedCommands();
std::vector<std::string> GetCommandNames() const;