diff options
author | Brad King <brad.king@kitware.com> | 2009-01-20 19:36:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-01-20 19:36:18 (GMT) |
commit | 2c81e5fb5cd592e9450250364e6667082014f0b7 (patch) | |
tree | 8897bcaca936aaedba35f3153f976b315b912329 /Source/cmForEachCommand.cxx | |
parent | a541cac325715cd50f604ede864eba8edfbb2673 (diff) | |
download | CMake-2c81e5fb5cd592e9450250364e6667082014f0b7.zip CMake-2c81e5fb5cd592e9450250364e6667082014f0b7.tar.gz CMake-2c81e5fb5cd592e9450250364e6667082014f0b7.tar.bz2 |
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/cmForEachCommand.cxx')
-rw-r--r-- | Source/cmForEachCommand.cxx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index b13a849..193f0a0 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -20,13 +20,6 @@ bool cmForEachFunctionBlocker:: 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; - } - if (!cmSystemTools::Strucmp(lff.Name.c_str(),"foreach")) { // record the number of nested foreach commands @@ -37,6 +30,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endofreach for this statement 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; } + // at end of for each execute recorded commands // store the old value std::string oldDef; @@ -44,7 +41,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { oldDef = mf.GetDefinition(this->Args[0].c_str()); } - this->Executing = true; std::vector<std::string>::const_iterator j = this->Args.begin(); ++j; @@ -65,21 +61,18 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, inStatus.SetReturnInvoked(true); // restore the variable to its prior value mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); - mf.RemoveFunctionBlocker(lff); return true; } if (status.GetBreakInvoked()) { // restore the variable to its prior value mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); - mf.RemoveFunctionBlocker(lff); return true; } } } // restore the variable to its prior value mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); - mf.RemoveFunctionBlocker(lff); return true; } else |