ENH: Refactor policy stack representation

This defines PolicyMap as a public member of cmPolicies.  Its previous
role as a policy stack entry is now called PolicyStackEntry and
represented as a class to which more information can be added later.
This commit is contained in:
Brad King 2009-01-22 10:56:39 -05:00
parent e8a0e90133
commit 8997f4760a
3 changed files with 16 additions and 7 deletions

View File

@ -3599,11 +3599,10 @@ cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id)
{ {
// Is the policy set in our stack? // Is the policy set in our stack?
for(std::vector<PolicyMap>::reverse_iterator for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin();
psi = this->PolicyStack.rbegin();
psi != this->PolicyStack.rend(); ++psi) psi != this->PolicyStack.rend(); ++psi)
{ {
PolicyMap::const_iterator pse = psi->find(id); PolicyStackEntry::const_iterator pse = psi->find(id);
if(pse != psi->end()) if(pse != psi->end())
{ {
return pse->second; return pse->second;
@ -3678,7 +3677,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
bool cmMakefile::PushPolicy() bool cmMakefile::PushPolicy()
{ {
// Allocate a new stack entry. // Allocate a new stack entry.
this->PolicyStack.push_back(PolicyMap()); this->PolicyStack.push_back(PolicyStackEntry());
return true; return true;
} }

View File

@ -931,9 +931,15 @@ private:
std::map<cmStdString, cmTarget*> ImportedTargets; std::map<cmStdString, cmTarget*> ImportedTargets;
// stack of policy settings // stack of policy settings
typedef std::map<cmPolicies::PolicyID, struct PolicyStackEntry: public cmPolicies::PolicyMap
cmPolicies::PolicyStatus> PolicyMap; {
std::vector<PolicyMap> PolicyStack; typedef cmPolicies::PolicyMap derived;
PolicyStackEntry(): derived() {}
PolicyStackEntry(derived const& d): derived(d) {}
PolicyStackEntry(PolicyStackEntry const& r): derived(r) {}
};
typedef std::vector<PolicyStackEntry> PolicyStackType;
PolicyStackType PolicyStack;
cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id); cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id);
bool CheckCMP0000; bool CheckCMP0000;

View File

@ -89,6 +89,10 @@ public:
///! Get docs for policies ///! Get docs for policies
void GetDocumentation(std::vector<cmDocumentationEntry>& v); void GetDocumentation(std::vector<cmDocumentationEntry>& v);
/** Represent a set of policy values. */
typedef std::map<cmPolicies::PolicyID,
cmPolicies::PolicyStatus> PolicyMap;
private: private:
// might have to make these internal for VS6 not sure yet // might have to make these internal for VS6 not sure yet
std::map<PolicyID,cmPolicy *> Policies; std::map<PolicyID,cmPolicy *> Policies;