cmMakefile: Create a unified raii for macro scopes.
This commit is contained in:
parent
d5dc4169ac
commit
ca140c2e89
|
@ -96,12 +96,8 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce matching logical blocks inside the macro.
|
cmMakefile::MacroPushPop macroScope(this->Makefile,
|
||||||
cmMakefile::LexicalPushPop lexScope(this->Makefile);
|
this->Policies);
|
||||||
|
|
||||||
// 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
|
// set the value of argc
|
||||||
std::ostringstream argcDefStream;
|
std::ostringstream argcDefStream;
|
||||||
|
@ -191,8 +187,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
{
|
{
|
||||||
// The error message should have already included the call stack
|
// The error message should have already included the call stack
|
||||||
// so we do not need to report an error here.
|
// so we do not need to report an error here.
|
||||||
lexScope.Quiet();
|
macroScope.Quiet();
|
||||||
polScope.Quiet();
|
|
||||||
inStatus.SetNestedError(true);
|
inStatus.SetNestedError(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1582,6 +1582,22 @@ void cmMakefile::PopFunctionScope(bool reportError)
|
||||||
this->PopScope();
|
this->PopScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PushMacroScope(const cmPolicies::PolicyMap& pm)
|
||||||
|
{
|
||||||
|
this->PushFunctionBlockerBarrier();
|
||||||
|
|
||||||
|
this->PushPolicy(true, pm);
|
||||||
|
this->PushPolicyBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PopMacroScope(bool reportError)
|
||||||
|
{
|
||||||
|
this->PopPolicyBarrier(reportError);
|
||||||
|
this->PopPolicy();
|
||||||
|
|
||||||
|
this->PopFunctionBlockerBarrier(reportError);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
class cmMakefileCurrent
|
class cmMakefileCurrent
|
||||||
{
|
{
|
||||||
|
@ -5451,3 +5467,16 @@ cmMakefile::FunctionPushPop::~FunctionPushPop()
|
||||||
{
|
{
|
||||||
this->Makefile->PopFunctionScope(this->ReportError);
|
this->Makefile->PopFunctionScope(this->ReportError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf,
|
||||||
|
const cmPolicies::PolicyMap& pm)
|
||||||
|
: Makefile(mf), ReportError(true)
|
||||||
|
{
|
||||||
|
this->Makefile->PushMacroScope(pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmMakefile::MacroPushPop::~MacroPushPop()
|
||||||
|
{
|
||||||
|
this->Makefile->PopMacroScope(this->ReportError);
|
||||||
|
}
|
||||||
|
|
|
@ -759,8 +759,23 @@ public:
|
||||||
bool ReportError;
|
bool ReportError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MacroPushPop
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MacroPushPop(cmMakefile* mf,
|
||||||
|
cmPolicies::PolicyMap const& pm);
|
||||||
|
~MacroPushPop();
|
||||||
|
|
||||||
|
void Quiet() { this->ReportError = false; }
|
||||||
|
private:
|
||||||
|
cmMakefile* Makefile;
|
||||||
|
bool ReportError;
|
||||||
|
};
|
||||||
|
|
||||||
void PushFunctionScope(cmPolicies::PolicyMap const& pm);
|
void PushFunctionScope(cmPolicies::PolicyMap const& pm);
|
||||||
void PopFunctionScope(bool reportError);
|
void PopFunctionScope(bool reportError);
|
||||||
|
void PushMacroScope(cmPolicies::PolicyMap const& pm);
|
||||||
|
void PopMacroScope(bool reportError);
|
||||||
void PushScope();
|
void PushScope();
|
||||||
void PopScope();
|
void PopScope();
|
||||||
void RaiseScope(const std::string& var, const char *value);
|
void RaiseScope(const std::string& var, const char *value);
|
||||||
|
|
Loading…
Reference in New Issue