[Cmake-commits] CMake branch, next, updated. v3.2.2-2379-ga15f5f3

Stephen Kelly steveire at gmail.com
Thu Apr 30 17:54:07 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  a15f5f34b55c1d22fe1104f2d76730db8b9d15f3 (commit)
       via  4dbe2e1eb4413e81786c4f5af85dc40895dab207 (commit)
       via  7557f2ede2696753c496d02b793b8a19bb164a93 (commit)
       via  be765f47a28b33e50a842143c5304ade07357150 (commit)
       via  c855e7cb89f679a5886e4eb54ebf6c8387c3b047 (commit)
       via  c1b6d1eec8b007f33de5b770cfce27f37bfe5de7 (commit)
       via  6c1c6977f70456f5c4ac692185bf65e654df73a0 (commit)
       via  f7a47e45dfdb7af3644899bcbe9a2f0b3470181f (commit)
       via  7d902b1a214ec806e75465cad0e1cf3439d384c3 (commit)
       via  eb9d21dc1ca6c57b4e3aa02782007891480e6911 (commit)
      from  4445ea0056c4adf2025fd653235c0244250a09c6 (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=a15f5f34b55c1d22fe1104f2d76730db8b9d15f3
commit a15f5f34b55c1d22fe1104f2d76730db8b9d15f3
Merge: 4445ea0 4dbe2e1
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Apr 30 17:54:06 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Apr 30 17:54:06 2015 -0400

    Merge topic 'refactor-cmDefinitions' into next
    
    4dbe2e1e cmDefinitions: Remove Parent pointer.
    7557f2ed cmDefinitions: Inline GetInternal into Get.
    be765f47 cmDefinitions: Externalize the stack loop for the Get method.
    c855e7cb cmDefinitions: Extract loop from GetInternal to Get.
    c1b6d1ee cmDefinitions: Use Set API in Get implementation.
    6c1c6977 cmDefinitions: Use map::operator[] in Get.
    f7a47e45 cmDefinitions: Simplify API of GetInternal.
    7d902b1a cmDefinitions: Remove conditionals before loop.
    eb9d21dc cmDefinitions: Replace GetInternal recursion with looping.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4dbe2e1eb4413e81786c4f5af85dc40895dab207
commit 4dbe2e1eb4413e81786c4f5af85dc40895dab207
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:19:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:17 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 7789e57..13ebf7b 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -12,12 +12,6 @@
 #include "cmDefinitions.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 6813c82..a698090 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -28,12 +28,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; }
-
   std::pair<const char*, bool> Get(const std::string& key);
 
   /** Set (or unset if null) a value associated with a key.  */
@@ -65,9 +59,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 b4c2101..445d774 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=7557f2ede2696753c496d02b793b8a19bb164a93
commit 7557f2ede2696753c496d02b793b8a19bb164a93
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:08:30 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:17 2015 +0200

    cmDefinitions: Inline GetInternal into Get.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index b422f51..7789e57 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -18,7 +18,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((const char*)0, false);
@@ -30,12 +30,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 b8f9fa3..6813c82 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -76,9 +76,6 @@ private:
 #endif
   MapType Map;
 
-  // Internal query and update methods.
-  std::pair<const char*, bool> GetInternal(const std::string& key);
-
   void MakeClosure(std::set<std::string>& undefined,
                    std::list<cmDefinitions>::const_reverse_iterator rbegin,
                    std::list<cmDefinitions>::const_reverse_iterator rend);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=be765f47a28b33e50a842143c5304ade07357150
commit be765f47a28b33e50a842143c5304ade07357150
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:10:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:17 2015 +0200

    cmDefinitions: Externalize the stack loop for the Get method.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 10f780c..b422f51 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -30,28 +30,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::list<cmDefinitions*> ups;
-  cmDefinitions* up = this;
-  std::pair<const char*, bool> result((const char*)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::list<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 ef83e4a..b8f9fa3 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -23,8 +23,7 @@
  * \brief Store a scope of variable definitions for CMake language.
  *
  * This stores the state of variable definitions (set or unset) for
- * one scope.  Sets are always local.  Gets search parent scopes
- * transitively and save results locally.
+ * one scope.  Sets are always local.
  */
 class cmDefinitions
 {
@@ -35,9 +34,7 @@ public:
   /** 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);
+  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 5686b1b..b4c2101 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -70,7 +70,23 @@ public:
 
   const char* GetDefinition(std::string const& name)
   {
-    return this->VarStack.back().Get(name);
+    std::pair<const char*, bool> result((const char*)0, false);
+    std::list<cmDefinitions>::reverse_iterator it = VarStack.rbegin();
+    for ( ; it != this->VarStack.rend(); ++it)
+      {
+      result = it->Get(name);
+      if(result.second)
+        {
+        break;
+        }
+      }
+    std::list<cmDefinitions>::reverse_iterator last = it;
+    // Store the result in intermediate scopes.
+    for (it = this->VarStack.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=c855e7cb89f679a5886e4eb54ebf6c8387c3b047
commit c855e7cb89f679a5886e4eb54ebf6c8387c3b047
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:10:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:17 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 c4b7437..10f780c 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -12,26 +12,34 @@
 #include "cmDefinitions.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((const char*)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::list<cmDefinitions*> ups;
-  Def def = this->NoDef;
   cmDefinitions* up = this;
+  std::pair<const char*, bool> result((const char*)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);
@@ -41,15 +49,9 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::list<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 18c9737..ef83e4a 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -67,7 +67,6 @@ private:
     Def(Def const& d): std_string(d), Exists(d.Exists) {}
     bool Exists;
   };
-  static Def NoDef;
 
   // Parent scope, if any.
   cmDefinitions* Up;
@@ -81,7 +80,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);
 
   void MakeClosure(std::set<std::string>& undefined,
                    std::list<cmDefinitions>::const_reverse_iterator rbegin,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c1b6d1eec8b007f33de5b770cfce27f37bfe5de7
commit c1b6d1eec8b007f33de5b770cfce27f37bfe5de7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:28:19 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:17 2015 +0200

    cmDefinitions: Use Set API in Get implementation.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 52f3412..c4b7437 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -41,7 +41,7 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::list<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=6c1c6977f70456f5c4ac692185bf65e654df73a0
commit 6c1c6977f70456f5c4ac692185bf65e654df73a0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:09:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:16 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 b6e3dd5..52f3412 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -41,7 +41,7 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::list<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=f7a47e45dfdb7af3644899bcbe9a2f0b3470181f
commit f7a47e45dfdb7af3644899bcbe9a2f0b3470181f
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:02:25 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:16 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 e623581..b6e3dd5 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -21,16 +21,14 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+const char* cmDefinitions::GetInternal(const std::string& key)
 {
   std::list<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;
@@ -43,16 +41,15 @@ cmDefinitions::GetInternal(const std::string& key)
   for (std::list<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 4c7f11f..18c9737 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -81,7 +81,7 @@ private:
   MapType Map;
 
   // Internal query and update methods.
-  Def const& GetInternal(const std::string& key);
+  const char* GetInternal(const std::string& key);
 
   void MakeClosure(std::set<std::string>& undefined,
                    std::list<cmDefinitions>::const_reverse_iterator rbegin,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d902b1a214ec806e75465cad0e1cf3439d384c3
commit 7d902b1a214ec806e75465cad0e1cf3439d384c3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:48:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:16 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 af7be90..e623581 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -24,19 +24,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::list<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=eb9d21dc1ca6c57b4e3aa02782007891480e6911
commit eb9d21dc1ca6c57b4e3aa02782007891480e6911
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:19:42 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 23:48:16 2015 +0200

    cmDefinitions: Replace GetInternal recursion with looping.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 61328be..af7be90 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -34,9 +34,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::list<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::list<cmDefinitions*>::const_iterator it = ups.begin();
+       it != ups.end(); ++it)
+    {
+    i = (*it)->Map.insert(MapType::value_type(key, def)).first;
+    }
+  return i->second;
 }
 
 //----------------------------------------------------------------------------

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list