]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Wed, 19 Mar 2008 14:58:13 +0000 (14:58 +0000)
committerguigues <guigues>
Wed, 19 Mar 2008 14:58:13 +0000 (14:58 +0000)
kernel/install/CMakeLists.txt
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkInterpreter.h
kernel/src/bbtkWxConsole.cxx
kernel/src/bbtkWxConsole.h
kernel/src/bbtkWxEditor.cxx
packages/std/src/bbstdExecBbiCommand.cxx
packages/wx/src/bbwxCommandButton.cxx
packages/wxvtk/bbs/appli/ExampleMIPWithControls.bbs

index f9ebc074cf253d9871559820f60e4874d9793b14..ba7d6d7e275227bcef6d99a7cc31a1f311e96672 100644 (file)
@@ -46,7 +46,7 @@ IF(WIN32)
   INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_vc_custom.dll                    DESTINATION bin/ )
   INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_odbc_vc_custom.dll       DESTINATION bin/ )
   INSTALL(   FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_net_vc_custom.dll                DESTINATION bin/ )
-ENDIF(WIN32)
+
 
 
 
@@ -61,6 +61,7 @@ message("eed3 " ${iLST} )
   )
 ENDFOREACH(iLST)
 
+ENDIF(WIN32)
 
 INSTALL(
   DIRECTORY  ${BBTK_BINARY_DIR}/${BBTK_DOC_REL_PATH}
index 2147d0ca35c1b84760ca57380c523ad77b85b89a..674513f847edc62677042542069d0285351b42f0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/18 12:51:26 $
-  Version:   $Revision: 1.46 $
+  Date:      $Date: 2008/03/19 14:58:13 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -302,57 +302,41 @@ bufferNb =0;
   /**
    *  
    */
-  void Interpreter::InterpretFile( const std::string& filename )
+  Interpreter::ExitStatus Interpreter::InterpretFile( const std::string& filename )
   {
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
-  //  std::cout << "==========================================Entree InterpretFile ["<<filename<<"] try SwitchToFile "<<std::endl;
+
     bool exm = mCommandLine;
     mCommandLine = false;
 
+    ExitStatus status = OK;
+
     try 
     {
       SwitchToFile(filename);
-
-/*
-      for( std::vector<std::string>::iterator it =mFileName.begin(); it!=mFileName.end(); ++it)
-      {
-         std::cout << "A=== [" << (*it) << "]" << std::endl;
-      }
-*/      
       bool insideComment = false; // for multiline comment
       while (mFile.size()>0) 
       {
-/*
-         for( std::vector<std::string>::iterator it =mFileName.begin(); it!=mFileName.end(); ++it)
-         {
-            std::cout << "B=== [" << (*it) << "]" << std::endl;
-         }
-*/      
-
-         //while ((mFile.size()>0) && !mFile.back()->eof() ) 
-         //{
-//      std::cout << "mFile.size() "<< mFile.size() << " mFileName.back() [" << mFileName.back() << "]" <<  std::endl;
-        while (!mFile.back()->eof()) {
-                    mLine.back()++;
-            char buf[500];
-            mFile.back()->getline(buf,500);
-            std::string str(buf);
-// std::cout << " in InterpretFile mFile.back()->getline [" << str << "]" << std::endl;    
-            int size=str.length();
-            if ( str[ size-1 ]==13  )
+       while (!mFile.back()->eof()) {
+         mLine.back()++;
+         char buf[500];
+         mFile.back()->getline(buf,500);
+         std::string str(buf);
+         int size=str.length();
+         if ( str[ size-1 ]==13  )
             {
-               str.erase(size-1,1);
+             str.erase(size-1,1);
             }
-      
-               InterpretLine(str, insideComment);
-
+         
+         InterpretLine(str, insideComment);
+         
        }//while
-       //if (mFile.size()>0) 
        CloseCurrentFile();
       }
     }
     catch (QuitException e) 
     {
+      status = QUIT;
     }
     catch (bbtk::Exception e) 
     {
@@ -361,6 +345,7 @@ bufferNb =0;
          std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
          std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
       }    
+      status = ERROR;
     }
     catch (std::exception& e) 
     {
@@ -368,15 +353,17 @@ bufferNb =0;
        if (mFileName.size()) {
           std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
           std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
-       }    
+       }  
+      status = ERROR;
     }  
     catch (...)
     {
-       std::cout << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
+       std::cerr << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
        if (mFileName.size()) {
-          std::cout << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
-          std::cout << "* LINE  : "<<mLine.back()<<std::endl;
+          std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
+          std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
       }    
+       status = ERROR;
     }
 
     CloseAllFiles();
@@ -384,6 +371,8 @@ bufferNb =0;
     bbtkDecTab("Interpreter",9);
 
     mCommandLine = exm;
+    
+    return status;
   }
   //=======================================================================
 
@@ -392,93 +381,128 @@ bufferNb =0;
   /**
    *  
    */
-  void Interpreter::InterpretBuffer( std::stringstream* buffer )
+  Interpreter::ExitStatus 
+  Interpreter::InterpretBuffer( std::stringstream* buffer )
   {
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretBuffer()"<<std::endl);
-  //  std::cout << "==========================================Entree InterpretFile ["<<filename<<"] try SwitchToFile "<<std::endl;
+
     bool exm = mCommandLine;
     mCommandLine = false;
 
+    ExitStatus status = OK;
+
     try 
     {
       SwitchToStream(buffer);
-
-/*
-      for( std::vector<std::string>::iterator it =mFileName.begin(); it!=mFileName.end(); ++it)
-      {
-         std::cout << "A=== [" << (*it) << "]" << std::endl;
-      }
-*/      
       bool insideComment = false; // for multiline comment
       while (mFile.size()>0) 
       {
-/*
-         for( std::vector<std::string>::iterator it =mFileName.begin(); it!=mFileName.end(); ++it)
-         {
-            std::cout << "B=== [" << (*it) << "]" << std::endl;
-         }
-*/      
-
-         //while ((mFile.size()>0) && !mFile.back()->eof() ) 
-         //{
-//      std::cout << "mFile.size() "<< mFile.size() << " mFileName.back() [" << mFileName.back() << "]" <<  std::endl;
-        while (!mFile.back()->eof()) {
-                    mLine.back()++;
-            char buf[500];
-            mFile.back()->getline(buf,500);
-            std::string str(buf);
-// std::cout << " in InterpretFile mFile.back()->getline [" << str << "]" << std::endl;    
-            int size=str.length();
-            if ( str[ size-1 ]==13  )
+       while (!mFile.back()->eof()) {
+         mLine.back()++;
+         char buf[500];
+         mFile.back()->getline(buf,500);
+         std::string str(buf);
+         
+         int size=str.length();
+         if ( str[ size-1 ]==13  )
             {
-               str.erase(size-1,1);
+             str.erase(size-1,1);
             }
-      
-               InterpretLine(str, insideComment);
-
-       }//while
-       //if (mFile.size()>0) 
-       CloseCurrentFile();
+         
+         InterpretLine(str, insideComment);
+         
+       }//while
+       
+       CloseCurrentFile();
       }
     }
     catch (QuitException e) 
-    { 
-      //      std::cout  << "**QuitException caught**"<<std::endl;
-    }
+      
+       status = QUIT;
+      }
     catch (bbtk::Exception e) 
-    {
-      std::cerr << "* ERROR : "<<e.GetMessage()<<std::endl;
-      if (mFileName.size()) {
-         std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
-         std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
-      }    
-    }
+      {
+       std::cerr << "* ERROR : "<<e.GetMessage()<<std::endl;
+       if (mFileName.size()) 
+         {
+           std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
+           std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
+         }    
+       status = ERROR;
+      }
     catch (std::exception& e) 
-    {
-       std::cerr << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
-       if (mFileName.size()) {
-          std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
-          std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
-       }    
+      {
+       std::cerr << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
+       if (mFileName.size()) 
+         {
+           std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
+           std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
+         }    
+       status = ERROR;
     }  
     catch (...)
-    {
-       std::cout << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
-       if (mFileName.size()) {
-          std::cout << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
-          std::cout << "* LINE  : "<<mLine.back()<<std::endl;
-      }    
-    }
-
+      {
+       std::cerr 
+         << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
+       if (mFileName.size()) 
+         {
+           std::cerr << "* FILE  : \""<<mFileName.back()<<"\""<<std::endl;
+           std::cerr << "* LINE  : "<<mLine.back()<<std::endl;
+         }    
+       status = ERROR;
+      }
+    
     CloseAllFiles();
     bbtkDebugMessage("Interpreter",9,"EO Interpreter::InterpretBuffer()"<<std::endl);
     bbtkDecTab("Interpreter",9);
-
+    
     mCommandLine = exm;
+    return status;
   }
   //=======================================================================
 
+  //=======================================================================
+  /// Runs the interpretation of a command
+  Interpreter::ExitStatus Interpreter::InterpretLine( const std::string& line )
+  {
+    bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
+
+    ExitStatus status = OK;
 
+    try 
+    {
+      bool insideComment = false;
+      InterpretLine(line, insideComment);
+    }
+    catch (QuitException e) 
+      { 
+      status = QUIT;
+      }
+    catch (bbtk::Exception e) 
+      {
+       std::cerr << "* ERROR : "<<e.GetMessage()<<std::endl;
+       status = ERROR;
+      }
+    catch (std::exception& e) 
+      {
+       std::cerr << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
+       status = ERROR;
+    }  
+    catch (...)
+      {
+       std::cerr 
+         << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
+       status = ERROR;
+      }
+    
+
+    bbtkDebugMessage("Interpreter",9,"EO Interpreter::InterpretLine()"
+                    <<std::endl);
+    bbtkDecTab("Interpreter",9);
+    
+    return status;
+  }
+  
 
   //=======================================================================  
   /**
@@ -1696,6 +1720,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
       }
       catch (QuitException e)
       {
+       bbtkMessage("Interpreter",1,"Interpreter : Quit"<<std::endl);
         again = false;
       }
       catch (bbtk::Exception e) 
index b87846854bf2fb5bcacc780dfe832870e3d9f53c..ea2f77acf7bec9e87656c303c7ce921a2b55c8b9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/18 12:51:26 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2008/03/19 14:58:13 $
+  Version:   $Revision: 1.16 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -97,9 +97,30 @@ namespace bbtk
     /// Destructor
     ~Interpreter();
 
+
+    typedef enum 
+      {
+       OK,
+       ERROR,
+       QUIT
+      }
+      ExitStatus;
+
+    /// Runs the interpretation of a file
+    ExitStatus InterpretFile( const std::string& filename);
+
+    /// Runs the interpretation of a buffer and deletes it !
+    ExitStatus InterpretBuffer( std::stringstream* buffer );
+
+    /// Runs the interpretation of a command
+    ExitStatus InterpretLine( const std::string& line );
+
+
     /// Launches a command line interpreter (with a prompt)
     void CommandLineInterpreter();
 
+
+
     /// Sets the inputs of the workspace :
     /// the map is passed as is to the Executer
     void SetInputs(const std::map<std::string,std::string>& m)
@@ -115,13 +136,28 @@ namespace bbtk
 
     void SetDialogMode(DialogModeType t) { mExecuter->SetDialogMode(t); }
 
-    /// Runs the interpretation of a file
-    void InterpretFile( const std::string& filename);
+    /// Sets the bool that indicates wether we are in command line context
+    void SetCommandLine(bool v = true) { mCommandLine = v; }
 
-    /// Runs the interpretation of a buffer and deletes it !
-    void InterpretBuffer( std::stringstream* buffer );
 
-    /// Interprets a line (either from a file or typed interactively)
+    
+#ifdef _USE_WXWIDGETS_
+    /// Sets the WxConsole that created the interpreter (if any)
+    void SetWxConsole(WxConsole* c) { mWxConsole = c; }
+    /// Gets the WxConsole that created the interpreter (if any) 
+    WxConsole* GetWxConsole() { return mWxConsole; }
+    /// Gets the WxConsole that created the interpreter (if any) - const 
+    const WxConsole* GetWxConsole() const { return mWxConsole; }
+#endif
+
+    /// Gets the Executer 
+    VirtualExec* GetExecuter() { return mExecuter; }
+    /// Gets the Executer (const)
+    const VirtualExec* GetExecuter() const { return mExecuter; }
+
+
+  protected:
+    /// Interprets a line 
     void InterpretLine( const std::string& line, bool &insideComment );
 
     /// Reads a line from prompt
@@ -171,22 +207,7 @@ namespace bbtk
                                 int n,
                                 std::vector<std::string>& commands );
 
-    /// Sets the bool that indicates wether we are in command line context
-    void SetCommandLine(bool v = true) { mCommandLine = v; }
-
-#ifdef _USE_WXWIDGETS_
-    /// Sets the WxConsole that created the interpreter (if any)
-    void SetWxConsole(WxConsole* c) { mWxConsole = c; }
-    /// Gets the WxConsole that created the interpreter (if any) 
-    WxConsole* GetWxConsole() { return mWxConsole; }
-    /// Gets the WxConsole that created the interpreter (if any) - const 
-    const WxConsole* GetWxConsole() const { return mWxConsole; }
-#endif
 
-    /// Gets the Executer 
-    VirtualExec* GetExecuter() { return mExecuter; }
-    /// Gets the Executer (const)
-    const VirtualExec* GetExecuter() const { return mExecuter; }
 
   private:
 
index 943cfc19ec40f01eb87c4986c55a9c2458d22f87..dc7dc1d337b33b4e321dee8d4b8814fb5bcda257 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/19 12:26:07 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2008/03/19 14:58:13 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -288,34 +288,28 @@ namespace bbtk
     mwxTextHistory->SetDefaultStyle(*mwxTextHistoryAttr);
 
     //printf("WxConsole::CommandString 03 \n");
-    try 
-    {
-      bool insideComment = false;
-
-      mInterpreter->InterpretLine( wx2std(line), insideComment );
-    }
-    catch (bbtk::QuitException)
-    {
-       Close(true); 
-    }
-    catch (bbtk::Exception e) 
-    {
-       e.Print();
-    }
-    catch (std::exception& e) 
-    {
-       std::cout << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
-    }
-    catch (...)
-    {
-       std::cout << "* UNDEFINED ERROR (not a bbtk nor a std exception)"
-                 << std::endl;
-    }
+    if (  mInterpreter->InterpretLine( wx2std(line) ) == 
+         Interpreter::QUIT )
+      {
+       Close(true); 
+      }
+
     //printf("WxConsole::CommandString 06 \n");
   }
   //================================================================
 
-
+  //================================================================
+  /// Runs the interpretation of a file
+  void WxConsole::InterpretFile( const std::string& filename) 
+  { 
+    if ( mInterpreter->InterpretFile(filename) ==
+        Interpreter::ERROR ) 
+      {
+       Show();
+      }
+  }
+  //================================================================
+  
   //================================================================
   void WxConsole::OnMenuQuit(wxCommandEvent& WXUNUSED(event))
   {
@@ -411,14 +405,13 @@ printf("EED WxConsole::OnMenuCreatePackage 06 \n");
 //EED  std::cout << "bbi: include "<<filepath<<std::endl;
 //EED  I->InterpretFile( filepath );
 
-    bool insideComment = false; // for multiline comment
-       I->InterpretLine( "exec freeze" ,insideComment );
-       I->InterpretLine( "include *" ,insideComment );
-       I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials" ,insideComment );
-       I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages" ,insideComment );
-       I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories" ,insideComment );
-       I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors",insideComment  );
-
+    I->InterpretLine( "exec freeze");
+    I->InterpretLine( "include *");
+    I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials");
+    I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages");
+    I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories");
+    I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors");
+    
     delete I;
   }
   //================================================================
index 87abef3e8df164c70445683c8f0237dc6eab4121..343ccd8841615781a4eaf6d09c91758df3e75528 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxConsole.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/18 12:51:26 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2008/03/19 14:58:13 $
+  Version:   $Revision: 1.10 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -79,8 +79,8 @@ namespace bbtk
     { mInterpreter->SetDialogMode(t); }
     
     /// Runs the interpretation of a file
-    void InterpretFile( const std::string& filename) 
-    { mInterpreter->InterpretFile(filename); }
+    void InterpretFile( const std::string& filename);
+
 
     void OnMenuQuit(wxCommandEvent& event);
     void OnMenuAbout(wxCommandEvent& event);
index 264f159af8b01daac26dd237e71c83cf25facf4b..f178a89c4167023d460453ee9feb601eda0a5333 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxEditor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/19 08:03:59 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/03/19 14:58:13 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -349,8 +349,7 @@ namespace bbtk
       }
 
     std::stringstream* buffer = new std::stringstream(bbtk::wx2std(mwxInputText->GetValue()));
-    bool com = false;
-    mInterpreter->InterpretLine("reset",com);
+    mInterpreter->InterpretLine("reset");
     try 
       {
        mInterpreter->InterpretBuffer(buffer);
index ae427d5bf595f549bb0991464e11b0b8983d1b67..af65ae7aa897b9b7af07e6bb796049e05b7f5a6d 100755 (executable)
@@ -58,8 +58,8 @@ namespace bbstd
                  ccommand[i]=34;
                }
            }           
-         bool insideComment = false; // for multiline comment
-         I->InterpretLine( ccommand, insideComment);
+       
+         I->InterpretLine( ccommand );
          pos1=pos2+1;
          pos2 = bbGetInputIn().find(";",pos2+1);
          
index 9b39118b2bf63fc395bd1af88bc53673f7c8f08f..15021cb59a75889ab2c91eb00e5cd3bea64e628d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbwxCommandButton.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/19 12:26:09 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2008/03/19 14:58:14 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 
   l'Image). All rights reserved. See Doc/License.txt or
@@ -111,8 +111,7 @@ namespace bbwx
                ccommand[i]=34;  // "
              }
          }             
-       bool insideComment = false; // for multiline comment
-       I->InterpretLine( ccommand, insideComment );
+       I->InterpretLine( ccommand );
        pos1=pos2+1;
        pos2 = commandstr.find(";",pos2+1);
        
index a49a021e223b83f26b5c87ba1b5d4eed66208f8e..f7bb73249cda08260aaadc589c97547f5e3ca19b 100644 (file)
@@ -24,5 +24,5 @@ set MIP.Scale 200
 #set MIP.Colour "0.5 0 0"
 set MIP.Title "MIP Controls"
 
-set main.title "ExampleMIPWithControls"
+set main.WinTitle "ExampleMIPWithControls"
 exec main