diff options
author | Brad King <brad.king@kitware.com> | 2014-10-27 12:32:26 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-10-27 12:32:26 (GMT) |
commit | 8eb64831bec333914aab3af54e2d1deded02eb90 (patch) | |
tree | fa90031d682546d1b491be67c481a394edf18861 /Source | |
parent | 21cf9364f092004a027f11b5bf574804cc8cfded (diff) | |
parent | d1b62185d6b66b27a3ef31b79d4cff1c5126793e (diff) | |
download | CMake-8eb64831bec333914aab3af54e2d1deded02eb90.zip CMake-8eb64831bec333914aab3af54e2d1deded02eb90.tar.gz CMake-8eb64831bec333914aab3af54e2d1deded02eb90.tar.bz2 |
Merge topic 'revert-definition-map-lookup'
d1b62185 Merge branch 'parent-scope-tests' into variable-pull-failure
5f414cef Revert "cmDefinitions: Don't store parent lookups"
e0c0b1ac test: add a test for PARENT_SCOPE with multiple scopes
064c415d test: add test for PARENT_SCOPE behavior
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDefinitions.cxx | 22 | ||||
-rw-r--r-- | Source/cmDefinitions.h | 10 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 2 |
3 files changed, 10 insertions, 24 deletions
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 5515f35..fe32dd5 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -29,7 +29,7 @@ void cmDefinitions::Reset(cmDefinitions* parent) //---------------------------------------------------------------------------- cmDefinitions::Def const& -cmDefinitions::GetInternal(const std::string& key) const +cmDefinitions::GetInternal(const std::string& key) { MapType::const_iterator i = this->Map.find(key); if(i != this->Map.end()) @@ -38,8 +38,9 @@ cmDefinitions::GetInternal(const std::string& key) const } if(cmDefinitions* up = this->Up) { - // Query the parent scope. - return up->GetInternal(key); + // Query the parent scope and store the result locally. + Def def = up->GetInternal(key); + return this->Map.insert(MapType::value_type(key, def)).first->second; } return this->NoDef; } @@ -62,26 +63,13 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def) } //---------------------------------------------------------------------------- -const char* cmDefinitions::Get(const std::string& key) const +const char* cmDefinitions::Get(const std::string& key) { Def const& def = this->GetInternal(key); return def.Exists? def.c_str() : 0; } //---------------------------------------------------------------------------- -void cmDefinitions::Pull(const std::string& key) -{ - if (this->Up) - { - Def const& def = this->Up->GetInternal(key); - if (def.Exists) - { - this->SetInternal(key, def); - } - } -} - -//---------------------------------------------------------------------------- const char* cmDefinitions::Set(const std::string& key, const char* value) { Def const& def = this->SetInternal(key, Def(value)); diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 5209a8b..a2f053f 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -36,11 +36,9 @@ public: /** Returns the parent scope, if any. */ cmDefinitions* GetParent() const { return this->Up; } - /** Get the value associated with a key; null if none. */ - const char* Get(const std::string& key) const; - - /** Pull a variable from the parent. */ - void Pull(const std::string& key); + /** Get the value associated with a key; null if none. + Store the result locally if it came from a parent. */ + const char* Get(const std::string& key); /** Set (or unset if null) a value associated with a key. */ const char* Set(const std::string& key, const char* value); @@ -82,7 +80,7 @@ private: MapType Map; // Internal query and update methods. - Def const& GetInternal(const std::string& key) const; + Def const& GetInternal(const std::string& key); Def const& SetInternal(const std::string& key, Def const& def); // Implementation of Closure() method. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8cc1e88..8a8aadc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4476,7 +4476,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) if(cmDefinitions* up = cur.GetParent()) { // First localize the definition in the current scope. - cur.Pull(var); + cur.Get(var); // Now update the definition in the parent scope. up->Set(var, varDef); |