[Cmake-commits] CMake branch, next, updated. v3.3.0-rc1-294-g9e18e80

Stephen Kelly steveire at gmail.com
Mon Jun 8 17:17:29 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  9e18e80a4235f5c8ff453057ff58349a1171fbac (commit)
       via  9477e5fc3796d4e9d4e66a78ebdcdd9855013a2c (commit)
       via  bc61da9da1eefbca0c01d53a0f409d38de5aa418 (commit)
       via  ff4fef0db4e585e543ea270bf099791c65692143 (commit)
       via  2ef3f2c2b67f47a8b649aa1c9b83cbfe4b81e674 (commit)
      from  c057802e482031a7a05e86e8fc0931c1ebd76ddb (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=9e18e80a4235f5c8ff453057ff58349a1171fbac
commit 9e18e80a4235f5c8ff453057ff58349a1171fbac
Merge: c057802 9477e5f
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Jun 8 17:17:28 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jun 8 17:17:28 2015 -0400

    Merge topic 'cmLinkedTree-definitions' into next
    
    9477e5fc cmMakefile: Decouple the container of cmDefinitions from scoping logic.
    bc61da9d cmDefinitions: Implement in terms of cmLinkedTree.
    ff4fef0d cmLinkedTree: Add operator* to the iterator.
    2ef3f2c2 cmMakefile: Extract InitializeVarStack method.

diff --cc Source/cmMakefile.cxx
index cb9611a,afc46ae..615bedc
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@@ -100,12 -129,10 +129,10 @@@ public
  
    bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
    {
-     std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin();
-     assert(it != this->VarStack.rend());
-     ++it;
-     if(it == this->VarStack.rend())
+     assert(this->VarScopeIter->Vars != this->VarTree.Root());
+     if(this->VarScopeIter->Parent == this->VarTree.Root())
        {
 -      cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent();
 +      cmLocalGenerator* plg = mf->LocalGenerator->GetParent();
        if(!plg)
          {
          return false;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9477e5fc3796d4e9d4e66a78ebdcdd9855013a2c
commit 9477e5fc3796d4e9d4e66a78ebdcdd9855013a2c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 31 11:26:05 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Jun 8 23:11:40 2015 +0200

    cmMakefile: Decouple the container of cmDefinitions from scoping logic.
    
    Maintain a Parent tree node for writing to in RaiseScope.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 8fc8e7c..afc46ae 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -45,73 +45,92 @@
 class cmMakefile::Internals
 {
 public:
+  struct VarScope
+  {
+    cmLinkedTree<cmDefinitions>::iterator Vars;
+    cmLinkedTree<cmDefinitions>::iterator Parent;
+  };
+
   cmLinkedTree<cmDefinitions> VarTree;
-  cmLinkedTree<cmDefinitions>::iterator VarTreeIter;
+  cmLinkedTree<VarScope> VarScopes;
+  cmLinkedTree<VarScope>::iterator VarScopeIter;
   bool IsSourceFileTryCompile;
 
   void PushDefinitions()
   {
-    assert(this->VarTreeIter.IsValid());
-    this->VarTreeIter = this->VarTree.Extend(this->VarTreeIter);
+    assert(this->VarScopeIter.IsValid());
+    assert(this->VarScopeIter->Vars.IsValid());
+    cmLinkedTree<cmDefinitions>::iterator origin =
+        this->VarScopeIter->Vars;
+    cmLinkedTree<cmDefinitions>::iterator parentScope =
+        this->VarTree.Extend(origin);
+    this->VarScopeIter->Vars = parentScope;
+    this->VarScopeIter = this->VarScopes.Extend(this->VarScopeIter);
+    this->VarScopeIter->Parent = parentScope;
+    this->VarScopeIter->Vars = this->VarTree.Extend(origin);
   }
 
-  void InitializeVarStack()
+  void InitializeVarScope()
   {
-    this->VarTreeIter = this->VarTree.Root();
-    this->PushDefinitions();
+    assert(!this->VarScopeIter.IsValid());
+    this->VarScopeIter = this->VarScopes.Extend(this->VarScopes.Root());
+    this->VarScopeIter->Vars = this->VarTree.Extend(this->VarTree.Root());
+    this->VarScopeIter->Parent = this->VarTree.Root();
   }
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    *this->VarTreeIter =
-        cmDefinitions::MakeClosure(parent->Internal->VarTreeIter,
+    assert(this->VarScopeIter.IsValid());
+    assert(this->VarScopeIter->Vars.IsValid());
+    *this->VarScopeIter->Vars =
+        cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars,
                                    parent->Internal->VarTree.Root());
   }
 
   const char* GetDefinition(std::string const& name)
   {
-    assert(this->VarTreeIter != this->VarTree.Root());
+    assert(this->VarScopeIter.IsValid());
+    assert(this->VarScopeIter->Vars.IsValid());
     return cmDefinitions::Get(name,
-                              this->VarTreeIter, this->VarTree.Root());
+                              this->VarScopeIter->Vars, this->VarTree.Root());
   }
 
   bool IsInitialized(std::string const& name)
   {
     return cmDefinitions::HasKey(name,
-                                 this->VarTreeIter, this->VarTree.Root());
+                              this->VarScopeIter->Vars, this->VarTree.Root());
   }
 
   void SetDefinition(std::string const& name, std::string const& value)
   {
-    this->VarTreeIter->Set(name, value.c_str());
+    this->VarScopeIter->Vars->Set(name, value.c_str());
   }
 
   void RemoveDefinition(std::string const& name)
   {
-    this->VarTreeIter->Set(name, 0);
+    this->VarScopeIter->Vars->Set(name, 0);
   }
 
   std::vector<std::string> UnusedKeys() const
   {
-    return this->VarTreeIter->UnusedKeys();
+    return this->VarScopeIter->Vars->UnusedKeys();
   }
 
   std::vector<std::string> ClosureKeys() const
   {
-    return cmDefinitions::ClosureKeys(this->VarTreeIter, this->VarTree.Root());
+    return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars,
+                                      this->VarTree.Root());
   }
 
   void PopDefinitions()
   {
-    ++this->VarTreeIter;
+    ++this->VarScopeIter;
   }
 
   bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
   {
-    cmLinkedTree<cmDefinitions>::iterator it = this->VarTreeIter;
-    assert(it != this->VarTree.Root());
-    ++it;
-    if(it == this->VarTree.Root())
+    assert(this->VarScopeIter->Vars != this->VarTree.Root());
+    if(this->VarScopeIter->Parent == this->VarTree.Root())
       {
       cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent();
       if(!plg)
@@ -133,10 +152,10 @@ public:
       return true;
       }
     // First localize the definition in the current scope.
-    cmDefinitions::Raise(var, this->VarTreeIter, this->VarTree.Root());
+    cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root());
 
     // Now update the definition in the parent scope.
-    it->Set(var, varDef);
+    this->VarScopeIter->Parent->Set(var, varDef);
     return true;
   }
 };
@@ -147,7 +166,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
     LocalGenerator(localGenerator),
     StateSnapshot(localGenerator->GetStateSnapshot())
 {
-  this->Internal->InitializeVarStack();
+  this->Internal->InitializeVarScope();
   this->Internal->IsSourceFileTryCompile = false;
 
   // Initialize these first since AddDefaultDefinitions calls AddDefinition

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc61da9da1eefbca0c01d53a0f409d38de5aa418
commit bc61da9da1eefbca0c01d53a0f409d38de5aa418
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat May 30 17:08:34 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Jun 8 23:10:09 2015 +0200

    cmDefinitions: Implement in terms of cmLinkedTree.
    
    Store the definitions in a cmLinkedTree in the cmMakefile.  This can
    be moved to cmState and then the tree will provide snapshotting
    possibilities.  It will also make the Closure copy created at
    the start of each cmMakefile unnecesarry.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 2dab169..b06fb5c 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -56,9 +56,9 @@ void cmDefinitions::Raise(const std::string& key,
 }
 
 bool cmDefinitions::HasKey(const std::string& key,
-                           StackConstIter begin, StackConstIter end)
+                           StackIter begin, StackIter end)
 {
-  for (StackConstIter it = begin; it != end; ++it)
+  for (StackIter it = begin; it != end; ++it)
     {
     MapType::const_iterator i = it->Map.find(key);
     if (i != it->Map.end())
@@ -94,12 +94,12 @@ std::vector<std::string> cmDefinitions::UnusedKeys() const
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin,
-                                         StackConstIter end)
+cmDefinitions cmDefinitions::MakeClosure(StackIter begin,
+                                         StackIter end)
 {
   cmDefinitions closure;
   std::set<std::string> undefined;
-  for (StackConstIter it = begin; it != end; ++it)
+  for (StackIter it = begin; it != end; ++it)
     {
     // Consider local definitions.
     for(MapType::const_iterator mi = it->Map.begin();
@@ -125,12 +125,12 @@ cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin,
 
 //----------------------------------------------------------------------------
 std::vector<std::string>
-cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end)
+cmDefinitions::ClosureKeys(StackIter begin, StackIter end)
 {
   std::set<std::string> bound;
   std::vector<std::string> defined;
 
-  for (StackConstIter it = begin; it != end; ++it)
+  for (StackIter it = begin; it != end; ++it)
     {
     defined.reserve(defined.size() + it->Map.size());
     for(MapType::const_iterator mi = it->Map.begin();
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 5fdcaab..411867c 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -13,6 +13,9 @@
 #define cmDefinitions_h
 
 #include "cmStandardIncludes.h"
+
+#include "cmLinkedTree.h"
+
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #ifdef CMake_HAVE_CXX11_UNORDERED_MAP
 #include <unordered_map>
@@ -32,26 +35,26 @@
  */
 class cmDefinitions
 {
-  typedef std::list<cmDefinitions>::reverse_iterator StackIter;
-  typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter;
+  typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
 public:
   static const char* Get(const std::string& key,
                          StackIter begin, StackIter end);
 
-  static void Raise(const std::string& key, StackIter begin, StackIter end);
+  static void Raise(const std::string& key,
+                    StackIter begin, StackIter end);
 
   static bool HasKey(const std::string& key,
-                     StackConstIter begin, StackConstIter end);
+                     StackIter begin, StackIter end);
 
   /** Set (or unset if null) a value associated with a key.  */
   void Set(const std::string& key, const char* value);
 
   std::vector<std::string> UnusedKeys() const;
 
-  static std::vector<std::string> ClosureKeys(StackConstIter begin,
-                                              StackConstIter end);
+  static std::vector<std::string> ClosureKeys(StackIter begin,
+                                              StackIter end);
 
-  static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end);
+  static cmDefinitions MakeClosure(StackIter begin, StackIter end);
 
 private:
   // String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2eff2bc..8fc8e7c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -45,70 +45,73 @@
 class cmMakefile::Internals
 {
 public:
-  std::list<cmDefinitions> VarStack;
+  cmLinkedTree<cmDefinitions> VarTree;
+  cmLinkedTree<cmDefinitions>::iterator VarTreeIter;
   bool IsSourceFileTryCompile;
 
   void PushDefinitions()
   {
-    this->VarStack.push_back(cmDefinitions());
+    assert(this->VarTreeIter.IsValid());
+    this->VarTreeIter = this->VarTree.Extend(this->VarTreeIter);
   }
 
   void InitializeVarStack()
   {
+    this->VarTreeIter = this->VarTree.Root();
     this->PushDefinitions();
   }
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    this->VarStack.back() =
-        cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(),
-                                   parent->Internal->VarStack.rend());
+    *this->VarTreeIter =
+        cmDefinitions::MakeClosure(parent->Internal->VarTreeIter,
+                                   parent->Internal->VarTree.Root());
   }
 
   const char* GetDefinition(std::string const& name)
   {
-    return cmDefinitions::Get(name, this->VarStack.rbegin(),
-                                    this->VarStack.rend());
+    assert(this->VarTreeIter != this->VarTree.Root());
+    return cmDefinitions::Get(name,
+                              this->VarTreeIter, this->VarTree.Root());
   }
 
   bool IsInitialized(std::string const& name)
   {
-    return cmDefinitions::HasKey(name, this->VarStack.rbegin(),
-                                 this->VarStack.rend());
+    return cmDefinitions::HasKey(name,
+                                 this->VarTreeIter, this->VarTree.Root());
   }
 
   void SetDefinition(std::string const& name, std::string const& value)
   {
-    this->VarStack.back().Set(name, value.c_str());
+    this->VarTreeIter->Set(name, value.c_str());
   }
 
   void RemoveDefinition(std::string const& name)
   {
-    this->VarStack.back().Set(name, 0);
+    this->VarTreeIter->Set(name, 0);
   }
 
   std::vector<std::string> UnusedKeys() const
   {
-    return this->VarStack.back().UnusedKeys();
+    return this->VarTreeIter->UnusedKeys();
   }
 
   std::vector<std::string> ClosureKeys() const
   {
-    return cmDefinitions::ClosureKeys(this->VarStack.rbegin(),
-                                      this->VarStack.rend());
+    return cmDefinitions::ClosureKeys(this->VarTreeIter, this->VarTree.Root());
   }
 
   void PopDefinitions()
   {
-    this->VarStack.pop_back();
+    ++this->VarTreeIter;
   }
 
   bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
   {
-    std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin();
-    assert(it != this->VarStack.rend());
+    cmLinkedTree<cmDefinitions>::iterator it = this->VarTreeIter;
+    assert(it != this->VarTree.Root());
     ++it;
-    if(it == this->VarStack.rend())
+    if(it == this->VarTree.Root())
       {
       cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent();
       if(!plg)
@@ -130,7 +133,7 @@ public:
       return true;
       }
     // First localize the definition in the current scope.
-    cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend());
+    cmDefinitions::Raise(var, this->VarTreeIter, this->VarTree.Root());
 
     // Now update the definition in the parent scope.
     it->Set(var, varDef);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff4fef0db4e585e543ea270bf099791c65692143
commit ff4fef0db4e585e543ea270bf099791c65692143
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Jun 8 20:09:55 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Jun 8 23:07:01 2015 +0200

    cmLinkedTree: Add operator* to the iterator.
    
    This is needed to make it possible to assign new definitions to
    a point in the tree.  This can be removed when that is not needed
    anymore.

diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index d2339c4..df00b30 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -87,6 +87,24 @@ public:
       return this->Tree->GetPointer(this->Position - 1);
     }
 
+    ReferenceType operator*() const
+    {
+      assert(this->Tree);
+      assert(this->Tree->UpPositions.size() == this->Tree->Data.size());
+      assert(this->Position <= this->Tree->Data.size());
+      assert(this->Position > 0);
+      return this->Tree->GetReference(this->Position - 1);
+    }
+
+    ReferenceType operator*()
+    {
+      assert(this->Tree);
+      assert(this->Tree->UpPositions.size() == this->Tree->Data.size());
+      assert(this->Position <= this->Tree->Data.size());
+      assert(this->Position > 0);
+      return this->Tree->GetReference(this->Position - 1);
+    }
+
     bool operator==(iterator other) const
     {
       assert(this->Tree);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2ef3f2c2b67f47a8b649aa1c9b83cbfe4b81e674
commit 2ef3f2c2b67f47a8b649aa1c9b83cbfe4b81e674
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Jun 8 20:04:24 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Jun 8 23:06:41 2015 +0200

    cmMakefile: Extract InitializeVarStack method.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a8b163a..2eff2bc 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -53,6 +53,11 @@ public:
     this->VarStack.push_back(cmDefinitions());
   }
 
+  void InitializeVarStack()
+  {
+    this->PushDefinitions();
+  }
+
   void InitializeDefinitions(cmMakefile* parent)
   {
     this->VarStack.back() =
@@ -139,7 +144,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
     LocalGenerator(localGenerator),
     StateSnapshot(localGenerator->GetStateSnapshot())
 {
-  this->Internal->PushDefinitions();
+  this->Internal->InitializeVarStack();
   this->Internal->IsSourceFileTryCompile = false;
 
   // Initialize these first since AddDefaultDefinitions calls AddDefinition

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

Summary of changes:
 Source/cmDefinitions.cxx |   14 ++++-----
 Source/cmDefinitions.h   |   17 ++++++-----
 Source/cmLinkedTree.h    |   18 ++++++++++++
 Source/cmMakefile.cxx    |   71 ++++++++++++++++++++++++++++++++--------------
 4 files changed, 84 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list