[Cmake-commits] CMake branch, next, updated. v3.2.2-2385-gf255936

Stephen Kelly steveire at gmail.com
Thu Apr 30 19:20:37 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  f255936761560c10aadb7e0b22b4c6851278f61b (commit)
       via  b5e5acfbf45c4f234a1fa0a93bfdef91d11497ac (commit)
       via  5a305a353a20e447515ba866b31cf7c37149de9d (commit)
       via  d66e4374a0f9618e3a6560ff73c3a85cb733ab4c (commit)
      from  74b8c6e3c9c62d9df550fb20ef33ae3251f351cd (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=f255936761560c10aadb7e0b22b4c6851278f61b
commit f255936761560c10aadb7e0b22b4c6851278f61b
Merge: 74b8c6e b5e5acf
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Apr 30 19:20:34 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Apr 30 19:20:34 2015 -0400

    Merge topic 'refactor-cmDefinitions-Get' into next
    
    b5e5acfb cmDefinitions: Replace recursion with loop.
    5a305a35 cmDefinitions: Remove Parent pointer.
    d66e4374 cmDefinitions: Accept varStack pointers in Get API.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5e5acfbf45c4f234a1fa0a93bfdef91d11497ac
commit b5e5acfbf45c4f234a1fa0a93bfdef91d11497ac
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri May 1 01:13:38 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri May 1 01:13:38 2015 +0200

    cmDefinitions: Replace recursion with loop.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index ae01fd9..1d0e108 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -22,20 +22,27 @@ cmDefinitions::GetInternal(const std::string& key,
     std::list<cmDefinitions>::reverse_iterator rit,
     std::list<cmDefinitions>::reverse_iterator rend)
 {
-  assert(&*rit == this);
-  MapType::const_iterator i = this->Map.find(key);
-  if(i != this->Map.end())
+  std::list<cmDefinitions>::reverse_iterator rbegin = rit;
+  assert(rit != rend);
+  MapType::const_iterator i;
+  Def def = this->NoDef;
+  for ( ; rit != rend; ++rit)
     {
-    return i->second;
+    i = rit->Map.find(key);
+    if(i != rit->Map.end())
+      {
+      def = i->second;
+      break;
+      }
     }
-  ++rit;
-  if(rit == rend)
+
+  std::list<cmDefinitions>::reverse_iterator last = rit;
+  // Store the result in intermediate scopes.
+  for (rit = rbegin; rit != last; ++rit)
     {
-    return this->NoDef;
+    i = rit->Map.insert(MapType::value_type(key, def)).first;
     }
-  // Query the parent scope and store the result locally.
-  Def def = rit->GetInternal(key, rit, rend);
-  return this->Map.insert(MapType::value_type(key, def)).first->second;
+  return i->second;
 }
 
 //----------------------------------------------------------------------------

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5a305a353a20e447515ba866b31cf7c37149de9d
commit 5a305a353a20e447515ba866b31cf7c37149de9d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:19:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri May 1 01:00:10 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 b5a3a34..ae01fd9 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -17,12 +17,6 @@
 cmDefinitions::Def cmDefinitions::NoDef;
 
 //----------------------------------------------------------------------------
-cmDefinitions::cmDefinitions(cmDefinitions* parent)
-  : Up(parent)
-{
-}
-
-//----------------------------------------------------------------------------
 cmDefinitions::Def const&
 cmDefinitions::GetInternal(const std::string& key,
     std::list<cmDefinitions>::reverse_iterator rit,
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index ec78f09..8b78f2c 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -29,12 +29,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.  */
   const char* Get(const std::string& key,
@@ -71,9 +65,6 @@ private:
   };
   static Def NoDef;
 
-  // 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 ae7e564..b16d7e6 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=d66e4374a0f9618e3a6560ff73c3a85cb733ab4c
commit d66e4374a0f9618e3a6560ff73c3a85cb733ab4c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Apr 30 00:19:55 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri May 1 00:56:01 2015 +0200

    cmDefinitions: Accept varStack pointers in Get API.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 61328be..b5a3a34 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -11,6 +11,8 @@
 ============================================================================*/
 #include "cmDefinitions.h"
 
+#include <assert.h>
+
 //----------------------------------------------------------------------------
 cmDefinitions::Def cmDefinitions::NoDef;
 
@@ -22,27 +24,32 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 
 //----------------------------------------------------------------------------
 cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+cmDefinitions::GetInternal(const std::string& key,
+    std::list<cmDefinitions>::reverse_iterator rit,
+    std::list<cmDefinitions>::reverse_iterator rend)
 {
+  assert(&*rit == this);
   MapType::const_iterator i = this->Map.find(key);
   if(i != this->Map.end())
     {
     return i->second;
     }
-  cmDefinitions* up = this->Up;
-  if(!up)
+  ++rit;
+  if(rit == rend)
     {
     return this->NoDef;
     }
   // Query the parent scope and store the result locally.
-  Def def = up->GetInternal(key);
+  Def def = rit->GetInternal(key, rit, 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 rit,
+    std::list<cmDefinitions>::reverse_iterator rend)
 {
-  Def const& def = this->GetInternal(key);
+  Def const& def = this->GetInternal(key, rit, rend);
   return def.Exists? def.c_str() : 0;
 }
 
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4c7f11f..ec78f09 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 rit,
+                  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 rit,
+                         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)

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

Summary of changes:
 Source/cmDefinitions.cxx |   44 ++++++++++++++++++++++++++------------------
 Source/cmDefinitions.h   |   17 ++++++-----------
 Source/cmMakefile.cxx    |   10 +++-------
 3 files changed, 35 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list