summaryrefslogtreecommitdiffstats
path: root/Source/cmDefinitions.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmDefinitions.cxx')
-rw-r--r--Source/cmDefinitions.cxx22
1 files changed, 17 insertions, 5 deletions
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index babf1c4..98becf8 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -28,7 +28,7 @@ void cmDefinitions::Reset(cmDefinitions* parent)
//----------------------------------------------------------------------------
cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+cmDefinitions::GetInternal(const std::string& key) const
{
MapType::const_iterator i = this->Map.find(key);
if(i != this->Map.end())
@@ -37,9 +37,8 @@ cmDefinitions::GetInternal(const std::string& key)
}
else if(cmDefinitions* up = this->Up)
{
- // 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;
+ // Query the parent scope.
+ return up->GetInternal(key);
}
return this->NoDef;
}
@@ -71,13 +70,26 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def)
}
//----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
+const char* cmDefinitions::Get(const std::string& key) const
{
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));