cmMakefile: Create a unified raii for function scopes.
This commit is contained in:
parent
91cd014d64
commit
d5dc4169ac
|
@ -73,7 +73,6 @@ public:
|
||||||
cmPolicies::PolicyMap Policies;
|
cmPolicies::PolicyMap Policies;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool cmFunctionHelperCommand::InvokeInitialPass
|
bool cmFunctionHelperCommand::InvokeInitialPass
|
||||||
(const std::vector<cmListFileArgument>& args,
|
(const std::vector<cmListFileArgument>& args,
|
||||||
cmExecutionStatus & inStatus)
|
cmExecutionStatus & inStatus)
|
||||||
|
@ -93,14 +92,8 @@ bool cmFunctionHelperCommand::InvokeInitialPass
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we push a scope on the makefile
|
cmMakefile::FunctionPushPop functionScope(this->Makefile,
|
||||||
cmMakefile::ScopePushPop varScope(this->Makefile);
|
this->Policies);
|
||||||
cmMakefile::LexicalPushPop lexScope(this->Makefile);
|
|
||||||
static_cast<void>(varScope);
|
|
||||||
|
|
||||||
// Push a weak policy scope which restores the policies recorded at
|
|
||||||
// function creation.
|
|
||||||
cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
|
|
||||||
|
|
||||||
// set the value of argc
|
// set the value of argc
|
||||||
std::ostringstream strStream;
|
std::ostringstream strStream;
|
||||||
|
@ -145,8 +138,7 @@ bool cmFunctionHelperCommand::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();
|
functionScope.Quiet();
|
||||||
polScope.Quiet();
|
|
||||||
inStatus.SetNestedError(true);
|
inStatus.SetNestedError(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1562,6 +1562,26 @@ void cmMakefile::InitializeFromParent()
|
||||||
this->ImportedTargets = parent->ImportedTargets;
|
this->ImportedTargets = parent->ImportedTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PushFunctionScope(const cmPolicies::PolicyMap& pm)
|
||||||
|
{
|
||||||
|
this->PushScope();
|
||||||
|
|
||||||
|
this->PushFunctionBlockerBarrier();
|
||||||
|
|
||||||
|
this->PushPolicy(true, pm);
|
||||||
|
this->PushPolicyBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmMakefile::PopFunctionScope(bool reportError)
|
||||||
|
{
|
||||||
|
this->PopPolicyBarrier(reportError);
|
||||||
|
this->PopPolicy();
|
||||||
|
|
||||||
|
this->PopFunctionBlockerBarrier(reportError);
|
||||||
|
|
||||||
|
this->PopScope();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
class cmMakefileCurrent
|
class cmMakefileCurrent
|
||||||
{
|
{
|
||||||
|
@ -5418,3 +5438,16 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf,
|
||||||
|
cmPolicies::PolicyMap const& pm)
|
||||||
|
: Makefile(mf), ReportError(true)
|
||||||
|
{
|
||||||
|
this->Makefile->PushFunctionScope(pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmMakefile::FunctionPushPop::~FunctionPushPop()
|
||||||
|
{
|
||||||
|
this->Makefile->PopFunctionScope(this->ReportError);
|
||||||
|
}
|
||||||
|
|
|
@ -746,7 +746,21 @@ public:
|
||||||
const std::vector<cmTestGenerator*>& GetTestGenerators() const
|
const std::vector<cmTestGenerator*>& GetTestGenerators() const
|
||||||
{ return this->TestGenerators; }
|
{ return this->TestGenerators; }
|
||||||
|
|
||||||
// push and pop variable scopes
|
class FunctionPushPop
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FunctionPushPop(cmMakefile* mf,
|
||||||
|
cmPolicies::PolicyMap const& pm);
|
||||||
|
~FunctionPushPop();
|
||||||
|
|
||||||
|
void Quiet() { this->ReportError = false; }
|
||||||
|
private:
|
||||||
|
cmMakefile* Makefile;
|
||||||
|
bool ReportError;
|
||||||
|
};
|
||||||
|
|
||||||
|
void PushFunctionScope(cmPolicies::PolicyMap const& pm);
|
||||||
|
void PopFunctionScope(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