]> Creatis software - bbtk.git/commitdiff
* Fixed problem with 'include *'
authorguigues <guigues>
Fri, 7 Mar 2008 11:15:15 +0000 (11:15 +0000)
committerguigues <guigues>
Fri, 7 Mar 2008 11:15:15 +0000 (11:15 +0000)
* Finished 'no global factory' (fixes + box ExecBbiCommand works)

kernel/src/bbtkExecuter.cxx
kernel/src/bbtkInterpreter.cxx
packages/std/src/bbstdExecBbiCommand.cxx

index 241573ade7462e73776fdfb48f29080613897eff..5244a04a60d26bd355ed841d66040a5ca40e03a0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkExecuter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/07 08:40:14 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2008/03/07 11:15:15 $
+  Version:   $Revision: 1.14 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -107,6 +107,7 @@ namespace bbtk
                            BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
     // Create user workspace
     mRootCBB = new ComplexBlackBoxDescriptor("workspace"); //,f);
+    mRootCBB->SetFactory(GetFactory());
     mRootCBB->AddToAuthor("bbi (internal)");
     mRootCBB->AddToDescription("User's workspace");
     mOpenDefinition.push_back(CBBDefinition(mRootCBB,"user"));
@@ -161,6 +162,7 @@ namespace bbtk
                         <<std::endl);
 
     ComplexBlackBoxDescriptor* b = new ComplexBlackBoxDescriptor(name);
+    b->SetFactory(GetFactory());
     b->SetScriptFileName(scriptfilename);
     mOpenDefinition.push_back( CBBDefinition( b, pack ) );
     
index e9bf1e8c8cef24bb0af3c64b2162b637a33acb73..c63ec51f30a6862bd033f3865c24fa0001386051 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/07 08:40:14 $
-  Version:   $Revision: 1.40 $
+  Date:      $Date: 2008/03/07 11:15:15 $
+  Version:   $Revision: 1.41 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -795,7 +795,11 @@ 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,name);
+          std::string command("include ");
+          command += *i;
+          //  LoadScript(*i,name);
+          bool tmp;
+          InterpretLine(command,tmp);
            nbBssFiles++;
         }
         if (nbBssFiles==0)
@@ -846,7 +850,11 @@ 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,name);
+          std::string command("include ");
+          command += *i;
+          bool tmp;
+          InterpretLine(command,tmp);
+          //           LoadScript(*i,name);
            nbBssFiles++;
         }
         if (nbBssFiles==0)
index 0310c090375f27c50f60033921b83ddee5183b53..feb9588e2b7502e5cd8bdf3b63b616a4eaa4a4ab 100755 (executable)
@@ -16,38 +16,56 @@ namespace bbstd
 
   void ExecBbiCommand::DoProcess()
     {
-       int i;
-       
-       bool ok=true;
-       int pos1=0,pos2;
-       pos2 = bbGetInputIn().find(";",pos1);
-       std::string ccommand;
-       while (ok==true)
+      // Look for the interpreter
+      bbtk::Interpreter* I = 0;
+      if (bbGetParent() != 0) 
        {
-               if (pos2==-1) 
+         bbtk::Factory* f = ((bbtk::ComplexBlackBoxDescriptor*)bbGetParent()
+                       ->bbGetDescriptor())->GetFactory();
+         if ((f != 0)&&
+             (f->GetExecuter()))
+           {
+             I = f->GetExecuter()->GetInterpreter();
+           }
+       }
+      if (I==0) 
+       {
+         //      bbtkError("ExecBbiCommand::DoProcess() : could not find interpreter");
+         I = new bbtk::Interpreter();
+       }
+
+      int i;
+      
+      bool ok=true;
+      int pos1=0,pos2;
+      pos2 = bbGetInputIn().find(";",pos1);
+      std::string ccommand;
+      while (ok==true)
+       {
+         if (pos2==-1) 
+           {
+             ok=false;
+             ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
+           } else {
+           ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
+         }
+         for ( i=0 ; i < ccommand.length() ; i++)
+           {
+             if (ccommand[i]==39)
                {
-                       ok=false;
-                       ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
-               } else {
-                       ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
+                 ccommand[i]=34;
                }
-               for ( i=0 ; i < ccommand.length() ; i++)
-               {
-                       if (ccommand[i]==39)
-                       {
-                               ccommand[i]=34;
-                       }
-               }               
-      bool insideComment = false; // for multiline comment
-               bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand, insideComment);
-               pos1=pos2+1;
-               pos2 = bbGetInputIn().find(";",pos2+1);
-
+           }           
+         bool insideComment = false; // for multiline comment
+         I->InterpretLine( ccommand, insideComment);
+         pos1=pos2+1;
+         pos2 = bbGetInputIn().find(";",pos2+1);
+         
        }
-       
-
-
-/*  Grrr  not works in windows
+      
+      
+      
+      /*  Grrr  not works in windows
        char * pch;
        pch = strtok (bbGetInputIn(),";");
        while (pch != NULL)