[Cmake-commits] [cmake-commits] king committed cmForEachCommand.cxx 1.27 1.28 cmForEachCommand.h 1.19 1.20 cmIfCommand.cxx 1.91 1.92 cmIfCommand.h 1.50 1.51 cmMakefile.cxx 1.492 1.493 cmMakefile.h 1.242 1.243 cmWhileCommand.cxx 1.13 1.14 cmWhileCommand.h 1.9 1.10

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Jan 20 14:36:20 EST 2009


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

Modified Files:
	cmForEachCommand.cxx cmForEachCommand.h cmIfCommand.cxx 
	cmIfCommand.h cmMakefile.cxx cmMakefile.h cmWhileCommand.cxx 
	cmWhileCommand.h 
Log Message:
ENH: Refactor function blocker deletion

When a function blocker decides to remove itself we previously removed
it at every return point from the C++ scope in which its removal is
needed.  This teaches function blockers to transfer ownership of
themselves from cmMakefile to an automatic variable for deletion on
return.  Since this removes blockers before they replay their commands,
we no longer need to avoid running blockers on their own commands.


Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.91
retrieving revision 1.92
diff -C 2 -d -r1.91 -r1.92
*** cmIfCommand.cxx	20 Jan 2009 19:35:21 -0000	1.91
--- cmIfCommand.cxx	20 Jan 2009 19:36:18 -0000	1.92
***************
*** 28,38 ****
                    cmExecutionStatus &inStatus)
  {
-   // Prevent recusion and don't let this blocker block its own
-   // commands.
-   if (this->Executing)
-     {
-     return false;
-     }
- 
    // we start by recording all the functions
    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
--- 28,31 ----
***************
*** 46,51 ****
      if (!this->ScopeDepth) 
        {
        // execute the functions for the true parts of the if statement
-       this->Executing = true;
        cmExecutionStatus status;
        int scopeDepth = 0;
--- 39,47 ----
      if (!this->ScopeDepth) 
        {
+       // Remove the function blocker for this scope or bail.
+       cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(lff));
+       if(!fb.get()) { return false; }
+ 
        // execute the functions for the true parts of the if statement
        cmExecutionStatus status;
        int scopeDepth = 0;
***************
*** 105,109 ****
                mf.IssueMessage(cmake::FATAL_ERROR, err);
                cmSystemTools::SetFatalErrorOccured();
-               mf.RemoveFunctionBlocker(lff);
                return true;
                }
--- 101,104 ----
***************
*** 125,129 ****
              {
              inStatus.SetReturnInvoked(true);
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 120,123 ----
***************
*** 131,140 ****
              {
              inStatus.SetBreakInvoked(true);
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
            }
          }
-       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 125,132 ----

Index: cmIfCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -C 2 -d -r1.50 -r1.51
*** cmIfCommand.h	10 Sep 2008 15:58:40 -0000	1.50
--- cmIfCommand.h	20 Jan 2009 19:36:18 -0000	1.51
***************
*** 30,34 ****
  public:
    cmIfFunctionBlocker() {
!     this->HasRun = false; this->ScopeDepth = 0; this->Executing = false;}
    virtual ~cmIfFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
--- 30,34 ----
  public:
    cmIfFunctionBlocker() {
!     this->HasRun = false; this->ScopeDepth = 0; }
    virtual ~cmIfFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
***************
*** 44,48 ****
    bool HasRun;
    unsigned int ScopeDepth;
-   bool Executing;
  };
  
--- 44,47 ----

Index: cmWhileCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmWhileCommand.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C 2 -d -r1.9 -r1.10
*** cmWhileCommand.h	23 Jan 2008 15:27:59 -0000	1.9
--- cmWhileCommand.h	20 Jan 2009 19:36:18 -0000	1.10
***************
*** 30,34 ****
  {
  public:
!   cmWhileFunctionBlocker() {Executing = false; Depth=0;}
    virtual ~cmWhileFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
--- 30,34 ----
  {
  public:
!   cmWhileFunctionBlocker() {this->Depth=0;}
    virtual ~cmWhileFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
***************
*** 40,44 ****
    std::vector<cmListFileArgument> Args;
    std::vector<cmListFileFunction> Functions;
-   bool Executing;
  private:
    int Depth;
--- 40,43 ----

Index: cmWhileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmWhileCommand.cxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -C 2 -d -r1.13 -r1.14
*** cmWhileCommand.cxx	28 Jun 2008 15:16:36 -0000	1.13
--- cmWhileCommand.cxx	20 Jan 2009 19:36:18 -0000	1.14
***************
*** 22,32 ****
                    cmExecutionStatus &inStatus)
  {
-   // Prevent recusion and don't let this blocker block its own
-   // commands.
-   if (this->Executing)
-     {
-     return false;
-     }
-   
    // at end of for each execute recorded commands
    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"while"))
--- 22,25 ----
***************
*** 40,43 ****
--- 33,40 ----
      if (!this->Depth) 
        {
+       // Remove the function blocker for this scope or bail.
+       cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(lff));
+       if(!fb.get()) { return false; }
+ 
        std::string errorString;
      
***************
*** 47,51 ****
          cmIfCommand::IsTrue(expandedArguments,errorString,&mf);
  
-       this->Executing = true;
        while (isTrue)
          {      
--- 44,47 ----
***************
*** 58,67 ****
              {
              inStatus.SetReturnInvoked(true);
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
            if (status.GetBreakInvoked())
              {
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 54,61 ----
***************
*** 72,76 ****
            cmIfCommand::IsTrue(expandedArguments,errorString,&mf);
          }
-       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 66,69 ----

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.242
retrieving revision 1.243
diff -C 2 -d -r1.242 -r1.243
*** cmMakefile.h	20 Jan 2009 19:35:22 -0000	1.242
--- cmMakefile.h	20 Jan 2009 19:36:18 -0000	1.243
***************
*** 32,35 ****
--- 32,36 ----
  #endif
  
+ #include <cmsys/auto_ptr.hxx>
  #include <cmsys/RegularExpression.hxx>
  
***************
*** 90,96 ****
    void AddFunctionBlocker(cmFunctionBlocker *fb)
      { this->FunctionBlockers.push_back(fb);}
!   void RemoveFunctionBlocker(cmFunctionBlocker *fb)
!     { this->FunctionBlockers.remove(fb);}
!   void RemoveFunctionBlocker(const cmListFileFunction& lff);
  
    /**
--- 91,101 ----
    void AddFunctionBlocker(cmFunctionBlocker *fb)
      { this->FunctionBlockers.push_back(fb);}
! 
!   /**
!    * Remove the function blocker whose scope ends with the given command.
!    * This returns ownership of the function blocker object.
!    */
!   cmsys::auto_ptr<cmFunctionBlocker>
!   RemoveFunctionBlocker(const cmListFileFunction& lff);
  
    /**

Index: cmForEachCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmForEachCommand.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -C 2 -d -r1.27 -r1.28
*** cmForEachCommand.cxx	29 Feb 2008 17:18:11 -0000	1.27
--- cmForEachCommand.cxx	20 Jan 2009 19:36:18 -0000	1.28
***************
*** 21,31 ****
                    cmExecutionStatus &inStatus)
  {
-   // Prevent recusion and don't let this blocker block its own
-   // commands.
-   if (this->Executing)
-     {
-     return false;
-     }
- 
    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"foreach"))
      {
--- 21,24 ----
***************
*** 38,41 ****
--- 31,38 ----
      if (!this->Depth) 
        {
+       // Remove the function blocker for this scope or bail.
+       cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(lff));
+       if(!fb.get()) { return false; }
+ 
        // at end of for each execute recorded commands
        // store the old value
***************
*** 45,49 ****
          oldDef = mf.GetDefinition(this->Args[0].c_str());
          }
-       this->Executing = true;
        std::vector<std::string>::const_iterator j = this->Args.begin();
        ++j;
--- 42,45 ----
***************
*** 66,70 ****
              // restore the variable to its prior value
              mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 62,65 ----
***************
*** 73,77 ****
              // restore the variable to its prior value
              mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 68,71 ----
***************
*** 80,84 ****
        // restore the variable to its prior value
        mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
-       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 74,77 ----

Index: cmForEachCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmForEachCommand.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** cmForEachCommand.h	23 Jan 2008 15:27:59 -0000	1.19
--- cmForEachCommand.h	20 Jan 2009 19:36:18 -0000	1.20
***************
*** 30,34 ****
  {
  public:
!   cmForEachFunctionBlocker() {this->Executing = false; Depth = 0;}
    virtual ~cmForEachFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
--- 30,34 ----
  {
  public:
!   cmForEachFunctionBlocker() {this->Depth = 0;}
    virtual ~cmForEachFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
***************
*** 40,44 ****
    std::vector<std::string> Args;
    std::vector<cmListFileFunction> Functions;
-   bool Executing;
  private:
    int Depth;
--- 40,43 ----

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.492
retrieving revision 1.493
diff -C 2 -d -r1.492 -r1.493
*** cmMakefile.cxx	20 Jan 2009 19:35:21 -0000	1.492
--- cmMakefile.cxx	20 Jan 2009 19:36:18 -0000	1.493
***************
*** 2396,2400 ****
  }
  
! void cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff)
  {
    // loop over all function blockers to see if any block this command
--- 2396,2401 ----
  }
  
! cmsys::auto_ptr<cmFunctionBlocker>
! cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff)
  {
    // loop over all function blockers to see if any block this command
***************
*** 2407,2416 ****
        cmFunctionBlocker* b = *pos;
        this->FunctionBlockers.remove(b);
!       delete b;
!       break;
        }
      }
  
!   return;
  }
  
--- 2408,2416 ----
        cmFunctionBlocker* b = *pos;
        this->FunctionBlockers.remove(b);
!       return cmsys::auto_ptr<cmFunctionBlocker>(b);
        }
      }
  
!   return cmsys::auto_ptr<cmFunctionBlocker>();
  }
  



More information about the Cmake-commits mailing list