[Cmake-commits] CMake branch, next, updated. v3.2.2-2103-g3fdd925

Stephen Kelly steveire at gmail.com
Sun Apr 26 10:38:46 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  3fdd9250b9656a62aaf989eced0e6c6f8bc01e5f (commit)
       via  2ad0aaa739904b47d13b73b4fe8ca6ad89535bac (commit)
       via  5b23937d0f6080420b4b4364a479026489c501f8 (commit)
       via  85af96bcb2f6195602ecaa9db31519907212e8c9 (commit)
       via  2b160179406942eab300971990ec2291441cd8d8 (commit)
       via  8fa91aae6a62de805c90b9938fc759948f0dfedf (commit)
       via  7d2d2756242367a546d20906311c354b55c8e6f0 (commit)
       via  8c8bb238a18ba56ca2e428387c85baa3d3f6a7e1 (commit)
       via  7cf2a241ee93bd05de53b0008e654a24526a772e (commit)
       via  17ae88e198b0b1e8b11f7be2a53cd324b74fe2a2 (commit)
       via  c5db80e325b1c5da73f903533ba66453e27a9fb9 (commit)
       via  9743e487686230f2719c787597c0f0347c25d9c3 (commit)
       via  b9910cb776d49e82149fcf5a02a78b13b4177059 (commit)
       via  a55719eb01158838ea550c6dfb986121fe21267b (commit)
       via  01b0b763640048dab6b69e9b6a4b67dfd16d1d75 (commit)
       via  728010ec3e62f1ee57a3d77b9693b3b0d09b7c92 (commit)
       via  6c1735a5500aebd55d8ed8e854a76334ad3d6606 (commit)
       via  a56334284c9753101f0236c07b23f7b38bc8a98e (commit)
       via  2d627a25883454d3c304c7651ef38a4cf98d7c4d (commit)
       via  9a2f454f3ac20af811a52dc41bfbb4ccaddbff46 (commit)
       via  00d298f56df5a2fbed9a3012dfae936e2f57459d (commit)
       via  22f2bcc62b0c38f2cd6ca4ee5ccc367a9594a1f6 (commit)
       via  ca907da953118b4dc360845024523fad81c8cb7f (commit)
       via  90ff34a130ed2946e22955d840a025042a99a50c (commit)
       via  fb3ba073ad90836738a60c3dabea951d064a5952 (commit)
       via  27b97998d0c180c1cf55a22ad424a8bad9be4428 (commit)
       via  269d3e0246f57e8c0bc49acdfd2bdebbf626d635 (commit)
       via  be90997deffcf5a780abc7e0f9d574c02ec372b3 (commit)
       via  7692d983d48b4b8ec439e4f50044350dbc0fbc3a (commit)
      from  bb64e2206a4455ea7d9be55f315187c87ad62fd7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3fdd9250b9656a62aaf989eced0e6c6f8bc01e5f
commit 3fdd9250b9656a62aaf989eced0e6c6f8bc01e5f
Merge: bb64e22 2ad0aaa
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 10:38:43 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Apr 26 10:38:43 2015 -0400

    Merge topic 'refactor-cmDefinitions' into next
    
    2ad0aaa7 cmDefinitions: Change LocalKeys to return a vector.
    5b23937d cmMakefile: Store definition stack as a vector.
    85af96bc cmDefinitions: Remove Parent pointer.
    2b160179 cmDefinitions: Convert MakeClosure into a static method.
    8fa91aae cmDefinitions: Implement MakeClosure in terms of a vector of ancestors.
    7d2d2756 cmDefinitions: Use vector of cmDefinitions* to create closure.
    8c8bb238 cmDefinitions: Replace recursion with loop.
    7cf2a241 cmDefinitions: Replace private constructor with MakeClosure.
    17ae88e1 cmDefinitions: Externalize looping for ClosureKeys.
    c5db80e3 cmDefinitions: Make ClosureKeys API vector-based.
    9743e487 cmDefinitions: Inline GetClosureKeys implementation.
    b9910cb7 cmDefinitions: Replace ClosureKeys recursion with looping.
    a55719eb cmDefinitions: Inline GetInternal into Get.
    01b0b763 cmDefinitions: Externalize the stack loop for the Get method.
    728010ec cmDefinitions: Extract loop from GetInternal to Get.
    6c1735a5 cmDefinitions: Use Set API in Get implementation.
    ...


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2ad0aaa739904b47d13b73b4fe8ca6ad89535bac
commit 2ad0aaa739904b47d13b73b4fe8ca6ad89535bac
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:34:13 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:35:01 2015 +0200

    cmDefinitions: Change LocalKeys to return a vector.
    
    This is more efficient and we lose nothing.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 37c12f4..6f1bd02 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -38,16 +38,17 @@ void cmDefinitions::Erase(const std::string& key)
 }
 
 //----------------------------------------------------------------------------
-std::set<std::string> cmDefinitions::LocalKeys() const
+std::vector<std::string> cmDefinitions::LocalKeys() const
 {
-  std::set<std::string> keys;
+  std::vector<std::string> keys;
+  keys.reserve(this->Map.size());
   // Consider local definitions.
   for(MapType::const_iterator mi = this->Map.begin();
       mi != this->Map.end(); ++mi)
     {
     if (mi->second.Exists)
       {
-      keys.insert(mi->first);
+      keys.push_back(mi->first);
       }
     }
   return keys;
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 3f52dfa..8ac310a 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -37,7 +37,7 @@ public:
   void Erase(const std::string& key);
 
   /** Get the set of all local keys.  */
-  std::set<std::string> LocalKeys() const;
+  std::vector<std::string> LocalKeys() const;
 
   /** Compute the closure of all defined keys with values.
       This flattens the scope.  The result has no parent.  */
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9699a3a..6482dc1 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -115,7 +115,7 @@ public:
       }
   }
 
-  std::set<std::string> LocalKeys() const
+  std::vector<std::string> LocalKeys() const
   {
     return this->VarStack.back().LocalKeys();
   }
@@ -1922,8 +1922,8 @@ void cmMakefile::CheckForUnusedVariables() const
     {
     return;
     }
-  const std::set<std::string>& locals = this->Internal->LocalKeys();
-  std::set<std::string>::const_iterator it = locals.begin();
+  const std::vector<std::string>& locals = this->Internal->LocalKeys();
+  std::vector<std::string>::const_iterator it = locals.begin();
   for (; it != locals.end(); ++it)
     {
     this->CheckForUnused("out of scope", *it);
@@ -4474,10 +4474,10 @@ void cmMakefile::PopScope()
 
   std::set<std::string> init = this->Internal->VarInitStack.top();
   std::set<std::string> usage = this->Internal->VarUsageStack.top();
-  const std::set<std::string>& locals = this->Internal->LocalKeys();
+  const std::vector<std::string>& locals = this->Internal->LocalKeys();
   // Remove initialization and usage information for variables in the local
   // scope.
-  std::set<std::string>::const_iterator it = locals.begin();
+  std::vector<std::string>::const_iterator it = locals.begin();
   for (; it != locals.end(); ++it)
     {
     init.erase(*it);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5b23937d0f6080420b4b4364a479026489c501f8
commit 5b23937d0f6080420b4b4364a479026489c501f8
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:22:52 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:24:44 2015 +0200

    cmMakefile: Store definition stack as a vector.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 75628b6..9699a3a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -46,23 +46,21 @@
 class cmMakefile::Internals
 {
 public:
-  std::list<cmDefinitions> VarStack;
+  std::vector<cmDefinitions> VarStack;
   std::stack<std::set<std::string> > VarInitStack;
   std::stack<std::set<std::string> > VarUsageStack;
   bool IsSourceFileTryCompile;
 
   void PushDefinitions()
   {
-    this->VarStack.push_back(cmDefinitions());
+    this->VarStack.resize(this->VarStack.size() + 1);
   }
 
   void InitializeDefinitions(cmMakefile* parent)
   {
     std::vector<cmDefinitions const*> defPtrs;
-    defPtrs.reserve(this->VarStack.size());
-    for (std::list<cmDefinitions>::iterator it =
-         parent->Internal->VarStack.begin();
-         it != parent->Internal->VarStack.end(); ++it)
+    for (std::vector<cmDefinitions>::iterator it = parent->Internal->VarStack.begin();
+        it != parent->Internal->VarStack.end(); ++it)
       {
       defPtrs.push_back(&*it);
       }
@@ -75,7 +73,7 @@ public:
   {
     std::vector<cmDefinitions*> defPtrs;
     defPtrs.reserve(this->VarStack.size());
-    for (std::list<cmDefinitions>::iterator it = this->VarStack.begin();
+    for (std::vector<cmDefinitions>::iterator it = this->VarStack.begin();
         it != this->VarStack.end(); ++it)
       {
       defPtrs.push_back(&*it);
@@ -126,7 +124,7 @@ public:
   {
     std::vector<std::string> closureKeys;
     std::vector<std::string> undefinedKeys;
-    for (std::list<cmDefinitions>::const_iterator it = this->VarStack.begin();
+    for (std::vector<cmDefinitions>::const_iterator it = this->VarStack.begin();
         it != this->VarStack.end(); ++it)
       {
       std::vector<std::string> const& localKeys = it->Keys(undefinedKeys);
@@ -147,14 +145,14 @@ public:
 
   bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
   {
-    cmDefinitions& cur = this->VarStack.back();
-    if(cmDefinitions* up = cur.GetParent())
+    if(this->VarStack.size() > 1)
       {
       // First localize the definition in the current scope.
-      cur.Get(var);
+      this->GetDefinition(var);
 
       // Now update the definition in the parent scope.
-      up->Set(var, varDef);
+      cmDefinitions& up = this->VarStack[this->VarStack.size() - 2];
+      up.Set(var, varDef);
       }
     else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
       {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=85af96bcb2f6195602ecaa9db31519907212e8c9
commit 85af96bcb2f6195602ecaa9db31519907212e8c9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:19:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:23:27 2015 +0200

    cmDefinitions: Remove Parent pointer.
    
    All structural knowledge of the stack of scopes is now external.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 987837c..37c12f4 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -14,12 +14,6 @@
 #include <assert.h>
 
 //----------------------------------------------------------------------------
-cmDefinitions::cmDefinitions(cmDefinitions* parent)
-  : Up(parent)
-{
-}
-
-//----------------------------------------------------------------------------
 std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
 {
   MapType::const_iterator i = this->Map.find(key);
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 0d53ea0..3f52dfa 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -27,12 +27,6 @@
 class cmDefinitions
 {
 public:
-  /** Construct with the given parent scope.  */
-  cmDefinitions(cmDefinitions* parent = 0);
-
-  /** Returns the parent scope, if any.  */
-  cmDefinitions* GetParent() const { return this->Up; }
-
   /** Get the value associated with a key; null if none.
       Store the result locally if it came from a parent.  */
   std::pair<const char*, bool> Get(const std::string& key);
@@ -70,9 +64,6 @@ private:
     bool Exists;
   };
 
-  // Parent scope, if any.
-  cmDefinitions* Up;
-
   // Local definitions, set or unset.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   typedef cmsys::hash_map<std::string, Def> MapType;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 8e745c1..75628b6 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -53,12 +53,7 @@ public:
 
   void PushDefinitions()
   {
-    cmDefinitions* parent = 0;
-    if (!this->VarStack.empty())
-      {
-      parent = &this->VarStack.back();
-      }
-    this->VarStack.push_back(cmDefinitions(parent));
+    this->VarStack.push_back(cmDefinitions());
   }
 
   void InitializeDefinitions(cmMakefile* parent)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b160179406942eab300971990ec2291441cd8d8
commit 2b160179406942eab300971990ec2291441cd8d8
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:13:56 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:23:27 2015 +0200

    cmDefinitions: Convert MakeClosure into a static method.
    
    Accept a range of cmDefinitions*.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 13aab1b..987837c 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -60,18 +60,13 @@ std::set<std::string> cmDefinitions::LocalKeys() const
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions cmDefinitions::MakeClosure() const
+cmDefinitions cmDefinitions::MakeClosure(
+    std::vector<cmDefinitions const*>::iterator begin,
+    std::vector<cmDefinitions const*>::iterator end)
 {
   std::set<std::string> undefined;
   cmDefinitions closure;
-  cmDefinitions const* defs = this;
-  std::vector<cmDefinitions const*> ups;
-  while(defs)
-    {
-    ups.push_back(defs);
-    defs = defs->Up;
-    }
-  closure.MakeClosure(undefined, ups.begin(), ups.end());
+  closure.MakeClosure(undefined, begin, end);
   return closure;
 }
 
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 2d71f2c..0d53ea0 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -52,7 +52,9 @@ public:
   std::vector<std::string>
   Keys(std::vector<std::string>& undefinedKeys) const;
 
-  cmDefinitions MakeClosure() const;
+  static cmDefinitions MakeClosure(
+      std::vector<cmDefinitions const*>::iterator begin,
+      std::vector<cmDefinitions const*>::iterator end);
 
 private:
   // String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 3308d1c..8e745c1 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -63,7 +63,17 @@ public:
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure();
+    std::vector<cmDefinitions const*> defPtrs;
+    defPtrs.reserve(this->VarStack.size());
+    for (std::list<cmDefinitions>::iterator it =
+         parent->Internal->VarStack.begin();
+         it != parent->Internal->VarStack.end(); ++it)
+      {
+      defPtrs.push_back(&*it);
+      }
+    std::reverse(defPtrs.begin(), defPtrs.end());
+    this->VarStack.back() = cmDefinitions::MakeClosure(defPtrs.begin(),
+                                                       defPtrs.end());
   }
 
   const char* GetDefinition(std::string const& name)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8fa91aae6a62de805c90b9938fc759948f0dfedf
commit 8fa91aae6a62de805c90b9938fc759948f0dfedf
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:00:18 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:23:27 2015 +0200

    cmDefinitions: Implement MakeClosure in terms of a vector of ancestors.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index c947df6..13aab1b 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -64,22 +64,25 @@ cmDefinitions cmDefinitions::MakeClosure() const
 {
   std::set<std::string> undefined;
   cmDefinitions closure;
-  closure.MakeClosure(undefined, this);
-  return closure;
-}
-
-//----------------------------------------------------------------------------
-void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
-                                cmDefinitions const* defs)
-{
-  std::vector<cmDefinitions*> ups;
+  cmDefinitions const* defs = this;
+  std::vector<cmDefinitions const*> ups;
   while(defs)
     {
     ups.push_back(defs);
     defs = defs->Up;
     }
-  for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
-       it != ups.end(); ++it)
+  closure.MakeClosure(undefined, ups.begin(), ups.end());
+  return closure;
+}
+
+//----------------------------------------------------------------------------
+void
+cmDefinitions::MakeClosure(std::set<std::string>& undefined,
+                           std::vector<cmDefinitions const*>::iterator begin,
+                           std::vector<cmDefinitions const*>::iterator end)
+{
+  for (std::vector<cmDefinitions const*>::const_iterator it = begin;
+       it != end; ++it)
     {
     // Consider local definitions.
     for(MapType::const_iterator mi = (*it)->Map.begin();
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index fcd8acb..2d71f2c 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -80,7 +80,8 @@ private:
   MapType Map;
 
   void MakeClosure(std::set<std::string>& undefined,
-                   cmDefinitions const* defs);
+                   std::vector<cmDefinitions const*>::iterator begin,
+                   std::vector<cmDefinitions const*>::iterator end);
 };
 
 #endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d2d2756242367a546d20906311c354b55c8e6f0
commit 7d2d2756242367a546d20906311c354b55c8e6f0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:54:02 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:23:19 2015 +0200

    cmDefinitions: Use vector of cmDefinitions* to create closure.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index d2102c7..c947df6 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -72,11 +72,18 @@ cmDefinitions cmDefinitions::MakeClosure() const
 void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
                                 cmDefinitions const* defs)
 {
+  std::vector<cmDefinitions*> ups;
   while(defs)
     {
+    ups.push_back(defs);
+    defs = defs->Up;
+    }
+  for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
+       it != ups.end(); ++it)
+    {
     // Consider local definitions.
-    for(MapType::const_iterator mi = defs->Map.begin();
-        mi != defs->Map.end(); ++mi)
+    for(MapType::const_iterator mi = (*it)->Map.begin();
+        mi != (*it)->Map.end(); ++mi)
       {
       // Use this key if it is not already set or unset.
       if(this->Map.find(mi->first) == this->Map.end() &&
@@ -92,7 +99,6 @@ void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
           }
         }
       }
-    defs = defs->Up;
     }
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c8bb238a18ba56ca2e428387c85baa3d3f6a7e1
commit 8c8bb238a18ba56ca2e428387c85baa3d3f6a7e1
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:49:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:07:14 2015 +0200

    cmDefinitions: Replace recursion with loop.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index fda29ac..d2102c7 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -72,29 +72,27 @@ cmDefinitions cmDefinitions::MakeClosure() const
 void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
                                 cmDefinitions const* defs)
 {
-  // Consider local definitions.
-  for(MapType::const_iterator mi = defs->Map.begin();
-      mi != defs->Map.end(); ++mi)
+  while(defs)
     {
-    // Use this key if it is not already set or unset.
-    if(this->Map.find(mi->first) == this->Map.end() &&
-       undefined.find(mi->first) == undefined.end())
+    // Consider local definitions.
+    for(MapType::const_iterator mi = defs->Map.begin();
+        mi != defs->Map.end(); ++mi)
       {
-      if(mi->second.Exists)
-        {
-        this->Map.insert(*mi);
-        }
-      else
+      // Use this key if it is not already set or unset.
+      if(this->Map.find(mi->first) == this->Map.end() &&
+         undefined.find(mi->first) == undefined.end())
         {
-        undefined.insert(mi->first);
+        if(mi->second.Exists)
+          {
+          this->Map.insert(*mi);
+          }
+        else
+          {
+          undefined.insert(mi->first);
+          }
         }
       }
-    }
-
-  // Traverse parents.
-  if(cmDefinitions const* up = defs->Up)
-    {
-    this->ClosureImpl(undefined, up);
+    defs = defs->Up;
     }
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7cf2a241ee93bd05de53b0008e654a24526a772e
commit 7cf2a241ee93bd05de53b0008e654a24526a772e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:44:26 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:07:11 2015 +0200

    cmDefinitions: Replace private constructor with MakeClosure.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index a2c6be6..fda29ac 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -60,21 +60,16 @@ std::set<std::string> 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<std::string> undefined;
-  this->ClosureImpl(undefined, root);
+  cmDefinitions closure;
+  closure.MakeClosure(undefined, this);
+  return closure;
 }
 
 //----------------------------------------------------------------------------
-void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
+void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
                                 cmDefinitions const* defs)
 {
   // Consider local definitions.
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index c6b5feb..fcd8acb 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -52,6 +52,8 @@ public:
   std::vector<std::string>
   Keys(std::vector<std::string>& undefinedKeys) const;
 
+  cmDefinitions MakeClosure() const;
+
 private:
   // String with existence boolean.
   struct Def: public std::string
@@ -77,10 +79,7 @@ private:
 #endif
   MapType Map;
 
-  // Implementation of Closure() method.
-  struct ClosureTag {};
-  cmDefinitions(ClosureTag const&, cmDefinitions const* root);
-  void ClosureImpl(std::set<std::string>& undefined,
+  void MakeClosure(std::set<std::string>& undefined,
                    cmDefinitions const* defs);
 };
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index cc5456c..3308d1c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -63,7 +63,7 @@ public:
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    this->VarStack.back() = parent->Internal->VarStack.back().Closure();
+    this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure();
   }
 
   const char* GetDefinition(std::string const& name)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17ae88e198b0b1e8b11f7be2a53cd324b74fe2a2
commit 17ae88e198b0b1e8b11f7be2a53cd324b74fe2a2
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:38:36 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 16:01:03 2015 +0200

    cmDefinitions: Externalize looping for ClosureKeys.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index f602060..a2c6be6 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -104,28 +104,18 @@ void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
 }
 
 //----------------------------------------------------------------------------
-std::vector<std::string> cmDefinitions::ClosureKeys() const
+std::vector<std::string>
+cmDefinitions::Keys(std::vector<std::string>& undefined) const
 {
-  std::set<std::string> defined;
-  std::set<std::string> undefined;
-
-  cmDefinitions const* up = this;
-
-  while (up)
+  std::vector<std::string> defined;
+  defined.reserve(this->Map.size());
+  for(MapType::const_iterator mi = this->Map.begin();
+      mi != this->Map.end(); ++mi)
     {
-    // Consider local definitions.
-    for(MapType::const_iterator mi = up->Map.begin();
-        mi != up->Map.end(); ++mi)
-      {
-      // Use this key if it is not already set or unset.
-      if(defined.find(mi->first) == defined.end() &&
-         undefined.find(mi->first) == undefined.end())
-        {
-        std::set<std::string>& m = mi->second.Exists? defined : undefined;
-        m.insert(mi->first);
-        }
-      }
-    up = this->Up;
+    std::vector<std::string>& m = mi->second.Exists? defined : undefined;
+    m.push_back(mi->first);
     }
-  return std::vector<std::string>(defined.begin(), defined.end());
+  undefined.erase(std::unique(undefined.begin(), undefined.end()),
+                  undefined.end());
+  return defined;
 }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 9fe5830..c6b5feb 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -49,8 +49,8 @@ public:
       This flattens the scope.  The result has no parent.  */
   cmDefinitions Closure() const;
 
-  /** Compute the set of all defined keys.  */
-  std::vector<std::string> ClosureKeys() const;
+  std::vector<std::string>
+  Keys(std::vector<std::string>& undefinedKeys) const;
 
 private:
   // String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d565f7d..cc5456c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -119,7 +119,20 @@ public:
 
   std::vector<std::string> ClosureKeys() const
   {
-    return this->VarStack.back().ClosureKeys();
+    std::vector<std::string> closureKeys;
+    std::vector<std::string> undefinedKeys;
+    for (std::list<cmDefinitions>::const_iterator it = this->VarStack.begin();
+        it != this->VarStack.end(); ++it)
+      {
+      std::vector<std::string> const& localKeys = it->Keys(undefinedKeys);
+      closureKeys.insert(closureKeys.end(), localKeys.begin(), localKeys.end());
+      std::vector<std::string>::iterator newIt =
+          closureKeys.end() - localKeys.size();
+      std::inplace_merge(closureKeys.begin(), newIt, closureKeys.end());
+      }
+    closureKeys.erase(std::unique(closureKeys.begin(),
+                                  closureKeys.end()), closureKeys.end());
+    return closureKeys;
   }
 
   void PopDefinitions()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c5db80e325b1c5da73f903533ba66453e27a9fb9
commit c5db80e325b1c5da73f903533ba66453e27a9fb9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:36:49 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:38:13 2015 +0200

    cmDefinitions: Make ClosureKeys API vector-based.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 1fa07d9..f602060 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -104,7 +104,7 @@ void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
 }
 
 //----------------------------------------------------------------------------
-std::set<std::string> cmDefinitions::ClosureKeys() const
+std::vector<std::string> cmDefinitions::ClosureKeys() const
 {
   std::set<std::string> defined;
   std::set<std::string> undefined;
@@ -127,5 +127,5 @@ std::set<std::string> cmDefinitions::ClosureKeys() const
       }
     up = this->Up;
     }
-  return defined;
+  return std::vector<std::string>(defined.begin(), defined.end());
 }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 407fab3..9fe5830 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -50,7 +50,7 @@ public:
   cmDefinitions Closure() const;
 
   /** Compute the set of all defined keys.  */
-  std::set<std::string> ClosureKeys() const;
+  std::vector<std::string> ClosureKeys() const;
 
 private:
   // String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 47bc36d..d565f7d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -117,7 +117,7 @@ public:
     return this->VarStack.back().LocalKeys();
   }
 
-  std::set<std::string> ClosureKeys() const
+  std::vector<std::string> ClosureKeys() const
   {
     return this->VarStack.back().ClosureKeys();
   }
@@ -2519,8 +2519,7 @@ std::vector<std::string> cmMakefile
   std::vector<std::string> res;
   if ( !cacheonly )
     {
-    std::set<std::string> definitions = this->Internal->ClosureKeys();
-    res.insert(res.end(), definitions.begin(), definitions.end());
+    res = this->Internal->ClosureKeys();
     }
   std::vector<std::string> cacheKeys =
       this->GetState()->GetCacheEntryKeys();

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9743e487686230f2719c787597c0f0347c25d9c3
commit 9743e487686230f2719c787597c0f0347c25d9c3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:38:09 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:38:09 2015 +0200

    cmDefinitions: Inline GetClosureKeys implementation.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 7521f62..1fa07d9 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -108,14 +108,7 @@ std::set<std::string> cmDefinitions::ClosureKeys() const
 {
   std::set<std::string> defined;
   std::set<std::string> undefined;
-  this->ClosureKeys(defined, undefined);
-  return defined;
-}
 
-//----------------------------------------------------------------------------
-void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
-                                std::set<std::string>& undefined) const
-{
   cmDefinitions const* up = this;
 
   while (up)
@@ -134,4 +127,5 @@ void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
       }
     up = this->Up;
     }
+  return defined;
 }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index caca127..407fab3 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -82,10 +82,6 @@ private:
   cmDefinitions(ClosureTag const&, cmDefinitions const* root);
   void ClosureImpl(std::set<std::string>& undefined,
                    cmDefinitions const* defs);
-
-  // Implementation of ClosureKeys() method.
-  void ClosureKeys(std::set<std::string>& defined,
-                   std::set<std::string>& undefined) const;
 };
 
 #endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b9910cb776d49e82149fcf5a02a78b13b4177059
commit b9910cb776d49e82149fcf5a02a78b13b4177059
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 11:38:08 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:11:51 2015 +0200

    cmDefinitions: Replace ClosureKeys recursion with looping.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 1b9a6a5..7521f62 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -116,22 +116,22 @@ std::set<std::string> cmDefinitions::ClosureKeys() const
 void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
                                 std::set<std::string>& undefined) const
 {
-  // Consider local definitions.
-  for(MapType::const_iterator mi = this->Map.begin();
-      mi != this->Map.end(); ++mi)
+  cmDefinitions const* up = this;
+
+  while (up)
     {
-    // Use this key if it is not already set or unset.
-    if(defined.find(mi->first) == defined.end() &&
-       undefined.find(mi->first) == undefined.end())
+    // Consider local definitions.
+    for(MapType::const_iterator mi = up->Map.begin();
+        mi != up->Map.end(); ++mi)
       {
-      std::set<std::string>& m = mi->second.Exists? defined : undefined;
-      m.insert(mi->first);
+      // Use this key if it is not already set or unset.
+      if(defined.find(mi->first) == defined.end() &&
+         undefined.find(mi->first) == undefined.end())
+        {
+        std::set<std::string>& m = mi->second.Exists? defined : undefined;
+        m.insert(mi->first);
+        }
       }
-    }
-
-  // Traverse parents.
-  if(cmDefinitions const* up = this->Up)
-    {
-    up->ClosureKeys(defined, undefined);
+    up = this->Up;
     }
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a55719eb01158838ea550c6dfb986121fe21267b
commit a55719eb01158838ea550c6dfb986121fe21267b
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:08:30 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:10:53 2015 +0200

    cmDefinitions: Inline GetInternal into Get.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 528f362..1b9a6a5 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -20,7 +20,7 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 }
 
 //----------------------------------------------------------------------------
-std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
+std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
 {
   MapType::const_iterator i = this->Map.find(key);
   std::pair<const char*, bool> result(0, false);
@@ -32,12 +32,6 @@ std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
 }
 
 //----------------------------------------------------------------------------
-std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
-{
-  return this->GetInternal(key);
-}
-
-//----------------------------------------------------------------------------
 void cmDefinitions::Set(const std::string& key, const char* value)
 {
   Def def(value);
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 31f3fef..caca127 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -77,9 +77,6 @@ private:
 #endif
   MapType Map;
 
-  // Internal query and update methods.
-  std::pair<const char*, bool> GetInternal(const std::string& key);
-
   // Implementation of Closure() method.
   struct ClosureTag {};
   cmDefinitions(ClosureTag const&, cmDefinitions const* root);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=01b0b763640048dab6b69e9b6a4b67dfd16d1d75
commit 01b0b763640048dab6b69e9b6a4b67dfd16d1d75
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:10:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:10:53 2015 +0200

    cmDefinitions: Externalize the stack loop for the Get method.
    
    Use a temporary vector to traverse the stack backwards.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 64d8ffc..528f362 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -32,28 +32,9 @@ std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
+std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
 {
-  std::vector<cmDefinitions*> ups;
-  cmDefinitions* up = this;
-  std::pair<const char*, bool> result(0, false);
-  while (up)
-    {
-    result = up->GetInternal(key);
-    if(result.second)
-      {
-      break;
-      }
-    ups.push_back(up);
-    up = up->Up;
-    }
-  // Store the result in intermediate scopes.
-  for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
-       it != ups.end(); ++it)
-    {
-    (*it)->Set(key, result.first);
-    }
-  return result.first;
+  return this->GetInternal(key);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index a90c8ba..31f3fef 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -35,7 +35,7 @@ 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);
+  std::pair<const char*, bool> Get(const std::string& key);
 
   /** Set (or unset if null) a value associated with a key.  */
   void Set(const std::string& key, const char* value);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7b7e3e0..47bc36d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -68,7 +68,30 @@ public:
 
   const char* GetDefinition(std::string const& name)
   {
-    return this->VarStack.back().Get(name);
+    std::vector<cmDefinitions*> defPtrs;
+    defPtrs.reserve(this->VarStack.size());
+    for (std::list<cmDefinitions>::iterator it = this->VarStack.begin();
+        it != this->VarStack.end(); ++it)
+      {
+      defPtrs.push_back(&*it);
+      }
+    std::pair<const char*, bool> result(0, false);
+    std::vector<cmDefinitions*>::const_reverse_iterator it = defPtrs.rbegin();
+    for ( ; it != defPtrs.rend(); ++it)
+      {
+      result = (*it)->Get(name);
+      if(result.second)
+        {
+        break;
+        }
+      }
+    std::vector<cmDefinitions*>::const_reverse_iterator last = it;
+    // Store the result in intermediate scopes.
+    for (it = defPtrs.rbegin(); it != last; ++it)
+      {
+      (*it)->Set(name, result.first);
+      }
+    return result.first;
   }
 
   void SetDefinition(std::string const& name, std::string const& value)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=728010ec3e62f1ee57a3d77b9693b3b0d09b7c92
commit 728010ec3e62f1ee57a3d77b9693b3b0d09b7c92
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:10:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:10:53 2015 +0200

    cmDefinitions: Extract loop from GetInternal to Get.
    
    Remove now-unused NoDef static member.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 35e36b4..64d8ffc 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -14,26 +14,34 @@
 #include <assert.h>
 
 //----------------------------------------------------------------------------
-cmDefinitions::Def cmDefinitions::NoDef;
-
-//----------------------------------------------------------------------------
 cmDefinitions::cmDefinitions(cmDefinitions* parent)
   : Up(parent)
 {
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::GetInternal(const std::string& key)
+std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
+{
+  MapType::const_iterator i = this->Map.find(key);
+  std::pair<const char*, bool> result(0, false);
+  if(i != this->Map.end())
+    {
+    result = std::make_pair(i->second.Exists ? i->second.c_str() : 0, true);
+    }
+  return result;
+}
+
+//----------------------------------------------------------------------------
+const char* cmDefinitions::Get(const std::string& key)
 {
   std::vector<cmDefinitions*> ups;
-  Def def = this->NoDef;
   cmDefinitions* up = this;
+  std::pair<const char*, bool> result(0, false);
   while (up)
     {
-    MapType::const_iterator i = up->Map.find(key);
-    if(i != up->Map.end())
+    result = up->GetInternal(key);
+    if(result.second)
       {
-      def = i->second;
       break;
       }
     ups.push_back(up);
@@ -43,15 +51,9 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    (*it)->Set(key, def.Exists? def.c_str() : 0);
+    (*it)->Set(key, result.first);
     }
-  return def.Exists? def.c_str() : 0;
-}
-
-//----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
-{
-  return this->GetInternal(key);
+  return result.first;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index f2c71c5..a90c8ba 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -65,7 +65,6 @@ private:
     Def(Def const& d): std_string(d), Exists(d.Exists) {}
     bool Exists;
   };
-  static Def NoDef;
 
   // Parent scope, if any.
   cmDefinitions* Up;
@@ -79,7 +78,7 @@ private:
   MapType Map;
 
   // Internal query and update methods.
-  const char* GetInternal(const std::string& key);
+  std::pair<const char*, bool> GetInternal(const std::string& key);
 
   // Implementation of Closure() method.
   struct ClosureTag {};

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c1735a5500aebd55d8ed8e854a76334ad3d6606
commit 6c1735a5500aebd55d8ed8e854a76334ad3d6606
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:28:19 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:10:52 2015 +0200

    cmDefinitions: Use Set API in Get implementation.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 3cdeb07..35e36b4 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -43,7 +43,7 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    (*it)->Map[key] = def;
+    (*it)->Set(key, def.Exists? def.c_str() : 0);
     }
   return def.Exists? def.c_str() : 0;
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a56334284c9753101f0236c07b23f7b38bc8a98e
commit a56334284c9753101f0236c07b23f7b38bc8a98e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:09:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 15:09:11 2015 +0200

    cmDefinitions: Use map::operator[] in Get.
    
    The key is not already in the map.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 3ea2c36..3cdeb07 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -43,7 +43,7 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    (*it)->Map.insert(MapType::value_type(key, def));
+    (*it)->Map[key] = def;
     }
   return def.Exists? def.c_str() : 0;
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d627a25883454d3c304c7651ef38a4cf98d7c4d
commit 2d627a25883454d3c304c7651ef38a4cf98d7c4d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:02:25 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 14:38:36 2015 +0200

    cmDefinitions: Simplify API of GetInternal.
    
    Remove need to keep iterator over loops.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 8705dfa..3ea2c36 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -23,16 +23,14 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+const char* cmDefinitions::GetInternal(const std::string& key)
 {
   std::vector<cmDefinitions*> ups;
   Def def = this->NoDef;
-  MapType::const_iterator i;
   cmDefinitions* up = this;
   while (up)
     {
-    i = up->Map.find(key);
+    MapType::const_iterator i = up->Map.find(key);
     if(i != up->Map.end())
       {
       def = i->second;
@@ -45,16 +43,15 @@ cmDefinitions::GetInternal(const std::string& key)
   for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    i = (*it)->Map.insert(MapType::value_type(key, def)).first;
+    (*it)->Map.insert(MapType::value_type(key, def));
     }
-  return i->second;
+  return def.Exists? def.c_str() : 0;
 }
 
 //----------------------------------------------------------------------------
 const char* cmDefinitions::Get(const std::string& key)
 {
-  Def const& def = this->GetInternal(key);
-  return def.Exists? def.c_str() : 0;
+  return this->GetInternal(key);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 13f885d..f2c71c5 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -79,7 +79,7 @@ private:
   MapType Map;
 
   // Internal query and update methods.
-  Def const& GetInternal(const std::string& key);
+  const char* GetInternal(const std::string& key);
 
   // Implementation of Closure() method.
   struct ClosureTag {};

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9a2f454f3ac20af811a52dc41bfbb4ccaddbff46
commit 9a2f454f3ac20af811a52dc41bfbb4ccaddbff46
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:48:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 14:36:54 2015 +0200

    cmDefinitions: Remove conditionals before loop.
    
    They are now redundant.
    
    In the previous code, we knew that this->Map did not contain the
    searched value, so we stored 'this' in the ups list.  Now we don't
    know that prior to the loop.  Only cmDefinitions which do not
    contain the value should be in the ups list.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 91107b1..8705dfa 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -26,19 +26,10 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 cmDefinitions::Def const&
 cmDefinitions::GetInternal(const std::string& key)
 {
-  MapType::const_iterator i = this->Map.find(key);
-  if(i != this->Map.end())
-    {
-    return i->second;
-    }
-  cmDefinitions* up = this->Up;
-  if(!up)
-    {
-    return this->NoDef;
-    }
   std::vector<cmDefinitions*> ups;
-  ups.push_back(this);
   Def def = this->NoDef;
+  MapType::const_iterator i;
+  cmDefinitions* up = this;
   while (up)
     {
     i = up->Map.find(key);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=00d298f56df5a2fbed9a3012dfae936e2f57459d
commit 00d298f56df5a2fbed9a3012dfae936e2f57459d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:19:42 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 13:46:54 2015 +0200

    cmDefinitions: Replace GetInternal recursion with looping.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 34ba509..91107b1 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -36,9 +36,27 @@ cmDefinitions::GetInternal(const std::string& key)
     {
     return this->NoDef;
     }
-  // 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;
+  std::vector<cmDefinitions*> ups;
+  ups.push_back(this);
+  Def def = this->NoDef;
+  while (up)
+    {
+    i = up->Map.find(key);
+    if(i != up->Map.end())
+      {
+      def = i->second;
+      break;
+      }
+    ups.push_back(up);
+    up = up->Up;
+    }
+  // Store the result in intermediate scopes.
+  for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
+       it != ups.end(); ++it)
+    {
+    i = (*it)->Map.insert(MapType::value_type(key, def)).first;
+    }
+  return i->second;
 }
 
 //----------------------------------------------------------------------------

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=22f2bcc62b0c38f2cd6ca4ee5ccc367a9594a1f6
commit 22f2bcc62b0c38f2cd6ca4ee5ccc367a9594a1f6
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:39:53 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 13:46:54 2015 +0200

    cmDefinitions: Invert conditional code.
    
    Return the simple case first.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 032a96e..34ba509 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -31,13 +31,14 @@ cmDefinitions::GetInternal(const std::string& key)
     {
     return i->second;
     }
-  if(cmDefinitions* up = this->Up)
+  cmDefinitions* up = this->Up;
+  if(!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;
+    return this->NoDef;
     }
-  return this->NoDef;
+  // 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;
 }
 
 //----------------------------------------------------------------------------

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca907da953118b4dc360845024523fad81c8cb7f
commit ca907da953118b4dc360845024523fad81c8cb7f
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 16:36:48 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 13:46:53 2015 +0200

    cmDefinitions: Externalize the Set logic.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 58500c9..032a96e 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -11,6 +11,8 @@
 ============================================================================*/
 #include "cmDefinitions.h"
 
+#include <assert.h>
+
 //----------------------------------------------------------------------------
 cmDefinitions::Def cmDefinitions::NoDef;
 
@@ -49,16 +51,7 @@ const char* cmDefinitions::Get(const std::string& key)
 void cmDefinitions::Set(const std::string& key, const char* value)
 {
   Def def(value);
-  if(this->Up || def.Exists)
-    {
-    // In lower scopes we store keys, defined or not.
-    this->Map[key] = def;
-    }
-  else
-    {
-    // In the top-most scope we need not store undefined keys.
-    this->Map.erase(key);
-    }
+  this->Map[key] = def;
 }
 
 void cmDefinitions::Erase(const std::string& key)
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d767802..7b7e3e0 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -78,7 +78,15 @@ public:
 
   void RemoveDefinition(std::string const& name)
   {
-    this->VarStack.back().Set(name, 0);
+    if (this->VarStack.size() > 1)
+      {
+      // In lower scopes we store keys, defined or not.
+      this->VarStack.back().Set(name, 0);
+      }
+    else
+      {
+      this->VarStack.back().Erase(name);
+      }
   }
 
   std::set<std::string> LocalKeys() const

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=90ff34a130ed2946e22955d840a025042a99a50c
commit 90ff34a130ed2946e22955d840a025042a99a50c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 16:33:26 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 13:46:25 2015 +0200

    cmDefinitions: Add an Erase method.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index abb46b3..58500c9 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -61,6 +61,11 @@ void cmDefinitions::Set(const std::string& key, const char* value)
     }
 }
 
+void cmDefinitions::Erase(const std::string& key)
+{
+  this->Map.erase(key);
+}
+
 //----------------------------------------------------------------------------
 std::set<std::string> cmDefinitions::LocalKeys() const
 {
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 83cd0d9..13f885d 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -40,6 +40,8 @@ public:
   /** Set (or unset if null) a value associated with a key.  */
   void Set(const std::string& key, const char* value);
 
+  void Erase(const std::string& key);
+
   /** Get the set of all local keys.  */
   std::set<std::string> LocalKeys() const;
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb3ba073ad90836738a60c3dabea951d064a5952
commit fb3ba073ad90836738a60c3dabea951d064a5952
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 11:33:47 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 13:46:25 2015 +0200

    cmDefinitions: Inline SetInternal method.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index d5f6ebc..abb46b3 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -39,9 +39,16 @@ cmDefinitions::GetInternal(const std::string& key)
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions::Def const&
-cmDefinitions::SetInternal(const std::string& key, Def const& def)
+const char* cmDefinitions::Get(const std::string& key)
 {
+  Def const& def = this->GetInternal(key);
+  return def.Exists? def.c_str() : 0;
+}
+
+//----------------------------------------------------------------------------
+void cmDefinitions::Set(const std::string& key, const char* value)
+{
+  Def def(value);
   if(this->Up || def.Exists)
     {
     // In lower scopes we store keys, defined or not.
@@ -55,19 +62,6 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def)
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
-{
-  Def const& def = this->GetInternal(key);
-  return def.Exists? def.c_str() : 0;
-}
-
-//----------------------------------------------------------------------------
-void cmDefinitions::Set(const std::string& key, const char* value)
-{
-  this->SetInternal(key, Def(value));
-}
-
-//----------------------------------------------------------------------------
 std::set<std::string> cmDefinitions::LocalKeys() const
 {
   std::set<std::string> keys;
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 690df1f..83cd0d9 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -78,7 +78,6 @@ private:
 
   // Internal query and update methods.
   Def const& GetInternal(const std::string& key);
-  Def const& SetInternal(const std::string& key, Def const& def);
 
   // Implementation of Closure() method.
   struct ClosureTag {};

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27b97998d0c180c1cf55a22ad424a8bad9be4428
commit 27b97998d0c180c1cf55a22ad424a8bad9be4428
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 16:29:54 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 13:46:25 2015 +0200

    cmDefinitions: Remove unused Set return value.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 6a27659..d5f6ebc 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -45,13 +45,12 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def)
   if(this->Up || def.Exists)
     {
     // In lower scopes we store keys, defined or not.
-    return (this->Map[key] = def);
+    this->Map[key] = def;
     }
   else
     {
     // In the top-most scope we need not store undefined keys.
     this->Map.erase(key);
-    return this->NoDef;
     }
 }
 
@@ -63,10 +62,9 @@ const char* cmDefinitions::Get(const std::string& key)
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::Set(const std::string& key, const char* value)
+void cmDefinitions::Set(const std::string& key, const char* value)
 {
-  Def const& def = this->SetInternal(key, Def(value));
-  return def.Exists? def.c_str() : 0;
+  this->SetInternal(key, Def(value));
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index ab588ee..690df1f 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -38,7 +38,7 @@ public:
   const char* Get(const std::string& key);
 
   /** Set (or unset if null) a value associated with a key.  */
-  const char* Set(const std::string& key, const char* value);
+  void Set(const std::string& key, const char* value);
 
   /** Get the set of all local keys.  */
   std::set<std::string> LocalKeys() const;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=269d3e0246f57e8c0bc49acdfd2bdebbf626d635
commit 269d3e0246f57e8c0bc49acdfd2bdebbf626d635
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 17:21:51 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 13:43:08 2015 +0200

    cmMakefile: Remove stack adaptor for the VarStack.
    
    The purpose of the stack is to allow access only to the top of it.  Access
    to items which are not at the top is needed, so cmDefinitions objects
    get a Parent pointer.  Because that Parent pointer must not be left
    dangling, the stack must be implemented with a linked list.
    
    These are all problems resulting from the incorrect use of stack in the
    first place as it is not a suitable interface for what is needed here.  Remove
    it now.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9da01db..d767802 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -46,7 +46,7 @@
 class cmMakefile::Internals
 {
 public:
-  std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack;
+  std::list<cmDefinitions> VarStack;
   std::stack<std::set<std::string> > VarInitStack;
   std::stack<std::set<std::string> > VarUsageStack;
   bool IsSourceFileTryCompile;
@@ -56,49 +56,49 @@ public:
     cmDefinitions* parent = 0;
     if (!this->VarStack.empty())
       {
-      parent = &this->VarStack.top();
+      parent = &this->VarStack.back();
       }
-    this->VarStack.push(cmDefinitions(parent));
+    this->VarStack.push_back(cmDefinitions(parent));
   }
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    this->VarStack.top() = parent->Internal->VarStack.top().Closure();
+    this->VarStack.back() = parent->Internal->VarStack.back().Closure();
   }
 
   const char* GetDefinition(std::string const& name)
   {
-    return this->VarStack.top().Get(name);
+    return this->VarStack.back().Get(name);
   }
 
   void SetDefinition(std::string const& name, std::string const& value)
   {
-    this->VarStack.top().Set(name, value.c_str());
+    this->VarStack.back().Set(name, value.c_str());
   }
 
   void RemoveDefinition(std::string const& name)
   {
-    this->VarStack.top().Set(name, 0);
+    this->VarStack.back().Set(name, 0);
   }
 
   std::set<std::string> LocalKeys() const
   {
-    return this->VarStack.top().LocalKeys();
+    return this->VarStack.back().LocalKeys();
   }
 
   std::set<std::string> ClosureKeys() const
   {
-    return this->VarStack.top().ClosureKeys();
+    return this->VarStack.back().ClosureKeys();
   }
 
   void PopDefinitions()
   {
-    this->VarStack.pop();
+    this->VarStack.pop_back();
   }
 
   bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
   {
-    cmDefinitions& cur = this->VarStack.top();
+    cmDefinitions& cur = this->VarStack.back();
     if(cmDefinitions* up = cur.GetParent())
       {
       // First localize the definition in the current scope.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=be90997deffcf5a780abc7e0f9d574c02ec372b3
commit be90997deffcf5a780abc7e0f9d574c02ec372b3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 16:03:04 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 11:31:10 2015 +0200

    cmMakefile: Use the Internal class to enclose the VarStack.
    
    Put knowledge of the implementation details in one place.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c77a90c..9da01db 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -50,16 +50,92 @@ public:
   std::stack<std::set<std::string> > VarInitStack;
   std::stack<std::set<std::string> > VarUsageStack;
   bool IsSourceFileTryCompile;
+
+  void PushDefinitions()
+  {
+    cmDefinitions* parent = 0;
+    if (!this->VarStack.empty())
+      {
+      parent = &this->VarStack.top();
+      }
+    this->VarStack.push(cmDefinitions(parent));
+  }
+
+  void InitializeDefinitions(cmMakefile* parent)
+  {
+    this->VarStack.top() = parent->Internal->VarStack.top().Closure();
+  }
+
+  const char* GetDefinition(std::string const& name)
+  {
+    return this->VarStack.top().Get(name);
+  }
+
+  void SetDefinition(std::string const& name, std::string const& value)
+  {
+    this->VarStack.top().Set(name, value.c_str());
+  }
+
+  void RemoveDefinition(std::string const& name)
+  {
+    this->VarStack.top().Set(name, 0);
+  }
+
+  std::set<std::string> LocalKeys() const
+  {
+    return this->VarStack.top().LocalKeys();
+  }
+
+  std::set<std::string> ClosureKeys() const
+  {
+    return this->VarStack.top().ClosureKeys();
+  }
+
+  void PopDefinitions()
+  {
+    this->VarStack.pop();
+  }
+
+  bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
+  {
+    cmDefinitions& cur = this->VarStack.top();
+    if(cmDefinitions* up = cur.GetParent())
+      {
+      // First localize the definition in the current scope.
+      cur.Get(var);
+
+      // Now update the definition in the parent scope.
+      up->Set(var, varDef);
+      }
+    else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
+      {
+      // Update the definition in the parent directory top scope.  This
+      // directory's scope was initialized by the closure of the parent
+      // scope, so we do not need to localize the definition first.
+      cmMakefile* parent = plg->GetMakefile();
+      if (varDef)
+        {
+        parent->AddDefinition(var, varDef);
+        }
+      else
+        {
+        parent->RemoveDefinition(var);
+        }
+      }
+    else
+      {
+      return false;
+      }
+    return true;
+  }
 };
 
 // default is not to be building executables
 cmMakefile::cmMakefile(): Internal(new Internals)
 {
-  const cmDefinitions& defs = cmDefinitions();
-  const std::set<std::string> globalKeys = defs.LocalKeys();
-  this->Internal->VarStack.push(defs);
-  this->Internal->VarInitStack.push(globalKeys);
-  this->Internal->VarUsageStack.push(globalKeys);
+  this->Internal->PushDefinitions();
+  this->Internal->VarInitStack.push(std::set<std::string>());
+  this->Internal->VarUsageStack.push(std::set<std::string>());
   this->Internal->IsSourceFileTryCompile = false;
 
   // Initialize these first since AddDefaultDefinitions calls AddDefinition
@@ -1499,7 +1575,7 @@ void cmMakefile::InitializeFromParent()
   cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
 
   // Initialize definitions with the closure of the parent scope.
-  this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure();
+  this->Internal->InitializeDefinitions(parent);
 
   this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
                       this->GetCurrentSourceDirectory());
@@ -1699,7 +1775,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
     return;
     }
 
-  this->Internal->VarStack.top().Set(name, value);
+  this->Internal->SetDefinition(name, value);
   if (!this->Internal->VarUsageStack.empty() &&
       this->VariableInitialized(name))
     {
@@ -1769,13 +1845,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
   this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0,
                                           doc, type);
   // if there was a definition then remove it
-  this->Internal->VarStack.top().Set(name, 0);
+  this->Internal->RemoveDefinition(name);
 }
 
 
 void cmMakefile::AddDefinition(const std::string& name, bool value)
 {
-  this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
+  this->Internal->SetDefinition(name, value ? "ON" : "OFF");
   if (!this->Internal->VarUsageStack.empty() &&
       this->VariableInitialized(name))
     {
@@ -1799,8 +1875,7 @@ void cmMakefile::CheckForUnusedVariables() const
     {
     return;
     }
-  const cmDefinitions& defs = this->Internal->VarStack.top();
-  const std::set<std::string>& locals = defs.LocalKeys();
+  const std::set<std::string>& locals = this->Internal->LocalKeys();
   std::set<std::string>::const_iterator it = locals.begin();
   for (; it != locals.end(); ++it)
     {
@@ -1874,7 +1949,7 @@ void cmMakefile::CheckForUnused(const char* reason,
 
 void cmMakefile::RemoveDefinition(const std::string& name)
 {
-  this->Internal->VarStack.top().Set(name, 0);
+  this->Internal->RemoveDefinition(name);
   if (!this->Internal->VarUsageStack.empty() &&
       this->VariableInitialized(name))
     {
@@ -2347,7 +2422,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
 
 bool cmMakefile::IsDefinitionSet(const std::string& name) const
 {
-  const char* def = this->Internal->VarStack.top().Get(name);
+  const char* def = this->Internal->GetDefinition(name);
   this->Internal->VarUsageStack.top().insert(name);
   if(!def)
     {
@@ -2373,7 +2448,7 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
     {
     this->Internal->VarUsageStack.top().insert(name);
     }
-  const char* def = this->Internal->VarStack.top().Get(name);
+  const char* def = this->Internal->GetDefinition(name);
   if(!def)
     {
     def = this->GetState()->GetInitializedCacheValue(name);
@@ -2413,8 +2488,7 @@ std::vector<std::string> cmMakefile
   std::vector<std::string> res;
   if ( !cacheonly )
     {
-    std::set<std::string> definitions =
-        this->Internal->VarStack.top().ClosureKeys();
+    std::set<std::string> definitions = this->Internal->ClosureKeys();
     res.insert(res.end(), definitions.begin(), definitions.end());
     }
   std::vector<std::string> cacheKeys =
@@ -4329,10 +4403,9 @@ std::string cmMakefile::GetListFileStack() const
 
 void cmMakefile::PushScope()
 {
-  cmDefinitions* parent = &this->Internal->VarStack.top();
+  this->Internal->PushDefinitions();
   const std::set<std::string>& init = this->Internal->VarInitStack.top();
   const std::set<std::string>& usage = this->Internal->VarUsageStack.top();
-  this->Internal->VarStack.push(cmDefinitions(parent));
   this->Internal->VarInitStack.push(init);
   this->Internal->VarUsageStack.push(usage);
 
@@ -4353,10 +4426,9 @@ void cmMakefile::PopScope()
 
   this->PopLoopBlockBarrier();
 
-  cmDefinitions* current = &this->Internal->VarStack.top();
   std::set<std::string> init = this->Internal->VarInitStack.top();
   std::set<std::string> usage = this->Internal->VarUsageStack.top();
-  const std::set<std::string>& locals = current->LocalKeys();
+  const std::set<std::string>& locals = this->Internal->LocalKeys();
   // Remove initialization and usage information for variables in the local
   // scope.
   std::set<std::string>::const_iterator it = locals.begin();
@@ -4372,7 +4444,8 @@ void cmMakefile::PopScope()
       usage.erase(*it);
       }
     }
-  this->Internal->VarStack.pop();
+
+  this->Internal->PopDefinitions();
   this->Internal->VarInitStack.pop();
   this->Internal->VarUsageStack.pop();
   // Push initialization and usage up to the parent scope.
@@ -4387,31 +4460,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
     return;
     }
 
-  cmDefinitions& cur = this->Internal->VarStack.top();
-  if(cmDefinitions* up = cur.GetParent())
-    {
-    // First localize the definition in the current scope.
-    cur.Get(var);
-
-    // Now update the definition in the parent scope.
-    up->Set(var, varDef);
-    }
-  else if(cmLocalGenerator* plg = this->LocalGenerator->GetParent())
-    {
-    // Update the definition in the parent directory top scope.  This
-    // directory's scope was initialized by the closure of the parent
-    // scope, so we do not need to localize the definition first.
-    cmMakefile* parent = plg->GetMakefile();
-    if (varDef)
-      {
-      parent->AddDefinition(var, varDef);
-      }
-    else
-      {
-      parent->RemoveDefinition(var);
-      }
-    }
-  else
+  if (!this->Internal->RaiseScope(var, varDef, this))
     {
     std::ostringstream m;
     m << "Cannot set \"" << var << "\": current scope has no parent.";

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7692d983d48b4b8ec439e4f50044350dbc0fbc3a
commit 7692d983d48b4b8ec439e4f50044350dbc0fbc3a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 15:59:25 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Apr 25 15:59:25 2015 +0200

    cmDefinitions: Remove unused method.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index fe32dd5..6a27659 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -21,13 +21,6 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 }
 
 //----------------------------------------------------------------------------
-void cmDefinitions::Reset(cmDefinitions* parent)
-{
-  this->Up = parent;
-  this->Map.clear();
-}
-
-//----------------------------------------------------------------------------
 cmDefinitions::Def const&
 cmDefinitions::GetInternal(const std::string& key)
 {
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index a2f053f..ab588ee 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -30,9 +30,6 @@ public:
   /** Construct with the given parent scope.  */
   cmDefinitions(cmDefinitions* parent = 0);
 
-  /** Reset object as if newly constructed.  */
-  void Reset(cmDefinitions* parent = 0);
-
   /** Returns the parent scope, if any.  */
   cmDefinitions* GetParent() const { return this->Up; }
 

-----------------------------------------------------------------------

Summary of changes:
 Source/cmDefinitions.cxx |  155 ++++++++++++------------------------
 Source/cmDefinitions.h   |   45 ++++-------
 Source/cmMakefile.cxx    |  195 ++++++++++++++++++++++++++++++++++------------
 3 files changed, 208 insertions(+), 187 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list