summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-04-29 22:19:55 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-05-01 17:34:59 (GMT)
commit8b1745a1c5ed992e632bd4865c0f6a34b136041d (patch)
tree8687b5bf485fb9ee23106e9255ee0a85ecde2448 /Source
parente8ae46e5e228cc3008e64766e6c8da48b1835545 (diff)
downloadCMake-8b1745a1c5ed992e632bd4865c0f6a34b136041d.zip
CMake-8b1745a1c5ed992e632bd4865c0f6a34b136041d.tar.gz
CMake-8b1745a1c5ed992e632bd4865c0f6a34b136041d.tar.bz2
cmDefinitions: Accept varStack iterators in Get API.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDefinitions.cxx21
-rw-r--r--Source/cmDefinitions.h8
-rw-r--r--Source/cmMakefile.cxx3
3 files changed, 22 insertions, 10 deletions
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 61328be..94d27c2 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -11,6 +11,8 @@
============================================================================*/
#include "cmDefinitions.h"
+#include <assert.h>
+
//----------------------------------------------------------------------------
cmDefinitions::Def cmDefinitions::NoDef;
@@ -21,28 +23,33 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
}
//----------------------------------------------------------------------------
-cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+cmDefinitions::Def const& cmDefinitions::GetInternal(
+ const std::string& key,
+ std::list<cmDefinitions>::reverse_iterator rbegin,
+ std::list<cmDefinitions>::reverse_iterator rend)
{
+ assert(&*rbegin == this);
MapType::const_iterator i = this->Map.find(key);
if(i != this->Map.end())
{
return i->second;
}
- cmDefinitions* up = this->Up;
- if(!up)
+ ++rbegin;
+ if(rbegin == rend)
{
return this->NoDef;
}
// Query the parent scope and store the result locally.
- Def def = up->GetInternal(key);
+ Def def = rbegin->GetInternal(key, rbegin, rend);
return this->Map.insert(MapType::value_type(key, def)).first->second;
}
//----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
+const char* cmDefinitions::Get(const std::string& key,
+ std::list<cmDefinitions>::reverse_iterator rbegin,
+ std::list<cmDefinitions>::reverse_iterator rend)
{
- Def const& def = this->GetInternal(key);
+ Def const& def = this->GetInternal(key, rbegin, rend);
return def.Exists? def.c_str() : 0;
}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4c7f11f..2bcfcb0 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -37,7 +37,9 @@ public:
/** 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);
+ const char* Get(const std::string& key,
+ std::list<cmDefinitions>::reverse_iterator rbegin,
+ std::list<cmDefinitions>::reverse_iterator rend);
/** Set (or unset if null) a value associated with a key. */
void Set(const std::string& key, const char* value);
@@ -81,7 +83,9 @@ private:
MapType Map;
// Internal query and update methods.
- Def const& GetInternal(const std::string& key);
+ Def const& GetInternal(const std::string& key,
+ std::list<cmDefinitions>::reverse_iterator rbegin,
+ std::list<cmDefinitions>::reverse_iterator rend);
void MakeClosure(std::set<std::string>& undefined,
std::list<cmDefinitions>::const_reverse_iterator rbegin,
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5686b1b..ae7e564 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -70,7 +70,8 @@ public:
const char* GetDefinition(std::string const& name)
{
- return this->VarStack.back().Get(name);
+ return this->VarStack.back().Get(name, this->VarStack.rbegin(),
+ this->VarStack.rend());
}
void SetDefinition(std::string const& name, std::string const& value)