[Cmake-commits] CMake branch, next, updated. v3.2.2-2316-gfc61a05

Stephen Kelly steveire at gmail.com
Wed Apr 29 16:52:47 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  fc61a05bcedf783768b6f39a8d45e9519064d987 (commit)
       via  aaaa65b6a5cdf227282a9d04bf5287413757ff03 (commit)
       via  f983d8913b3293f0f328811d243222c6e19c795e (commit)
       via  24885d4efa17d4232e266ef053899613c32fdeb7 (commit)
       via  012a75a00f060d6ca36cc9ffb97439a7ad526395 (commit)
       via  ca9fa77d5d34a993073cd5256d65f88cd2e1a28f (commit)
       via  78e1454ea09e9c568578e26971d6cd45b7fa39c7 (commit)
       via  818bf727c1eb4a500decb5856715a964c948242e (commit)
       via  5067ae41b03442a7dba9210595e782678835a3ff (commit)
       via  60200ca5088058c70282500994727f2017276df8 (commit)
       via  b43c162e99c7302ae81c746bc5aab1d9a64787b3 (commit)
      from  1bd5ae8f4b73be4b589ce89f8fa6b9d464a6ba3a (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=fc61a05bcedf783768b6f39a8d45e9519064d987
commit fc61a05bcedf783768b6f39a8d45e9519064d987
Merge: 1bd5ae8 aaaa65b
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Apr 29 16:52:46 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Apr 29 16:52:46 2015 -0400

    Merge topic 'refactor-cmDefinitions' into next
    
    aaaa65b6 cmMakefile: Remove stack adaptor for the VarStack.
    f983d891 cmDefinitions: Replace recursion with loop.
    24885d4e cmDefinitions: Replace private constructor with MakeClosure.
    012a75a0 cmDefinitions: Make ClosureKeys API vector-based.
    ca9fa77d cmDefinitions: Inline GetClosureKeys implementation.
    78e1454e cmDefinitions: Replace ClosureKeys recursion with looping.
    818bf727 cmDefinitions: Change LocalKeys to return a vector.
    5067ae41 cmDefinitions: Externalize the Set logic.
    60200ca5 cmDefinitions: Add an Erase method.
    b43c162e cmMakefile: Use the Internal class to enclose the VarStack.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aaaa65b6a5cdf227282a9d04bf5287413757ff03
commit aaaa65b6a5cdf227282a9d04bf5287413757ff03
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 17:21:51 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:51:47 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.
    
    The existence of the Parent pointer is a workaround for the inappropriate
    use of stack in the first place.  Remove it now.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index dbb355c..8cfb83a 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,24 +56,24 @@ 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().MakeClosure();
+    this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure();
   }
 
   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)
@@ -81,32 +81,32 @@ public:
     if (this->VarStack.size() > 1)
       {
       // In lower scopes we store keys, defined or not.
-      this->VarStack.top().Set(name, 0);
+      this->VarStack.back().Set(name, 0);
       }
     else
       {
-      this->VarStack.top().Erase(name);
+      this->VarStack.back().Erase(name);
       }
   }
 
   std::vector<std::string> LocalKeys() const
   {
-    return this->VarStack.top().LocalKeys();
+    return this->VarStack.back().LocalKeys();
   }
 
   std::vector<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=f983d8913b3293f0f328811d243222c6e19c795e
commit f983d8913b3293f0f328811d243222c6e19c795e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:49:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:51:46 2015 +0200

    cmDefinitions: Replace recursion with loop.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index c4d285a..2ee2618 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -87,29 +87,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->MakeClosure(undefined, up);
+    defs = defs->Up;
     }
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=24885d4efa17d4232e266ef053899613c32fdeb7
commit 24885d4efa17d4232e266ef053899613c32fdeb7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:44:26 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:51:46 2015 +0200

    cmDefinitions: Replace private constructor with MakeClosure.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index f2100eb..c4d285a 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -75,21 +75,16 @@ std::vector<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.
@@ -114,7 +109,7 @@ void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
   // Traverse parents.
   if(cmDefinitions const* up = defs->Up)
     {
-    this->ClosureImpl(undefined, up);
+    this->MakeClosure(undefined, up);
     }
 }
 
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4664090..6917402 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -45,13 +45,11 @@ public:
   /** Get the set of all local keys.  */
   std::vector<std::string> LocalKeys() const;
 
-  /** Compute the closure of all defined keys with values.
-      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;
 
+  cmDefinitions MakeClosure() const;
+
 private:
   // String with existence boolean.
   struct Def: public std::string
@@ -81,10 +79,7 @@ private:
   // Internal query and update methods.
   Def const& GetInternal(const std::string& key);
 
-  // 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 e2a9f61..dbb355c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -63,7 +63,7 @@ public:
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    this->VarStack.top() = parent->Internal->VarStack.top().Closure();
+    this->VarStack.top() = parent->Internal->VarStack.top().MakeClosure();
   }
 
   const char* GetDefinition(std::string const& name)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=012a75a00f060d6ca36cc9ffb97439a7ad526395
commit 012a75a00f060d6ca36cc9ffb97439a7ad526395
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:36:49 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:51:28 2015 +0200

    cmDefinitions: Make ClosureKeys API vector-based.
    
    Construct the final list directly in a named return value.  Use
    a single set to track bindings already found.
    
    Co-Author: Brad King <brad.king at kitware.com>

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 4b0eed4..f2100eb 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -119,10 +119,10 @@ 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;
+  std::vector<std::string> defined;
+  std::set<std::string> bound;
 
   cmDefinitions const* up = this;
 
@@ -133,11 +133,9 @@ std::set<std::string> cmDefinitions::ClosureKeys() const
         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())
+      if(bound.insert(mi->first).second && mi->second.Exists)
         {
-        std::set<std::string>& m = mi->second.Exists? defined : undefined;
-        m.insert(mi->first);
+        defined.push_back(mi->first);
         }
       }
     up = up->Up;
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 950970b..4664090 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 9209e49..e2a9f61 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -94,7 +94,7 @@ public:
     return this->VarStack.top().LocalKeys();
   }
 
-  std::set<std::string> ClosureKeys() const
+  std::vector<std::string> ClosureKeys() const
   {
     return this->VarStack.top().ClosureKeys();
   }
@@ -2514,8 +2514,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=ca9fa77d5d34a993073cd5256d65f88cd2e1a28f
commit ca9fa77d5d34a993073cd5256d65f88cd2e1a28f
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:38:09 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:49:05 2015 +0200

    cmDefinitions: Inline GetClosureKeys implementation.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index a6f46e2..4b0eed4 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -123,14 +123,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)
@@ -149,4 +142,5 @@ void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
       }
     up = up->Up;
     }
+  return defined;
 }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index d21ec23..950970b 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -86,10 +86,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=78e1454ea09e9c568578e26971d6cd45b7fa39c7
commit 78e1454ea09e9c568578e26971d6cd45b7fa39c7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 11:38:08 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:49:05 2015 +0200

    cmDefinitions: Replace ClosureKeys recursion with looping.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 448ba9d..a6f46e2 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -131,22 +131,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 = up->Up;
     }
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=818bf727c1eb4a500decb5856715a964c948242e
commit 818bf727c1eb4a500decb5856715a964c948242e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:34:13 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:49:05 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 d2b37bb..448ba9d 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -58,16 +58,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 13f885d..d21ec23 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -43,7 +43,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 8754427..9209e49 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -89,7 +89,7 @@ public:
       }
   }
 
-  std::set<std::string> LocalKeys() const
+  std::vector<std::string> LocalKeys() const
   {
     return this->VarStack.top().LocalKeys();
   }
@@ -1901,8 +1901,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);
@@ -4431,10 +4431,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=5067ae41b03442a7dba9210595e782678835a3ff
commit 5067ae41b03442a7dba9210595e782678835a3ff
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 16:36:48 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:48:56 2015 +0200

    cmDefinitions: Externalize the Set logic.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 58500c9..d2b37bb 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -49,16 +49,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 d71b815..8754427 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -78,7 +78,15 @@ public:
 
   void RemoveDefinition(std::string const& name)
   {
-    this->VarStack.top().Set(name, 0);
+    if (this->VarStack.size() > 1)
+      {
+      // In lower scopes we store keys, defined or not.
+      this->VarStack.top().Set(name, 0);
+      }
+    else
+      {
+      this->VarStack.top().Erase(name);
+      }
   }
 
   std::set<std::string> LocalKeys() const

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=60200ca5088058c70282500994727f2017276df8
commit 60200ca5088058c70282500994727f2017276df8
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 16:33:26 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:48:12 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=b43c162e99c7302ae81c746bc5aab1d9a64787b3
commit b43c162e99c7302ae81c746bc5aab1d9a64787b3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Apr 25 16:03:04 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 29 22:48:12 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 0935383..d71b815 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -50,6 +50,84 @@ 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
@@ -59,11 +137,9 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
     StateSnapshot(localGenerator->GetGlobalGenerator()
                                 ->GetCMakeInstance()->GetState())
 {
-  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;
 
   if (this->LocalGenerator->GetParent())
@@ -1523,7 +1599,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());
@@ -1717,7 +1793,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))
     {
@@ -1787,13 +1863,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))
     {
@@ -1817,8 +1893,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)
     {
@@ -1892,7 +1967,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))
     {
@@ -2365,7 +2440,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)
     {
@@ -2391,7 +2466,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);
@@ -2431,8 +2506,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 =
@@ -4324,10 +4398,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);
 
@@ -4348,10 +4421,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();
@@ -4367,7 +4439,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.
@@ -4382,31 +4455,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.";

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list