From 24885d4efa17d4232e266ef053899613c32fdeb7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Apr 2015 15:44:26 +0200 Subject: cmDefinitions: Replace private constructor with MakeClosure. --- Source/cmDefinitions.cxx | 17 ++++++----------- Source/cmDefinitions.h | 11 +++-------- Source/cmMakefile.cxx | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index f2100eb..c4d285a 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -75,21 +75,16 @@ std::vector cmDefinitions::LocalKeys() const } //---------------------------------------------------------------------------- -cmDefinitions cmDefinitions::Closure() const -{ - return cmDefinitions(ClosureTag(), this); -} - -//---------------------------------------------------------------------------- -cmDefinitions::cmDefinitions(ClosureTag const&, cmDefinitions const* root): - Up(0) +cmDefinitions cmDefinitions::MakeClosure() const { std::set undefined; - this->ClosureImpl(undefined, root); + cmDefinitions closure; + closure.MakeClosure(undefined, this); + return closure; } //---------------------------------------------------------------------------- -void cmDefinitions::ClosureImpl(std::set& undefined, +void cmDefinitions::MakeClosure(std::set& undefined, cmDefinitions const* defs) { // Consider local definitions. @@ -114,7 +109,7 @@ void cmDefinitions::ClosureImpl(std::set& undefined, // Traverse parents. if(cmDefinitions const* up = defs->Up) { - this->ClosureImpl(undefined, up); + this->MakeClosure(undefined, up); } } diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 4664090..6917402 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -45,13 +45,11 @@ public: /** Get the set of all local keys. */ std::vector LocalKeys() const; - /** Compute the closure of all defined keys with values. - This flattens the scope. The result has no parent. */ - cmDefinitions Closure() const; - /** Compute the set of all defined keys. */ std::vector ClosureKeys() const; + cmDefinitions MakeClosure() const; + private: // String with existence boolean. struct Def: public std::string @@ -81,10 +79,7 @@ private: // Internal query and update methods. Def const& GetInternal(const std::string& key); - // Implementation of Closure() method. - struct ClosureTag {}; - cmDefinitions(ClosureTag const&, cmDefinitions const* root); - void ClosureImpl(std::set& undefined, + void MakeClosure(std::set& undefined, cmDefinitions const* defs); }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e2a9f61..dbb355c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -63,7 +63,7 @@ public: void InitializeDefinitions(cmMakefile* parent) { - this->VarStack.top() = parent->Internal->VarStack.top().Closure(); + this->VarStack.top() = parent->Internal->VarStack.top().MakeClosure(); } const char* GetDefinition(std::string const& name) -- cgit v0.12