cmDefinitions: Convert MakeClosure into a static method.

Accept a range of cmDefinitions*.
This commit is contained in:
Stephen Kelly 2015-04-26 16:13:56 +02:00
parent 60becdc65c
commit aa4d1ee80f
3 changed files with 16 additions and 11 deletions

View File

@ -75,18 +75,13 @@ std::vector<std::string> cmDefinitions::LocalKeys() const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDefinitions cmDefinitions::MakeClosure() const cmDefinitions cmDefinitions::MakeClosure(
std::list<cmDefinitions const*>::iterator begin,
std::list<cmDefinitions const*>::iterator end)
{ {
std::set<std::string> undefined; std::set<std::string> undefined;
cmDefinitions closure; cmDefinitions closure;
cmDefinitions const* defs = this; closure.MakeClosure(undefined, begin, end);
std::list<cmDefinitions const*> ups;
while(defs)
{
ups.push_back(defs);
defs = defs->Up;
}
closure.MakeClosure(undefined, ups.begin(), ups.end());
return closure; return closure;
} }

View File

@ -50,7 +50,9 @@ public:
/** Compute the set of all defined keys. */ /** Compute the set of all defined keys. */
std::vector<std::string> ClosureKeys() const; std::vector<std::string> ClosureKeys() const;
cmDefinitions MakeClosure() const; static cmDefinitions MakeClosure(
std::list<cmDefinitions const*>::iterator begin,
std::list<cmDefinitions const*>::iterator end);
private: private:
// String with existence boolean. // String with existence boolean.

View File

@ -63,7 +63,15 @@ public:
void InitializeDefinitions(cmMakefile* parent) void InitializeDefinitions(cmMakefile* parent)
{ {
this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure(); std::list<cmDefinitions const*> defPtrs;
for (std::list<cmDefinitions>::iterator it =
parent->Internal->VarStack.begin();
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)