X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkInterpreter.cxx;h=ab194e90913eb95ebf7b8e4ec58c7064dc6d48ff;hb=5e6e754f059d5fb6b25b883f89f76333228ba5c4;hp=28dbfe43798c7b94b7c46668c8df21f3035bdc79;hpb=97d3e37bb950037df11ff1f40a43b2328ce460ee;p=bbtk.git diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index 28dbfe4..ab194e9 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ $ Language: C++ - Date: $Date: 2008/03/03 14:55:55 $ - Version: $Revision: 1.39 $ + Date: $Date: 2008/03/10 06:24:13 $ + Version: $Revision: 1.42 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,7 +37,7 @@ namespace bbtk { -Interpreter* Interpreter::mGlobalInterpreter = NULL; + //Interpreter* Interpreter::mGlobalInterpreter = NULL; //======================================================================= /** @@ -45,15 +45,17 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL; */ Interpreter::Interpreter() : +#ifdef _USE_WXWIDGETS_ + mWxConsole(0), +#endif mCommandLine(false) { bbtk::MessageManager::RegisterMessageType("Echo","Level>0 : Prints the 'echo' commands of the user.\n\tLevel>1 : Prints the command being interpreted",1); bbtk::MessageManager::RegisterMessageType("Interpreter","Messages of the interpreter",0); bbtkDebugMessageInc("Interpreter",9,"Interpreter::Interpreter()" <SetInterpreter(this); // For the time being, comment out previous line, and // uncomment next line to check Transcriptor @@ -291,7 +293,6 @@ Interpreter* Interpreter::mGlobalInterpreter = NULL; std::cout << "=========================================~Interpreter()" << std::endl; bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <0) { +printf("EED --- %s --- Interpreter::InterpretFile \n", mFileName[0].c_str() ); while ((mFile.size()>0) && (!mFile.back()->eof())) +//EED3 (!mFile[0]->eof())) { mLine.back()++; char buf[500]; mFile.back()->getline(buf,500); +//EED3 mFile[0]->getline(buf,500); std::string str(buf); int size=str.length(); @@ -330,6 +342,7 @@ std::cout << "=========================================~Interpreter()" << std::e } InterpretLine(str, insideComment); +printf("EED Interpreter::InterpretFile %s\n", str.c_str() ); } //if (mFile.size()>0) CloseCurrentFile(); @@ -573,16 +586,16 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment ) // if 'source' was given if (words.size()==3) { - this->mExecuter->SetCurrentFileName(words[1]); + GetExecuter()->SetCurrentFileName(words[1]); } break; case cLoad: - LoadPackage(words[1]); + GetExecuter()->GetFactory()->LoadPackage(words[1]); break; case cUnload: - UnLoadPackage(words[1]); + GetExecuter()->GetFactory()->UnLoadPackage(words[1]); break; case cQuit : @@ -794,7 +807,11 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& { 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) @@ -837,15 +854,20 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& } foundFile = true; - + Filenames.clear(); int nbFiles = Utilities::Explore(fullDirectoryName, false, Filenames); nbBssFiles = 0; for (std::vector::iterator i = Filenames.begin(); i!= Filenames.end(); ++i) { +//EEDprintf("EED Interpreter::SwitchToFile %s\n",(*i).c_str() ); 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) @@ -963,9 +985,25 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& void Interpreter::LoadScript( std::string fullPathScriptName, std::string includeScriptName) { - if (find(mFileName.begin(),mFileName.end(),fullPathScriptName) - !=mFileName.end()) +//EED printf("EED Interpreter::LoadScript >>01\n"); + Utilities::replace( fullPathScriptName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); + + bool okScriptExist=false; + int iStrScript,sizeVecStricpt=mFileName.size(); + for ( iStrScript=0;iStrScript>__ %s\n", iStrScript,mFileName[iStrScript].c_str(),fullPathScriptName.c_str() ); + if (mFileName[iStrScript] == fullPathScriptName ) + { + printf(" EED %d Interpreter::LoadScript iguales\n",iStrScript ); + okScriptExist=true; + } // if + } // for + + if (find(mFileName.begin(),mFileName.end(),fullPathScriptName)!=mFileName.end()) +// if (okScriptExist==true) { +//EED printf("EED Interpreter::LoadScript Exit method\n"); bbtkMessage("Interpreter",1,"file '"<& mFileName.push_back(fullPathScriptName); mIncludeFileName.push_back(includeScriptName); mLine.push_back(0); +//EED printf("EED Interpreter::LoadScript >>02\n"); return; } @@ -1005,15 +1044,23 @@ void Interpreter::SplitLine ( const std::string& str, std::vector& return; } + bbtkDebugMessage("Interpreter",9," Closing file '"<close(); delete mFile.back(); mFile.pop_back(); - bbtkDebugMessage("Interpreter",9, - " Closing file '"<close(); + delete mFile[0]; + mFile.erase( mFile.begin() ); + mFileName.erase( mFileName.begin() ); + mIncludeFileName.erase( mIncludeFileName.begin() ); + mLine.erase( mLine.begin() ); +*/ + bbtkDebugMessage("Interpreter",9," Remains " <& words) { if (words[1]=="packages") { - PrintPackages(true); + GetExecuter()->GetFactory()->PrintPackages(true); return; } try @@ -1104,16 +1151,16 @@ void Interpreter::Help(const std::vector& words) { try { - HelpPackage(words[1]); + GetExecuter()->GetFactory()->HelpPackage(words[1]); #ifdef _USE_WXWIDGETS_ - if ( WxConsole::GetInstance() != 0 ) + if ( mWxConsole != 0 ) { std::string url = ConfigurationFile::GetInstance().Get_doc_path(); url += "/bbdoc/" + words[1] + "/index.html"; if (Utilities::FileExists(url)) { - WxConsole::GetInstance()->ShowHtmlPage(url); + mWxConsole->ShowHtmlPage(url); } } #endif @@ -1123,9 +1170,9 @@ void Interpreter::Help(const std::vector& words) try { std::string package; - HelpBlackBox(words[1],package); + GetExecuter()->GetFactory()->HelpBlackBox(words[1],package); #ifdef _USE_WXWIDGETS_ - if ( WxConsole::GetInstance() != 0 ) + if ( mWxConsole != 0 ) { std::string url = ConfigurationFile::GetInstance().Get_doc_path(); @@ -1133,7 +1180,7 @@ void Interpreter::Help(const std::vector& words) if (Utilities::FileExists(url)) { url += "#" + words[1]; - WxConsole::GetInstance()->ShowHtmlPage(url); + mWxConsole->ShowHtmlPage(url); } } #endif @@ -1142,7 +1189,7 @@ void Interpreter::Help(const std::vector& words) { try { - this->mExecuter->ShowRelations(words[1],"0","9999"); + GetExecuter()->ShowRelations(words[1],"0","9999"); } catch (bbtk::Exception h){ bbtkError("\""<& words) { if ( words[1]=="packages" ) { - PrintPackages(true,true); + GetExecuter()->GetFactory()->PrintPackages(true,true); return; } try { - HelpPackage(words[1],true); + GetExecuter()->GetFactory()->HelpPackage(words[1],true); } catch (bbtk::Exception f) { @@ -1531,7 +1578,7 @@ void Interpreter::Graph(const std::vector& words) bool system_display = true; #ifdef _USE_WXWIDGETS_ - if ( WxConsole::GetInstance() != 0 ) system_display = false; + if ( mWxConsole != 0 ) system_display = false; #endif if (words.size()==1) @@ -1564,8 +1611,8 @@ void Interpreter::Graph(const std::vector& words) } #ifdef _USE_WXWIDGETS_ - if ( WxConsole::GetInstance() != 0 ) - WxConsole::GetInstance()->ShowHtmlPage(page); + if ( mWxConsole != 0 ) + mWxConsole->ShowHtmlPage(page); #endif } //======================================================================= @@ -1581,7 +1628,7 @@ void Interpreter::Index(const std::string& filename, else if (type=="Packages") t = Factory::Packages; else if (type=="Adaptors") t = Factory::Adaptors; - GetGlobalFactory()->CreateHtmlIndex(t,filename); + GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename); } //=======================================================================