X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkInterpreterVirtual.cxx;h=451ade9e45cabbbfea1285770f41f77aa45bec28;hb=a39a5800b5e01f19a4f2d0ccf0ad7754a30e69a2;hp=85354e69d2162611b35f6ec9442831a19ed26ed4;hpb=4e0c70c1aa10fed31d4a6bf30cb316eaa1194e13;p=bbtk.git diff --git a/kernel/src/bbtkInterpreterVirtual.cxx b/kernel/src/bbtkInterpreterVirtual.cxx index 85354e6..451ade9 100644 --- a/kernel/src/bbtkInterpreterVirtual.cxx +++ b/kernel/src/bbtkInterpreterVirtual.cxx @@ -1,4 +1,31 @@ -/*========================================================================= +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ Language: C++ @@ -6,27 +33,7 @@ Version: $Revision: 1.88 $ =========================================================================*/ -/* --------------------------------------------------------------------- - -* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) -* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux -* -* This software is governed by the CeCILL-B license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL-B -* license as circulated by CEA, CNRS and INRIA at the following URL -* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -* or in the file LICENSE.txt. -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited -* liability. -* -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL-B license and that you accept its terms. -* ------------------------------------------------------------------------ */ + /** * \file @@ -339,7 +346,6 @@ namespace bbtk */ - } //======================================================================= @@ -510,6 +516,7 @@ namespace bbtk //======================================================================= void InterpreterVirtual::CatchUnknownException() { +printf("EED InterpreterVirtual::CatchUnknownException Start\n"); //EED Borrame if (GetExecuter()->GetNoErrorMode()) //EED Borrame { //EED Borrame std::string file("?"); @@ -550,27 +557,28 @@ namespace bbtk CloseAllFiles(); std::cerr << mess.str(); } +printf("EED InterpreterVirtual::CatchUnknownException End\n"); } //======================================================================= //======================================================================= -#define CATCH_MACRO \ - catch (InterpreterException e) \ - { \ - CatchInterpreterException(e); \ - } \ +#define CATCH_MACRO \ + catch (InterpreterException e) \ + { \ + CatchInterpreterException(e); \ + } \ catch (bbtk::Exception e) \ - { \ - CatchBbtkException(e); \ - } \ + { \ + CatchBbtkException(e); \ + } \ catch (std::exception& e) \ - { \ + { \ CatchStdException(e); \ - } \ - catch (...) \ - { \ - CatchUnknownException(); \ + } \ + catch (...) \ + { \ + CatchUnknownException(); \ } //======================================================================= @@ -578,7 +586,7 @@ namespace bbtk //======================================================================= InterpreterVirtual::ExitStatus InterpreterVirtual::InterpretFile( const std::string& filename, bool source ) { - bbtkDebugMessage("interpreter",4,"==> InterpreterVirtual::InterpretFile(\""< InterpreterVirtual::InterpretFile(\""< InterpreterVirtual::InterpretBuffer()"< InterpreterVirtual::DoInterpretLine(\"" < words; SplitLine(line,words); + + // Empty line if (words.size()<1) { @@ -847,6 +856,7 @@ namespace bbtk bbtkMessage("interpreter",9,"Multiline Comment"<(mFile.back()); - if (fs!=0) in_script = true; - file = mFileName.back(); - line = mLine.back(); - } - if (command.code==cBreak) + { +//EED-Borrame bool in_script = false; +//EED-Borrame std::string file(""); +//EED-Borrame int line = 0; + +//EED-Borrame if (mFileName.size()) +//EED-Borrame { +//EED-Borrame std::ifstream* fs = dynamic_cast(mFile.back()); +//EED-Borrame if (fs!=0) in_script = true; +//EED-Borrame file = mFileName.back(); +//EED-Borrame line = mLine.back(); +//EED-Borrame } + if (command.code==cBreak) { /* std::cout << "BreakException(" @@ -906,18 +915,17 @@ namespace bbtk commandBreak(); //EED Borrame bbtkError("break");//,in_script,file,line); // throw BreakException(in_script,file,line); - } - else - { + } else { commandQuit(); //EED Borrame bbtkError("quit");//,in_script,file,line); //throw QuitException(in_script,file,line); - } - return; - } + } // cBreak + return; + } // cBreak cQuit //std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<Define(words[1],"",filename); } else @@ -1119,7 +1128,7 @@ namespace bbtk bbtkDebugMessage("interpreter",6,"<== InterpreterVirtual::DoInterpretLine(\"" <.bbs std::vector Filenames; - + std::string tmpFilenames; + // The following is *NOT* a debug time message : // It's a user intended message. // Please don't remove it. @@ -1291,7 +1301,7 @@ namespace bbtk std::stringstream* stream = new std::stringstream; //if (upath.size()!=0) // avoid troubles for "*" - + // ==== no path provided : look in root bbs path if (upath.size()==0) { @@ -1352,20 +1362,41 @@ namespace bbtk } } - // === search paths list complete : now explore it int nbBssFiles = 0; // ==== relative name, iterate + load all .bbs/.bbp files std::vector::iterator i; for (i=script_paths.begin();i!=script_paths.end();i++) { + bbtkMessage("interpreter",1, "--> Looking in '" << *i << "'" << std::endl); Filenames.clear(); //int nbFiles = Utilities::Explore(*i, false, Filenames); - + + int iFilesnames,jFilesnames,sizeFilenames; + sizeFilenames=Filenames.size(); + + + // EEDd 30 sept 2012 + //Sorting list of files + for (iFilesnames=0;iFilesnames Filenames[jFilesnames] ) + { + tmpFilenames = Filenames[iFilesnames]; + Filenames[iFilesnames] = Filenames[jFilesnames]; + Filenames[jFilesnames] = tmpFilenames; + } // if Filesnames + } // for iFilesnames + } // for iFilesnames + + + for (std::vector::iterator j = Filenames.begin(); j!= Filenames.end(); ++j) { @@ -1463,6 +1494,7 @@ namespace bbtk } std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false); + //Addition JCP tfullPathScriptName.size()>=4 if(tfullPathScriptName.size()>=4){ if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb") @@ -1524,19 +1556,32 @@ namespace bbtk return; } else { LoadScript(fullPathScriptName,name); -//EED Borrame if (source) GetExecuter()->SetCurrentFileName(fullPathScriptName); - if (source) SetCurrentFileName(fullPathScriptName); + if (source) + { + // Over writing the fullpath of the bbp file. + SetCurrentFileName( fullPathScriptName ); + SetTypeOfScript_Application(); + } } + return; } //======================================================================= //======================================================================= - void InterpreterVirtual::SetCurrentFileName(std::string fullPathScriptName) // virtual + void InterpreterVirtual::SetCurrentFileName(const std::string &fullPathScriptName) // virtual { } //======================================================================= + + //======================================================================= + void InterpreterVirtual::SetTypeOfScript_Application( ) + { + } + //======================================================================= + + //======================================================================= void InterpreterVirtual::SwitchToStream( std::stringstream* stream ) { @@ -1650,6 +1695,7 @@ void InterpreterVirtual::SwitchToStream( std::stringstream* stream ) void InterpreterVirtual::InterpretCommand( const std::vector& words, CommandInfoType& info ) { + bbtkDebugMessage("interpreter",9,"==> InterpreterVirtual::InterpretCommand(...)"<& words,"<second; - bbtkDebugMessage("interpreter",9,"<== InterpreterVirtual::InterpretCommand(...)"<