From 8997f4760a83efb270f3f9234a016451c0884fe2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Jan 2009 10:56:39 -0500 Subject: [PATCH] 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. --- Source/cmMakefile.cxx | 7 +++---- Source/cmMakefile.h | 12 +++++++++--- Source/cmPolicies.h | 4 ++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 890f75290..f9b40b1a0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3599,11 +3599,10 @@ cmPolicies::PolicyStatus cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) { // Is the policy set in our stack? - for(std::vector::reverse_iterator - psi = this->PolicyStack.rbegin(); + for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); psi != this->PolicyStack.rend(); ++psi) { - PolicyMap::const_iterator pse = psi->find(id); + PolicyStackEntry::const_iterator pse = psi->find(id); if(pse != psi->end()) { return pse->second; @@ -3678,7 +3677,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, bool cmMakefile::PushPolicy() { // Allocate a new stack entry. - this->PolicyStack.push_back(PolicyMap()); + this->PolicyStack.push_back(PolicyStackEntry()); return true; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c6061d73c..4daec1662 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -931,9 +931,15 @@ private: std::map ImportedTargets; // stack of policy settings - typedef std::map PolicyMap; - std::vector PolicyStack; + struct PolicyStackEntry: public cmPolicies::PolicyMap + { + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(): derived() {} + PolicyStackEntry(derived const& d): derived(d) {} + PolicyStackEntry(PolicyStackEntry const& r): derived(r) {} + }; + typedef std::vector PolicyStackType; + PolicyStackType PolicyStack; cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id); bool CheckCMP0000; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 02f7276b1..8dc7f31be 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -89,6 +89,10 @@ public: ///! Get docs for policies void GetDocumentation(std::vector& v); + /** Represent a set of policy values. */ + typedef std::map PolicyMap; + private: // might have to make these internal for VS6 not sure yet std::map Policies;