[Cmake-commits] CMake branch, next, updated. v3.3.0-rc1-420-g044833f

Stephen Kelly steveire at gmail.com
Wed Jun 10 15:21:14 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  044833f9862b3c5657aff6d5e939f6e1c6cef8ed (commit)
       via  043e3b04bedfa2050d023eb91e961dfe6a489c5c (commit)
      from  3acb236e86a081e522417b0881f87d08f904ee3d (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=044833f9862b3c5657aff6d5e939f6e1c6cef8ed
commit 044833f9862b3c5657aff6d5e939f6e1c6cef8ed
Merge: 3acb236 043e3b0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jun 10 15:21:13 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jun 10 15:21:13 2015 -0400

    Merge topic 'cmLinkedTree-definitions' into next
    
    043e3b04 Revert "cmMakefile: Extract InitializeVarStack method."


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=043e3b04bedfa2050d023eb91e961dfe6a489c5c
commit 043e3b04bedfa2050d023eb91e961dfe6a489c5c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jun 10 21:20:35 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Jun 10 21:20:47 2015 +0200

    Revert "cmMakefile: Extract InitializeVarStack method."
    
    This reverts commit 236dc270cc5092ac009a2b94294d02fdd72a1eb1.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index b06fb5c..2dab169 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,
-                           StackIter begin, StackIter end)
+                           StackConstIter begin, StackConstIter end)
 {
-  for (StackIter it = begin; it != end; ++it)
+  for (StackConstIter 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(StackIter begin,
-                                         StackIter end)
+cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin,
+                                         StackConstIter end)
 {
   cmDefinitions closure;
   std::set<std::string> undefined;
-  for (StackIter it = begin; it != end; ++it)
+  for (StackConstIter it = begin; it != end; ++it)
     {
     // Consider local definitions.
     for(MapType::const_iterator mi = it->Map.begin();
@@ -125,12 +125,12 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin,
 
 //----------------------------------------------------------------------------
 std::vector<std::string>
-cmDefinitions::ClosureKeys(StackIter begin, StackIter end)
+cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end)
 {
   std::set<std::string> bound;
   std::vector<std::string> defined;
 
-  for (StackIter it = begin; it != end; ++it)
+  for (StackConstIter 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 411867c..5fdcaab 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -13,9 +13,6 @@
 #define cmDefinitions_h
 
 #include "cmStandardIncludes.h"
-
-#include "cmLinkedTree.h"
-
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #ifdef CMake_HAVE_CXX11_UNORDERED_MAP
 #include <unordered_map>
@@ -35,26 +32,26 @@
  */
 class cmDefinitions
 {
-  typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
+  typedef std::list<cmDefinitions>::reverse_iterator StackIter;
+  typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter;
 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,
-                     StackIter begin, StackIter end);
+                     StackConstIter begin, StackConstIter 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(StackIter begin,
-                                              StackIter end);
+  static std::vector<std::string> ClosureKeys(StackConstIter begin,
+                                              StackConstIter end);
 
-  static cmDefinitions MakeClosure(StackIter begin, StackIter end);
+  static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end);
 
 private:
   // String with existence boolean.
diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index df00b30..d2339c4 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -87,24 +87,6 @@ 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);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index afc46ae..a8b163a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -45,92 +45,65 @@
 class cmMakefile::Internals
 {
 public:
-  struct VarScope
-  {
-    cmLinkedTree<cmDefinitions>::iterator Vars;
-    cmLinkedTree<cmDefinitions>::iterator Parent;
-  };
-
-  cmLinkedTree<cmDefinitions> VarTree;
-  cmLinkedTree<VarScope> VarScopes;
-  cmLinkedTree<VarScope>::iterator VarScopeIter;
+  std::list<cmDefinitions> VarStack;
   bool IsSourceFileTryCompile;
 
   void PushDefinitions()
   {
-    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 InitializeVarScope()
-  {
-    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();
+    this->VarStack.push_back(cmDefinitions());
   }
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    assert(this->VarScopeIter.IsValid());
-    assert(this->VarScopeIter->Vars.IsValid());
-    *this->VarScopeIter->Vars =
-        cmDefinitions::MakeClosure(parent->Internal->VarScopeIter->Vars,
-                                   parent->Internal->VarTree.Root());
+    this->VarStack.back() =
+        cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(),
+                                   parent->Internal->VarStack.rend());
   }
 
   const char* GetDefinition(std::string const& name)
   {
-    assert(this->VarScopeIter.IsValid());
-    assert(this->VarScopeIter->Vars.IsValid());
-    return cmDefinitions::Get(name,
-                              this->VarScopeIter->Vars, this->VarTree.Root());
+    return cmDefinitions::Get(name, this->VarStack.rbegin(),
+                                    this->VarStack.rend());
   }
 
   bool IsInitialized(std::string const& name)
   {
-    return cmDefinitions::HasKey(name,
-                              this->VarScopeIter->Vars, this->VarTree.Root());
+    return cmDefinitions::HasKey(name, this->VarStack.rbegin(),
+                                 this->VarStack.rend());
   }
 
   void SetDefinition(std::string const& name, std::string const& value)
   {
-    this->VarScopeIter->Vars->Set(name, value.c_str());
+    this->VarStack.back().Set(name, value.c_str());
   }
 
   void RemoveDefinition(std::string const& name)
   {
-    this->VarScopeIter->Vars->Set(name, 0);
+    this->VarStack.back().Set(name, 0);
   }
 
   std::vector<std::string> UnusedKeys() const
   {
-    return this->VarScopeIter->Vars->UnusedKeys();
+    return this->VarStack.back().UnusedKeys();
   }
 
   std::vector<std::string> ClosureKeys() const
   {
-    return cmDefinitions::ClosureKeys(this->VarScopeIter->Vars,
-                                      this->VarTree.Root());
+    return cmDefinitions::ClosureKeys(this->VarStack.rbegin(),
+                                      this->VarStack.rend());
   }
 
   void PopDefinitions()
   {
-    ++this->VarScopeIter;
+    this->VarStack.pop_back();
   }
 
   bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
   {
-    assert(this->VarScopeIter->Vars != this->VarTree.Root());
-    if(this->VarScopeIter->Parent == this->VarTree.Root())
+    std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin();
+    assert(it != this->VarStack.rend());
+    ++it;
+    if(it == this->VarStack.rend())
       {
       cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent();
       if(!plg)
@@ -152,10 +125,10 @@ public:
       return true;
       }
     // First localize the definition in the current scope.
-    cmDefinitions::Raise(var, this->VarScopeIter->Vars, this->VarTree.Root());
+    cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend());
 
     // Now update the definition in the parent scope.
-    this->VarScopeIter->Parent->Set(var, varDef);
+    it->Set(var, varDef);
     return true;
   }
 };
@@ -166,7 +139,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
     LocalGenerator(localGenerator),
     StateSnapshot(localGenerator->GetStateSnapshot())
 {
-  this->Internal->InitializeVarScope();
+  this->Internal->PushDefinitions();
   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, 36 insertions(+), 84 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list