]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index 921c27860460d25cea276b50e4d4d7de6c4e5627..ca1bd896e3d918bbc82a4f77c881c10f889fadb5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/01/28 10:50:54 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/01/28 15:08:53 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -99,6 +99,22 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL;
     info.help = "Executes the black box of name <box> (and connected boxes if needed). If the special keyword 'freeze' is given then freezes any further execution command. 'unfreeze' reverts to normal execution mode.";
     mCommandDict[info.keyword] = info;
 
+    info.keyword = "package";
+    info.argmin = 1;
+    info.argmax = 1;
+    info.code = cPackage;
+    info.syntax = "package <name>";
+    info.help = "Begins the definition of a package.";
+    mCommandDict[info.keyword] = info;
+    
+    info.keyword = "endpackage";
+    info.argmin = 0;
+    info.argmax = 0;
+    info.code = cEndPackage;
+    info.syntax = "endpackage";
+    info.help = "Ends the definition of a package.";
+    mCommandDict[info.keyword] = info;
+
     info.keyword = "define";
     info.argmin = 1;
     info.argmax = 2;
@@ -420,6 +436,14 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
         mExecuter->Connect(left,right,left2,right2);
         break;
         
+      case cPackage :
+        mExecuter->BeginPackage(words[1]);
+        break;
+
+      case cEndPackage :
+        mExecuter->EndPackage();
+        break;
+        
       case cDefine :
         if (mFileName.size()>0) 
         {
@@ -427,7 +451,7 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
         }
         if (words.size()==2) 
         {
-           mExecuter->Define(words[1],"user",filename);
+           mExecuter->Define(words[1],"",filename);
         }
         else 
         {
@@ -709,7 +733,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
   //
     bbtkDebugMessageInc("Interpreter",9,"Interpreter::SwitchToFile( \""
                          <<name<<"\")"<<std::endl);
-
+verbose = true;
     std::vector<std::string> script_paths;
     std::string libname;  // full path library name
     std::string pkgname;  // e.g. <scriptname>.bbs
@@ -726,7 +750,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
     bool foundFile     = false;
     std::string::size_type slash_position = name.find_last_of("/\\");
             
-    if (slash_position != std::string::npos)
+    if (false) //slash_position != std::string::npos)
     {       // ------------------------------------- check user supplied location 
       fullnameGiven = true;
       libname =  Utilities::ExpandLibName(name, verbose);
@@ -768,7 +792,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
           path = currentDir;
         }
 
-        libname = Utilities::MakePkgnameFromPath(path, pkgname);
+        libname = Utilities::MakePkgnameFromPath(path, name); //pkgname);
       // Check if library exists           
         if ( ! Utilities::FileExists(libname) )
         {