]> Creatis software - bbtk.git/blob - kernel/src/bbtkInterpreter.cxx
a71ded325b84c46a1900800762e04b74f7afab1b
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkInterpreter.cxx,v $
4   Language:  C++
5   Date:      $Date: 2012/11/14 07:12:00 $
6   Version:   $Revision: 1.94 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief class Interpreter :
34  */
35
36 #include "bbtkInterpreter.h"
37 #include "bbtkExecuter.h"
38 #include "bbtkTranscriptor.h"
39 #include "bbtkMessageManager.h"
40 #include "bbtkConfigurationFile.h"
41 #include "bbtkUtilities.h"
42 #include "bbtkAtomicBlackBox.h"
43 #include "bbtkWxBlackBox.h"
44 #include <sys/stat.h>
45 #include <algorithm>
46 #ifdef CMAKE_HAVE_TERMIOS_H
47 #include <termios.h>
48 #define BBTK_USE_TERMIOS_BASED_PROMPT
49 #endif
50
51 #include <string>
52
53 namespace bbtk
54 {
55
56  //=======================================================================
57   Interpreter::Pointer Interpreter::New(const std::string& cpp_file) 
58   {
59     bbtkDebugMessage("kernel",9,"Interpreter::New('"<<cpp_file<<"')"<<std::endl);
60     return MakePointer(new Interpreter(cpp_file));
61   }
62  //=======================================================================
63
64  //=======================================================================
65   Interpreter::Pointer Interpreter::New(VirtualExec::Pointer e) 
66   {
67     bbtkDebugMessage("kernel",9,"Interpreter::New(VirtualExec)"<<std::endl);
68     return MakePointer(new Interpreter(e));
69   }
70  //=======================================================================
71
72  //=======================================================================
73   Interpreter::Interpreter(const std::string& cpp_file) 
74   {
75     bbtkDebugMessage("object",2,"==> Interpreter("<<cpp_file<<")"<<std::endl);
76     Init(VirtualExec::Pointer(), cpp_file);
77     bbtkDebugMessage("object",2,"<== Interpreter("<<cpp_file<<")"<<std::endl);
78   }
79   //=======================================================================
80
81  //=======================================================================
82   Interpreter::Interpreter(VirtualExec::Pointer e) 
83   {
84     bbtkDebugMessage("object",2,"==> Interpreter(VirtualExec)"<<std::endl);
85     Init(e,"");
86     bbtkDebugMessage("object",2,"<== Interpreter(VirtualExec)"<<std::endl);
87   }
88   //=======================================================================
89
90   //=======================================================================
91   void Interpreter::Init(VirtualExec::Pointer e, const std::string& cpp_file) 
92   {
93     if (e)
94       {
95         mVirtualExecuter = e;
96       }
97     else if (cpp_file.size()!=0)
98       {
99         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
100       }
101     else 
102       {
103         bbtk::Executer::Pointer exe = bbtk::Executer::New();
104         mRealExecuter = exe;
105         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(exe);
106       }
107
108           
109           
110     // Lock this pointer or will auto-destruct !!
111     if (!e) mVirtualExecuter->SetInterpreter(MakePointer(this,true));
112
113           
114           bbtk::InterpreterVirtual::Init();
115   } 
116   //=======================================================================
117   
118   
119   
120   //=======================================================================  
121   /**
122    *  
123    */
124   Interpreter::~Interpreter()
125   {
126     bbtkDebugMessage("object",2,"==> ~Interpreter()" <<std::endl);
127     mVirtualExecuter = VirtualExec::Pointer();
128     bbtkDebugMessage("object",2,"<== ~Interpreter()" <<std::endl);
129   }
130   //=======================================================================
131
132 /*EED Borrame
133   //=======================================================================
134   InterpreterException::InterpreterException( const std::string& message,
135                                       bool in_script_file,
136                                       const std::string& script_file,
137                                       int script_line 
138                                       )
139     : Exception("interpreter",0,message),
140       mInScriptFile(in_script_file),
141       mScriptFile(script_file),
142       mScriptLine(script_line)
143   {
144   }
145   //=======================================================================
146   //=======================================================================
147   InterpreterException::InterpreterException( const Exception& excep,
148                       bool in_script_file,
149                       const std::string& script_file,
150                       int script_line 
151                       )
152     : Exception(excep),
153       mInScriptFile(in_script_file),
154       mScriptFile(script_file),
155       mScriptLine(script_line)
156   {
157   }
158   //=======================================================================
159 */
160
161   //=======================================================================
162   void Interpreter::CatchInterpreterException( const InterpreterException& e )
163   {
164     if (GetExecuter()->GetNoErrorMode()) 
165       {
166         bbtkWarning("ERROR :"<<e.GetErrorMessage()
167                     <<" ("<<e.GetScriptFile()<<":"<<e.GetScriptLine()
168                     <<" skipped");
169
170         return;
171       }
172           
173           bbtk::InterpreterVirtual::CatchInterpreterException(  e );      
174   }
175   //=======================================================================
176
177   //=======================================================================
178   void Interpreter::CatchBbtkException( const bbtk::Exception& e )
179   {
180     if (GetExecuter()->GetNoErrorMode()) 
181       {
182         std::string file("?");
183         int line = 0;
184         if (mFileName.size()) {
185           file = mFileName.back();
186           line = mLine.back();
187         }    
188         bbtkWarning("ERROR '"<<e.GetErrorMessage()
189                     <<"' ("<<file<<":"<<line<<") skipped");
190         
191         return;
192       }
193           
194           bbtk::InterpreterVirtual::CatchBbtkException(  e );     
195   }
196   //=======================================================================
197   
198   //=======================================================================
199   void Interpreter::CatchStdException( const std::exception& e )
200   {  
201         if (GetExecuter()->GetNoErrorMode()) 
202         {
203                 std::string file("?");
204                 int line = 0;
205                 if (mFileName.size()) 
206                 {
207                         file = mFileName.back();
208                         line = mLine.back();
209                 }    
210                 bbtkWarning("ERROR '"<<e.what() <<"' ("<<file<<":"<<line<<") skipped");
211                 return;
212       }
213           bbtk::InterpreterVirtual::CatchStdException(  e );      
214   }
215   //=======================================================================
216
217   //=======================================================================
218   void Interpreter::CatchUnknownException()
219   {
220         if (GetExecuter()->GetNoErrorMode()) 
221         {
222                 std::string file("?");
223                 int line = 0;
224                 if (mFileName.size()) 
225                 {
226                         file = mFileName.back();
227                         line = mLine.back();
228                 }  
229                 bbtkWarning("UNDEFINED ERROR " <<"("<<file<<":"<<line<<") skipped");
230                 return;
231         }
232
233           bbtk::InterpreterVirtual::CatchUnknownException( );     
234   }
235   //=======================================================================
236
237   //=======================================================================
238   
239 #define CATCH_MACRO                                     \
240   catch (InterpreterException e)                        \
241     {                                                   \
242       CatchInterpreterException(e);                     \
243     }                                                   \
244   catch (bbtk::Exception e)                             \
245     {                                                   \
246       CatchBbtkException(e);                            \
247     }                                                   \
248   catch (std::exception& e)                             \
249     {                                                   \
250       CatchStdException(e);                             \
251     }                                                   \
252   catch (...)                                           \
253     {                                                   \
254       CatchUnknownException();                          \
255     }                                           
256   //=======================================================================
257    
258 /*EED Borrame
259   //=======================================================================
260   Interpreter::ExitStatus Interpreter::InterpretFile( const std::string& filename, bool source )
261   {
262     bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
263
264     bool exm = mCommandLine;
265     mCommandLine = false;
266
267     try 
268     {
269       mStatus = Interpreter_OK;
270       SwitchToFile(filename,source);
271       mInsideComment = false;
272       InterpretCurrentStreams();
273     } 
274     CATCH_MACRO;
275     
276     bbtkDebugMessage("interpreter",4,
277                      "<== Interpreter::InterpretFile(\""
278                      <<filename<<"\")"<<std::endl);
279
280
281     mCommandLine = exm;
282     
283     return mStatus;
284   }
285   //=======================================================================
286
287
288   //=======================================================================
289   Interpreter::ExitStatus 
290   Interpreter::InterpretBuffer( std::stringstream* buffer )
291   {
292     bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretBuffer()"<<std::endl);
293
294     bool exm = mCommandLine;
295     mCommandLine = false;
296
297     try 
298     {
299       mStatus = Interpreter_OK;
300       SwitchToStream(buffer);
301       mInsideComment = false;
302       InterpretCurrentStreams();
303     }
304     CATCH_MACRO;
305     
306     //    CloseAllFiles();
307     bbtkDebugMessage("interpreter",4,"<== Interpreter::InterpretBuffer()"<<std::endl);
308
309     
310     mCommandLine = exm;
311     return mStatus;
312   }
313   //=======================================================================
314
315   //=======================================================================
316   /// Interprets the currently open streams
317   Interpreter::ExitStatus Interpreter::InterpretCurrentStreams()
318   {
319     bbtkDebugMessage("interpreter",4,
320                      "==> Interpreter::InterpretCurrentStreams()"<<std::endl);
321
322     while (mFile.size()>0) 
323       {
324         while (!mFile.back()->eof()) {
325           mLine.back()++;
326           char buf[500];
327           mFile.back()->getline(buf,500);
328           std::string str(buf);
329           //size 0 JCP 21-09-2009
330           int size=str.length();
331           if(size != 0){
332                   if ( str[ size-1 ]==13  )
333             {
334               str.erase(size-1,1);
335             }
336                   try
337                         {
338                           DoInterpretLine(str);
339                         }
340                   CATCH_MACRO;
341           }
342           
343         } 
344         CloseCurrentFile();
345       }
346     bbtkDebugMessage("interpreter",4,
347                      "<== Interpreter::InterpretCurrentStreams()"<<std::endl);
348
349     return mStatus;
350   }
351   //=======================================================================
352
353   //=======================================================================
354   /// Runs the interpretation of a command
355   Interpreter::ExitStatus Interpreter::InterpretLine( const std::string& line )
356   {
357     bbtkDebugMessage("interpreter",5,"==> Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
358
359     try 
360     {
361       mStatus = Interpreter_OK;
362       mInsideComment = false;
363 //std::cout<<"JCP bbtkInterpreter.cxx Interpreter::InterpretLine("<<std::endl;
364       DoInterpretLine(line );
365     }
366     CATCH_MACRO;
367     
368     
369    bbtkDebugMessage("interpreter",5,"<== Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
370     
371     return mStatus;
372   }
373   //=======================================================================  
374 */
375         
376         
377         void Interpreter::commandNew(const std::string &boxType,const  std::string &boxName)  //virtual
378     {
379                 mVirtualExecuter->Create(boxType,boxName);
380     }
381         
382         void Interpreter::commandDelete(const std::string &boxName)  //virtual
383     {
384                 mVirtualExecuter->Destroy(boxName);
385     }
386
387         void Interpreter::commandConnection(const std::string &nodeFrom,const  std::string &outputLabel,const  std::string &nodeTo,const  std::string &inputLabel) //virtual
388     {
389                 mVirtualExecuter->Connect(nodeFrom,outputLabel,nodeTo,inputLabel);
390     }
391                 
392         void Interpreter::commandPackage(const std::string &packageName) //virtual
393     {
394                 mVirtualExecuter->BeginPackage(packageName);
395     }
396         
397         void Interpreter::commandEndPackage() //virtual
398     {
399                 mVirtualExecuter->EndPackage();
400     }
401         
402         void Interpreter::commandDefine(const std::string &name,const  std::string &pack,const  std::string &scriptfilename) //virtual
403     {
404                 mVirtualExecuter->Define(name,pack,scriptfilename);
405     }
406
407         void Interpreter::commandEndDefine() //virtual
408     {
409                 mVirtualExecuter->EndDefine();
410     }
411
412         void Interpreter::commandKind(const std::string &kind) //virtual
413     {
414                 mVirtualExecuter->Kind(kind);
415     }
416         
417         void Interpreter::commandPrint(const std::string &value) //virtual
418     {
419                 mVirtualExecuter->Print(value);
420     }
421         
422         
423         void Interpreter::commandExec(const std::string &word) //virtual
424     {
425                 if (word=="freeze") 
426                 {
427                         mVirtualExecuter->SetNoExecMode(true);
428                         mThrow = false;
429                 }
430                 else if (word=="freeze_no_error") 
431                 {
432                         mVirtualExecuter->SetNoExecMode(true);
433                         mVirtualExecuter->SetNoErrorMode(true);
434                         mThrow = false;
435                 }
436                 else if (word=="unfreeze") 
437                 {
438                         mVirtualExecuter->SetNoExecMode(false);
439                         mVirtualExecuter->SetNoErrorMode(false);
440                 }
441                 else
442                 {
443                         mVirtualExecuter->Execute(word);
444                 } // if
445     }
446         
447         
448         void Interpreter::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string  &help) //virtual
449     {
450                 mVirtualExecuter->DefineInput(name,box,input,help);
451     }
452         
453         void Interpreter::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string  &help) //virtual
454     {
455                 mVirtualExecuter->DefineOutput(name,box,output,help);
456     }
457         
458         void Interpreter::commandSet(const std::string &box,const std::string &input,const std::string &value) //virtual
459     {
460                 mVirtualExecuter->Set(box,input,value);
461     }
462
463         void Interpreter::commandAuthor(const std::string &author) //virtual
464     {
465                 mVirtualExecuter->Author(author);
466     }
467
468         void Interpreter::commandCategory(const std::string &categorytype) //virtual
469     {
470                 mVirtualExecuter->Category(categorytype);
471     }
472         
473         void Interpreter::commandDescription(const std::string &description) //virtual
474     {
475                 mVirtualExecuter->Description(description);
476     }
477
478         
479         void Interpreter::commandClear() //virtual
480     {
481                 mVirtualExecuter->Clear();
482     }
483         
484         void Interpreter::commandInclude(const std::string &word, bool ok) //virtual
485     {
486                 // if 'source' was given (words.size()==3) then tell to set the 
487                 // source file name of the current complex box with the full file name included
488                 if (mCommandLine)
489                 {
490                         InterpretFile(word, ok ); 
491                 }
492                 else
493                 {
494                         SwitchToFile(word , ok );
495                 }
496     }
497         
498         
499         void Interpreter::commandLoad(const std::string &packageName) //virtual
500     {
501                 GetExecuter()->LoadPackage(packageName);
502     }
503
504         void Interpreter::commandUnload(const std::string &packageName) //virtual
505     {
506                 GetExecuter()->UnLoadPackage(packageName);
507     }
508         
509         void Interpreter::commandBreak() //virtual
510     {
511             /*
512                  std::cout << "BreakException(" 
513                  <<in_script<<","
514                  <<file<<","
515                  <<line<<")"<<std::endl;
516                  */
517                 bbtkError("break");//,in_script,file,line);
518             //      throw BreakException(in_script,file,line);
519     }
520         
521         void Interpreter::commandQuit() //virtual
522     {
523                 bbtkError("quit");//,in_script,file,line);
524                 //throw QuitException(in_script,file,line);
525     }
526         
527         void Interpreter::commandMessage() //virtual
528     {
529                 mVirtualExecuter->HelpMessages();
530     }
531         
532         void Interpreter::commandMessage(const std::string &kind,const std::string &levelstr) //virtual
533     {
534                 int level=0;
535                 sscanf(levelstr.c_str(),"%d",&level);
536                 mVirtualExecuter->SetMessageLevel(kind,level);
537
538     }
539         
540         
541 /*EED Borrame   
542   //=======================================================================  
543   void Interpreter::DoInterpretLine( const std::string& line ) //virtual
544    {
545     bbtkDebugMessage("interpreter",6,"==> Interpreter::DoInterpretLine(\""
546                      <<line<<"\")"<<std::endl);
547     std::vector<std::string> words;
548     SplitLine(line,words);
549
550     // Empty line
551     if (words.size()<1) 
552     {
553        bbtkDebugDecTab("interpreter",9);
554        return;
555     }
556
557     // Single line comment : # or //
558     if ( words[0][0]=='#' || (words[0][0]=='/' && words[0][1]=='/') ) 
559     {  
560        bbtkDebugDecTab("interpreter",9);
561        bbtkMessage("interpreter",9,"Comment"<<std::endl);
562        return;
563     }
564
565     // Multi line comment ( / * ... * / ) -delimiters on different lines !-   <<<<<<<  / *     * /
566     
567     if (words[0][0]=='/' && words[0][1]=='*') 
568     {  
569        bbtkDebugDecTab("interpreter",9);
570        bbtkMessage("interpreter",9,"In multiline comment"<<std::endl);
571        mInsideComment = true;
572        return;
573     }
574
575     if (words[0][0]=='*' && words[0][1]=='/') 
576     {  
577        bbtkDebugDecTab("interpreter",9);
578        bbtkMessage("interpreter",9,"Out multiline comment"<<std::endl);
579        if ( !mInsideComment ) {
580           bbtkDebugDecTab("interpreter",9);
581           bbtkMessage("interpreter",9,"Comment mismatch : '* /' with no matching '/ *'"<<std::endl);        <<<<<<<<< * /       / * 
582        }
583        mInsideComment = false;
584        return;
585     }
586
587     if (mInsideComment) 
588     {  
589        bbtkDebugDecTab("interpreter",9);
590        bbtkMessage("interpreter",9,"Multiline Comment"<<std::endl);
591        return;
592     }
593
594     // Command 
595     CommandInfoType command;
596     InterpretCommand(words,command);
597 //std::cout<<"JCP bbtkInterpreter command.keyword ="<<command.keyword<<std::endl;
598     bbtkDebugMessage("interpreter",9,
599                      "Command='"<<command.keyword
600                       <<"' code="<<command.code<<std::endl); 
601           
602     std::string left,right,left2,right2;
603     std::string filename;
604
605 //ups1 EED borrame        
606     // message command
607     if (command.code==cMessage)
608       {
609         if (words.size()<3)
610           {
611                   commandMessage();
612 //EED Borrame       mVirtualExecuter->HelpMessages();
613           }
614         else
615           {
616                 commandMessage(words[1],words[2]);
617 //EED Borrame           sscanf(words[2].c_str(),"%d",&level);
618 //EED Borrame       mVirtualExecuter->SetMessageLevel(words[1],level);
619           }
620         return;
621       }
622     else 
623       {
624         bbtkMessage("echo",2,line<<std::endl);
625       }
626
627     // break and quit commands
628     if ((command.code==cBreak) || (command.code==cQuit))
629       {
630         bool in_script = false;
631         std::string file("");
632         int line = 0;
633
634         if (mFileName.size()) 
635           {
636             std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
637             if (fs!=0) in_script = true;          
638             file = mFileName.back();
639             line = mLine.back();
640           } 
641         if (command.code==cBreak)
642           {
643 //          std::cout << "BreakException(" 
644 //                    <<in_script<<","
645 //                    <<file<<","
646 //                    <<line<<")"<<std::endl;
647                   commandBreak();
648 //EED Borrame       bbtkError("break");//,in_script,file,line);
649             //      throw BreakException(in_script,file,line);
650           }       
651         else 
652           {
653                   commandQuit();
654 //EED Borrame       bbtkError("quit");//,in_script,file,line);
655               //throw QuitException(in_script,file,line);
656           }
657         return;
658       }   
659 //std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl;
660     // other cammands
661
662     switch (command.code) 
663       {
664       case cNew :
665                 commandNew(words[1],words[2]);
666 //EED Borrame        mVirtualExecuter->Create(words[1],words[2]);
667         break;
668
669       case cDelete :
670                           commandDelete(words[1]);
671 //EED Borrame   mVirtualExecuter->Destroy(words[1]);
672         break;
673
674       case cConnect :
675         Utilities::SplitAroundFirstDot(words[1],left,right);
676         Utilities::SplitAroundFirstDot(words[2],left2,right2);      
677         commandConnection(left,right,left2,right2);
678 //EED Borrame        mVirtualExecuter->Connect(left,right,left2,right2);
679         break;
680
681       case cPackage :
682                           commandPackage(words[1]);
683 //EED Borrame                mVirtualExecuter->BeginPackage(words[1]);
684         break;
685
686       case cEndPackage :
687                           commandEndPackage();
688 //EED Borrame        mVirtualExecuter->EndPackage();
689         break;
690
691       case cDefine :
692         if (mFileName.size()>0) 
693         {
694 //???                   commandDefine(????);
695                    filename = mFileName.back(); //mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back());
696         }
697         if (words.size()==2) 
698         {
699                         commandDefine(words[1],"",filename);
700 //EED Borrame           mVirtualExecuter->Define(words[1],"",filename);
701         }
702         else
703         {
704                         commandDefine(words[1],words[2],filename);
705 //EED Borrame           mVirtualExecuter->Define(words[1],words[2],filename);
706         }
707         break;
708
709       case cEndDefine :
710                 commandEndDefine();
711 //EED Borrame        mVirtualExecuter->EndDefine();
712         break;
713
714       case cKind :
715                         commandKind(words[1]);
716 //EED Borrame        mVirtualExecuter->Kind(words[1]);
717         break;
718
719       case cPrint :
720                           commandPrint(words[1]);
721 //EED Borrame        mVirtualExecuter->Print(words[1]);
722         break;
723                           
724       case cExec :
725                           commandExec(words[1]);
726 //EED Borrame        if (words[1]=="freeze") 
727 //EED Borrame     {
728 //EED Borrame       mVirtualExecuter->SetNoExecMode(true);
729 //EED Borrame       mThrow = false;
730 //EED Borrame     }
731 //EED Borrame   else if (words[1]=="freeze_no_error") 
732 //EED Borrame     {
733 //EED Borrame       mVirtualExecuter->SetNoExecMode(true);
734 //EED Borrame       mVirtualExecuter->SetNoErrorMode(true);
735 //EED Borrame       mThrow = false;
736 //EED Borrame     }
737 //EED Borrame   else if (words[1]=="unfreeze") 
738 //EED Borrame     {
739 //EED Borrame       mVirtualExecuter->SetNoExecMode(false);
740 //EED Borrame       mVirtualExecuter->SetNoErrorMode(false);
741 //EED Borrame     }
742 //EED Borrame   else
743 //EED Borrame     {
744 //EED Borrame       mVirtualExecuter->Execute(words[1]);
745 //EED Borrame     }
746                           
747         break;
748
749       case cInput :
750         Utilities::SplitAroundFirstDot(words[2],left,right);
751                           commandInput(words[1],left,right,words[3]);
752 //EED Borrame        mVirtualExecuter->DefineInput(words[1],left,right,words[3]);
753         break;
754
755       case cOutput :
756         Utilities::SplitAroundFirstDot(words[2],left,right);
757                 commandOutput(words[1],left,right,words[3]);
758 //EED Borrame         mVirtualExecuter->DefineOutput(words[1],left,right,words[3]);
759         break;
760
761       case cSet :
762         Utilities::SplitAroundFirstDot(words[1],left,right);
763                 commandSet(left,right,words[2]);
764 //EED Borrame        mVirtualExecuter->Set(left,right,words[2]);
765         break;
766
767       case cAuthor :
768                 commandAuthor(words[1]);
769 //EED Borrame        mVirtualExecuter->Author(words[1]);
770         break;
771
772       case cNewGUI :
773                 commandNewGUI(words[1],words[2]);
774         break;
775
776       case cCategory :
777                 commandCategory(words[1]);
778 //EED Borrame   mVirtualExecuter->Category(words[1]);
779         break;
780
781       case cIndex :
782         if (words.size()==1)
783                         commandIndex("tmp_index.html");
784         else if (words.size()==2)
785                         commandIndex(words[1]);
786         else if (words.size()==3)
787                         commandIndex(words[1],words[2]);
788         break;
789
790       case cDescription :
791                 commandDescription(words[1]);
792 //EED Borrame        mVirtualExecuter->Description(words[1]);
793         break;
794
795       case cHelp :
796         commandHelp(words);
797         break;
798
799
800       case cGraph :
801         commandGraph(words);
802         break;
803
804       case cConfig :
805         commandConfig();
806         break;
807
808       case cReset :  
809         commandReset();
810         break;
811         
812       case cClear :  
813                 commandClear();
814 //EED Borrame           mVirtualExecuter->Clear();
815         break;
816
817       case cInclude :
818                           commandInclude( words[1] , (words.size()==3) );
819 //EED Borrame           // if 'source' was given (words.size()==3) then tell to set the 
820 //EED Borrame           // source file name of the current complex box with the full file name included
821 //EED Borrame           if (mCommandLine)
822 //EED Borrame        {
823 //EED Borrame           InterpretFile(words[1],(words.size()==3)); 
824 //EED Borrame        } else{
825 //EED Borrame            SwitchToFile(words[1],(words.size()==3) );
826 //EED Borrame        }
827                 break;
828
829       case cLoad:
830                 commandLoad( words[1] );
831 //EED Borrame        GetExecuter()->LoadPackage(words[1]);
832         break;
833
834       case cUnload:
835                 commandUnload( words[1] );
836 //EED Borrame        GetExecuter()->UnLoadPackage(words[1]);
837         break;
838
839       case cDebug :
840                           if (words.size()==2) commandDebug(words[1]);
841                                 else commandDebug("");
842         break;
843                           
844         // obsolete
845     //  case cWorkspace :
846     //    if (words.size() == 2) 
847     //    {
848     //       if (words[1]=="freeze")        mVirtualExecuter->SetNoExecMode(true);
849     //       else if (words[1]=="unfreeze") mVirtualExecuter->SetNoExecMode(false);
850     //    }
851     //    else
852     //    {
853     //       mVirtualExecuter->SetWorkspaceName(words[2]);
854     //    }
855     //    break;
856
857                 default:
858         bbtkInternalError("should not reach here !!!");
859    }
860
861     bbtkDebugMessage("interpreter",6,"<== Interpreter::DoInterpretLine(\""
862                      <<line<<"\")"<<std::endl);
863     
864   }
865   //=======================================================================  
866
867
868
869
870   //=======================================================================
871   void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>& tokens)
872 {
873     bbtkDebugMessage("interpreter",9,"==> Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
874
875     std::string delimiters = "\"";
876     std::vector<std::string> quote;
877     Utilities::SplitString(str,delimiters,quote);
878
879     delimiters = " \t";
880     std::vector<std::string>::iterator i;
881     for (i=quote.begin(); i!=quote.end(); ) 
882     {
883        Utilities::SplitString(*i,delimiters,tokens);
884        ++i;
885        if (i!=quote.end()) 
886        {
887         //    bbtkDebugMessage("interpreter",0,"\""<<*i<<"\""<<std::endl);
888           tokens.push_back(*i);
889           ++i;
890        }
891     }
892
893     for (i=tokens.begin(); i!=tokens.end(); ++i) 
894     {
895       bbtkDebugMessage("interpreter",9,"--["<<*i<<"]"<<std::endl);
896     }
897     bbtkDebugMessage("interpreter",9,"<== Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
898
899  }
900   //=======================================================================
901 */
902
903
904   //=======================================================================
905   void Interpreter::commandReset()  // virtual
906   {
907     // Cannot close all files if the reset command is read from a file !
908     CloseAllFiles();
909     mFileNameHistory.clear();
910     this->mVirtualExecuter->Reset();
911   }
912   //=======================================================================
913
914   //=======================================================================
915   /**
916    *
917    */
918   /*
919   void Interpreter::Print( const std::string& str)
920   {
921     if (mVirtualExecuter->GetNoExecMode()) return;
922
923     bbtkDebugMessageInc("interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
924
925  // TO DO :
926  // InterpretLine ("load std")
927  // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 
928  // InterpretLine("new Print _P_") 
929  // InterpretLine("connect _C_.Out _P_.In")
930  // int num = 1
931  
932
933     std::vector<std::string> chains;
934     std::string delimiters("$");
935
936     // Skip delimiters at beginning.
937     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
938     bool is_text = true;
939     if (lastPos>0) is_text = false;
940
941     // Find first delimiter.
942     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
943
944     while (std::string::npos != pos || std::string::npos != lastPos)
945     {
946        if (is_text) 
947        {
948           // Found a text token, add it to the vector.
949           chains.push_back(str.substr(lastPos, pos - lastPos));
950  // std::string token = str.substr(lastPos, pos - lastPos)
951  // InterpretLine("set _C_.In%num% %token%")
952  
953        }
954        else 
955        {
956
957        // is an output (between $$) : decode 
958          std::string tok,box,output;
959          tok = str.substr(lastPos, pos - lastPos);
960          Utilities::SplitAroundFirstDot(tok,box,output);
961          chains.push_back( mVirtualExecuter->Get(box,output) );
962
963 // InterpretLine("connect %tok% _C_.In%num%") 
964
965        }
966         // Skip delimiters.  Note the "not_of"
967        lastPos = str.find_first_not_of(delimiters, pos);
968         // Find next delimiter
969        pos = str.find_first_of(delimiters, lastPos);
970     //
971        is_text = !is_text;
972 // num ++;
973      }
974 // InterpretLine("exec _P_")
975 // if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
976
977      std::vector<std::string>::iterator i;
978      for (i= chains.begin(); i!=chains.end(); ++i) 
979      {
980
981        Utilities::SubsBackslashN(*i);
982        std::cout << *i;
983      }
984      std::cout << std::endl;
985      bbtkDebugDecTab("interpreter",9);
986  }
987 */
988
989   //=======================================================================
990   /**
991    *
992    */
993 /*EED Borrame
994   // =========================================================================
995   void Interpreter::SwitchToFile( const std::string& name , bool source )
996   {
997   // Note : in the following :
998   // name : the user supplied name 
999   //      - abreviated name    e.g.       scr   scr.bbs
1000   //      - relative full name e.g.       ./scr.bbs   ../../scr.bbs 
1001   //      - absolute full name e.g.       /home/usrname/proj/dir/scr.bbs
1002   //          same for Windows, with      c:, d: ...
1003   //
1004   // use ./directory/subdir/scrname.bbs
1005   //
1006
1007     bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToFile( \""
1008                      <<name<<"\")"<<std::endl);
1009
1010     std::vector<std::string> script_paths;
1011     std::string fullPathScriptName;  // full path script name
1012     std::string pkgname;             // e.g. <scriptname>.bbs
1013     std::vector<std::string> Filenames;
1014
1015     // The following is *NOT* a debug time message :
1016     // It's a user intended message.
1017     // Please don't remove it.
1018     bbtkMessage("interpreter",1,
1019         "look for : [" << name
1020         << "]" << std::endl);
1021
1022
1023     std::string upath;
1024     pkgname = Utilities::ExtractScriptName(name,upath);
1025
1026     bbtkMessage("interpreter",3,
1027                 "package name:[" << pkgname
1028                  << "] path:[" << upath << "]" << std::endl);
1029     bool fullnameGiven = false; 
1030     bool foundFile     = false;
1031
1032     // ==== "*" provided : load all scripts in given path 
1033     // relative (e.g. std/boxes/ *) or absolute      <<<<<<<< / *
1034     if (pkgname == "*") 
1035       {
1036
1037         std::stringstream* stream = new std::stringstream;
1038         //if (upath.size()!=0) // avoid troubles for "*"
1039         
1040         // ==== no path provided : look in root bbs path
1041         if (upath.size()==0)
1042           {
1043             //      bbtkMessage("interpreter",1,
1044             // LG : add all bbs path
1045             //  script_paths.push_back(  ConfigurationFile::GetInstance().Get_root_bbs_path() );
1046             std::vector<std::string>::const_iterator i;
1047             for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin();
1048                  i!=ConfigurationFile::GetInstance().Get_bbs_paths().end();
1049                  i++)
1050               {
1051                 script_paths.push_back(*i);
1052               }
1053           }
1054         // ==== absolute path provided 
1055         else if (upath[0]=='/' || upath[1] == ':' ) 
1056           {
1057             if ( Utilities::IsDirectory( upath ) )
1058               {
1059                 script_paths.push_back(upath);
1060               }
1061             else 
1062               {
1063                 bbtkError("'"<<upath<<"' : directory does not exist"); 
1064               }
1065           }
1066         // ==== relative path provided : search all bbs path appended with 
1067         // the relative path provided
1068         else
1069           {    
1070             std::vector<std::string>::const_iterator i;
1071             for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin();
1072                  i!=ConfigurationFile::GetInstance().Get_bbs_paths().end();
1073                  i++)
1074               {
1075                 std::string full_path(*i);
1076                 // we *really* want '.' to be the current working directory
1077                 if (full_path == ".") 
1078                   {
1079                     char buf[2048]; // for getcwd
1080                     char * currentDir = getcwd(buf, 2048);
1081                     std::string cwd(currentDir);
1082                     full_path = currentDir;
1083                   } // if full_path
1084                 
1085                 full_path += ConfigurationFile::GetInstance().Get_file_separator();
1086                 full_path += upath;
1087                 
1088                 if ( Utilities::IsDirectory( full_path ) )
1089                   {
1090                     script_paths.push_back(full_path);
1091                   }
1092               } 
1093             if (script_paths.empty())
1094               {
1095                 bbtkError("no '"<<upath<<"' subdir found in search paths" 
1096                           << std::endl);
1097               }
1098           }
1099         
1100         
1101         // === search paths list complete : now explore it
1102         int nbBssFiles = 0;     
1103         // ==== relative name, iterate + load all .bbs/.bbp files
1104         std::vector<std::string>::iterator i;
1105         for (i=script_paths.begin();i!=script_paths.end();i++)
1106           {
1107             bbtkMessage("interpreter",1,
1108                         "--> Looking in '" << *i << "'" << std::endl);
1109             
1110             Filenames.clear();
1111             //int nbFiles = 
1112             Utilities::Explore(*i, false, Filenames);
1113             
1114             for (std::vector<std::string>::iterator j = Filenames.begin(); 
1115                  j!= Filenames.end(); ++j)
1116               {
1117                 int lgr = (*j).size();
1118                 if (lgr < 5) continue;  
1119                 // ignore non .bbp file
1120                 if ( (*j).substr(lgr-4, 4) != ".bbp") continue; 
1121                 
1122                 (*stream) << "include \"" << *j << "\"\n";
1123                 bbtkMessage("interpreter",2,"  --> Found '" << *j << "'" << std::endl);
1124                 
1125                 nbBssFiles++;
1126               } // for (std::vector...
1127           } // for (i=script_...
1128
1129         // === Result ...
1130         if (nbBssFiles==0)
1131           {
1132             bbtkMessage("interpreter",1,
1133                         "  --> No .bbp found"<< std::endl);
1134           } 
1135         else 
1136           {
1137             bbtkMessage("interpreter",1,
1138                         "  --> "<<nbBssFiles<<" .bbp found"<< std::endl);
1139             SwitchToStream(stream);
1140           }
1141         return;
1142       }  
1143     //=============== end pkgname=="*" ===========
1144     
1145     
1146     // if name starts with a / or a . or contains : user is assumed to have passed a relative/absolute name
1147     // (not only a plain script name)
1148     // we trust him, and try to expland the directory name
1149     // WARNING : starting from current local directory :  ./whatYouWant  (./ mandatory!)
1150
1151     if (name[0]=='/' || name[1] == ':' || name[0]=='.')  // absolute path (linux/windows) or relative path
1152     { 
1153
1154       // ===========================================================check user supplied location
1155       fullnameGiven = true;
1156
1157       fullPathScriptName =  Utilities::ExpandLibName(name, false);
1158
1159       // allow user to always forget ".bbs"
1160       int l = fullPathScriptName.size();
1161
1162       if (l!=0) 
1163           {
1164          if ((fullPathScriptName.substr(l-4, 4) != ".bbs")&&
1165                          (fullPathScriptName.substr(l-4, 4) != ".bbp"))
1166          {
1167                         std::string tfullPathScriptName = fullPathScriptName + ".bbs";
1168                         if ( Utilities::FileExists(tfullPathScriptName) )
1169                         {
1170                                 fullPathScriptName = tfullPathScriptName;
1171                                 foundFile = true;
1172                         }
1173                         else 
1174                         {
1175                                 tfullPathScriptName = fullPathScriptName + ".bbp";
1176                                 if ( Utilities::FileExists(tfullPathScriptName) )
1177                                 {
1178                                         fullPathScriptName = tfullPathScriptName;
1179                                         foundFile = true;
1180                                 }
1181                         }
1182                  }
1183                  else 
1184                  {
1185                         if ( Utilities::FileExists(fullPathScriptName) )
1186                         {
1187                                 foundFile = true;
1188                         }
1189                  }
1190           } // endif l != 0
1191   }
1192   else
1193   // =============================== iterate on the paths
1194   {
1195       script_paths = ConfigurationFile::GetInstance().Get_bbs_paths();
1196       std::string path;
1197       std::vector<std::string>::iterator i;
1198       for (i=script_paths.begin();i!=script_paths.end();++i)
1199           {
1200                 path = *i;
1201                 // we *really* want '.' to be the current working directory
1202                 if (path == ".") 
1203                 {
1204                         char buf[2048]; // for getcwd
1205                         char * currentDir = getcwd(buf, 2048);
1206                         std::string cwd(currentDir);
1207                         path = currentDir;
1208                 }
1209           
1210                 std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false);
1211 //Addition JCP tfullPathScriptName.size()>=4 
1212                 if(tfullPathScriptName.size()>=4){
1213                         if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb")
1214                         {
1215                           fullPathScriptName = tfullPathScriptName;
1216                                 if ( ! Utilities::FileExists(fullPathScriptName) )
1217                                 {
1218                                         // The following is *NOT* a debug time message :
1219                                         // It's a user intended message.
1220                                         // Please don't remove it.
1221                                         bbtkMessage("interpreter",2,
1222                                   "   [" <<fullPathScriptName <<"] : does not exist" 
1223                                   <<std::endl);
1224                                         continue;  // try next path
1225                                 }
1226                                 bbtkMessage("interpreter",2,
1227                                           "   [" <<fullPathScriptName 
1228                                           <<"] : found" <<std::endl);
1229                                 foundFile = true;
1230                                 break; // a script was found; we stop iterating
1231                         }
1232                         else 
1233                         {
1234                                 fullPathScriptName = tfullPathScriptName + ".bbs";
1235                                 // Check if library exists
1236                                 if ( ! Utilities::FileExists(fullPathScriptName) )
1237                                 {
1238                                         fullPathScriptName = tfullPathScriptName + ".bbp";
1239                                         if ( ! Utilities::FileExists(fullPathScriptName) )
1240                                         {
1241                                                 // The following is *NOT* a debug time message :
1242                                                 // It's a user intended message.
1243                                                 // Please don't remove it.
1244                                                 bbtkMessage("interpreter",2,
1245                                                 "   [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 
1246                                                 <<std::endl);
1247                                                 continue;  // try next path
1248                                         }
1249                                 }
1250                                 bbtkMessage("interpreter",2,
1251                                   "   [" <<fullPathScriptName 
1252                                   <<"] : found" <<std::endl);
1253                                 foundFile = true;
1254                                 break; // a script was found; we stop iterating
1255                         }
1256                 }               
1257         } //------------------ // end for ( package_paths.begin();i!=package_paths.end() )
1258   }
1259
1260     if (!foundFile)
1261       {
1262         if (fullnameGiven)
1263           if(fullPathScriptName == "")
1264             bbtkError("Path ["<<upath<<"] doesn't exist");
1265           else
1266             bbtkError("Script ["<<fullPathScriptName<<"] not found");
1267         else
1268           bbtkError("No ["<<pkgname<<".bbs/.bbp] script found");
1269         return;
1270       }
1271     else
1272         {
1273       LoadScript(fullPathScriptName,name);
1274           if (source) SetCurrentFileName(fullPathScriptName);
1275         }
1276     
1277     return;
1278   }
1279   //=======================================================================
1280 */
1281
1282         //=======================================================================
1283         void Interpreter::SetCurrentFileName(const std::string &fullPathScriptName)  // virtual 
1284         {
1285                 GetExecuter()->SetCurrentFileName(fullPathScriptName);
1286         }       
1287         //=======================================================================
1288         
1289         
1290         void Interpreter::SetTypeOfScript_Application()
1291         {
1292                 GetExecuter()->SetTypeOfScript_Application();
1293         }
1294
1295         
1296         
1297 /*EED Borrame   
1298   //=======================================================================
1299 void Interpreter::SwitchToStream( std::stringstream* stream )
1300 {
1301   bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToStream()"
1302                    <<std::endl);
1303    mFile.push_back(stream);
1304     std::ostringstream buffer_name;
1305     bufferNb++;
1306     buffer_name << "buffer_" ;
1307
1308     if (mFileName.size()>0 )
1309     {
1310        buffer_name << mFileName.back() << "_" << mLine.back();
1311     }
1312     mFileName.push_back(buffer_name.str());
1313     mIncludeFileName.push_back(buffer_name.str());
1314     mLine.push_back(0);
1315 }
1316   //=======================================================================
1317 */
1318         
1319 /*      
1320   //=======================================================================
1321   void Interpreter::LoadScript( std::string fullPathScriptName,
1322                                 std::string includeScriptName)
1323   {
1324     bbtkDebugMessage("interpreter",4,"==> Interpreter::LoadScript("
1325                      <<fullPathScriptName<<")"
1326                      <<std::endl);
1327
1328     Utilities::replace( fullPathScriptName , 
1329                          INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
1330    
1331      if (find(mFileNameHistory.begin(),
1332               mFileNameHistory.end(),
1333               fullPathScriptName)!=mFileNameHistory.end())
1334      {
1335         return;
1336      }
1337
1338     std::ifstream* s;
1339     s = new std::ifstream;
1340     s->open(fullPathScriptName.c_str());
1341     if (!s->good())
1342     {
1343         bbtkError("Could not open file ["<<fullPathScriptName<<"]");
1344         return;
1345     }
1346
1347     bbtkMessage("interpreter",1,"   -->[" << fullPathScriptName 
1348                 << "] found" << std::endl);
1349
1350     mFile.push_back(s);
1351     mFileName.push_back(fullPathScriptName);
1352     mFileNameHistory.push_back(fullPathScriptName);
1353     mIncludeFileName.push_back(includeScriptName);
1354     mLine.push_back(0);
1355
1356     return;
1357   }
1358   //=======================================================================
1359 */
1360
1361 /*EED Borrame
1362   //=======================================================================
1363   void Interpreter::CloseCurrentFile()
1364   {
1365     bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseCurrentFile()"
1366                       <<std::endl);
1367
1368     if (mFile.size()==0)
1369     {
1370       bbtkDebugMessage("interpreter",9," -> no file left open"<<std::endl);
1371       return;
1372     }
1373
1374     bbtkDebugMessage("interpreter",9," Closing file '"<<mFileName.back()<<"'"<<std::endl);
1375
1376     std::ifstream* file = dynamic_cast<std::ifstream*>(mFile.back());
1377     if (file!=0) file->close();
1378
1379     delete mFile.back();
1380     mFile.pop_back();
1381     mFileName.pop_back();
1382     mIncludeFileName.pop_back();
1383     mLine.pop_back();
1384
1385     bbtkDebugMessage("interpreter",9," Remains "
1386                      <<mFile.size()
1387                      <<" open"<<std::endl);
1388     bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseCurrentFile()"
1389                      <<std::endl);
1390   }
1391   //=======================================================================
1392
1393  //=======================================================================
1394   void Interpreter::CloseAllFiles()
1395   {
1396     bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseAllFiles()"
1397                       <<std::endl);
1398
1399     while (mFile.size() != 0) 
1400     {
1401        CloseCurrentFile();
1402     }
1403     bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseAllFiles()"
1404                       <<std::endl);
1405   }
1406   //=======================================================================
1407
1408
1409   //=======================================================================
1410   void Interpreter::InterpretCommand( const std::vector<std::string>& words,
1411                                       CommandInfoType& info )
1412   {
1413     bbtkDebugMessage("interpreter",9,"==> Interpreter::InterpretCommand(...)"<<std::endl);
1414
1415     // searches the command keyword
1416     CommandDictType::iterator c;
1417     c = mCommandDict.find(words[0]);
1418     if ( c == mCommandDict.end() ) {
1419       bbtkError(words[0]<<" : unknown command");
1420     }
1421
1422     // tests the number of args 
1423     if ( ( ((int)words.size())-1 < c->second.argmin ) ||
1424          ( ((int)words.size())-1 > c->second.argmax ) )
1425     {
1426        commandHelp(words[0]);
1427        bbtkError(words[0]<<" : wrong number of arguments");
1428     }
1429 //std::cout<<"Interpreter::InterpretCommand( const std::vector<std::string>& words,"<<std::endl;
1430     info = c->second;
1431
1432     bbtkDebugMessage("interpreter",9,"<== Interpreter::InterpretCommand(...)"<<std::endl);
1433
1434   }
1435   //=======================================================================
1436  */
1437
1438
1439   //=======================================================================
1440   /// Displays help on all the commands
1441 void Interpreter::commandHelp(const std::vector<std::string>& words)
1442 {
1443     unsigned int nbarg = words.size()-1;
1444
1445     if (nbarg==0) 
1446     {
1447        HelpCommands();
1448     }
1449     else if (nbarg==1) 
1450     {
1451       if (words[1]=="packages") 
1452       {
1453          GetExecuter()->GetFactory()->PrintHelpListPackages(true);
1454          return;
1455       }
1456       try 
1457       {
1458           commandHelp(words[1]);
1459       }
1460       catch (bbtk::Exception e) 
1461       {
1462          try 
1463          {
1464             GetExecuter()->GetFactory()->PrintHelpPackage(words[1]);
1465             if ( mUser != 0 )
1466               {
1467                 std::string url = 
1468                   ConfigurationFile::GetInstance().Get_doc_path();
1469                 url += "/bbdoc/" + words[1] + "/index.html";
1470                 if (Utilities::FileExists(url)) 
1471                   {
1472                     mUser->InterpreterUserViewHtmlPage(url);
1473                   }
1474               }
1475          }
1476          catch (bbtk::Exception f) 
1477          {
1478            try 
1479              {
1480                std::string package;
1481                GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1],
1482                                                                 package);
1483                if ( mUser != 0 )
1484                  {
1485                    std::string url = 
1486                      ConfigurationFile::GetInstance().Get_doc_path();
1487                    url += "/bbdoc/" + package + "/index.html";
1488                    if (Utilities::FileExists(url)) 
1489                      {
1490                        url += "#" + words[1];
1491                        mUser->InterpreterUserViewHtmlPage(url);
1492                      }
1493                  }
1494              }
1495            catch (bbtk::Exception g) 
1496              {
1497                try
1498                  {
1499                    GetExecuter()->PrintHelpBlackBox(words[1],"0","9999");
1500                  }
1501                catch (bbtk::Exception h){
1502                  bbtkError("\""<<words[1].c_str()
1503                            <<"\" is not a known command, package, black box type or black box name");
1504                }
1505              }
1506          }
1507       }
1508     }
1509     else if (nbarg==2) 
1510     {
1511       if (words[2]=="all")
1512       {
1513          if ( words[1]=="packages" )
1514          {
1515             GetExecuter()->GetFactory()->PrintHelpListPackages(true,true);
1516             return;
1517           }
1518          try 
1519          {
1520             GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true);
1521          }
1522          catch (bbtk::Exception f) 
1523          {
1524          }
1525      }
1526      else 
1527      {
1528         commandHelp(words[0]);
1529         bbtkError(words[0]<<" : syntax error");
1530      }
1531   }
1532   else 
1533   {
1534      bbtkError("Should not reach here !!!");
1535   }
1536 }
1537   //=======================================================================
1538
1539    //===================================================================    
1540   /// Displays the Configuration
1541   void Interpreter::commandConfig() const
1542   {
1543     ConfigurationFile::GetInstance().GetHelp(1);
1544   }  
1545    //===================================================================    
1546
1547   //=======================================================================
1548   /// Displays help on all the commands
1549   void Interpreter::HelpCommands()
1550   {
1551     std::cout << "Available commands :" << std::endl;
1552     CommandDictType::iterator i;
1553     for ( i =  mCommandDict.begin();
1554           i != mCommandDict.end();
1555         ++i) {
1556               std::cout << " " << i->first << std::endl;
1557       //      std::cout << "   usage : " << i->second.syntax << std::endl;
1558       //     std::cout << "    " << i->second.help << std::endl;
1559
1560     }
1561   }
1562   //=======================================================================
1563
1564
1565         
1566   //=======================================================================
1567   /// Displays help on a particular commands
1568   void Interpreter::commandHelp(const std::string& s)
1569   {
1570     CommandDictType::iterator c;
1571     c = mCommandDict.find(s);
1572     if ( c == mCommandDict.end() ) {
1573       bbtkError(s<<" : Unknown command");
1574     }   
1575     //    std::cout << " " << s << " : "<<  std::endl;
1576     //    CommandParamDictType::iterator i;
1577     //    for ( i =  c->second.begin();
1578     //      i != c->second.end();
1579     //      ++i) {
1580     std::cout << " usage : " << c->second.syntax << std::endl;
1581     std::cout << "  " << c->second.help << std::endl;
1582
1583   }
1584   //=======================================================================
1585
1586 /*EED Borrame
1587   //=======================================================================
1588   /// Fills the vector commands with the commands which 
1589   /// have the first n chars of buf for prefix
1590   /// TODO : skip initial spaces in buf and also return the position of first
1591   /// non blank char in buf
1592   void Interpreter::FindCommandsWithPrefix( char* buf,
1593                                             int n,
1594                                             std::vector<std::string>& commands )
1595   {
1596     CommandDictType::const_iterator i;
1597     for (i=mCommandDict.begin(); i!=mCommandDict.end(); ++i)
1598     {
1599       if ((i->first).find(buf,0,n) == 0) 
1600         commands.push_back(i->first);
1601     }
1602   }
1603   //=======================================================================
1604 */
1605  
1606
1607 /*EED Borrame
1608   //=======================================================================
1609 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT
1610   
1611   inline void PrintChar(char c) { write(STDOUT_FILENO,&c,1); }
1612   inline void BackSpace() { write(STDOUT_FILENO,"\b \b",3); }
1613   
1614   // LG : KEYBOARD CODES AS SCANNED ON MY TTY : UNIVERSAL ?
1615   // IF NOT THE USER SHOULD BE ABLE TO CONFIGURE IT
1616   // E.G. STORE THIS IN bbtk_config.xml
1617 #define BBTK_UP_ARROW_KBCODE    0x00415B1B
1618 #define BBTK_DOWN_ARROW_KBCODE  0x00425B1B
1619 #define BBTK_RIGHT_ARROW_KBCODE 0x00435B1B
1620 #define BBTK_LEFT_ARROW_KBCODE  0x00445B1B
1621 #define BBTK_BACKSPACE_KBCODE   0x00000008
1622 #define BBTK_DEL_KBCODE         0x0000007F
1623 #define BBTK_SPACE_KBCODE       0x00000020 
1624
1625   //=======================================================================
1626   void Interpreter::GetLineFromPrompt(std::string& s)
1627   {
1628     int c;
1629     unsigned int ind=0;
1630
1631     unsigned int MAX_LINE_SIZE = 160;
1632     unsigned int MAX_HISTORY_SIZE = 100;
1633
1634     char* newline = new char[MAX_LINE_SIZE];
1635     memset(newline,0,MAX_LINE_SIZE);
1636     char* histline = new char[MAX_LINE_SIZE];
1637     memset(histline,0,MAX_LINE_SIZE);
1638
1639     char* line = newline;
1640     unsigned int hist = mHistory.size();
1641
1642     write(1,"> ",2);
1643     while(1)
1644     {
1645        c=0;
1646        read ( STDIN_FILENO, &c, 4) ;
1647
1648        bbtkDebugMessage("debug",9,"[0x"<<std::hex<<c<<"]\n");
1649
1650        // Printable character
1651        if ( (ind<MAX_LINE_SIZE-1) &&
1652             ( c >= BBTK_SPACE_KBCODE ) && 
1653             ( c <  BBTK_DEL_KBCODE )) 
1654        {
1655           PrintChar(c);
1656           line[ind++]=c;
1657        }
1658       // CR
1659        else if (c=='\n')
1660        {
1661        // delete the unused line
1662           if (line==newline)
1663               delete histline;
1664           else
1665               delete newline;
1666    
1667     // empty lines are not stored in from history
1668           if (strlen(line)) 
1669           {
1670              // if history too long : delete oldest command
1671              if (mHistory.size()>MAX_HISTORY_SIZE) 
1672              {
1673                 delete mHistory.front();
1674                 mHistory.pop_front();
1675              }
1676              mHistory.push_back(line);
1677           }
1678           break;
1679         }
1680        // Backspace
1681         else if ( (ind>0) && 
1682                   ((c == BBTK_BACKSPACE_KBCODE) ||
1683                    (c == BBTK_DEL_KBCODE)) )
1684           {
1685             line[ind--]=' ';
1686             BackSpace();
1687           }
1688         // Tab 
1689         else if (c=='\t')
1690           {
1691             // TODO : Command completion  
1692             std::vector<std::string> commands;
1693             FindCommandsWithPrefix( line,ind,commands);
1694             if (commands.size()==1) 
1695               {
1696                 std::string com = *commands.begin();
1697                 for (; ind<com.size(); ++ind) 
1698                   {
1699                     PrintChar(com[ind]); 
1700                     line[ind]=com[ind];
1701                   }
1702                 PrintChar(' '); 
1703                 line[ind++]=' ';
1704               }
1705             else if (commands.size()>1) 
1706               {
1707                 std::vector<std::string>::iterator i;
1708                 write(1,"\n",1);
1709                 for (i=commands.begin();i!=commands.end();++i) 
1710                   {
1711                     write(STDOUT_FILENO,(*i).c_str(),strlen((*i).c_str()));
1712                     PrintChar(' ');
1713                   }
1714                 write(STDOUT_FILENO,"\n> ",3);
1715                 //for (int j=0;j<ind;++j) 
1716                   //{
1717                     write(STDOUT_FILENO,line,ind); 
1718                     //  }
1719               }
1720           }
1721         // Arrow up : back in history
1722         else if (c==BBTK_UP_ARROW_KBCODE)
1723           {
1724             if (hist) 
1725               {
1726                 // erase current line
1727                 while (ind--) BackSpace();
1728                 // 
1729                 hist--;
1730                 // 
1731                 strcpy(histline,mHistory[hist]);
1732                 line = histline;
1733                 ind = strlen(line);
1734                 
1735                 write(STDOUT_FILENO,line,ind);
1736               }
1737           }
1738         // Arrow down : down in history
1739         else if (c==BBTK_DOWN_ARROW_KBCODE)
1740           {
1741             if (hist<mHistory.size()-1) 
1742               {
1743                 // erase current line
1744                 while (ind--) BackSpace();
1745                 // 
1746                 hist++;
1747                 // 
1748                 strcpy(histline,mHistory[hist]);
1749                 line = histline;
1750                 ind = strlen(line);
1751                 
1752                 write(STDOUT_FILENO,line,ind);
1753               }
1754             // end of history : switch back to newline
1755             else if (hist==mHistory.size()-1)
1756               {
1757                 // erase current line
1758                 while (ind--) BackSpace();
1759                 // 
1760                 hist++;
1761                 // 
1762                 line = newline;
1763                 ind = strlen(line);
1764                 
1765                 write(STDOUT_FILENO,line,ind);
1766               }
1767           }
1768         // Arrow right
1769         else if (line[ind]!=0 && c==BBTK_RIGHT_ARROW_KBCODE)
1770           {
1771             PrintChar(line[ind]);
1772             ind++;
1773           }
1774
1775         // Arrow left
1776         else if (ind>0 && c==BBTK_LEFT_ARROW_KBCODE)
1777           {
1778             PrintChar('\b');
1779             ind--;
1780     
1781           }
1782
1783       }
1784     write(STDOUT_FILENO,"\n\r",2);
1785     
1786     
1787     s = line;
1788     
1789   }
1790 #else
1791
1792   //=======================================================================
1793   void Interpreter::GetLineFromPrompt(std::string& s)
1794   {  
1795     s.clear();
1796
1797     putchar('>');
1798     putchar(' ');
1799
1800     do 
1801     {
1802       char c = getchar();
1803       if (c=='\n') 
1804       {
1805         putchar('\n');
1806         break;
1807       }
1808       if (c=='\t') 
1809       {
1810         // putchar('T');
1811         continue;
1812       }
1813       // putchar(c);
1814       s += c;
1815     } 
1816     while (true);  
1817     
1818   }
1819   //=======================================================================  
1820
1821 #endif
1822 */
1823
1824         
1825         
1826         
1827         
1828         
1829 /*EED Borrame
1830   //=======================================================================
1831   void Interpreter::CommandLineInterpreter()
1832   {
1833     bbtkDebugMessageInc("interpreter",9,
1834                         "Interpreter::CommandLineInterpreter()"<<std::endl);
1835
1836 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT  
1837     // Initialise the tty in non canonical mode with no echo
1838     // oter remembers the previous settings to restore them after 
1839     struct termios ter,oter;
1840     tcgetattr(0,&ter);
1841     oter=ter;
1842     ter.c_lflag &= ~ECHO;
1843     ter.c_lflag &= ~ICANON;
1844     ter.c_cc[VMIN]=1;
1845     ter.c_cc[VTIME]=0;
1846     tcsetattr(0,TCSANOW,&ter);
1847 #endif
1848     
1849     mCommandLine = true;
1850     bool again = true;
1851     // bool insideComment = false; // for multiline comment  
1852     mInsideComment = false;
1853     do 
1854     {
1855       try
1856       {
1857         std::string line;
1858         GetLineFromPrompt(line);
1859         DoInterpretLine(line); //, insideComment);
1860       }
1861  //     catch (QuitException e)
1862  //     {
1863  //     bbtkMessage("interpreter",1,"Interpreter : Quit"<<std::endl);
1864  //        again = false;
1865       }
1866       catch (bbtk::Exception e) 
1867       {
1868         e.Print();
1869       }
1870         catch (std::exception& e) 
1871       {
1872         std::cerr << "* ERROR :: "<<e.what()<<" (not in bbtk)"<<std::endl;
1873       }
1874       catch (...)
1875       {
1876         std::cerr << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
1877       }
1878     }
1879     while (again);
1880
1881 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT
1882     tcsetattr(0,TCSANOW,&oter);
1883 #endif
1884
1885     std::cout << "Good bye !" << std::endl;
1886
1887     bbtkDebugDecTab("interpreter",9);
1888   }
1889 */
1890                   
1891 //=======================================================================
1892 void Interpreter::commandGraph(const std::vector<std::string>& words)
1893 {
1894   std::string page;
1895     bool system_display = true;
1896
1897     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
1898       system_display = false; 
1899  
1900     if (words.size()==1) 
1901     {
1902       page = mVirtualExecuter->ShowGraph(".","0","0","","","",system_display);
1903     }
1904     else if (words.size()==2) 
1905     {
1906       page = mVirtualExecuter->ShowGraph(words[1],"0","0","","","",system_display);
1907     }
1908     else if (words.size()==3) 
1909     {
1910       page = mVirtualExecuter->ShowGraph(words[1],words[2],"0","","","",system_display);
1911     }
1912     else if (words.size()==4) 
1913     {
1914       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],"","","",system_display);
1915     } 
1916     else if (words.size()==5) 
1917     {
1918       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],"","",system_display);
1919     } 
1920     else if (words.size()==6) 
1921     {
1922       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display);
1923     } 
1924     else if (words.size()==7) 
1925       {
1926         page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display);
1927       } 
1928     
1929     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
1930       mUser->InterpreterUserViewHtmlPage(page);
1931
1932   }
1933 //=======================================================================
1934
1935
1936 //=======================================================================
1937 void  Interpreter::commandIndex(const std::string& filename, 
1938                          const std::string& type)
1939 {
1940   Factory::IndexEntryType t;
1941   if (type=="Initials") t = Factory::Initials;
1942   else if (type=="Categories") t = Factory::Categories;
1943   else if (type=="Packages") t = Factory::Packages;
1944   else if (type=="Adaptors") t = Factory::Adaptors;
1945   
1946   GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename);
1947 }
1948 //=======================================================================
1949
1950
1951 //=======================================================================
1952 void  Interpreter::commandNewGUI(const std::string& boxname,
1953                              const std::string& instanceName)
1954 {
1955   if (mRealExecuter.expired())
1956     {
1957       bbtkError("command 'newgui' cannot be compiled yet");
1958     }
1959
1960   std::string typeName = instanceName+"Type";
1961   std::stringstream* s = new std::stringstream;
1962   // create the complex box
1963   (*s) << "define "<<typeName<<std::endl;
1964   //  (*s) << "  description 'Automatically generated user interface for the box "
1965   //       << boxname << "'" <<std::endl;
1966   // create the Layout box
1967   (*s) << "  load wx"<<std::endl;
1968   (*s) << "  new LayoutLine layout"<<std::endl;
1969   // create the output 'Widget'
1970   (*s) << "  output Widget layout.Widget Widget"<<std::endl;
1971   // the box change output 
1972   (*s) << "  new MultipleInputs change"<<std::endl;
1973   (*s) << "  output BoxChange change.Out BoxChange"<<std::endl;
1974
1975   // Browse the inputs of the box in order to find which ones are not 
1976   // connected and can be adapted from a widget adaptor
1977   // vector which stores the list of inputs of the box which must be connected
1978   std::vector<std::string> in;
1979  
1980   Factory::Pointer F = mVirtualExecuter->GetFactory();
1981   /*
1982   Package::Pointer user = F->GetPackage("user");
1983   */
1984   ComplexBlackBoxDescriptor::Pointer workspace = 
1985     mRealExecuter.lock()->GetCurrentDescriptor();
1986
1987   if (workspace==0)
1988     {
1989       delete s;
1990       bbtkError("interpreter::CreateGUI : could not access the executer currently defined complex box");
1991     }
1992  
1993
1994   /*
1995     (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
1996   */
1997
1998   BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
1999   //  BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
2000   // int nb = 0;
2001   BlackBox::InputConnectorMapType::iterator i;
2002   for (i=box->bbGetInputConnectorMap().begin();
2003        i!=box->bbGetInputConnectorMap().end();
2004        ++i)
2005     {
2006       // If the input is connected : continue
2007       if (i->second->IsConnected()) continue;
2008       // Get the input descriptor 
2009       const BlackBoxInputDescriptor* d = box->bbGetDescriptor()->GetInputDescriptor(i->first);
2010       // If it is a "system" input : skip it
2011 #ifdef USE_WXWIDGETS
2012       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) ||
2013            ( d->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) )
2014         continue;
2015 #else
2016       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) )
2017         continue;
2018 #endif
2019       bool widok = true;
2020       std::string widget,adaptor;
2021       // try to find a widget adaptor
2022       if (F->FindWidgetAdaptor(DataInfo(d->GetTypeInfo(),""),
2023                                d->GetDataInfo(),
2024                                adaptor))
2025         {
2026           // command to create the adaptor
2027           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
2028           // Sets the label of the widget adaptor to the name of the input
2029           (*s) << "  set "<<i->first<<".Label "<<i->first<<std::endl;
2030           // Sets the initial value of the widget to the value of the input
2031           (*s) << "  set "<<i->first<<".In \" "
2032                <<box->bbGetInputAsString(i->first)<<"\""
2033                << std::endl;
2034           // store the input name
2035           in.push_back(i->first);
2036           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
2037             //<i->first<<"'"<<std::endl;
2038           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
2039         }
2040       // try to find a two pieces adaptor
2041       else if (F->FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""),
2042                                      d->GetDataInfo(),
2043                                      widget,adaptor) )
2044         {
2045           // command to create the widget
2046           (*s) << "  new "<<widget<<" "<<i->first<<"Widget"<<std::endl;
2047           // command to create the adaptor
2048           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
2049           // connect the two
2050           (*s) << "  connect "<<i->first<<"Widget.Out "
2051                <<i->first<<".In"<<std::endl;
2052           // Sets the label of the widget adaptor to the name of the input
2053           (*s) << "  set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
2054           // Sets the initial value of the widget to the value of the input
2055           (*s) << "  set "<<i->first<<"Widget.In \" "
2056                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
2057           // store the input name
2058           in.push_back(i->first);
2059           (*s) << "  connect "<<i->first<<"Widget.Widget layout.Widget"<<in.size()<<std::endl;
2060             //<i->first<<"'"<<std::endl;
2061           (*s) << "  connect "<<i->first<<"Widget.BoxChange change.In"<<in.size()<<std::endl;
2062
2063         }
2064       // try to find an adaptor from string 
2065       // If found then can create a text input which 
2066       // will be automatically adapted 
2067       else if (F->FindAdaptor(DataInfo(typeid(std::string),""),
2068                                d->GetDataInfo(),
2069                                adaptor))
2070         {
2071           // command to create the adaptor
2072           (*s) << "  new InputText "<<i->first<<std::endl;
2073           // Sets the label of the widget adaptor to the name of the input
2074           (*s) << "  set "<<i->first<<".Title "<<i->first<<std::endl;
2075           // Sets the initial value of the widget to the value of the input
2076           (*s) << "  set "<<i->first<<".In \" "
2077                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
2078           // store the input name
2079           in.push_back(i->first);
2080           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
2081             //<i->first<<"'"<<std::endl;
2082           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
2083
2084         }
2085       else 
2086         {
2087           widok = false;
2088         }
2089       if (widok)
2090         {
2091           // command to create the output
2092           (*s) << "  output "<<i->first<<" "
2093                <<i->first<<".Out "<<i->first<<std::endl;
2094             //         <<" Output of the widget which allows to set "
2095           
2096         }
2097     }   
2098   // Inputs for window properties
2099   (*s) << "  input WinTitle layout.WinTitle Title"<<std::endl;
2100   (*s) << "  input WinWidth layout.WinWidth Width"<<std::endl;
2101   (*s) << "  input WinHeight layout.WinHeight Height"<<std::endl;
2102   (*s) << "  input WinDialog layout.WinDialog Dialog"<<std::endl;
2103   (*s) << "  input WinHide layout.WinHide Hide"<<std::endl;
2104
2105   
2106   
2107   // Execute the box executes the layout
2108   (*s) << "  exec layout" << std::endl;
2109   (*s) << "endefine" << std::endl;
2110   // (*s) << "help "<< typeName<< std::endl;
2111   // instanciate the box and connect it
2112   (*s) << "new "<<typeName<<" "<<instanceName<<std::endl;
2113   // connections
2114   std::vector<std::string>::iterator j;
2115   for (j=in.begin();j!=in.end();++j)
2116     {
2117       // connect
2118       (*s) << "connect "<<instanceName<<"."<<*j<<" "
2119            << boxname<<"."<<*j<<std::endl;
2120     }
2121   // That's all folks ! now execute the commands :
2122   SwitchToStream(s);
2123 }
2124 //=======================================================================
2125
2126
2127
2128  //==========================================================================
2129   void Interpreter::commandDebug(const std::string& name)
2130   {
2131     if ((name.length()==2)&&(name[0]=='-'))
2132       {
2133         if (name[1]=='D')
2134           {
2135             bbtk::StaticInitTime::PrintObjectListInfo = true;
2136           }
2137         if (name[1]=='C')
2138           {
2139             //      int o = MessageManager::GetMessageLevel("debug");
2140             //      if (o<2) MessageManager::SetMessageLevel("debug",2);
2141             mVirtualExecuter->GetFactory()->Check();
2142             //      MessageManager::SetMessageLevel("debug",o);
2143           }
2144       }
2145     else 
2146       {
2147         Object:: PrintObjectListInfo(name);
2148       }
2149   }
2150  //==========================================================================
2151
2152   /*
2153   //==========================================================================
2154   // Adds a callback when 'break' command issued
2155   void Interpreter::AddBreakObserver( BreakCallbackType c )
2156   {
2157     mBreakSignal.connect(c);
2158   }
2159  //==========================================================================
2160  */
2161
2162  //==========================================================================
2163   std::string Interpreter::GetObjectName() const
2164   {
2165     return std::string("Interpreter");
2166   }
2167   //==========================================================================
2168   
2169   //==========================================================================
2170   std::string  Interpreter::GetObjectInfo() const 
2171   {
2172     std::stringstream i;
2173     return i.str();
2174   }
2175   //==========================================================================
2176
2177   //==========================================================================
2178 size_t  Interpreter::GetObjectSize() const 
2179 {
2180   size_t s = Superclass::GetObjectSize();
2181   s += Interpreter::GetObjectInternalSize();
2182   return s;
2183   }
2184   //==========================================================================
2185   //==========================================================================
2186 size_t  Interpreter::GetObjectInternalSize() const 
2187 {
2188   size_t s = sizeof(Interpreter);
2189   return s;
2190   }
2191   //==========================================================================
2192   //==========================================================================
2193   size_t  Interpreter::GetObjectRecursiveSize() const 
2194   {
2195     size_t s = Superclass::GetObjectRecursiveSize();
2196     s += Interpreter::GetObjectInternalSize();
2197     s += mVirtualExecuter->GetObjectRecursiveSize();
2198     return s;
2199   }
2200   //==========================================================================
2201 }//namespace
2202
2203