[cmake-commits] martink committed cmBootstrapCommands.cxx 1.18 1.19 cmCommands.cxx 1.119 1.120 cmMakefile.cxx 1.417 1.418 cmMakefile.h 1.215 1.216 cmake.cxx 1.334 1.335

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Dec 3 13:35:35 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv2655

Modified Files:
	cmBootstrapCommands.cxx cmCommands.cxx cmMakefile.cxx 
	cmMakefile.h cmake.cxx 
Log Message:
ENH: add functions and raise scope


Index: cmCommands.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCommands.cxx,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- cmCommands.cxx	29 Oct 2007 16:21:05 -0000	1.119
+++ cmCommands.cxx	3 Dec 2007 18:35:33 -0000	1.120
@@ -21,7 +21,6 @@
 #include "cmDefinePropertyCommand.cxx"
 #include "cmElseIfCommand.cxx"
 #include "cmEnableLanguageCommand.cxx"
-#include "cmEndMacroCommand.cxx"
 #include "cmEndWhileCommand.cxx"
 #include "cmExecuteProcessCommand.cxx"
 #include "cmExportCommand.cxx"
@@ -72,7 +71,6 @@
   commands.push_back(new cmDefinePropertyCommand);
   commands.push_back(new cmElseIfCommand);
   commands.push_back(new cmEnableLanguageCommand);
-  commands.push_back(new cmEndMacroCommand);
   commands.push_back(new cmEndWhileCommand);
   commands.push_back(new cmExecuteProcessCommand);
   commands.push_back(new cmExportCommand);

Index: cmBootstrapCommands.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmBootstrapCommands.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cmBootstrapCommands.cxx	29 Oct 2007 16:21:05 -0000	1.18
+++ cmBootstrapCommands.cxx	3 Dec 2007 18:35:33 -0000	1.19
@@ -36,7 +36,9 @@
 #include "cmElseCommand.cxx"
 #include "cmEnableTestingCommand.cxx"
 #include "cmEndForEachCommand.cxx"
+#include "cmEndFunctionCommand.cxx"
 #include "cmEndIfCommand.cxx"
+#include "cmEndMacroCommand.cxx"
 #include "cmExecProgramCommand.cxx"
 #include "cmExternalMakefileProjectGenerator.cxx"
 #include "cmFindBase.cxx"
@@ -47,6 +49,7 @@
 #include "cmFindPathCommand.cxx"
 #include "cmFindProgramCommand.cxx"
 #include "cmForEachCommand.cxx"
+#include "cmFunctionCommand.cxx"
 #include "cmGetCMakePropertyCommand.cxx"
 #include "cmGetFilenameComponentCommand.cxx"
 #include "cmGetSourceFilePropertyCommand.cxx"
@@ -66,6 +69,7 @@
 #include "cmMessageCommand.cxx"
 #include "cmOptionCommand.cxx"
 #include "cmProjectCommand.cxx"
+#include "cmRaiseScopeCommand.cxx"
 #include "cmSetCommand.cxx"
 #include "cmSetPropertiesCommand.cxx"
 #include "cmSetSourceFilesPropertiesCommand.cxx"
@@ -95,7 +99,9 @@
   commands.push_back(new cmElseCommand);
   commands.push_back(new cmEnableTestingCommand);  
   commands.push_back(new cmEndForEachCommand);
+  commands.push_back(new cmEndFunctionCommand);
   commands.push_back(new cmEndIfCommand);
+  commands.push_back(new cmEndMacroCommand);
   commands.push_back(new cmExecProgramCommand);
   commands.push_back(new cmFileCommand);
   commands.push_back(new cmFindFileCommand);
@@ -104,6 +110,7 @@
   commands.push_back(new cmFindPathCommand);
   commands.push_back(new cmFindProgramCommand);
   commands.push_back(new cmForEachCommand);
+  commands.push_back(new cmFunctionCommand);
   commands.push_back(new cmGetCMakePropertyCommand);
   commands.push_back(new cmGetFilenameComponentCommand);
   commands.push_back(new cmGetSourceFilePropertyCommand);
@@ -122,6 +129,7 @@
   commands.push_back(new cmMessageCommand);
   commands.push_back(new cmOptionCommand);
   commands.push_back(new cmProjectCommand);
+  commands.push_back(new cmRaiseScopeCommand);
   commands.push_back(new cmSetCommand);
   commands.push_back(new cmSetPropertiesCommand);
   commands.push_back(new cmSetSourceFilesPropertiesCommand);

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.334
retrieving revision 1.335
diff -u -d -r1.334 -r1.335
--- cmake.cxx	19 Nov 2007 19:22:38 -0000	1.334
+++ cmake.cxx	3 Dec 2007 18:35:33 -0000	1.335
@@ -224,7 +224,8 @@
   for(RegisteredCommandsMap::iterator j = this->Commands.begin();
       j != this->Commands.end(); ++j)
     {
-    if ( !j->second->IsA("cmMacroHelperCommand") )
+    if ( !j->second->IsA("cmMacroHelperCommand") && 
+         !j->second->IsA("cmFunctionHelperCommand"))
       {
       commands.push_back(j->second);
       }

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -d -r1.215 -r1.216
--- cmMakefile.h	26 Aug 2007 07:17:10 -0000	1.215
+++ cmMakefile.h	3 Dec 2007 18:35:33 -0000	1.216
@@ -737,6 +737,11 @@
   // Define the properties
   static void DefineProperties(cmake *cm);
 
+  // push and pop variable scopes
+  void PushScope();
+  void PopScope();
+  void RaiseScope(const char *var);
+
 protected:
   // add link libraries and directories to the target
   void AddGlobalLinkInformation(const char* name, cmTarget& target);
@@ -787,7 +792,7 @@
   std::vector<cmSourceGroup> SourceGroups;
 #endif
 
-  DefinitionMap Definitions;
+  std::vector<DefinitionMap> DefinitionStack;
   std::vector<cmCommand*> UsedCommands;
   cmLocalGenerator* LocalGenerator;
   bool IsFunctionBlocked(const cmListFileFunction& lff);

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.417
retrieving revision 1.418
diff -u -d -r1.417 -r1.418
--- cmMakefile.cxx	6 Nov 2007 19:16:00 -0000	1.417
+++ cmMakefile.cxx	3 Dec 2007 18:35:33 -0000	1.418
@@ -42,6 +42,8 @@
 // default is not to be building executables
 cmMakefile::cmMakefile()
 {
+  this->DefinitionStack.push_back(DefinitionMap());
+
   // Setup the default include file regular expression (match everything).
   this->IncludeFileRegularExpression = "^.*$";
   // Setup the default include complaint regular expression (match nothing).
@@ -120,7 +122,7 @@
   this->SourceGroups = mf.SourceGroups;
 #endif
 
-  this->Definitions = mf.Definitions;
+  this->DefinitionStack.push_back(mf.DefinitionStack.back());
   this->LocalGenerator = mf.LocalGenerator;
   this->FunctionBlockers = mf.FunctionBlockers;
   this->DataMap = mf.DataMap;
@@ -1046,7 +1048,7 @@
   cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
 
   // copy the definitions
-  this->Definitions = parent->Definitions;
+  this->DefinitionStack.front() = parent->DefinitionStack.back();
 
   // copy include paths
   this->IncludeDirectories = parent->IncludeDirectories;
@@ -1225,7 +1227,7 @@
 #endif
 
   this->TemporaryDefinitionKey = name;
-  this->Definitions[this->TemporaryDefinitionKey] = value;
+  this->DefinitionStack.back()[this->TemporaryDefinitionKey] = value;
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
@@ -1274,7 +1276,7 @@
     }
   this->GetCacheManager()->AddCacheEntry(name, val, doc, type);
   // if there was a definition then remove it
-  this->Definitions.erase( DefinitionMap::key_type(name));
+  this->DefinitionStack.back().erase( DefinitionMap::key_type(name));
 }
 
 
@@ -1282,13 +1284,17 @@
 {
   if(value)
     {
-    this->Definitions.erase( DefinitionMap::key_type(name));
-    this->Definitions.insert(DefinitionMap::value_type(name, "ON"));
+    this->DefinitionStack.back()
+      .erase( DefinitionMap::key_type(name));
+    this->DefinitionStack.back()
+      .insert(DefinitionMap::value_type(name, "ON"));
     }
   else
     {
-    this->Definitions.erase( DefinitionMap::key_type(name));
-    this->Definitions.insert(DefinitionMap::value_type(name, "OFF"));
+    this->DefinitionStack.back()
+      .erase( DefinitionMap::key_type(name));
+    this->DefinitionStack.back()
+      .insert(DefinitionMap::value_type(name, "OFF"));
     }
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
@@ -1319,7 +1325,7 @@
 
 void cmMakefile::RemoveDefinition(const char* name)
 {
-  this->Definitions.erase(DefinitionMap::key_type(name));
+  this->DefinitionStack.back().erase(DefinitionMap::key_type(name));
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
   if ( vv )
@@ -1653,8 +1659,9 @@
 bool cmMakefile::IsDefinitionSet(const char* name) const
 {
   const char* def = 0;
-  DefinitionMap::const_iterator pos = this->Definitions.find(name);
-  if(pos != this->Definitions.end())
+  DefinitionMap::const_iterator pos = 
+    this->DefinitionStack.back().find(name);
+  if(pos != this->DefinitionStack.back().end())
     {
     def = (*pos).second.c_str();
     }
@@ -1686,8 +1693,9 @@
     }
 #endif
   const char* def = 0;
-  DefinitionMap::const_iterator pos = this->Definitions.find(name);
-  if(pos != this->Definitions.end())
+  DefinitionMap::const_iterator pos = 
+    this->DefinitionStack.back().find(name);
+  if(pos != this->DefinitionStack.back().end())
     {
     def = (*pos).second.c_str();
     }
@@ -1708,8 +1716,9 @@
       {
       // are unknown access allowed
       DefinitionMap::const_iterator pos2 =
-        this->Definitions.find("CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS");
-      if (pos2 != this->Definitions.end() &&
+        this->DefinitionStack.back()
+        .find("CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS");
+      if (pos2 != this->DefinitionStack.back().end() &&
           cmSystemTools::IsOn((*pos2).second.c_str()))
         {
         vv->VariableAccessed(name,
@@ -1743,8 +1752,8 @@
   if ( !cacheonly )
     {
     DefinitionMap::const_iterator it;
-    for ( it = this->Definitions.begin();
-          it != this->Definitions.end(); it ++ )
+    for ( it = this->DefinitionStack.back().begin();
+          it != this->DefinitionStack.back().end(); it ++ )
       {
       definitions[it->first] = 1;
       }
@@ -2822,6 +2831,38 @@
   return tmp.str();
 }
 
+
+void cmMakefile::PushScope()
+{
+  this->DefinitionStack.push_back(this->DefinitionStack.back());
+}
+
+void cmMakefile::PopScope()
+{
+  this->DefinitionStack.pop_back();
+}
+
+void cmMakefile::RaiseScope(const char *var)
+{
+  const char *varDef = this->GetDefinition(var);
+
+  // multiple scopes in this directory?
+  if (this->DefinitionStack.size() > 1)
+    {
+    this->DefinitionStack[this->DefinitionStack.size()-2][var] = varDef;
+    }
+  // otherwise do the parent
+  else
+    {
+    cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
+    if (parent)
+      {
+      parent->AddDefinition(var,varDef);
+      }
+    }
+}
+
+
 // define properties
 void cmMakefile::DefineProperties(cmake *cm)
 {



More information about the Cmake-commits mailing list