]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index c5a69ca1a5f6f44060f4f38c71161d7a32730e2f..f46dfe020106364527d225da512e04e2ce0f2db5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/02/05 12:16:55 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2008/02/06 09:32:25 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -170,7 +170,7 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
 
     info.syntax = "index [<filename> ['Initials'(default)|'Packages'|'Categories']]";
     info.help = "Creates an html index of known boxes. If filename is provided then save it to the file 'filename'. The default index entries are the initial letters of the names of the boxes. If 'Packages' or 'Categories' is provided then the entries are either the packages names or the categories";
-    mCommandDict[info.keyword] = info;
+    mCommandDict[info.category] = info;
 
     info.category = "reset";  //EED
     info.argmin = 0;
@@ -222,10 +222,10 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
 
     info.category = "include";
     info.argmin = 1;
-    info.argmax = 1;
+    info.argmax = 2;
     info.code = cInclude;
-    info.syntax = "include <filename>";
-    info.help = "Includes the file <filename>";
+    info.syntax = "include <filename> [source]";
+    info.help = "Includes the file <filename>.\n  'source' : If the keyword 'source' is provided then informs bbi that the included file is the source of the current box definition (Advanced; used to get the right 'Include' field in html doc of packages 'appli' scripts).";
     mCommandDict[info.category] = info;
 
     info.category = "quit";
@@ -463,7 +463,7 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
       case cDefine :
         if (mFileName.size()>0) 
         {
-           filename = Utilities::get_file_name(mFileName.back());
+         filename = mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back());
         }
         if (words.size()==2) 
         {
@@ -564,6 +564,11 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
         {
             SwitchToFile(words[1], true ); // true : better pass use_config_file
         }
+       // if 'source' was given
+       if (words.size()==3) 
+         {
+           this->mExecuter->SetCurrentFileName(words[1]);
+         }
         break;
         
       case cLoad:
@@ -766,7 +771,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
         {
            if ((*i).substr((*i).size()-4, 4) != ".bbs")
               continue;      // ignore non .bbs files
-           LoadScript(*i);
+           LoadScript(*i,name);
            nbBssFiles++;
         }
         if (nbBssFiles==0)
@@ -816,7 +821,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
 
            if ((*i).substr((*i).size()-4, 4) != ".bbs")
               continue;      // ignore non .bbs files
-           LoadScript(*i);
+           LoadScript(*i,name);
            nbBssFiles++;
         }
         if (nbBssFiles==0)
@@ -924,7 +929,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
        return;    
     }
     else
-       LoadScript(fullPathScriptName);
+      LoadScript(fullPathScriptName,name);
 
     return;
   }   
@@ -932,7 +937,8 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
 
   //=======================================================================
 
-  void Interpreter::LoadScript( std::string fullPathScriptName)
+  void Interpreter::LoadScript( std::string fullPathScriptName,
+                               std::string includeScriptName)
   {
     if (find(mFileName.begin(),mFileName.end(),fullPathScriptName)
        !=mFileName.end()) 
@@ -956,6 +962,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
 
     mFile.push_back(s);
     mFileName.push_back(fullPathScriptName);
+    mIncludeFileName.push_back(includeScriptName);
     mLine.push_back(0);
     return;  
   }
@@ -982,6 +989,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
                      " Closing file '"<<mFileName.back()<<"'"<<std::endl);
     
     mFileName.pop_back();
+    mIncludeFileName.pop_back();
     mLine.pop_back();
     bbtkDebugMessage("Interpreter",9," Remains "
                      <<mFile.size()
@@ -1008,6 +1016,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
       bbtkDebugMessage("Interpreter",9,
                       " Closing file '"<<mFileName.back()<<"'"<<std::endl);
       mFileName.pop_back();
+      mIncludeFileName.pop_back();
       mLine.pop_back();
     }
     bbtkDebugMessage("Interpreter",9,"EO Interpreter::CloseAllFiles()"
@@ -1128,7 +1137,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
   /// Displays the Configuration
   void Interpreter::Config() const
   {
-    bbtkDebugMessageInc("Core",9,"Factory::Config"<<std::endl);
+    bbtkDebugMessageInc("Kernel",9,"Factory::Config"<<std::endl);
     
     ConfigurationFile cf = ConfigurationFile::GetInstance();
     
@@ -1164,7 +1173,7 @@ void Interpreter::Help(const std::vector<std::string>& words)
       bbtkMessage("Help",1,"--- ["<<*i<<"]"<<std::endl);
     }
 
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
   }  
 
   //=======================================================================