]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index a9b480f86ae3c3a178c5af19d0a2b107704732d4..ea9adc9ba8f1ef9bae578080dc75dcf682a015a9 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/28 08:12:06 $
-  Version:   $Revision: 1.85 $
+  Date:      $Date: 2009/10/05 22:44:48 $
+  Version:   $Revision: 1.87 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -687,17 +687,20 @@ namespace bbtk
          char buf[500];
          mFile.back()->getline(buf,500);
          std::string str(buf);
-         
+         //size 0 JCP 21-09-2009
          int size=str.length();
-         if ( str[ size-1 ]==13  )
+         if(size != 0){
+                 if ( str[ size-1 ]==13  )
             {
              str.erase(size-1,1);
             }
-         try
-           {
-             DoInterpretLine(str);
-           }
-         CATCH_MACRO;
+                 try
+                       {
+                         DoInterpretLine(str);
+                       }
+                 CATCH_MACRO;
+         }
+         
        } 
        CloseCurrentFile();
       }
@@ -718,6 +721,7 @@ namespace bbtk
     {
       mStatus = Interpreter_OK;
       mInsideComment = false;
+//std::cout<<"JCP bbtkInterpreter.cxx Interpreter::InterpretLine("<<std::endl;
       DoInterpretLine(line );
     }
     CATCH_MACRO;
@@ -735,7 +739,6 @@ namespace bbtk
   {
     bbtkDebugMessage("interpreter",6,"==> Interpreter::DoInterpretLine(\""
                     <<line<<"\")"<<std::endl);
-    
     std::vector<std::string> words;
     SplitLine(line,words);
 
@@ -786,7 +789,7 @@ namespace bbtk
     // Command 
     CommandInfoType command;
     InterpretCommand(words,command);
-
+//std::cout<<"JCP bbtkInterpreter command.keyword ="<<command.keyword<<std::endl;
     bbtkDebugMessage("interpreter",9,
                      "Command='"<<command.keyword
                       <<"' code="<<command.code<<std::endl); 
@@ -819,6 +822,7 @@ namespace bbtk
        bool in_script = false;
        std::string file("");
        int line = 0;
+
        if (mFileName.size()) 
          {
            std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
@@ -844,7 +848,7 @@ namespace bbtk
          }
        return;
       }   
-
+//std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl;
     // other cammands
     switch (command.code) 
       {
@@ -1373,49 +1377,52 @@ namespace bbtk
                }
          
                std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false);
-               if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb")
-               {
-                 fullPathScriptName = tfullPathScriptName;
-                       if ( ! Utilities::FileExists(fullPathScriptName) )
+//Addition JCP tfullPathScriptName.size()>=4 
+               if(tfullPathScriptName.size()>=4){
+                       if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb")
                        {
-                               // The following is *NOT* a debug time message :
-                               // It's a user intended message.
-                               // Please don't remove it.
-                               bbtkMessage("interpreter",2,
-                         "   [" <<fullPathScriptName <<"] : does not exist" 
-                         <<std::endl);
-                               continue;  // try next path
-                       }
-                       bbtkMessage("interpreter",2,
-                             "   [" <<fullPathScriptName 
-                                 <<"] : found" <<std::endl);
-                       foundFile = true;
-                       break; // a script was found; we stop iterating
-               }
-               else 
-               {
-                       fullPathScriptName = tfullPathScriptName + ".bbs";
-                       // Check if library exists
-                       if ( ! Utilities::FileExists(fullPathScriptName) )
-                       {
-                               fullPathScriptName = tfullPathScriptName + ".bbp";
+                         fullPathScriptName = tfullPathScriptName;
                                if ( ! Utilities::FileExists(fullPathScriptName) )
                                {
                                        // The following is *NOT* a debug time message :
                                        // It's a user intended message.
                                        // Please don't remove it.
                                        bbtkMessage("interpreter",2,
-                                       "   [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 
-                                       <<std::endl);
+                                 "   [" <<fullPathScriptName <<"] : does not exist" 
+                                 <<std::endl);
                                        continue;  // try next path
                                }
+                               bbtkMessage("interpreter",2,
+                                         "   [" <<fullPathScriptName 
+                                         <<"] : found" <<std::endl);
+                               foundFile = true;
+                               break; // a script was found; we stop iterating
                        }
-                       bbtkMessage("interpreter",2,
-                     "   [" <<fullPathScriptName 
-                     <<"] : found" <<std::endl);
-                       foundFile = true;
-                       break; // a script was found; we stop iterating
-               }
+                       else 
+                       {
+                               fullPathScriptName = tfullPathScriptName + ".bbs";
+                               // Check if library exists
+                               if ( ! Utilities::FileExists(fullPathScriptName) )
+                               {
+                                       fullPathScriptName = tfullPathScriptName + ".bbp";
+                                       if ( ! Utilities::FileExists(fullPathScriptName) )
+                                       {
+                                               // The following is *NOT* a debug time message :
+                                               // It's a user intended message.
+                                               // Please don't remove it.
+                                               bbtkMessage("interpreter",2,
+                                               "   [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 
+                                               <<std::endl);
+                                               continue;  // try next path
+                                       }
+                               }
+                               bbtkMessage("interpreter",2,
+                                 "   [" <<fullPathScriptName 
+                                 <<"] : found" <<std::endl);
+                               foundFile = true;
+                               break; // a script was found; we stop iterating
+                       }
+               }               
        } //------------------ // end for ( package_paths.begin();i!=package_paths.end() )
   }
 
@@ -1570,7 +1577,7 @@ void Interpreter::SwitchToStream( std::stringstream* stream )
        HelpCommand(words[0]);
        bbtkError(words[0]<<" : wrong number of arguments");
     }
-
+//std::cout<<"Interpreter::InterpretCommand( const std::vector<std::string>& words,"<<std::endl;
     info = c->second;
 
     bbtkDebugMessage("interpreter",9,"<== Interpreter::InterpretCommand(...)"<<std::endl);
@@ -1593,7 +1600,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
     {
       if (words[1]=="packages") 
       {
-         GetExecuter()->GetFactory()->PrintPackages(true);
+         GetExecuter()->GetFactory()->PrintHelpListPackages(true);
          return;
       }
       try 
@@ -1604,7 +1611,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          try 
          {
-            GetExecuter()->GetFactory()->HelpPackage(words[1]);
+            GetExecuter()->GetFactory()->PrintHelpPackage(words[1]);
            if ( mUser != 0 )
              {
                std::string url = 
@@ -1621,7 +1628,8 @@ void Interpreter::Help(const std::vector<std::string>& words)
           try 
             {
               std::string package;
-              GetExecuter()->GetFactory()->HelpBlackBox(words[1],package);
+              GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1],
+                                                               package);
               if ( mUser != 0 )
                 {
                   std::string url = 
@@ -1638,7 +1646,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
             {
               try
                 {
-                  GetExecuter()->ShowRelations(words[1],"0","9999");
+                  GetExecuter()->PrintHelpBlackBox(words[1],"0","9999");
                 }
               catch (bbtk::Exception h){
                 bbtkError("\""<<words[1].c_str()
@@ -1654,12 +1662,12 @@ void Interpreter::Help(const std::vector<std::string>& words)
       {
          if ( words[1]=="packages" )
          {
-            GetExecuter()->GetFactory()->PrintPackages(true,true);
+            GetExecuter()->GetFactory()->PrintHelpListPackages(true,true);
             return;
           }
          try 
          {
-            GetExecuter()->GetFactory()->HelpPackage(words[1],true);
+            GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true);
          }
          catch (bbtk::Exception f) 
          {
@@ -2274,7 +2282,7 @@ void  Interpreter::NewGUI(const std::string& boxname,
          {
            //      int o = MessageManager::GetMessageLevel("debug");
            //      if (o<2) MessageManager::SetMessageLevel("debug",2);
-           mVirtualExecuter->GetFactory()->CheckPackages();
+           mVirtualExecuter->GetFactory()->Check();
            //      MessageManager::SetMessageLevel("debug",o);
          }
       }