summaryrefslogtreecommitdiff
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-01-20 14:36:18 -0500
committerBrad King <brad.king@kitware.com>2009-01-20 14:36:18 -0500
commit2c81e5fb5cd592e9450250364e6667082014f0b7 (patch)
tree8897bcaca936aaedba35f3153f976b315b912329 /Source/cmIfCommand.cxx
parenta541cac325715cd50f604ede864eba8edfbb2673 (diff)
downloadcmake-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/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx16
1 files changed, 4 insertions, 12 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index cbba2d3415..1a8c810587 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -27,13 +27,6 @@ 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;
- }
-
// we start by recording all the functions
if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
{
@@ -45,8 +38,11 @@ IsFunctionBlocked(const cmListFileFunction& lff,
// if this is the endif for this if statement, then start executing
if (!this->ScopeDepth)
{
+ // Remove the function blocker for this scope or bail.
+ cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(lff));
+ if(!fb.get()) { return false; }
+
// execute the functions for the true parts of the if statement
- this->Executing = true;
cmExecutionStatus status;
int scopeDepth = 0;
for(unsigned int c = 0; c < this->Functions.size(); ++c)
@@ -104,7 +100,6 @@ IsFunctionBlocked(const cmListFileFunction& lff,
err += ").";
mf.IssueMessage(cmake::FATAL_ERROR, err);
cmSystemTools::SetFatalErrorOccured();
- mf.RemoveFunctionBlocker(lff);
return true;
}
@@ -124,18 +119,15 @@ IsFunctionBlocked(const cmListFileFunction& lff,
if (status.GetReturnInvoked())
{
inStatus.SetReturnInvoked(true);
- mf.RemoveFunctionBlocker(lff);
return true;
}
if (status.GetBreakInvoked())
{
inStatus.SetBreakInvoked(true);
- mf.RemoveFunctionBlocker(lff);
return true;
}
}
}
- mf.RemoveFunctionBlocker(lff);
return true;
}
}