summaryrefslogtreecommitdiffstats
path: root/Source/cmMacroCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-01-22 18:16:47 (GMT)
committerBrad King <brad.king@kitware.com>2009-01-22 18:16:47 (GMT)
commit3028ca756c8621b3cc37032987eb01fbe61da248 (patch)
tree1a32991d7d25cefaa5b214759d84ab2c20a3c0b5 /Source/cmMacroCommand.cxx
parent18eadebc4c0b43443861f40ca243e18dbabb2324 (diff)
downloadCMake-3028ca756c8621b3cc37032987eb01fbe61da248.zip
CMake-3028ca756c8621b3cc37032987eb01fbe61da248.tar.gz
CMake-3028ca756c8621b3cc37032987eb01fbe61da248.tar.bz2
ENH: Better policies for functions and macros
This teaches functions and macros to use policies recorded at creation time when they are invoked. It restores the policies as a weak policy stack entry so that any policies set by a function escape to its caller as before.
Diffstat (limited to 'Source/cmMacroCommand.cxx')
-rw-r--r--Source/cmMacroCommand.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 9cc2653..c736e09 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -36,6 +36,7 @@ public:
// we must copy when we clone
newC->Args = this->Args;
newC->Functions = this->Functions;
+ newC->Policies = this->Policies;
return newC;
}
@@ -81,6 +82,7 @@ public:
std::vector<std::string> Args;
std::vector<cmListFileFunction> Functions;
+ cmPolicies::PolicyMap Policies;
};
@@ -110,6 +112,10 @@ bool cmMacroHelperCommand::InvokeInitialPass
// Enforce matching logical blocks inside the macro.
cmMakefile::LexicalPushPop lexScope(this->Makefile);
+ // Push a weak policy scope which restores the policies recorded at
+ // macro creation.
+ cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
+
// set the value of argc
cmOStringStream argcDefStream;
argcDefStream << expandedArgs.size();
@@ -219,6 +225,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
// The error message should have already included the call stack
// so we do not need to report an error here.
lexScope.Quiet();
+ polScope.Quiet();
inStatus.SetNestedError(true);
return false;
}
@@ -264,6 +271,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmMacroHelperCommand *f = new cmMacroHelperCommand();
f->Args = this->Args;
f->Functions = this->Functions;
+ mf.RecordPolicies(f->Policies);
std::string newName = "_" + this->Args[0];
mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(),
newName.c_str());