diff options
author | Brad King <brad.king@kitware.com> | 2009-01-20 14:36:18 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-01-20 14:36:18 -0500 |
commit | 2c81e5fb5cd592e9450250364e6667082014f0b7 (patch) | |
tree | 8897bcaca936aaedba35f3153f976b315b912329 /Source/cmWhileCommand.cxx | |
parent | a541cac325715cd50f604ede864eba8edfbb2673 (diff) | |
download | cmake-2c81e5fb5cd592e9450250364e6667082014f0b7.tar.gz |
ENH: Refactor function blocker deletion
When a function blocker decides to remove itself we previously removed
it at every return point from the C++ scope in which its removal is
needed. This teaches function blockers to transfer ownership of
themselves from cmMakefile to an automatic variable for deletion on
return. Since this removes blockers before they replay their commands,
we no longer need to avoid running blockers on their own commands.
Diffstat (limited to 'Source/cmWhileCommand.cxx')
-rw-r--r-- | Source/cmWhileCommand.cxx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 21fc286b4d..61d5d85b77 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -21,13 +21,6 @@ bool cmWhileFunctionBlocker:: IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, cmExecutionStatus &inStatus) { - // Prevent recusion and don't let this blocker block its own - // commands. - if (this->Executing) - { - return false; - } - // at end of for each execute recorded commands if (!cmSystemTools::Strucmp(lff.Name.c_str(),"while")) { @@ -39,6 +32,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endwhile for this while loop then execute if (!this->Depth) { + // Remove the function blocker for this scope or bail. + cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(lff)); + if(!fb.get()) { return false; } + std::string errorString; std::vector<std::string> expandedArguments; @@ -46,7 +43,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, bool isTrue = cmIfCommand::IsTrue(expandedArguments,errorString,&mf); - this->Executing = true; while (isTrue) { // Invoke all the functions that were collected in the block. @@ -57,12 +53,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, if (status.GetReturnInvoked()) { inStatus.SetReturnInvoked(true); - mf.RemoveFunctionBlocker(lff); return true; } if (status.GetBreakInvoked()) { - mf.RemoveFunctionBlocker(lff); return true; } } @@ -71,7 +65,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, isTrue = cmIfCommand::IsTrue(expandedArguments,errorString,&mf); } - mf.RemoveFunctionBlocker(lff); return true; } else |