cmDefinitions: Implement MakeClosure in terms of reverse iterators.
Iterate directly over the parent content provided by cmMakefile.
This commit is contained in:
parent
aa4d1ee80f
commit
f79cd99d6d
|
@ -76,27 +76,27 @@ std::vector<std::string> cmDefinitions::LocalKeys() const
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmDefinitions cmDefinitions::MakeClosure(
|
cmDefinitions cmDefinitions::MakeClosure(
|
||||||
std::list<cmDefinitions const*>::iterator begin,
|
std::list<cmDefinitions>::const_reverse_iterator rbegin,
|
||||||
std::list<cmDefinitions const*>::iterator end)
|
std::list<cmDefinitions>::const_reverse_iterator rend)
|
||||||
{
|
{
|
||||||
std::set<std::string> undefined;
|
std::set<std::string> undefined;
|
||||||
cmDefinitions closure;
|
cmDefinitions closure;
|
||||||
closure.MakeClosure(undefined, begin, end);
|
closure.MakeClosure(undefined, rbegin, rend);
|
||||||
return closure;
|
return closure;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmDefinitions::MakeClosure(std::set<std::string>& undefined,
|
cmDefinitions::MakeClosure(std::set<std::string>& undefined,
|
||||||
std::list<cmDefinitions const*>::iterator begin,
|
std::list<cmDefinitions>::const_reverse_iterator rbegin,
|
||||||
std::list<cmDefinitions const*>::iterator end)
|
std::list<cmDefinitions>::const_reverse_iterator rend)
|
||||||
{
|
{
|
||||||
for (std::list<cmDefinitions const*>::const_iterator it = begin;
|
for (std::list<cmDefinitions>::const_reverse_iterator it = rbegin;
|
||||||
it != end; ++it)
|
it != rend; ++it)
|
||||||
{
|
{
|
||||||
// Consider local definitions.
|
// Consider local definitions.
|
||||||
for(MapType::const_iterator mi = (*it)->Map.begin();
|
for(MapType::const_iterator mi = it->Map.begin();
|
||||||
mi != (*it)->Map.end(); ++mi)
|
mi != it->Map.end(); ++mi)
|
||||||
{
|
{
|
||||||
// Use this key if it is not already set or unset.
|
// Use this key if it is not already set or unset.
|
||||||
if(this->Map.find(mi->first) == this->Map.end() &&
|
if(this->Map.find(mi->first) == this->Map.end() &&
|
||||||
|
|
|
@ -51,8 +51,8 @@ public:
|
||||||
std::vector<std::string> ClosureKeys() const;
|
std::vector<std::string> ClosureKeys() const;
|
||||||
|
|
||||||
static cmDefinitions MakeClosure(
|
static cmDefinitions MakeClosure(
|
||||||
std::list<cmDefinitions const*>::iterator begin,
|
std::list<cmDefinitions>::const_reverse_iterator rbegin,
|
||||||
std::list<cmDefinitions const*>::iterator end);
|
std::list<cmDefinitions>::const_reverse_iterator rend);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// String with existence boolean.
|
// String with existence boolean.
|
||||||
|
@ -84,8 +84,8 @@ private:
|
||||||
Def const& GetInternal(const std::string& key);
|
Def const& GetInternal(const std::string& key);
|
||||||
|
|
||||||
void MakeClosure(std::set<std::string>& undefined,
|
void MakeClosure(std::set<std::string>& undefined,
|
||||||
std::list<cmDefinitions const*>::iterator begin,
|
std::list<cmDefinitions>::const_reverse_iterator rbegin,
|
||||||
std::list<cmDefinitions const*>::iterator end);
|
std::list<cmDefinitions>::const_reverse_iterator rend);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,15 +63,9 @@ public:
|
||||||
|
|
||||||
void InitializeDefinitions(cmMakefile* parent)
|
void InitializeDefinitions(cmMakefile* parent)
|
||||||
{
|
{
|
||||||
std::list<cmDefinitions const*> defPtrs;
|
this->VarStack.back() =
|
||||||
for (std::list<cmDefinitions>::iterator it =
|
cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(),
|
||||||
parent->Internal->VarStack.begin();
|
parent->Internal->VarStack.rend());
|
||||||
it != parent->Internal->VarStack.end(); ++it)
|
|
||||||
{
|
|
||||||
defPtrs.push_back(&*it);
|
|
||||||
}
|
|
||||||
this->VarStack.back() = cmDefinitions::MakeClosure(defPtrs.begin(),
|
|
||||||
defPtrs.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetDefinition(std::string const& name)
|
const char* GetDefinition(std::string const& name)
|
||||||
|
|
Loading…
Reference in New Issue