Logo ROOT  
Reference Guide
TTabCom.cxx
Go to the documentation of this file.
1 // @(#)root/rint:$Id$
2 // Author: Christian Lacunza <lacunza@cdfsg6.lbl.gov> 27/04/99
3 
4 // Modified by Artur Szostak <artur@alice.phy.uct.ac.za> : 1 June 2003
5 // Added support for namespaces.
6 
7 /*************************************************************************
8  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
9  * All rights reserved. *
10  * *
11  * For the licensing terms see $ROOTSYS/LICENSE. *
12  * For the list of contributors see $ROOTSYS/README/CREDITS. *
13  *************************************************************************/
14 
15 ////////////////////////////////////////////////////////////////////////////
16 // //
17 // TTabCom //
18 // //
19 // This class performs basic tab completion. //
20 // You should be able to hit [TAB] to complete a partially typed: //
21 // //
22 // username //
23 // environment variable //
24 // preprocessor directive //
25 // pragma //
26 // filename (with a context-sensitive path) //
27 // public member function or data member (including base classes) //
28 // global variable, function, or class name //
29 // //
30 // Also, something like //
31 // //
32 // someObject->Func([TAB] //
33 // someObject.Func([TAB] //
34 // someClass::Func([TAB] //
35 // someClass var([TAB] //
36 // new someClass([TAB] //
37 // //
38 // will print a list of prototypes for the indicated //
39 // method or constructor. //
40 // //
41 // Current limitations and bugs: //
42 // //
43 // 1. you can only use one member access operator at a time. //
44 // eg, this will work: gROOT->GetListOfG[TAB] //
45 // but this will not: gROOT->GetListOfGlobals()->Conta[TAB] //
46 // //
47 // 2. nothing is guaranteed to work on windows //
48 // (for one thing, /bin/env and /etc/passwd are hardcoded) //
49 // //
50 // 3. CINT shortcut #2 is deliberately not supported. //
51 // (using "operator.()" instead of "operator->()") //
52 // //
53 // 4. most identifiers (including C++ identifiers, usernames, //
54 // environment variables, etc) //
55 // are restriceted to this character set: [_a-zA-Z0-9] //
56 // therefore, you won't be able to complete things like //
57 // //
58 // operator new //
59 // operator+ //
60 // etc //
61 // //
62 // 5. ~whatever[TAB] always tries to complete a username. //
63 // use whitespace (~ whatever[TAB]) if you want to complete a global //
64 // identifier. //
65 // //
66 // 6. CINT shortcut #3 is not supported when trying to complete //
67 // the name of a global object. (it is supported when trying to //
68 // complete a member of a global object) //
69 // //
70 // 7. the list of #pragma's is hardcoded //
71 // (ie not obtained from the interpreter at runtime) //
72 // ==> user-defined #pragma's will not be recognized //
73 // //
74 // 8. the system include directories are also hardcoded //
75 // because i don't know how to get them from the interpreter. //
76 // fons, maybe they should be #ifdef'd for the different sytems? //
77 // //
78 // 9. the TabCom.FileIgnore resource is always applied, even if you //
79 // are not trying to complete a filename. //
80 // //
81 // 10. anything in quotes is assumed to be a filename //
82 // so (among other things) you can't complete a quoted class name: //
83 // eg, TClass class1( "TDict[TAB] //
84 // this won't work... looks for a file in pwd starting with TDict //
85 // //
86 // 11. the prototypes tend to omit the word "const" a lot. //
87 // this is a problem with ROOT or CINT. //
88 // //
89 // 12. when listing ambiguous matches, only one column is used, //
90 // even if there are many completions. //
91 // //
92 // 13. anonymous objects are not currently identified //
93 // so, for example, //
94 // //
95 // root> printf( TString([TAB //
96 // //
97 // gives an error message instead of listing TString's constructors. //
98 // (this could be fixed) //
99 // //
100 // 14. the routine that adds the "appendage" isn't smart enough to know //
101 // if it's already there: //
102 // //
103 // root> TCanvas::Update() //
104 // press [TAB] here ^ //
105 // root> TCanvas::Update()() //
106 // (this could be fixed) //
107 // //
108 // 15. the appendage is only applied if there is exactly 1 match. //
109 // eg, this //
110 // //
111 // root> G__at[TAB] //
112 // root> G__ateval //
113 // //
114 // happens instead of this //
115 // //
116 // root> G__at[TAB] //
117 // root> G__ateval( //
118 // //
119 // because there are several overloaded versions of G__ateval(). //
120 // (this could be fixed) //
121 // //
122 ////////////////////////////////////////////////////////////////////////////
123 
124 #include <cstdio>
125 #include <cassert>
126 #include <set>
127 
128 #include "RConfigure.h"
129 #include "TTabCom.h"
130 #include "TClass.h"
131 #include "TClassTable.h"
132 #include "TDataMember.h"
133 #include "TSystem.h"
134 #include "TROOT.h"
135 #include "TMethod.h"
136 #include "TEnv.h"
137 #include "TBenchmark.h"
138 #include "TError.h"
139 #include "TGlobal.h"
140 #include "TList.h"
141 #include "THashList.h"
142 #include "TObjString.h"
143 #include "Getline.h"
144 #include "TFunction.h"
145 #include "TMethodArg.h"
146 #include "TInterpreter.h"
147 #include "Riostream.h"
148 #include "Rstrstream.h"
149 #include "strlcpy.h"
150 
151 #define BUF_SIZE 1024 // must be smaller than/equal to fgLineBufSize in Getline.cxx and
152  // lineBufSize in cppcompleter.py
153 #define IfDebug(x) if(gDebug==TTabCom::kDebug) x
154 
155 #ifdef R__WIN32
156 const char kDelim = ';';
157 #else
158 const char kDelim = ':';
159 #endif
160 
161 
163 // ----------------------------------------------------------------------------
164 //
165 // global/file scope variables
166 //
168 
169 // ----------------------------------------------------------------------------
170 //
171 // constructors
172 //
173 
174 ////////////////////////////////////////////////////////////////////////////////
175 /// Default constructor.
176 
178  fpClasses(0),
179  fPrevInterpMarker(0),
180  fpDirectives(0),
181  fpEnvVars(0),
182  fpFiles(0),
183  fpGlobals(0),
184  fpPragmas(0),
185  fpSysIncFiles(0),
186  fpUsers(0),
187  fBuf(0),
188  fpLoc(0),
189  fVarIsPointer(kFALSE),
190  fLastIter(0)
191 {
192  InitPatterns();
193 }
194 
195 //
196 // constructors
197 //
198 // ----------------------------------------------------------------------------
199 
201 {
202  // Destructor.
203 
204  ClearAll();
205  ClearSysIncFiles(); // this one stays cached
206  ClearUsers(); // this one stays cached
207 }
208 
209 // ----------------------------------------------------------------------------
210 //
211 // public member functions
212 //
213 
214 
215 ////////////////////////////////////////////////////////////////////////////////
216 /// Clear classes and namespace collections.
217 
219 {
220  if (fpClasses) {
221  delete fpClasses;
222  fpClasses = 0;
223  }
224 
225 }
226 
227 ////////////////////////////////////////////////////////////////////////////////
228 /// Forget all Cpp directives seen so far.
229 
231 {
232  if (!fpDirectives)
233  return;
234  fpDirectives->Delete(0);
235  delete fpDirectives;
236  fpDirectives = 0;
237 }
238 
239 ////////////////////////////////////////////////////////////////////////////////
240 /// Forget all environment variables seen so far.
241 
243 {
244  if (!fpEnvVars)
245  return;
246  fpEnvVars->Delete(0);
247  delete fpEnvVars;
248  fpEnvVars = 0;
249 }
250 
251 ////////////////////////////////////////////////////////////////////////////////
252 /// Close all files.
253 
255 {
256  if (!fpFiles)
257  return;
258  fpFiles->Delete(0);
259  delete fpFiles;
260  fpFiles = 0;
261 }
262 
263 ////////////////////////////////////////////////////////////////////////////////
264 /// Forget all global functions seen so far.
265 /// Not needed anymore. Use gROOT->GetListOfGlobalFunctions()
266 
268 {
269 }
270 
271 ////////////////////////////////////////////////////////////////////////////////
272 /// Forget all global variables seen so far.
273 /// With teh new implamentation the list is gROOT->GetListOfGlobals(true).
274 
276 {
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////////
280 /// Forget all pragmas seen so far.
281 
283 {
284  if (!fpPragmas)
285  return;
286  fpPragmas->Delete(0);
287  delete fpPragmas;
288  fpPragmas = 0;
289 }
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Close system files.
293 
295 {
296  if (!fpSysIncFiles)
297  return;
298  fpSysIncFiles->Delete(0);
299  delete fpSysIncFiles;
300  fpSysIncFiles = 0;
301 }
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// Forget all user seen so far.
305 
307 {
308  if (!fpUsers)
309  return;
310  fpUsers->Delete(0);
311  delete fpUsers;
312  fpUsers = 0;
313 }
314 
315 ////////////////////////////////////////////////////////////////////////////////
316 /// clears all lists
317 /// except for user names and system include files.
318 
320 {
321  ClearClasses();
323  ClearEnvVars();
324  ClearFiles();
326  ClearGlobals();
327  ClearPragmas();
328 // ClearSysIncFiles(); <-- this one stays cached
329 // ClearUsers(); <-- this one stays cached
330 }
331 
332 ////////////////////////////////////////////////////////////////////////////////
333 /// Do the class rehash.
334 
336 {
337  ClearClasses();
339 }
340 
341 ////////////////////////////////////////////////////////////////////////////////
342 /// Cpp rehashing.
343 
345 {
348 }
349 
350 ////////////////////////////////////////////////////////////////////////////////
351 /// Environemnt variables rehashing.
352 
354 {
355  ClearEnvVars();
357 }
358 
359 ////////////////////////////////////////////////////////////////////////////////
360 /// Close files.
361 
363 {
364  ClearFiles(); /* path unknown */
365 } // think about this
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 /// Reload global functions.
369 
371 {
373 }
374 
375 ////////////////////////////////////////////////////////////////////////////////
376 /// Reload globals.
377 
379 {
380  ClearGlobals();
382 }
383 
384 ////////////////////////////////////////////////////////////////////////////////
385 /// Reload pragmas.
386 
388 {
389  ClearPragmas();
391 }
392 
393 ////////////////////////////////////////////////////////////////////////////////
394 /// Reload system include files.
395 
397 {
400 }
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 /// Reload users.
404 
406 {
407  ClearUsers();
408  GetListOfUsers();
409 }
410 
411 ////////////////////////////////////////////////////////////////////////////////
412 /// clears and then rebuilds all lists
413 /// except for user names and system include files.
414 
416 {
417  RehashClasses();
419  RehashEnvVars();
420  RehashFiles();
422  RehashGlobals();
423  RehashPragmas();
424 // RehashSysIncFiles(); <-- this one stays cached
425 // RehashUsers(); <-- this one stays cached
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Return the list of classes.
430 
432 {
433  if (!fpClasses) {
434  fpClasses = new THashList;
435  // Iterate over the table from the map file.
436  THashList* entries = gInterpreter->GetMapfile()->GetTable();
437  TIter next(entries);
438  while (const auto key = next()) {
439  // This is not needed with the new rootmap format
440  const char* className = key->GetName();
441  if (!strncmp(className, "Library.", 8))
442  className += 8;
443 
444  if (!strstr(className, ".h"))
445  fpClasses->Add(new TObjString(className));
446  }
447 
448  // We might have autoload entries that don't have a rootmap entry
449  // (libCore) and no interpreter info (not yet loaded).
450  TClassTable::Init(); // reset counter
451  while (const char* className = TClassTable::Next()) {
452  if (!fpClasses->FindObject(className)) {
453  fpClasses->Add(new TObjString(className));
454  }
455  }
456  }
457 
458  if (fPrevInterpMarker != gInterpreter->GetInterpreterStateMarker()) {
459  ClassInfo_t* ci = gInterpreter->ClassInfo_Factory(kFALSE /*all*/);
460  while (gInterpreter->ClassInfo_Next(ci)) {
461  const char* className = gInterpreter->ClassInfo_FullName(ci);
462  if (strstr(className, "(anonymous)"))
463  continue;
464  if (!fpClasses->FindObject(className)) {
465  fpClasses->Add(new TObjString(className));
466  }
467  }
468  gInterpreter->ClassInfo_Delete(ci);
469  }
470 
471  return fpClasses;
472 }
473 
474 ////////////////////////////////////////////////////////////////////////////////
475 /// Return the list of CPP directives.
476 
478 {
479  if (!fpDirectives) {
480  fpDirectives = new TContainer;
481 
482  fpDirectives->Add(new TObjString("if"));
483  fpDirectives->Add(new TObjString("ifdef"));
484  fpDirectives->Add(new TObjString("ifndef"));
485  fpDirectives->Add(new TObjString("elif"));
486  fpDirectives->Add(new TObjString("else"));
487  fpDirectives->Add(new TObjString("endif"));
488  fpDirectives->Add(new TObjString("include"));
489  fpDirectives->Add(new TObjString("define"));
490  fpDirectives->Add(new TObjString("undef"));
491  fpDirectives->Add(new TObjString("line"));
492  fpDirectives->Add(new TObjString("error"));
493  fpDirectives->Add(new TObjString("pragma"));
494  }
495 
496  return fpDirectives;
497 }
498 
499 ////////////////////////////////////////////////////////////////////////////////
500 /// "path" should be initialized with a colon separated list of
501 /// system directories
502 
504 {
505  static TString previousPath;
506 
507  if (path && fpFiles && strcmp(path, previousPath) == 0) {
508  return fpFiles;
509  } else {
510  ClearFiles();
511 
513  previousPath = path;
514  }
515 
516  return fpFiles;
517 }
518 
519 ////////////////////////////////////////////////////////////////////////////////
520 /// Uses "env" (Unix) or "set" (Windows) to get list of environment variables.
521 
523 {
524  if (!fpEnvVars) {
525  TString outf = ".TTabCom-";
526  FILE *fout = gSystem->TempFileName(outf);
527  if (!fout) return 0;
528  fclose(fout);
529  TString cmd;
530 
531 #ifndef WIN32
532  char *env = gSystem->Which(gSystem->Getenv("PATH"), "env", kExecutePermission);
533  if (!env)
534  return 0;
535  cmd = env;
536  cmd += " > ";
537  delete [] env;
538 #else
539  cmd = "set > ";
540 #endif
541  cmd += outf;
542  cmd += "\n";
543  gSystem->Exec(cmd.Data());
544 
545  // open the file
546  std::ifstream file1(outf);
547  if (!file1) {
548  Error("TTabCom::GetListOfEnvVars", "could not open file \"%s\"",
549  outf.Data());
550  gSystem->Unlink(outf);
551  return 0;
552  }
553  // parse, add
554  fpEnvVars = new TContainer;
555  TString line;
556  while (file1) // i think this loop goes one time extra which
557  // results in an empty string in the list, but i don't think it causes any
558  // problems.
559  {
560  line.ReadToDelim(file1, '=');
561  file1.ignore(32000, '\n');
562  fpEnvVars->Add(new TObjString(line.Data()));
563  }
564 
565  file1.close();
566  gSystem->Unlink(outf);
567  }
568 
569  return fpEnvVars;
570 }
571 
572 ////////////////////////////////////////////////////////////////////////////////
573 /// Return the list of globals.
574 
576 {
577  return (TSeqCollection*)gROOT->GetListOfGlobals(true);
578 }
579 
580 ////////////////////////////////////////////////////////////////////////////////
581 /// Return the list of global functions.
582 
584 {
585  return gROOT->GetListOfGlobalFunctions(true);
586 }
587 
588 ////////////////////////////////////////////////////////////////////////////////
589 /// Return the list of pragmas
590 
592 {
593  if (!fpPragmas) {
594  fpPragmas = new TContainer;
595 
596  fpPragmas->Add(new TObjString("ANSI "));
597  fpPragmas->Add(new TObjString("autocompile "));
598  fpPragmas->Add(new TObjString("bytecode "));
599  fpPragmas->Add(new TObjString("compile "));
600  fpPragmas->Add(new TObjString("endbytecode "));
601  fpPragmas->Add(new TObjString("endcompile "));
602  fpPragmas->Add(new TObjString("include "));
603  fpPragmas->Add(new TObjString("includepath "));
604  fpPragmas->Add(new TObjString("K&R "));
605  fpPragmas->Add(new TObjString("link "));
606  fpPragmas->Add(new TObjString("preprocess "));
607  fpPragmas->Add(new TObjString("preprocessor "));
608  fpPragmas->Add(new TObjString("security level"));
609  // "setertti " omitted. Ordinary user should not use this statement
610  // "setstdio " omitted. Ordinary user should not use this statement
611  // "setstream " omitted. Ordinary user should not use this statement
612  // "stub" omitted. Ordinary user should not use this statement
613 
614  }
615 
616  return fpPragmas;
617 }
618 
619 ////////////////////////////////////////////////////////////////////////////////
620 /// Return the list of system include files.
621 
623 {
624  if (!fpSysIncFiles) {
626  }
627 
628  return fpSysIncFiles;
629 }
630 
631 ////////////////////////////////////////////////////////////////////////////////
632 /// reads from "/etc/passwd"
633 
635 {
636  if (!fpUsers) {
637  fpUsers = new TContainer;
638 
639  std::ifstream passwd;
640  TString user;
641 
642  passwd.open("/etc/passwd");
643  while (passwd) {
644  user.ReadToDelim(passwd, ':');
645  fpUsers->Add(new TObjString(user));
646  passwd.ignore(32000, '\n');
647  }
648  passwd.close();
649  }
650 
651  return fpUsers;
652 }
653 
654 //
655 // public member functions
656 //
657 // ----------------------------------------------------------------------------
658 
659 // ----------------------------------------------------------------------------
660 //
661 // static utility functions
662 //
663 
664 ////////////////////////////////////////////////////////////////////////////////
665 ///[static utility function]///////////////////////////////////////////
666 ///
667 /// if all the strings in "*pList" have the same ith character,
668 /// that character is returned.
669 /// otherwise 0 is returned.
670 ///
671 /// any string "s" for which "ExcludedByFignore(s)" is true
672 /// will be ignored unless All the strings in "*pList"
673 /// are "ExcludedByFignore()"
674 ///
675 /// in addition, the number of strings which were not
676 /// "ExcludedByFignore()" is returned in "nGoodStrings".
677 ///
678 //////////////////////////////////////////////////////////////////////////
679 
681  Int_t & nGoodStrings)
682 {
683  assert(pList != 0);
684 
685  TIter next(pList);
686  TObject *pObj;
687  const char *s = "";
688  char ch0;
689  Bool_t isGood;
690  Bool_t atLeast1GoodString;
691 
692  // init
693  nGoodStrings = 0;
694  atLeast1GoodString = kFALSE;
695 
696  // first look for a good string
697  do {
698  if ((pObj = next())) {
699  s = pObj->GetName();
700  isGood = !ExcludedByFignore(s);
701  if (isGood) {
702  atLeast1GoodString = kTRUE;
703  nGoodStrings += 1;
704  }
705  } else {
706  // reached end of list without finding a single good string.
707  // just use the first one.
708  next.Reset();
709  pObj = next();
710  if (pObj) s = pObj->GetName();
711  break;
712  }
713  }
714  while (!isGood);
715 
716  // found a good string...
717  ch0 = s[i];
718 
719  // all subsequent good strings must have the same ith char
720  do {
721  if ((pObj = next())) {
722  s = pObj->GetName();
723  isGood = !ExcludedByFignore(s);
724  if (isGood)
725  nGoodStrings += 1;
726  } else
727  return ch0;
728  }
729  while (((int) strlen(s) >= i && s[i] == ch0) ||
730  (atLeast1GoodString && !isGood));
731 
732  return 0;
733 }
734 
735 ////////////////////////////////////////////////////////////////////////////////
736 ///[static utility function]/////////////////////////////
737 ///
738 /// adds a TObjString to "*pList"
739 /// for each entry found in the system directory "dirName"
740 ///
741 /// directories that do not exist are silently ignored.
742 ///
743 ///////////////////////////////////////////////////////////
744 
745 void TTabCom::AppendListOfFilesInDirectory(const char dirName[],
746  TSeqCollection * pList)
747 {
748  assert(dirName != 0);
749  assert(pList != 0);
750 
751  // open the directory
752  void *dir = gSystem->OpenDirectory(dirName);
753 
754  // it is normal for this function to receive names of directories that do not exist.
755  // they should be ignored and should not generate any error messages.
756  if (!dir)
757  return;
758 
759  // put each filename in the list
760  const char *tmp_ptr; // gSystem->GetDirEntry() returns 0 when no more files.
761  TString fileName;
762 
763  while ((tmp_ptr = gSystem->GetDirEntry(dir))) {
764  fileName = tmp_ptr;
765 
766  // skip "." and ".."
767  if (fileName == "." || fileName == "..")
768  continue;
769 
770  // add to list
771  pList->Add(new TObjString(dirName + fileName.Prepend("/")));
772  }
773  // NOTE:
774  // with a path like "/usr/include:/usr/include/CC:$ROOTDIR/include:$ROOTDIR/cint/include:..."
775  // the above loop could get traversed 700 times or more.
776  // ==> keep it minimal or it could cost whole seconds on slower machines.
777  // also: TClonesArray doesn't help.
778 
779  // close the directory
780  gSystem->FreeDirectory(dir);
781 }
782 
783 // -----\/-------- homemade RTTI ---------------\/------------------------
784 ////////////////////////////////////////////////////////////////////////////////
785 ///[static utility function]/////////////////////////////
786 ///
787 /// returns empty string on failure.
788 /// otherwise returns something like this: "TROOT*".
789 /// fails for non-class types (ie, int, char, etc).
790 /// fails for pointers to functions.
791 ///
792 ////////////////////////////////////
793 
794 TString TTabCom::DetermineClass(const char varName[])
795 {
796 
797  ///////////////////////////////////
798  //
799  // note that because of the strange way this function works,
800  // CINT will print
801  //
802  // Error: No symbol asdf in current scope FILE:/var/tmp/gaaa001HR LINE:1
803  //
804  // if "varName" is not defined. (in this case, varName=="asdf")
805  // i don't know how to suppress this.
806  //
807  ///////////////////////////////////
808 
809  assert(varName != 0);
810  IfDebug(std::cerr << "DetermineClass(\"" << varName << "\");" << std::endl);
811 
812  TString outf = ".TTabCom-";
813  FILE *fout = gSystem->TempFileName(outf);
814  if (!fout) return "";
815  fclose(fout);
816 
817  TString cmd(".> ");
818  cmd += outf;
819  //redirect
820  gROOT->ProcessLineSync(cmd.Data());
821 
822  cmd = "gROOT->ProcessLine(\"";
823  cmd += varName;
824  cmd += "\");";
825  cmd += "\n";
826  gROOT->ProcessLineSync(cmd.Data());
827  // the type of the variable whose name is "varName"
828  // should now be stored on disk in the file "tmpfile"
829 
830  gROOT->ProcessLineSync(".>");
831 
832  TString type = "";
833  int c;
834 
835  // open the file
836  std::ifstream file1(outf);
837  if (!file1) {
838  Error("TTabCom::DetermineClass", "could not open file \"%s\"",
839  outf.Data());
840  goto cleanup;
841  }
842  // first char should be '(', which we can ignore.
843  c = file1.get();
844  if (!file1 || c <= 0 || c != '(') {
845  Error("TTabCom::DetermineClass", "variable \"%s\" not defined?",
846  varName);
847  goto cleanup;
848  }
849  IfDebug(std::cerr << (char) c << std::flush);
850 
851  // in case of success, "class TClassName*)0x12345" remains or TClassName 0x[0-9][a-f]+
852  // in case of objects
853  // since the opening '(' was removed.
854 
855  if (type == "const" || type == "class") {
856  file1 >> type;
857  // ignore ' '
858  c = file1.get();
859  IfDebug(std::cerr << (char) c << std::flush);
860  }
861 
862  // this is what we want
863  type.ReadToDelim(file1, ')');
864  IfDebug(std::cerr << type << std::endl);
865 
866  // new version of CINT returns: "class TClassName*const)0x12345"
867  // so we have to strip off "const"
868  if (type.EndsWith("const"))
869  type.Remove(type.Length() - 5);
870 
871 cleanup:
872  // done reading from file
873  file1.close();
874  gSystem->Unlink(outf);
875 
876  return type;
877 }
878 
879 ////////////////////////////////////////////////////////////////////////////////
880 ///[static utility function]/////////////////////////////
881 ///
882 /// returns true iff "s" ends with one of
883 /// the strings listed in the "TabCom.FileIgnore" resource.
884 ///
885 //////////////////////////////////////////////////////////////
886 
888 {
889  const char *fignore = gEnv->GetValue("TabCom.FileIgnore", (char *) 0);
890 
891  if (!fignore) {
892  return kFALSE;
893  } else {
894 #ifdef R__SSTREAM
895  std::istringstream endings((char *) fignore);
896 #else
897  std::istrstream endings((char *) fignore); // do i need to make a copy first?
898 #endif
899  TString ending;
900 
901  ending.ReadToDelim(endings, kDelim);
902 
903  while (!ending.IsNull()) {
904  if (s.EndsWith(ending))
905  return kTRUE;
906  else
907  ending.ReadToDelim(endings, kDelim); // next
908  }
909  return kFALSE;
910  }
911 }
912 
913 ////////////////////////////////////////////////////////////////////////////////
914 ///[static utility function]/////////////////////////////
915 ///
916 /// returns a colon-separated string of directories
917 /// that CINT will search when you call #include<...>
918 ///
919 /// returns empty string on failure.
920 ///
921 ////////////////////////////////////////////////////////////
922 
924 {
925  // >i noticed that .include doesn't list the standard directories like
926  // >/usr/include or /usr/include/CC.
927  // >
928  // >how can i get a list of all the directories the interpreter will
929  // >search through when the user does a #include<...> ?
930  //
931  // Right now, there is no easy command to tell you about it. Instead, I can
932  // describe it here.
933  //
934  // 1) CINT first searches current working directory for #include "xxx"
935  // (#include <xxx> does not)
936  //
937  // 2) CINT searches include path directories given by -I option
938  //
939  // 3) CINT searches following standard include directories.
940  // $CINTSYSDIR/include
941  // $CINTSYSDIR/stl
942  // $CINTSYSDIR/msdev/include if VC++4.0
943  // $CINTSYSDIR/sc/include if Symantec C++
944  // /usr/include
945  // /usr/include/g++ if gcc,g++
946  // /usr/include/CC if HP-UX
947  // /usr/include/codelibs if HP-UX
948  //
949  // .include command only displays 2).
950  //
951  // Thank you
952  // Masaharu Goto
953 
954  // 1) current dir
955  // ----------------------------------------------
956  // N/A
957 
958 
959  // 2) -I option (and #pragma includepath)
960  // ----------------------------------------------
961 
962  // get this part of the include path from the interpreter
963  // and stick it in a tmp file.
964  TString outf = ".TTabCom-";
965  FILE *fout = gSystem->TempFileName(outf);
966  if (!fout) return "";
967  gCling->DisplayIncludePath(fout);
968  fclose(fout);
969 
970  // open the tmp file
971  std::ifstream file1(outf);
972  if (!file1) { // error
973  Error("TTabCom::GetSysIncludePath", "could not open file \"%s\"",
974  outf.Data());
975  gSystem->Unlink(outf);
976  return "";
977  }
978  // parse it.
979  TString token; // input buffer
980  TString path; // all directories so far (colon-separated)
981  file1 >> token; // skip "include"
982  file1 >> token; // skip "path:"
983  while (file1) {
984  file1 >> token;
985  if (!token.IsNull()) {
986  if (path.Length() > 0)
987  path.Append(":");
988  path.Append(token.Data() + 2); // +2 skips "-I"
989  }
990  }
991 
992  // done with the tmp file
993  file1.close();
994  gSystem->Unlink(outf);
995 
996  // 3) standard directories
997  // ----------------------------------------------
998 
999 #ifndef CINTINCDIR
1000  TString sCINTSYSDIR("$ROOTSYS/cint");
1001 #else
1002  TString sCINTSYSDIR(CINTINCDIR);
1003 #endif
1004  path.Append(":" + sCINTSYSDIR + "/include");
1005 // path.Append(":"+CINTSYSDIR+"/stl");
1006 // path.Append(":"+CINTSYSDIR+"/msdev/include");
1007 // path.Append(":"+CINTSYSDIR+"/sc/include");
1008  path.Append(":/usr/include");
1009 // path.Append(":/usr/include/g++");
1010 // path.Append(":/usr/include/CC");
1011 // path.Append(":/usr/include/codelibs");
1012 
1013  return path;
1014 }
1015 
1016 ////////////////////////////////////////////////////////////////////////////////
1017 ///[static utility function]/////////////////////////////
1018 ///
1019 /// calls TSystem::GetPathInfo() to see if "fileName"
1020 /// is a system directory.
1021 ///
1022 ////////////////////////////////////////////////////////
1023 
1024 Bool_t TTabCom::IsDirectory(const char fileName[])
1025 {
1026  FileStat_t stat;
1027  if (!gSystem->GetPathInfo(fileName, stat))
1028  return R_ISDIR(stat.fMode);
1029  else
1030  return false;
1031 }
1032 
1033 ////////////////////////////////////////////////////////////////////////////////
1034 ///[static utility function]/////////////////////////////
1035 ///
1036 /// creates a list containing the full path name for each file
1037 /// in the (colon separated) string "path1"
1038 ///
1039 /// memory is allocated with "new", so
1040 /// whoever calls this function takes responsibility for deleting it.
1041 ///
1042 ///////////////////////////////////////////////////////////////////////
1043 
1045 {
1046  assert(path1 != 0);
1047  if (!path1[0]) path1 = ".";
1048 
1049  TContainer *pList = new TContainer; // maybe use RTTI here? (since its a static function)
1050 #ifdef R__SSTREAM
1051  std::istringstream path((char *) path1);
1052 #else
1053  std::istrstream path((char *) path1);
1054 #endif
1055 
1056  while (path.good())
1057  {
1058  TString dirName;
1059  dirName.ReadToDelim(path, kDelim);
1060  if (dirName.IsNull())
1061  continue;
1062 
1063  IfDebug(std::cerr << "NewListOfFilesInPath(): dirName = " << dirName <<
1064  std::endl);
1065 
1066  AppendListOfFilesInDirectory(dirName, pList);
1067  }
1068 
1069  return pList;
1070 }
1071 
1072 ////////////////////////////////////////////////////////////////////////////////
1073 ///[static utility function]/////////////////////////////
1074 ///
1075 /// true if "fileName"
1076 /// 1. is an absolute path ("/tmp/a")
1077 /// 2. is a relative path ("../whatever", "./test")
1078 /// 3. starts with user name ("~/mail")
1079 /// 4. starts with an environment variable ("$ROOTSYS/bin")
1080 ///
1081 ///////////////////////////////////////////////////////////////////////////
1082 
1084 {
1085  char c1 = (fileName.Length() > 0) ? fileName[0] : 0;
1086  return c1 == '/' || c1 == '~' || c1 == '$' || fileName.BeginsWith("./")
1087  || fileName.BeginsWith("../");
1088 }
1089 
1090 ////////////////////////////////////////////////////////////////////////////////
1091 ///[static utility function]/////////////////////////////
1092 ///
1093 /// calling "NoMsg( errorLevel )",
1094 /// sets "gErrorIgnoreLevel" to "errorLevel+1" so that
1095 /// all errors with "level < errorLevel" will be ignored.
1096 ///
1097 /// calling the function with a negative argument
1098 /// (e.g., "NoMsg( -1 )")
1099 /// resets gErrorIgnoreLevel to its previous value.
1100 ///
1101 ///////////////////////////////////////////////////////////////////
1102 
1103 void TTabCom::NoMsg(Int_t errorLevel)
1104 {
1105  ////////////////////////////////////////////////////////////////
1106  //
1107  // if you call the function twice with a non-negative argument
1108  // (without an intervening call with a negative argument)
1109  // it will complain because it is almost certainly an error
1110  // that will cause the function to loose track of the previous
1111  // value of gErrorIgnoreLevel.
1112  //
1113  // most common causes: 1. suspiciously placed "return;" statement
1114  // 2. calling a function that calls "NoMsg()"
1115  //
1116  //////////////////////////////////////////////////////////////////
1117 
1118  const Int_t kNotDefined = -2;
1119  static Int_t old_level = kNotDefined;
1120 
1121  if (errorLevel < 0) // reset
1122  {
1123  if (old_level == kNotDefined) {
1124  std::cerr << "NoMsg(): ERROR 1. old_level==" << old_level << std::endl;
1125  return;
1126  }
1127 
1128  gErrorIgnoreLevel = old_level; // restore
1129  old_level = kNotDefined;
1130  } else // set
1131  {
1132  if (old_level != kNotDefined) {
1133  std::cerr << "NoMsg(): ERROR 2. old_level==" << old_level << std::endl;
1134  return;
1135  }
1136 
1137  old_level = gErrorIgnoreLevel;
1138  if (gErrorIgnoreLevel <= errorLevel)
1139  gErrorIgnoreLevel = errorLevel + 1;
1140  }
1141 }
1142 
1143 //
1144 // static utility functions
1145 //
1146 // ----------------------------------------------------------------------------
1147 
1148 
1149 // ----------------------------------------------------------------------------
1150 //
1151 // private member functions
1152 //
1153 //
1154 
1155 ////////////////////////////////////////////////////////////////////////////////
1156 /// [private]
1157 
1159  const TSeqCollection * pListOfCandidates,
1160  const char appendage[],
1161  std::ostream& out,
1163 {
1164  // returns position of first change in buffer
1165  // ------------------------------------------
1166  // -2 ==> new line altogether (whole thing needs to be redrawn, including prompt)
1167  // -1 ==> no changes
1168  // 0 ==> beginning of line
1169  // 1 ==> after 1st char
1170  // n ==> after nth char
1171 
1172  IfDebug(std::cerr << "TTabCom::Complete() ..." << std::endl);
1173  assert(fpLoc != 0);
1174  assert(pListOfCandidates != 0);
1175 
1176  Int_t pos = 0; // position of first change
1177  const int loc = *fpLoc; // location where TAB was pressed
1178 
1179  // -----------------------------------------
1180  //
1181  // 1. get the substring we need to complete
1182  //
1183  // NOTES:
1184  // s1 = original buffer
1185  // s2 = sub-buffer from 0 to wherever the user hit TAB
1186  // s3 = the actual text that needs completing
1187  //
1188  // -----------------------------------------
1189  TString s1(fBuf);
1190  TString s2 = s1(0, loc);
1191  TString s3 = s2(re);
1192 
1193  int start = s2.Index(re);
1194 
1195  IfDebug(std::cerr << " s1: " << s1 << std::endl);
1196  IfDebug(std::cerr << " s2: " << s2 << std::endl);
1197  IfDebug(std::cerr << " s3: " << s3 << std::endl);
1198  IfDebug(std::cerr << "start: " << start << std::endl);
1199  IfDebug(std::cerr << std::endl);
1200 
1201  // -----------------------------------------
1202  // 2. go through each possible completion,
1203  // keeping track of the number of matches
1204  // -----------------------------------------
1205  TList listOfMatches; // list of matches (local filenames only) (insertion order must agree across these 3 lists)
1206  TList listOfFullPaths; // list of matches (full filenames) (insertion order must agree across these 3 lists)
1207  listOfMatches.SetOwner();
1208  listOfFullPaths.SetOwner();
1209 
1210  int nMatches = 0; // number of matches
1211  TObject *pObj; // pointer returned by iterator
1212  TIter next_candidate(pListOfCandidates);
1213  TIter next_match(&listOfMatches);
1214  TIter next_fullpath(&listOfFullPaths);
1215 
1216  // stick all matches into "listOfMatches"
1217  while ((pObj = next_candidate())) {
1218  // get the full filename
1219  const char *s4 = pObj->GetName();
1220 
1221  assert(s4 != 0);
1222 
1223  // pick off tail
1224  const char *s5 = strrchr(s4, '/');
1225  if (!s5)
1226  s5 = s4; // no '/' found
1227  else
1228  s5 += 1; // advance past '/'
1229 
1230  // if case sensitive (normal behaviour), check for match
1231  // if case insensitive, convert to TString and compare case insensitively
1232  if ((cmp == TString::kExact) && (strstr(s5, s3) == s5)) {
1233  nMatches += 1;
1234  listOfMatches.Add(new TObjString(s5));
1235  listOfFullPaths.Add(new TObjString(s4));
1236  IfDebug(std::cerr << "adding " << s5 << '\t' << s4 << std::endl);
1237  } else if (cmp == TString::kIgnoreCase) {
1238  TString ts5(s5);
1239  if (ts5.BeginsWith(s3, cmp))
1240  {
1241  nMatches += 1;
1242  listOfMatches.Add(new TObjString(s5));
1243  listOfFullPaths.Add(new TObjString(s4));
1244  IfDebug(std::cerr << "adding " << s5 << '\t' << s4 << std::endl);
1245  }
1246  } else {
1247 //rdm IfDebug(std::cerr << "considered " << s5 << '\t' << s4 << std::endl);
1248  }
1249 
1250  }
1251 
1252  // -----------------------------------------
1253  // 3. beep, list, or complete
1254  // depending on how many matches were found
1255  // -----------------------------------------
1256 
1257  // 3a. no matches ==> bell
1258  TString partialMatch = "";
1259 
1260  if (nMatches == 0) {
1261  // Ring a bell!
1262  gSystem->Beep();
1263  pos = -1;
1264  goto done; //* RETURN *//
1265  }
1266  // 3b. one or more matches.
1267  char match[1024];
1268 
1269  if (nMatches == 1) {
1270  // get the (lone) match
1271  const char *short_name = next_match()->GetName();
1272  const char *full_name = next_fullpath()->GetName();
1273 
1274  pObj = pListOfCandidates->FindObject(short_name);
1275  if (pObj) {
1276  IfDebug(std::cerr << std::endl << "class: " << pObj->ClassName() << std::endl);
1277  TString className = pObj->ClassName();
1278  if (0);
1279  else if (className == "TMethod" || className == "TFunction") {
1280  TFunction *pFunc = (TFunction *) pObj;
1281  if (0 == pFunc->GetNargs())
1282  appendage = "()"; // no args
1283  else
1284  appendage = "("; // user needs to supply some args
1285  } else if (className == "TDataMember") {
1286  appendage = " ";
1287  }
1288  }
1289 
1290  CopyMatch(match, short_name, appendage, full_name);
1291  } else {
1292  // multiple matches ==> complete as far as possible
1293  Char_t ch;
1294  Int_t nGoodStrings;
1295 
1296  for (int i = 0;
1297  (ch = AllAgreeOnChar(i, &listOfMatches, nGoodStrings));
1298  i += 1) {
1299  IfDebug(std::cerr << " i=" << i << " ch=" << ch << std::endl);
1300  partialMatch.Append(ch);
1301  }
1302 
1303  const char *s;
1304  const char *s0;
1305 
1306  // multiple matches, but maybe only 1 of them is any good.
1307  if (nGoodStrings == 1) {
1308 
1309  // find the 1 good match
1310  do {
1311  s = next_match()->GetName();
1312  s0 = next_fullpath()->GetName();
1313  }
1314  while (ExcludedByFignore(s));
1315 
1316  // and use it.
1317  CopyMatch(match, s, appendage, s0);
1318  } else {
1319  IfDebug(std::cerr << "more than 1 GoodString" << std::endl);
1320 
1321  if (partialMatch.Length() > s3.Length())
1322  // this partial match is our (partial) completion.
1323  {
1324  CopyMatch(match, partialMatch.Data());
1325  } else
1326  // couldn't do any completing at all,
1327  // print a list of all the ambiguous matches
1328  // (except for those excluded by "FileIgnore")
1329  {
1330  IfDebug(std::cerr << "printing ambiguous matches" << std::endl);
1331  std::set<std::string> alreadyPrinted;
1332  while ((pObj = next_match())) {
1333  s = pObj->GetName();
1334  if (alreadyPrinted.insert(s).second) {
1335  // Nothing of that name has been printed yet.
1336  s0 = next_fullpath()->GetName();
1337  if (!ExcludedByFignore(s) || nGoodStrings == 0) {
1338  if (IsDirectory(s0))
1339  out << s << "/" << std::endl;
1340  else
1341  out << s << std::endl;
1342  }
1343  }
1344  }
1345  pos = -2;
1346  if (cmp == TString::kExact || partialMatch.Length() < s3.Length()) {
1347  goto done; //* RETURN *//
1348  } // else:
1349  // update the matching part, will have changed
1350  // capitalization because only cmp == TString::kIgnoreCase
1351  // matches.
1352  CopyMatch(match, partialMatch.Data());
1353  }
1354  }
1355  }
1356 
1357 
1358  // ---------------------------------------
1359  // 4. finally write text into the buffer.
1360  // ---------------------------------------
1361  {
1362  int i = strlen(fBuf); // old EOL position is i
1363  int l = strlen(match) - (loc - start); // new EOL position will be i+L
1364 
1365  // first check for overflow
1366  if (strlen(fBuf) + strlen(match) + 1 > BUF_SIZE) {
1367  Error("TTabCom::Complete", "buffer overflow");
1368  pos = -2;
1369  goto done; /* RETURN */
1370  }
1371  // debugging output
1372  IfDebug(std::cerr << " i=" << i << std::endl);
1373  IfDebug(std::cerr << " L=" << l << std::endl);
1374  IfDebug(std::cerr << "loc=" << loc << std::endl);
1375 
1376  // slide everything (including the null terminator) over to make space
1377  for (; i >= loc; i -= 1) {
1378  fBuf[i + l] = fBuf[i];
1379  }
1380 
1381  // insert match
1382  strlcpy(fBuf + start, match, BUF_SIZE - start);
1383 
1384  // the "get"->"Get" case of TString::kIgnore sets pos to -2
1385  // and falls through to update the buffer; we need to return
1386  // -2 in that case, so check here:
1387  if (pos != -2) {
1388  pos = loc; // position of first change in "fBuf"
1389  if (cmp == TString::kIgnoreCase && pos < 0) {
1390  // We might have changed somthing before loc, due to differences in
1391  // capitalization. So return start:
1392  pos = start;
1393  }
1394  }
1395  *fpLoc = loc + l; // new cursor position
1396  }
1397 
1398 done: // <----- goto label
1399  // un-init
1400  fpLoc = 0;
1401  fBuf = 0;
1402 
1403  return pos;
1404 }
1405 
1406 ////////////////////////////////////////////////////////////////////////////////
1407 /// [private]
1408 
1409 void TTabCom::CopyMatch(char dest[], const char localName[],
1410  const char appendage[],
1411  const char fullName[]) const
1412 {
1413  // if "appendage" is 0, no appendage is applied.
1414  //
1415  // if "appendage" is of the form "filenameXXX" then,
1416  // "filename" is ignored and "XXX" is taken to be the appendage,
1417  // but it will only be applied if the file is not a directory...
1418  // if the file is a directory, a "/" will be used for the appendage instead.
1419  //
1420  // if "appendage" is of the form "XXX" then "XXX" will be appended to the match.
1421 
1422  assert(dest != 0);
1423  assert(localName != 0);
1424 
1425  // potential buffer overflow.
1426  strcpy(dest, localName);
1427 
1428  const char *key = "filename";
1429  const int key_len = strlen(key);
1430 
1431  IfDebug(std::cerr << "CopyMatch()." << std::endl);
1432  IfDebug(std::cerr << "localName: " << (localName ? localName : "0") <<
1433  std::endl);
1434  IfDebug(std::cerr << "appendage: " << (appendage ? appendage : "0") <<
1435  std::endl);
1436  IfDebug(std::cerr << " fullName: " << (fullName ? fullName : "0") <<
1437  std::endl);
1438 
1439 
1440  // check to see if "appendage" starts with "key"
1441  if (appendage && strncmp(appendage, key, key_len) == 0) {
1442  // filenames get special treatment
1443  appendage += key_len;
1444  IfDebug(std::cerr << "new appendage: " << appendage << std::endl);
1445  if (IsDirectory(fullName)) {
1446  if (fullName)
1447  strcpy(dest + strlen(localName), "/");
1448  } else {
1449  if (appendage)
1450  strcpy(dest + strlen(localName), appendage);
1451  }
1452  } else {
1453  if (appendage)
1454  strcpy(dest + strlen(localName), appendage);
1455  }
1456 }
1457 
1458 ////////////////////////////////////////////////////////////////////////////////
1459 /// [private]
1460 
1462 {
1463  assert(fBuf != 0);
1464 
1465  const char *pStart; // start of match
1466  const char *pEnd; // end of match
1467 
1468  for (int context = 0; context < kNUM_PAT; ++context) {
1469  pEnd = Matchs(fBuf, *fpLoc, fPat[context], &pStart);
1470  if (pEnd) {
1471  IfDebug(std::cerr << std::endl
1472  << "context=" << context << " "
1473  << "RegExp=" << fRegExp[context]
1474  << std::endl);
1475  return EContext_t(context); //* RETURN *//
1476  }
1477  }
1478 
1479  return kUNKNOWN_CONTEXT; //* RETURN *//
1480 }
1481 
1482 ////////////////////////////////////////////////////////////////////////////////
1483 /// [private]
1484 
1486  const char defaultPath[]) const
1487 {
1488  if (PathIsSpecifiedInFileName(fileName)) {
1489  TString path = fileName;
1490  gSystem->ExpandPathName(path);
1491  Int_t end = path.Length()-1;
1492  if (end>0 && path[end]!='/' && path[end]!='\\') {
1493  path = gSystem->GetDirName(path);
1494  }
1495  return path;
1496  } else {
1497  TString newBase, extendedPath;
1498  if (fileName.Contains("/")) {
1499  Int_t end = fileName.Length()-1;
1500  if (fileName[end] != '/' && fileName[end] != '\\') {
1501  newBase = gSystem->GetDirName(fileName);
1502  } else {
1503  newBase = fileName;
1504  }
1505  extendedPath = ExtendPath(defaultPath, newBase);
1506  } else {
1507  newBase = "";
1508  extendedPath = defaultPath;
1509  }
1510  IfDebug(std::cerr << std::endl);
1511  IfDebug(std::cerr << " fileName: " << fileName << std::endl);
1512  IfDebug(std::cerr << " pathBase: " << newBase << std::endl);
1513  if (defaultPath) {
1514  IfDebug(std::cerr << " defaultPath: " << defaultPath << std::endl);
1515  } else {
1516  IfDebug(std::cerr << " defaultPath: " << std::endl);
1517  }
1518  IfDebug(std::cerr << "extendedPath: " << extendedPath << std::endl);
1519  IfDebug(std::cerr << std::endl);
1520 
1521  return extendedPath;
1522  }
1523 }
1524 
1525 ////////////////////////////////////////////////////////////////////////////////
1526 /// [private]
1527 
1528 TString TTabCom::ExtendPath(const char originalPath[], TString newBase) const
1529 {
1530  if (newBase.BeginsWith("/"))
1531  newBase.Remove(TString::kLeading, '/');
1532 #ifdef R__SSTREAM
1533  std::stringstream str;
1534 #else
1535  std::strstream str;
1536 #endif
1537  TString dir;
1538  TString newPath;
1539  if (originalPath) str << originalPath;
1540 
1541  while (str.good())
1542  {
1543  dir = "";
1544  dir.ReadToDelim(str, kDelim);
1545  if (dir.IsNull())
1546  continue; // ignore blank entries
1547  newPath.Append(dir);
1548  if (!newPath.EndsWith("/"))
1549  newPath.Append("/");
1550  newPath.Append(newBase);
1551  newPath.Append(kDelim);
1552  }
1553 
1554  return newPath.Strip(TString::kTrailing, kDelim);
1555 }
1556 
1557 ////////////////////////////////////////////////////////////////////////////////
1558 /// [private]
1559 
1560 Int_t TTabCom::Hook(char *buf, int *pLoc, std::ostream& out)
1561 {
1562  // initialize
1563  fBuf = buf;
1564  fpLoc = pLoc;
1565 
1566  // frodo: iteration counter for recursive MakeClassFromVarName
1567  fLastIter = 0;
1568 
1569  // default
1570  Int_t pos = -2; // position of the first character that was changed in the buffer (needed for redrawing)
1571 
1572  // get the context this tab was triggered in.
1573  EContext_t context = DetermineContext();
1574 
1575  // get the substring that triggered this tab (as defined by "SetPattern()")
1576  const char dummy[] = ".";
1577  TRegexp re1(context == kUNKNOWN_CONTEXT ? dummy : fRegExp[context]);
1578  TString s1(fBuf);
1579  TString s2 = s1(0, *fpLoc);
1580  TString s3 = s2(re1);
1581 
1582  switch (context) {
1583  case kUNKNOWN_CONTEXT:
1584  std::cerr << std::endl << "tab completion not implemented for this context" <<
1585  std::endl;
1586  pos = -2;
1587  break;
1588 
1589  case kSYS_UserName:
1590  {
1591  const TSeqCollection *pListOfUsers = GetListOfUsers();
1592 
1593  pos = Complete("[^~]*$", pListOfUsers, "/", out);
1594  }
1595  break;
1596  case kSYS_EnvVar:
1597  {
1598  const TSeqCollection *pEnv = GetListOfEnvVars();
1599 
1600  pos = Complete("[^$]*$", pEnv, "", out);
1601  }
1602  break;
1603 
1604  case kCINT_stdout:
1605  case kCINT_stderr:
1606  case kCINT_stdin:
1607  {
1608  const TString fileName = s3("[^ ><]*$");
1609  const TString filePath = DeterminePath(fileName,0);
1610  const TSeqCollection *pListOfFiles =
1611  GetListOfFilesInPath(filePath.Data());
1612 
1613 // pos = Complete( "[^ /]*$", pListOfFiles, " ", out );
1614  pos = Complete("[^ /]*$", pListOfFiles, "filename ", out);
1615  }
1616  break;
1617 
1618  case kCINT_Edit:
1619  case kCINT_Load:
1620  case kCINT_Exec:
1621  case kCINT_EXec:
1622  {
1623  const TString fileName = s3("[^ ]*$");
1624  const TString macroPath =
1625  DeterminePath(fileName, TROOT::GetMacroPath());
1626  const TSeqCollection *pListOfFiles =
1627  GetListOfFilesInPath(macroPath.Data());
1628 
1629 // pos = Complete( "[^ /]*$", pListOfFiles, " ", out);
1630  pos = Complete("[^ /]*$", pListOfFiles, "filename ", out);
1631  }
1632  break;
1633 
1634  case kCINT_pragma:
1635  {
1636  pos = Complete("[^ ]*$", GetListOfPragmas(), "", out);
1637  }
1638  break;
1639  case kCINT_includeSYS:
1640  {
1641  TString fileName = s3("[^<]*$");
1642  if (PathIsSpecifiedInFileName(fileName) || fileName.Contains("/")) {
1643  TString includePath =
1644  DeterminePath(fileName, GetSysIncludePath());
1645 
1646 // pos = Complete( "[^</]*$", GetListOfFilesInPath( includePath ), "> ", out);
1647  pos =
1648  Complete("[^</]*$", GetListOfFilesInPath(includePath),
1649  "filename> ", out);
1650  } else {
1651 // pos = Complete( "[^</]*$", GetListOfSysIncFiles(), "> ", out);
1652  pos =
1653  Complete("[^</]*$", GetListOfSysIncFiles(), "filename> ", out);
1654  }
1655  }
1656  break;
1657  case kCINT_includePWD:
1658  {
1659  const TString fileName = s3("[^\"]*$");
1660  const TString includePath = DeterminePath(fileName, ".");
1661  const TSeqCollection *pListOfFiles =
1662  GetListOfFilesInPath(includePath.Data());
1663 
1664 // pos = Complete( "[^\"/]*$", pListOfFiles, "\" ", out);
1665  pos = Complete("[^\"/]*$", pListOfFiles, "filename\" ", out);
1666  }
1667  break;
1668 
1669  case kCINT_cpp:
1670  {
1671  pos = Complete("[^# ]*$", GetListOfCppDirectives(), " ", out);
1672  }
1673  break;
1674 
1675  case kROOT_Load:
1676  {
1677  const TString fileName = s3("[^\"]*$");
1678  const TString dynamicPath = DeterminePath(fileName, gSystem->GetDynamicPath());
1679  const TSeqCollection *pListOfFiles = GetListOfFilesInPath(dynamicPath);
1680 
1681 // pos = Complete( "[^\"/]*$", pListOfFiles, "\");", out);
1682  pos = Complete("[^\"/]*$", pListOfFiles, "filename\");", out);
1683  }
1684  break;
1685 
1686  case kSYS_FileName:
1687  {
1688  const TString fileName = s3("[^ \"]*$");
1689  const TString filePath = DeterminePath(fileName,".");
1690  const TSeqCollection *pListOfFiles = GetListOfFilesInPath(filePath.Data());
1691 
1692  pos = Complete("[^\" /]*$", pListOfFiles, "filename\"", out);
1693  }
1694  break;
1695 
1696  case kCXX_ScopeMember:
1697  {
1698  const EContext_t original_context = context; // save this for later
1699 
1700  TClass *pClass;
1701  // may be a namespace, class, object, or pointer
1702  TString name = s3("^[_a-zA-Z][_a-zA-Z0-9]*");
1703 
1704  IfDebug(std::cerr << std::endl);
1705  IfDebug(std::cerr << "name: " << '"' << name << '"' << std::endl);
1706 
1707  // We need to decompose s3 a little more:
1708  // The part name is the partial symbol at the end of ::
1709  // eg. given s3 = "foo::bar::part" , partname = "part"
1710  TString partname = s3("[_a-zA-Z][_a-zA-Z0-9]*$");
1711 
1712  // The prefix, considering the s3 = "foo::bar::part" example would be
1713  // prefix = "foo::bar::". prefix equals the empty string if there is only one
1714  // or no set of colons in s3.
1715  // Note: we reconstruct the fully qualified name with a while loop because
1716  // it does not seem that TRegexp can handle something like "([_a-zA-Z][_a-zA-Z0-9]*::)+$"
1717  TString prefix = "";
1718  TString str = s2;
1719  str.Remove(str.Length() - partname.Length(), partname.Length());
1720  while (1) {
1721  TString sym = str("[_a-zA-Z][_a-zA-Z0-9]*::$");
1722  if (sym.Length() == 0)
1723  break;
1724  str.Remove(str.Length() - sym.Length(), sym.Length());
1725  prefix = sym + prefix;
1726  }
1727 
1728  // Not the preprefix would be = "foo::" from our previous example or the empty
1729  // string, "" if there is only one or no set of colons in prefix, eg. prefix = "bar::"
1730  TString preprefix = prefix;
1731  TString sym = prefix("[_a-zA-Z][_a-zA-Z0-9]*::$");
1732  preprefix.Remove(preprefix.Length() - sym.Length(), sym.Length());
1733 
1734  IfDebug(std::cerr << "prefix: " << '"' << prefix << '"' << std::endl);
1735  IfDebug(std::cerr << "preprefix: " << '"' << preprefix << '"' << std::endl);
1736 
1737  TString namesp = prefix;
1738  if (namesp.Length() >= 2)
1739  namesp.Remove(namesp.Length() - 2, 2); // Remove the '::' at the end of the string.
1740  IfDebug(std::cerr << "namesp: " << '"' << namesp << '"' << std::endl);
1741 
1742  // Make sure autoloading happens (if it can).
1743  TryMakeClassFromClassName(namesp);
1744 
1745  TContainer *pList = new TContainer;
1746  // Add all classes to pList that contain the prefix, i.e. are in the
1747  // specified namespace.
1748  const TSeqCollection *tmp = GetListOfClasses();
1749  if (!tmp) break;
1750 
1751  Int_t i;
1752  for (i = 0; i < tmp->GetSize(); i++) {
1753  TString astr = ((TObjString *) tmp->At(i))->String();
1754  TString rxp = "^";
1755  rxp += prefix;
1756  if (astr.Contains(TRegexp(rxp))) {
1757  astr.Remove(0, prefix.Length());
1758  TString s = astr("^[^: ]*");
1759  TObjString *ostr = new TObjString(s);
1760  if (!pList->Contains(ostr))
1761  pList->Add(ostr);
1762  else
1763  delete ostr;
1764  }
1765  }
1766 
1767  // If a class with the same name as the Namespace name exists then
1768  // add it to the pList. (I don't think the C++ spec allows for this
1769  // but do this anyway, cant harm).
1770  pClass = TryMakeClassFromClassName(preprefix + name);
1771  if (pClass) {
1772  pList->AddAll(pClass->GetListOfAllPublicMethods(true));
1773  pList->AddAll(pClass->GetListOfAllPublicDataMembers(true));
1774  }
1775 
1776  pos = Complete("[^: ]*$", pList, "", out);
1777 
1778  delete pList;
1779 
1780  if (context != original_context)
1781  pos = -2;
1782  }
1783  break;
1784 
1785  case kCXX_DirectMember:
1786  case kCXX_IndirectMember:
1787  {
1788  const EContext_t original_context = context; // save this for later
1789 
1790  TClass *pClass;
1791 
1792  // frodo: Instead of just passing the last portion of the string to
1793  // MakeClassFromVarName(), we now pass the all string and let
1794  // it decide how to handle it... I know it's not the best way
1795  // because of the context handling, but I wanted to "minimize"
1796  // the changes to the current code and this seemed the best way
1797  // to do it
1798  TString name = s1("[_a-zA-Z][-_a-zA-Z0-9<>():.]*$");
1799 
1800  IfDebug(std::cerr << std::endl);
1801  IfDebug(std::cerr << "name: " << '"' << name << '"' << std::endl);
1802 
1803  switch (context) {
1804  case kCXX_DirectMember:
1805  pClass = MakeClassFromVarName(name, context);
1806  break;
1807  case kCXX_IndirectMember:
1808  pClass = MakeClassFromVarName(name, context);
1809  break;
1810  default:
1811  Fatal("TTabCom::Hook","Conext case %d not handled",context);
1812  return 0; // Avoid warning about uninitialized pClass.
1813  }
1814  if (!pClass) {
1815  pos = -2;
1816  break;
1817  }
1818 
1819  TContainer *pList = new TContainer;
1820 
1821  pList->AddAll(pClass->GetListOfAllPublicMethods());
1822  pList->AddAll(pClass->GetListOfAllPublicDataMembers());
1823 
1824  switch (context) {
1825  case kCXX_DirectMember:
1826  {
1827  int* store_fpLoc = fpLoc;
1828  char* store_fBuf = fBuf;
1829  pos = Complete("[^. ]*$", pList, "(", out);
1830  if (pos == -1) {
1831  fpLoc = store_fpLoc;
1832  fBuf = store_fBuf;
1833  pos = Complete("[^. ]*$", pList, "(", out, TString::kIgnoreCase);
1834  }
1835  break;
1836  }
1837  case kCXX_IndirectMember:
1838  pos = Complete("[^> ]*$", pList, "(", out);
1839  break;
1840  default:
1841  Fatal("TTabCom::Hook","Conext case %d not handled",context);
1842  return 0; // Avoid warning about uninitialized pClass.
1843  }
1844 
1845  delete pList;
1846 
1847  if (context != original_context)
1848  pos = -2;
1849  }
1850  break;
1851 
1852  case kCXX_ScopeProto:
1853  {
1854  const EContext_t original_context = context; // save this for later
1855 
1856  // get class
1857  TClass *pClass;
1858  TString name = s3("^[_a-zA-Z][_a-zA-Z0-9]*");
1859  // "name" may now be the name of a class, object, or pointer
1860 
1861  IfDebug(std::cerr << std::endl);
1862  IfDebug(std::cerr << "name: " << '"' << name << '"' << std::endl);
1863 
1864  // We need to decompose s3 a little more:
1865  // The partname is the method symbol and a bracket at the end of ::
1866  // eg. given s3 = "foo::bar::part(" , partname = "part("
1867  TString partname = s3("[_a-zA-Z][_a-zA-Z0-9]* *($");
1868 
1869  // The prefix, considering the s3 = "foo::bar::part" example would be
1870  // prefix = "foo::bar::". prefix equals the empty string if there is only one
1871  // or no set of colons in s3.
1872  // Note: we reconstruct the fully qualified name with a while loop because
1873  // it does not seem that TRegexp can handle something like "([_a-zA-Z][_a-zA-Z0-9]*::)+$"
1874  TString prefix = "";
1875  TString str = s2;
1876  str.Remove(str.Length() - partname.Length(), partname.Length());
1877  while (1) {
1878  TString sym = str("[_a-zA-Z][_a-zA-Z0-9]*::$");
1879  if (sym.Length() == 0)
1880  break;
1881  str.Remove(str.Length() - sym.Length(), sym.Length());
1882  prefix = sym + prefix;
1883  }
1884 
1885  // Not the preprefix would be = "foo::" from our previous example or the empty
1886  // string, "" if there is only one or no set of colons in prefix, eg. prefix = "bar::"
1887  TString preprefix = prefix;
1888  TString sym = prefix("[_a-zA-Z][_a-zA-Z0-9]*::$");
1889  preprefix.Remove(preprefix.Length() - sym.Length(), sym.Length());
1890 
1891  IfDebug(std::cerr << "prefix: " << '"' << prefix << '"' << std::endl);
1892  IfDebug(std::cerr << "preprefix: " << '"' << preprefix << '"' << std::endl);
1893 
1894  pClass = MakeClassFromClassName(preprefix + name);
1895  if (!pClass) {
1896  pos = -2;
1897  break;
1898  }
1899  // get method name
1900  TString methodName;
1901 
1902  // (normal member function)
1903  methodName = s3("[^:>\\.(]*($");
1904  methodName.Chop();
1905  methodName.Remove(TString::kTrailing, ' ');
1906 
1907  IfDebug(std::cerr << methodName << std::endl);
1908 
1909  // get methods
1910  TContainer *pList = new TContainer;
1911  pList->AddAll(pClass->GetListOfAllPublicMethods());
1912 
1913  // print prototypes
1914  Bool_t foundOne = kFALSE;
1915  TIter nextMethod(pList);
1916  TMethod *pMethod;
1917  while ((pMethod = (TMethod *) nextMethod())) {
1918  if (methodName == pMethod->GetName()) {
1919  foundOne = kTRUE;
1920  out << pMethod->GetReturnTypeName()
1921  << " " << pMethod->GetName()
1922  << pMethod->GetSignature();
1923  const char *comment = pMethod->GetCommentString();
1924  if (comment && comment[0] != '\0') {
1925  out << " \t// " << comment;
1926  }
1927  out << std::endl;
1928  }
1929  }
1930 
1931  // done
1932  if (foundOne) {
1933  pos = -2;
1934  } else {
1935  gSystem->Beep();
1936  pos = -1;
1937  }
1938 
1939  // cleanup
1940  delete pList;
1941 
1942  if (context != original_context)
1943  pos = -2;
1944  }
1945  break;
1946 
1947  case kCXX_DirectProto:
1948  case kCXX_IndirectProto:
1949  case kCXX_NewProto:
1950  case kCXX_ConstructorProto:
1951  {
1952  const EContext_t original_context = context; // save this for later
1953 
1954  // get class
1955  TClass *pClass;
1956  TString name;
1957  if (context == kCXX_NewProto) {
1958  name = s3("[_a-zA-Z][_a-zA-Z0-9:]* *($", 3);
1959  name.Chop();
1960  name.Remove(TString::kTrailing, ' ');
1961  // "name" should now be the name of a class
1962  } else {
1963  name = s3("^[_a-zA-Z][_a-zA-Z0-9:]*");
1964  // "name" may now be the name of a class, object, or pointer
1965  }
1966  IfDebug(std::cerr << std::endl);
1967  IfDebug(std::cerr << "name: " << '"' << name << '"' << std::endl);
1968 
1969  // frodo: Again, passing the all string
1970  TString namerec = s1;
1971 
1972  switch (context) {
1973  case kCXX_ScopeProto:
1974  pClass = MakeClassFromClassName(name);
1975  break;
1976  case kCXX_DirectProto:
1977  pClass = MakeClassFromVarName(namerec, context); // frodo
1978  break;
1979  case kCXX_IndirectProto:
1980  pClass = MakeClassFromVarName(namerec, context); // frodo
1981  break;
1982  case kCXX_NewProto:
1983  pClass = MakeClassFromClassName(name);
1984  break;
1985  case kCXX_ConstructorProto:
1986  pClass = MakeClassFromClassName(name);
1987  break;
1988  default:
1989  Fatal("TTabCom::Hook","Conext case %d not handled",context);
1990  return 0; // Avoid warning about uninitialized pClass.
1991  }
1992  if (!pClass) {
1993  pos = -2;
1994  break;
1995  }
1996  // get method name
1997  TString methodName;
1998  if (context == kCXX_ConstructorProto || context == kCXX_NewProto) {
1999  // (constructor)
2000  methodName = name("[_a-zA-Z][_a-zA-Z0-9]*$");
2001  } else {
2002  // (normal member function)
2003  methodName = s3("[^:>\\.(]*($");
2004  methodName.Chop();
2005  methodName.Remove(TString::kTrailing, ' ');
2006  }
2007  IfDebug(std::cerr << methodName << std::endl);
2008 
2009  // get methods
2010  TContainer *pList = new TContainer;
2011  pList->AddAll(pClass->GetListOfAllPublicMethods());
2012 
2013  // print prototypes
2014  Bool_t foundOne = kFALSE;
2015  TIter nextMethod(pList);
2016  TMethod *pMethod;
2017  while ((pMethod = (TMethod *) nextMethod())) {
2018  if (methodName == pMethod->GetName()) {
2019  foundOne = kTRUE;
2020  out << pMethod->GetReturnTypeName()
2021  << " " << pMethod->GetName()
2022  << pMethod->GetSignature();
2023  const char *comment = pMethod->GetCommentString();
2024  if (comment && comment[0] != '\0') {
2025  out << " \t// " << comment;
2026  }
2027  out << std::endl;
2028  }
2029  }
2030 
2031  // done
2032  if (foundOne) {
2033  pos = -2;
2034  } else {
2035  gSystem->Beep();
2036  pos = -1;
2037  }
2038 
2039  // cleanup
2040  delete pList;
2041 
2042  if (context != original_context)
2043  pos = -2;
2044  }
2045  break;
2046 
2047  case kCXX_Global:
2048  {
2049  // first need to veto a few possibilities.
2050  int l2 = s2.Length(), l3 = s3.Length();
2051 
2052  // "abc().whatever[TAB]"
2053  if (l2 > l3 && s2[l2 - l3 - 1] == '.') {
2054  std::cerr << std::endl <<
2055  "tab completion not implemented for this context" << std::endl;
2056  break; // veto
2057  }
2058  // "abc()->whatever[TAB]"
2059  if (l2 > l3 + 1 && s2(l2 - l3 - 2, 2) == "->") {
2060  std::cerr << std::endl <<
2061  "tab completion not implemented for this context" << std::endl;
2062  break; // veto
2063  }
2064 
2065  TContainer *pList = new TContainer;
2066 
2067  const TSeqCollection *pL2 = GetListOfClasses();
2068  if (pL2) pList->AddAll(pL2);
2069 
2070  //
2071  const TSeqCollection *pC1 = GetListOfGlobals();
2072  if (pC1) pList->AddAll(pC1);
2073  //
2075  if (pC3) pList->AddAll(pC3);
2076 
2077  pos = Complete("[_a-zA-Z][_a-zA-Z0-9]*$", pList, "", out);
2078 
2079  delete pList;
2080  }
2081  break;
2082 
2083  case kCXX_GlobalProto:
2084  {
2085  // get function name
2086  TString functionName = s3("[_a-zA-Z][_a-zA-Z0-9]*");
2087  IfDebug(std::cerr << functionName << std::endl);
2088 
2089  TContainer listOfMatchingGlobalFuncs;
2090  TIter nextGlobalFunc(GetListOfGlobalFunctions());
2091  TObject *pObj;
2092  while ((pObj = nextGlobalFunc())) {
2093  if (strcmp(pObj->GetName(), functionName) == 0) {
2094  listOfMatchingGlobalFuncs.Add(pObj);
2095  }
2096  }
2097 
2098  if (listOfMatchingGlobalFuncs.IsEmpty()) {
2099  std::cerr << std::endl << "no such function: " << dblquote(functionName)
2100  << std::endl;
2101  } else {
2102  TIter next(&listOfMatchingGlobalFuncs);
2103  TFunction *pFunction;
2104  while ((pFunction = (TFunction *) next())) {
2105  out << pFunction->GetReturnTypeName()
2106  << " " << pFunction->GetName()
2107  << pFunction->GetSignature()
2108  << std::endl;
2109  }
2110  }
2111 
2112  pos = -2;
2113  }
2114  break;
2115 
2116  /******************************************************************/
2117  /* */
2118  /* default: should never happen */
2119  /* */
2120  /******************************************************************/
2121  default:
2122  Fatal("TTabCom::Hook","Conext case %d not handled",context);
2123  return 0; // Avoid warning about uninitialized pClass.
2124  }
2125 
2126  return pos;
2127 }
2128 
2129 ////////////////////////////////////////////////////////////////////////////////
2130 /// [private]
2131 
2133 {
2134  // add more patterns somewhere below.
2135  // add corresponding enum to "EContext_t"
2136  //
2137  // note:
2138  // 1. in some cases order is important ...
2139  //
2140  // the order of the "case" statements in "switch( context )" in "TTabCom::Hook()" is Not important.
2141  //
2142  // the order of the "SetPattern()" function calls below is Not important.
2143  //
2144  // the order of the initializers in the "EContext_t" enumeration Is important
2145  // because DetermineContext() goes through the array in order, and returns at the first match.
2146  //
2147  // 2. below, "$" will match cursor position
2148 
2149  SetPattern(kSYS_UserName, "~[_a-zA-Z0-9]*$");
2150  SetPattern(kSYS_EnvVar, "$[_a-zA-Z0-9]*$");
2151 
2152  SetPattern(kCINT_stdout, "; *>>?.*$"); // stdout
2153  SetPattern(kCINT_stderr, "; *2>>?.*$"); // stderr
2154  SetPattern(kCINT_stdin, "; *<.*$"); // stdin
2155 
2156  SetPattern(kCINT_Edit, "^ *\\.E .*$");
2157  SetPattern(kCINT_Load, "^ *\\.L .*$");
2158  SetPattern(kCINT_Exec, "^ *\\.x +[-0-9_a-zA-Z~$./]*$");
2159  SetPattern(kCINT_EXec, "^ *\\.X +[-0-9_a-zA-Z~$./]*$");
2160 
2161  SetPattern(kCINT_pragma, "^# *pragma +[_a-zA-Z0-9]*$");
2162  SetPattern(kCINT_includeSYS, "^# *include *<[^>]*$"); // system files
2163  SetPattern(kCINT_includePWD, "^# *include *\"[^\"]*$"); // local files
2164 
2165  SetPattern(kCINT_cpp, "^# *[_a-zA-Z0-9]*$");
2166 
2167  SetPattern(kROOT_Load, "gSystem *-> *Load *( *\"[^\"]*$");
2168 
2169  SetPattern(kCXX_NewProto, "new +[_a-zA-Z][_a-zA-Z0-9:]* *($");
2171  "[_a-zA-Z][_a-zA-Z0-9:]* +[_a-zA-Z][_a-zA-Z0-9]* *($");
2173  "[_a-zA-Z][_a-zA-Z0-9]* *:: *[_a-zA-Z0-9]* *($");
2175  "[_a-zA-Z][_a-zA-Z0-9()]* *\\. *[_a-zA-Z0-9]* *($");
2177  "[_a-zA-Z][_a-zA-Z0-9()]* *-> *[_a-zA-Z0-9]* *($");
2178 
2180  "[_a-zA-Z][_a-zA-Z0-9]* *:: *[_a-zA-Z0-9]*$");
2182  "[_a-zA-Z][_a-zA-Z0-9()]* *\\. *[_a-zA-Z0-9()]*$"); //
2183 
2185  "[_a-zA-Z][_a-zA-Z0-9()]* *-> *[_a-zA-Z0-9()]*$"); // frodo
2186 
2187  SetPattern(kSYS_FileName, "\"[-0-9_a-zA-Z~$./]*$");
2188  SetPattern(kCXX_Global, "[_a-zA-Z][_a-zA-Z0-9]*$");
2189  SetPattern(kCXX_GlobalProto, "[_a-zA-Z][_a-zA-Z0-9]* *($");
2190 }
2191 
2192 ////////////////////////////////////////////////////////////////////////////////
2193 /// [private]
2194 /// (does some specific error handling that makes the function unsuitable for general use.)
2195 /// returns a new'd TClass given the name of a class.
2196 /// user must delete.
2197 /// returns 0 in case of error.
2198 
2199 TClass *TTabCom::MakeClassFromClassName(const char className[]) const
2200 {
2201  // the TClass constructor will print a Warning message for classes that don't exist
2202  // so, ignore warnings temporarily.
2203  NoMsg(kWarning);
2204  TClass *pClass = TClass::GetClass(className);
2205  NoMsg(-1);
2206 
2207  if (!pClass){
2208  Error("TTabCom::MakeClassFromClassName", "Unknown class \"%s\"", className);
2209  return nullptr;
2210  }
2211 
2212  // make sure "className" exists
2213  // if (pClass->Size() == 0) { //namespace has 0 size
2214  if (pClass->GetListOfAllPublicMethods()->GetSize() == 0 &&
2215  pClass->GetListOfAllPublicDataMembers()->GetSize() == 0) {
2216  // i'm assuming this happens iff there was some error.
2217  // (misspelled the class name, for example)
2218  Error("TTabCom::MakeClassFromClassName", "class \"%s\" is not defined.", className);
2219  return 0;
2220  }
2221 
2222  return pClass;
2223 }
2224 
2225 ////////////////////////////////////////////////////////////////////////////////
2226 /// Same as above but does not print the error message.
2227 
2228 TClass *TTabCom::TryMakeClassFromClassName(const char className[]) const
2229 {
2230  // the TClass constructor will print a Warning message for classes that don't exist
2231  // so, ignore warnings temporarily.
2232  NoMsg(kWarning);
2233  TClass *pClass = TClass::GetClass(className);
2234  NoMsg(-1);
2235 
2236  return pClass;
2237 }
2238 
2239 ////////////////////////////////////////////////////////////////////////////////
2240 /// [private]
2241 /// (does some specific error handling that makes the function unsuitable for general use.)
2242 /// returns a new'd TClass given the name of a variable.
2243 /// user must delete.
2244 /// returns 0 in case of error.
2245 /// if user has operator.() or operator->() backwards, will modify: context, *fpLoc and fBuf.
2246 /// context sensitive behavior.
2247 
2249  EContext_t & context, int iter)
2250 {
2251  // frodo:
2252  // Because of the Member and Proto recursion, this has become a bit
2253  // complicated, so here is how it works:
2254  //
2255  // root [1] var.a.b.c[TAB]
2256  //
2257  // will generate the sucessive calls:
2258  // MakeClassFromVarName("var.a.b.c", context, 0) returns the class of "c"
2259  // MakeClassFromVarName("var.a.b", context, 1) returns the class of "b"
2260  // MakeClassFromVarName("var.a", context, 2) returns the class of "a"
2261  // MakeClassFromVarName("var", context, 3)
2262 
2263  // need to make sure "varName" exists
2264  // because "DetermineClass()" prints clumsy error message otherwise.
2265  Bool_t varName_exists = GetListOfGlobals()->Contains(varName) || // check in list of globals first.
2266  (gROOT->FindObject(varName) != 0); // then check CINT "shortcut #3"
2267 
2268 
2269  //
2270  // frodo: Member and Proto recursion code
2271  //
2272  if (0) printf("varName is [%s] with iteration [%i]\n", varName, iter);
2273 
2274  // ParseReverse will return 0 if there are no "." or "->" in the varName
2275  Int_t cut = ParseReverse(varName, strlen(varName));
2276 
2277  // If it's not a "simple" variable and if there is at least one "." or "->"
2278  if (!varName_exists && cut != 0)
2279  {
2280  TString parentName = varName;
2281  TString memberName = varName;
2282 
2283  // Check to see if this is the last call (last member/method)
2284  if (iter > fLastIter) fLastIter = iter;
2285 
2286  parentName[cut] = 0;
2287  if (0) printf("Parent string is [%s]\n", parentName.Data());
2288 
2289  // We are treating here cases like h->SetXTitle(gROOT->Get<TAB>
2290  // i.e. when the parentName has an unbalanced number of paranthesis.
2291  if (cut>2) {
2292  UInt_t level = 0;
2293  for(Int_t i = cut-1; i>=0; --i) {
2294  switch (parentName[i]) {
2295  case '(':
2296  if (level) --level;
2297  else {
2298  parentName = parentName(i+1,cut-i-1);
2299  i = 0;
2300  }
2301  break;
2302  case ')':
2303  ++level; break;
2304  }
2305  }
2306  }
2307 
2308  TClass *pclass;
2309  // Can be "." or "->"
2310  if (varName[cut] == '.') {
2311  memberName = varName+cut+1;
2312  if (0) printf("Member/method is [%s]\n", memberName.Data());
2313  EContext_t subcontext = kCXX_DirectMember;
2314  pclass = MakeClassFromVarName(parentName.Data(), subcontext, iter+1);
2315  } else {
2316  memberName = varName+cut+2;
2317  if (0) printf("Member/method is [%s]\n", memberName.Data());
2318  EContext_t subcontext = kCXX_IndirectMember;
2319  pclass = MakeClassFromVarName(parentName.Data(), subcontext, iter+1);
2320  }
2321 
2322  if (0) printf("I got [%s] from MakeClassFromVarName()\n", pclass->GetName());
2323 
2324  if (pclass)
2325  {
2326  if (0) printf("Variable [%s] exists!\n", parentName.Data());
2327 
2328  // If it's back in the first call of the function, return immediatly
2329  if (iter == 0) return pclass;
2330 
2331  if (0) printf("Trying data member [%s] of class [%s] ...\n",
2332  memberName.Data(), pclass->GetName());
2333 
2334  // Check if it's a member
2335  TDataMember *dmptr = 0; //pclass->GetDataMember(memberName.Data());
2336  TIter next(pclass->GetListOfAllPublicDataMembers());
2337  while ((dmptr = (TDataMember *) next())) {
2338  if (memberName == dmptr->GetName()) break;
2339  }
2340  if (dmptr)
2341  {
2342  if (0) printf("It's a member!\n");
2343 
2344  TString returnName = dmptr->GetTypeName();
2345  // if (returnName[returnName.Length()-1] == '*')
2346  // printf("It's a pointer!\n");
2347 
2348  TClass *mclass = TClass::GetClass(returnName.Data());
2349  return mclass;
2350  }
2351 
2352 
2353  // Check if it's a proto: must have ()
2354  // This might not be too safe to use :(
2355  char *parentesis_ptr = (char*)strrchr(memberName.Data(), '(');
2356  if (parentesis_ptr) *parentesis_ptr = 0;
2357 
2358 
2359  if (0) printf("Trying method [%s] of class [%s] ...\n",
2360  memberName.Data(), pclass->GetName());
2361 
2362  // Check if it's a method
2363  TMethod *mptr = 0; // pclass->GetMethodAny(memberName.Data());
2364  const TList *mlist = pclass->GetListOfAllPublicMethods();
2365  next = mlist;
2366  while ((mptr = (TMethod *) next())) {
2367  if (strcmp(memberName.Data(),mptr->GetName())==0) break;
2368  }
2369  if (mptr)
2370  {
2371  TString returnName = mptr->GetReturnTypeName();
2372 
2373  if (0) printf("It's a method called [%s] with return type [%s]\n",
2374  memberName.Data(), returnName.Data());
2375 
2376  // This will handle the methods that returns a pointer to a class
2377  if (returnName[returnName.Length()-1] == '*')
2378  {
2379  returnName[returnName.Length()-1] = 0;
2380  fVarIsPointer = kTRUE;
2381  }
2382  else
2383  {
2385  }
2386 
2387  TClass *mclass = TClass::GetClass(returnName.Data());
2388  return mclass;
2389  }
2390  }
2391  }
2392 
2393  //
2394  // frodo: End of Member and Proto recursion code
2395  //
2396 
2397 
2398  // not found...
2399  if (!varName_exists) {
2400  std::cerr << std::endl << "variable " << dblquote(varName) << " not defined."
2401  << std::endl;
2402  return 0; //* RETURN *//
2403  }
2404 
2405  /*****************************************************************************************/
2406  /* */
2407  /* this section is really ugly. */
2408  /* and slow. */
2409  /* it could be made a lot better if there was some way to tell whether or not a given */
2410  /* variable is a pointer or a pointer to a pointer. */
2411  /* */
2412  /*****************************************************************************************/
2413 
2414  TString className = DetermineClass(varName);
2415 
2416  if (className.IsNull() || className == "*") {
2417  // this will happen if "varName" is a fundamental type (as opposed to class type).
2418  // or a pointer to a pointer.
2419  // or a function pointer.
2420  std::cerr << std::endl << "problem determining class of " << dblquote(varName)
2421  << std::endl;
2422  return 0; //* RETURN *//
2423  }
2424 
2425  fVarIsPointer = className[className.Length() - 1] == '*';
2426 
2427  // frodo: I shouldn't have to do this, but for some reason now I have to
2428  // otherwise the varptr->[TAB] won't work :(
2429  if (fVarIsPointer || className[className.Length() - 1] == '&')
2430  className[className.Length()-1] = 0;
2431 
2432  // frodo case '.' dealt with in the previous if statement?!
2433  // frodo: I wasn't able to put the automatic "." to "->" replacing working
2434  // so I just commented out.
2435  //
2436 
2437 
2438  // Bool_t varIsPointer = className[className.Length() - 1] == '*';
2439 
2440  //printf("Context is %i, fContext is %i, pointer is %i\n", context, fContext, fVarIsPointer);
2441 
2442  if (fVarIsPointer &&
2443  (context == kCXX_DirectMember || context == kCXX_DirectProto)) {
2444  // user is using operator.() instead of operator->()
2445  // ==>
2446  // 1. we are in wrong context.
2447  // 2. user is lazy
2448  // 3. or maybe confused
2449 
2450  // 1. fix the context
2451  switch (context) {
2452  case kCXX_DirectMember:
2453  context = kCXX_IndirectMember;
2454  break;
2455  case kCXX_DirectProto:
2456  context = kCXX_IndirectProto;
2457  break;
2458  default:
2459  Fatal("TTabCom::MakeClassFromVarName","Conext case %d not handled",context);
2460  return 0; // Avoid warning about uninitialized pClass.
2461  }
2462 
2463  // 2. fix the operator.
2464  int i;
2465  for (i = *fpLoc; fBuf[i] != '.'; i -= 1) {
2466  }
2467  int loc = i;
2468  for (i = strlen(fBuf); i >= loc; i -= 1) {
2469  fBuf[i + 1] = fBuf[i];
2470  }
2471  fBuf[loc] = '-';
2472  fBuf[loc + 1] = '>';
2473  *fpLoc += 1;
2474 
2475  // 3. inform the user.
2476  std::cerr << std::endl << dblquote(varName) <<
2477  " is of pointer type. Use this operator: ->" << std::endl;
2478  return 0;
2479  }
2480 
2481  if (context == kCXX_IndirectMember || context == kCXX_IndirectProto) {
2482  if (fVarIsPointer) {
2483  // frodo: This part no longer makes sense...
2484  className.Chop(); // remove the '*'
2485 
2486  if (className[className.Length() - 1] == '*') {
2487  std::cerr << std::endl << "can't handle pointers to pointers." << std::endl;
2488  return 0; // RETURN
2489  }
2490  } else {
2491  // user is using operator->() instead of operator.()
2492  // ==>
2493  // 1. we are in wrong context.
2494  // 2. user is lazy
2495  // 3. or maybe confused
2496 
2497  // 1. fix the context
2498  switch (context) {
2499  case kCXX_IndirectMember:
2500  context = kCXX_DirectMember;
2501  break;
2502  case kCXX_IndirectProto:
2503  context = kCXX_DirectProto;
2504  break;
2505  default:
2506  Fatal("TTabCom::MakeClassFromVarName","Conext case %d not handled",context);
2507  return 0; // Avoid warning about uninitialized pClass.
2508  }
2509 
2510  // 2. fix the operator.
2511  int i;
2512  for (i = *fpLoc; fBuf[i - 1] != '-' && fBuf[i] != '>'; i -= 1) {
2513  }
2514  fBuf[i - 1] = '.';
2515  int len = strlen(fBuf);
2516  for (; i < len; i += 1) {
2517  fBuf[i] = fBuf[i + 1];
2518  }
2519  *fpLoc -= 1;
2520 
2521  // 3. inform the user.
2522  std::cerr << std::endl << dblquote(varName) <<
2523  " is not of pointer type. Use this operator: ." << std::endl;
2524  return 0;
2525  }
2526  }
2527 
2528  className.Strip(TString::kBoth);
2529 
2530  return TClass::GetClass(className);
2531 }
2532 
2533 ////////////////////////////////////////////////////////////////////////////////
2534 /// [private]
2535 
2536 void TTabCom::SetPattern(EContext_t handle, const char regexp[])
2537 {
2538  // prevent overflow
2539  if (handle >= kNUM_PAT) {
2540  std::cerr << std::endl
2541  << "ERROR: handle="
2542  << (int) handle << " >= kNUM_PAT=" << (int) kNUM_PAT << std::endl;
2543  return;
2544  }
2545 
2546  fRegExp[handle] = regexp;
2547  Makepat(regexp, fPat[handle], MAX_LEN_PAT);
2548 }
2549 
2550 
2551 
2552 ////////////////////////////////////////////////////////////////////////////////
2553 ///
2554 /// Returns the place in the string where to put the \0, starting the search
2555 /// from "start"
2556 ///
2557 
2558 int TTabCom::ParseReverse(const char *var_str, int start)
2559 {
2560  int end = 0;
2561  if (start > (int)strlen(var_str)) start = strlen(var_str);
2562 
2563  for (int i = start; i > 0; i--)
2564  {
2565  if (var_str[i] == '.') return i;
2566  if (var_str[i] == '>' && i > 0 && var_str[i-1] == '-') return i-1;
2567  }
2568 
2569  return end;
2570 }
TTabCom::RehashEnvVars
void RehashEnvVars()
Environemnt variables rehashing.
Definition: TTabCom.cxx:353
TTabCom.h
c
#define c(i)
Definition: RSha256.hxx:119
TTabCom::InitPatterns
void InitPatterns()
[private]
Definition: TTabCom.cxx:2132
l
auto * l
Definition: textangle.C:4
TTabCom::ExtendPath
TString ExtendPath(const char originalPath[], TString newBase) const
[private]
Definition: TTabCom.cxx:1528
TDataMember::GetTypeName
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
Definition: TDataMember.cxx:604
TTabCom::fVarIsPointer
Bool_t fVarIsPointer
Definition: TTabCom.h:223
TSystem::Unlink
virtual int Unlink(const char *name)
Unlink, i.e.
Definition: TSystem.cxx:1379
TSystem::GetPathInfo
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition: TSystem.cxx:1396
TString::ReadToDelim
std::istream & ReadToDelim(std::istream &str, char delim='\n')
Read up to an EOF, or a delimiting character, whichever comes first.
Definition: Stringio.cxx:89
TTabCom::NewListOfFilesInPath
static TSeqCollection * NewListOfFilesInPath(const char path[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1044
TTabCom::kCINT_Load
@ kCINT_Load
Definition: TTabCom.h:133
TTabCom::GetListOfFilesInPath
const TSeqCollection * GetListOfFilesInPath(const char path[])
"path" should be initialized with a colon separated list of system directories
Definition: TTabCom.cxx:503
Rstrstream.h
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TTabCom::fpDirectives
TSeqCollection * fpDirectives
Definition: TTabCom.h:210
TClass::GetListOfAllPublicMethods
const TList * GetListOfAllPublicMethods(Bool_t load=kTRUE)
Returns a list of all public methods of this class and its base classes.
Definition: TClass.cxx:3747
TTabCom::ClearUsers
void ClearUsers()
Forget all user seen so far.
Definition: TTabCom.cxx:306
TTabCom::kROOT_Load
@ kROOT_Load
Definition: TTabCom.h:151
TTabCom::kCXX_DirectProto
@ kCXX_DirectProto
Definition: TTabCom.h:170
TTabCom::ParseReverse
int ParseReverse(const char *var_str, int start)
Returns the place in the string where to put the \0, starting the search from "start".
Definition: TTabCom.cxx:2558
sym
#define sym(otri1, otri2)
Definition: triangle.c:932
TClass::GetListOfAllPublicDataMembers
TList * GetListOfAllPublicDataMembers(Bool_t load=kTRUE)
Returns a list of all public data members of this class and its base classes.
Definition: TClass.cxx:3764
TTabCom::kCXX_IndirectMember
@ kCXX_IndirectMember
Definition: TTabCom.h:177
dest
#define dest(otri, vertexptr)
Definition: triangle.c:1040
Matchs
const char * Matchs(const char *, size_t len, const Pattern_t *, const char **)
Match a string with a pattern.
Definition: Match.cxx:220
TTabCom::RehashAll
void RehashAll()
clears and then rebuilds all lists except for user names and system include files.
Definition: TTabCom.cxx:415
Makepat
int Makepat(const char *, Pattern_t *, int)
Make a pattern template from the string pointed to by exp.
Definition: Match.cxx:129
TString::Strip
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1106
TTabCom::fRegExp
const char * fRegExp[kNUM_PAT]
Definition: TTabCom.h:222
TSeqCollection::Add
virtual void Add(TObject *obj)
Definition: TSeqCollection.h:44
TString::Prepend
TString & Prepend(const char *cs)
Definition: TString.h:661
gEnv
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
TString::Data
const char * Data() const
Definition: TString.h:369
TFunction.h
TSystem::FreeDirectory
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition: TSystem.cxx:844
TTabCom::ClearCppDirectives
void ClearCppDirectives()
Forget all Cpp directives seen so far.
Definition: TTabCom.cxx:230
TTabCom::GetListOfClasses
const TSeqCollection * GetListOfClasses()
Return the list of classes.
Definition: TTabCom.cxx:431
TROOT::GetMacroPath
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition: TROOT.cxx:2712
TSystem::Which
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1544
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TTabCom::kCXX_ConstructorProto
@ kCXX_ConstructorProto
Definition: TTabCom.h:168
TObjString.h
TClassTable::Init
static void Init()
Definition: TClassTable.cxx:334
BUF_SIZE
#define BUF_SIZE
Definition: TTabCom.cxx:151
FileStat_t
Definition: TSystem.h:124
kWarning
const Int_t kWarning
Definition: TError.h:47
TCollection::Delete
virtual void Delete(Option_t *option="")=0
Delete this object.
TMethod.h
TString::kIgnoreCase
@ kIgnoreCase
Definition: TString.h:268
TTabCom::RehashGlobals
void RehashGlobals()
Reload globals.
Definition: TTabCom.cxx:378
TTabCom::GetSysIncludePath
static TString GetSysIncludePath()
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:923
TCollection::SetOwner
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Definition: TCollection.cxx:746
gInterpreter
#define gInterpreter
Definition: TInterpreter.h:558
TDataMember.h
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
TTabCom::kSYS_UserName
@ kSYS_UserName
Definition: TTabCom.h:121
TDataMember
Definition: TDataMember.h:31
TTabCom::kCXX_Global
@ kCXX_Global
Definition: TTabCom.h:181
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
TString::EndsWith
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2177
TTabCom::fPat
Pattern_t fPat[kNUM_PAT][MAX_LEN_PAT]
Definition: TTabCom.h:221
TTabCom::GetListOfEnvVars
const TSeqCollection * GetListOfEnvVars()
Uses "env" (Unix) or "set" (Windows) to get list of environment variables.
Definition: TTabCom.cxx:522
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TTabCom::ClearPragmas
void ClearPragmas()
Forget all pragmas seen so far.
Definition: TTabCom.cxx:282
TString::kExact
@ kExact
Definition: TString.h:268
TClass.h
TTabCom::kNUM_PAT
@ kNUM_PAT
Definition: TTabCom.h:186
TList.h
TTabCom::ClearGlobalFunctions
void ClearGlobalFunctions()
Forget all global functions seen so far.
Definition: TTabCom.cxx:267
TEnv::GetValue
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
TIter::Reset
void Reset()
Definition: TCollection.h:252
TSystem::TempFileName
virtual FILE * TempFileName(TString &base, const char *dir=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
Definition: TSystem.cxx:1495
passwd
Definition: TWinNTSystem.h:47
TTabCom::kCINT_Edit
@ kCINT_Edit
Definition: TTabCom.h:132
TCollection::Contains
Bool_t Contains(const char *name) const
Definition: TCollection.h:169
TTabCom::fpFiles
TSeqCollection * fpFiles
Definition: TTabCom.h:212
gTabCom
TTabCom * gTabCom
Definition: TTabCom.cxx:167
TEnv.h
TTabCom::~TTabCom
virtual ~TTabCom()
Definition: TTabCom.cxx:200
TString
Definition: TString.h:136
TTabCom::ClearAll
void ClearAll()
clears all lists except for user names and system include files.
Definition: TTabCom.cxx:319
TCollection::AddAll
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
Definition: TCollection.cxx:195
TTabCom::RehashClasses
void RehashClasses()
Do the class rehash.
Definition: TTabCom.cxx:335
kDelim
const char kDelim
Definition: TTabCom.cxx:158
TTabCom::fpClasses
TSeqCollection * fpClasses
Definition: TTabCom.h:208
TSystem::GetDirName
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:1030
TTabCom::SetPattern
void SetPattern(EContext_t handle, const char regexp[])
[private]
Definition: TTabCom.cxx:2536
bool
TTabCom::DetermineContext
EContext_t DetermineContext() const
[private]
Definition: TTabCom.cxx:1461
dblquote
#define dblquote(x)
Definition: TTabCom.h:43
TTabCom::MakeClassFromClassName
TClass * MakeClassFromClassName(const char className[]) const
private returns a new'd TClass given the name of a class.
Definition: TTabCom.cxx:2199
TTabCom::GetListOfUsers
const TSeqCollection * GetListOfUsers()
reads from "/etc/passwd"
Definition: TTabCom.cxx:634
TString::kBoth
@ kBoth
Definition: TString.h:267
TTabCom::fpUsers
TSeqCollection * fpUsers
Definition: TTabCom.h:216
TTabCom::GetListOfSysIncFiles
const TSeqCollection * GetListOfSysIncFiles()
Return the list of system include files.
Definition: TTabCom.cxx:622
TROOT.h
TTabCom::MakeClassFromVarName
TClass * MakeClassFromVarName(const char varName[], EContext_t &context, int iter=0)
private returns a new'd TClass given the name of a variable.
Definition: TTabCom.cxx:2248
TTabCom::kCINT_EXec
@ kCINT_EXec
Definition: TTabCom.h:135
TObjString
Definition: TObjString.h:28
MAX_LEN_PAT
#define MAX_LEN_PAT
Definition: TTabCom.h:42
TTabCom::TryMakeClassFromClassName
TClass * TryMakeClassFromClassName(const char className[]) const
Same as above but does not print the error message.
Definition: TTabCom.cxx:2228
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TTabCom::kCINT_stdin
@ kCINT_stdin
Definition: TTabCom.h:127
TTabCom::kCINT_includeSYS
@ kCINT_includeSYS
Definition: TTabCom.h:139
TTabCom::GetListOfGlobals
const TSeqCollection * GetListOfGlobals()
Return the list of globals.
Definition: TTabCom.cxx:575
s0
#define s0(x)
Definition: RSha256.hxx:108
TString::ECaseCompare
ECaseCompare
Definition: TString.h:268
TTabCom::PathIsSpecifiedInFileName
static Bool_t PathIsSpecifiedInFileName(const TString &fileName)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1083
IfDebug
#define IfDebug(x)
Definition: TTabCom.cxx:153
TTabCom::kCXX_IndirectProto
@ kCXX_IndirectProto
Definition: TTabCom.h:171
TMethod::GetCommentString
virtual const char * GetCommentString()
Returns a comment string from the class declaration.
Definition: TMethod.cxx:107
TClassTable.h
TTabCom::GetListOfGlobalFunctions
TCollection * GetListOfGlobalFunctions()
Return the list of global functions.
Definition: TTabCom.cxx:583
TTabCom::AppendListOfFilesInDirectory
static void AppendListOfFilesInDirectory(const char dirName[], TSeqCollection *pList)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:745
TTabCom::TContainer
TList TContainer
Definition: TTabCom.h:59
TString::Chop
TString & Chop()
Definition: TString.h:679
kExecutePermission
@ kExecutePermission
Definition: TSystem.h:45
TSystem.h
TTabCom::Hook
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
Definition: TTabCom.cxx:1560
TString::kTrailing
@ kTrailing
Definition: TString.h:267
THashList
Definition: THashList.h:34
TTabCom::ClearClasses
void ClearClasses()
Clear classes and namespace collections.
Definition: TTabCom.cxx:218
TTabCom::fpSysIncFiles
TSeqCollection * fpSysIncFiles
Definition: TTabCom.h:215
FileStat_t::fMode
Int_t fMode
Definition: TSystem.h:127
TTabCom::RehashPragmas
void RehashPragmas()
Reload pragmas.
Definition: TTabCom.cxx:387
TString::Remove
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
TInterpreter::DisplayIncludePath
virtual int DisplayIncludePath(FILE *) const
Definition: TInterpreter.h:252
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TString::Append
TString & Append(const char *cs)
Definition: TString.h:564
Fatal
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Definition: TError.cxx:245
TSystem::Exec
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:654
s1
#define s1(x)
Definition: RSha256.hxx:109
TTabCom::fpLoc
int * fpLoc
Definition: TTabCom.h:219
TMethod
Definition: TMethod.h:38
xmlio::String
const char * String
Definition: TXMLSetup.cxx:100
TTabCom::kUNKNOWN_CONTEXT
@ kUNKNOWN_CONTEXT
Definition: TTabCom.h:114
TTabCom::ClearSysIncFiles
void ClearSysIncFiles()
Close system files.
Definition: TTabCom.cxx:294
TTabCom::kCINT_pragma
@ kCINT_pragma
Definition: TTabCom.h:138
TGlobal.h
TBenchmark.h
TString::BeginsWith
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:615
TFunction::GetReturnTypeName
const char * GetReturnTypeName() const
Get full type description of function return type, e,g.: "class TDirectory*".
Definition: TFunction.cxx:141
TClass::GetClass
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2925
TTabCom::kCINT_stdout
@ kCINT_stdout
Definition: TTabCom.h:125
TSystem::ExpandPathName
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1272
TFunction::GetNargs
Int_t GetNargs() const
Number of function arguments.
Definition: TFunction.cxx:165
TTabCom::kCXX_NewProto
@ kCXX_NewProto
Definition: TTabCom.h:167
line
TLine * line
Definition: entrylistblock_figure1.C:235
TCollection::IsEmpty
virtual Bool_t IsEmpty() const
Definition: TCollection.h:186
TTabCom::RehashCppDirectives
void RehashCppDirectives()
Cpp rehashing.
Definition: TTabCom.cxx:344
TClassTable::Next
static char * Next()
Returns next class from sorted class table.
Definition: TClassTable.cxx:678
TSystem::Beep
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
Definition: TSystem.cxx:325
TTabCom::fLastIter
Int_t fLastIter
Definition: TTabCom.h:224
TTabCom::fPrevInterpMarker
ULong64_t fPrevInterpMarker
Definition: TTabCom.h:209
TTabCom::RehashFiles
void RehashFiles()
Close files.
Definition: TTabCom.cxx:362
unsigned int
TRegexp
Definition: TRegexp.h:31
THashList.h
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
TTabCom::RehashUsers
void RehashUsers()
Reload users.
Definition: TTabCom.cxx:405
TSeqCollection
Definition: TSeqCollection.h:28
TSystem::Getenv
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1661
gErrorIgnoreLevel
R__EXTERN Int_t gErrorIgnoreLevel
Definition: TError.h:129
TString::IsNull
Bool_t IsNull() const
Definition: TString.h:407
TTabCom::GetListOfCppDirectives
const TSeqCollection * GetListOfCppDirectives()
Return the list of CPP directives.
Definition: TTabCom.cxx:477
TTabCom::AllAgreeOnChar
static Char_t AllAgreeOnChar(int i, const TSeqCollection *pList, Int_t &nGoodStrings)
[static utility function]///////////////////////////////////////////
Definition: TTabCom.cxx:680
TSystem::OpenDirectory
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition: TSystem.cxx:835
TTabCom::DeterminePath
TString DeterminePath(const TString &fileName, const char defaultPath[]) const
[private]
Definition: TTabCom.cxx:1485
TTabCom
Definition: TTabCom.h:52
dummy
static RooMathCoreReg dummy
Definition: RooMathCoreReg.cxx:27
TTabCom::kCXX_ScopeMember
@ kCXX_ScopeMember
Definition: TTabCom.h:175
TCollection::GetSize
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
TInterpreter.h
TTabCom::kCINT_includePWD
@ kCINT_includePWD
Definition: TTabCom.h:140
TTabCom::EContext_t
EContext_t
Definition: TTabCom.h:113
TClass
Definition: TClass.h:80
R_ISDIR
Bool_t R_ISDIR(Int_t mode)
Definition: TSystem.h:115
TTabCom::IsDirectory
static Bool_t IsDirectory(const char fileName[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1024
TTabCom::RehashGlobalFunctions
void RehashGlobalFunctions()
Reload global functions.
Definition: TTabCom.cxx:370
TTabCom::NoMsg
static void NoMsg(Int_t errorLevel)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1103
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TSystem::GetDirEntry
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition: TSystem.cxx:852
TObject
Definition: TObject.h:37
gCling
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:559
TTabCom::DetermineClass
static TString DetermineClass(const char varName[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:794
TTabCom::kCINT_stderr
@ kCINT_stderr
Definition: TTabCom.h:126
name
char name[80]
Definition: TGX11.cxx:110
TTabCom::kSYS_FileName
@ kSYS_FileName
Definition: TTabCom.h:164
TTabCom::kCXX_GlobalProto
@ kCXX_GlobalProto
Definition: TTabCom.h:182
TTabCom::CopyMatch
void CopyMatch(char dest[], const char localName[], const char appendage[]=0, const char fullName[]=0) const
[private]
Definition: TTabCom.cxx:1409
TTabCom::kCXX_DirectMember
@ kCXX_DirectMember
Definition: TTabCom.h:176
TIter
Definition: TCollection.h:233
TTabCom::fBuf
char * fBuf
Definition: TTabCom.h:218
TString::kLeading
@ kLeading
Definition: TString.h:267
TTabCom::ClearEnvVars
void ClearEnvVars()
Forget all environment variables seen so far.
Definition: TTabCom.cxx:242
TFunction::GetSignature
const char * GetSignature()
Return signature of function.
Definition: TFunction.cxx:116
TTabCom::kCINT_cpp
@ kCINT_cpp
Definition: TTabCom.h:147
TTabCom::fpEnvVars
TSeqCollection * fpEnvVars
Definition: TTabCom.h:211
TCollection
Definition: TCollection.h:63
ROOT::TMetaUtils::propNames::comment
static const std::string comment("comment")
TMethodArg.h
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
type
int type
Definition: TGX11.cxx:121
TSystem::GetDynamicPath
virtual const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
Definition: TSystem.cxx:1791
TTabCom::kCXX_ScopeProto
@ kCXX_ScopeProto
Definition: TTabCom.h:169
TTabCom::RehashSysIncFiles
void RehashSysIncFiles()
Reload system include files.
Definition: TTabCom.cxx:396
TTabCom::ClearGlobals
void ClearGlobals()
Forget all global variables seen so far.
Definition: TTabCom.cxx:275
TTabCom::GetListOfPragmas
const TSeqCollection * GetListOfPragmas()
Return the list of pragmas.
Definition: TTabCom.cxx:591
TTabCom::ExcludedByFignore
static Bool_t ExcludedByFignore(TString s)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:887
Riostream.h
TTabCom::Complete
Int_t Complete(const TRegexp &re, const TSeqCollection *pListOfCandidates, const char appendage[], std::ostream &out, TString::ECaseCompare cmp=TString::kExact)
[private]
Definition: TTabCom.cxx:1158
Char_t
char Char_t
Definition: RtypesCore.h:33
TCollection::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Definition: TCollection.cxx:312
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
TSeqCollection::At
virtual TObject * At(Int_t idx) const =0
TTabCom::kSYS_EnvVar
@ kSYS_EnvVar
Definition: TTabCom.h:122
TFunction
Definition: TFunction.h:30
TTabCom::ClearFiles
void ClearFiles()
Close all files.
Definition: TTabCom.cxx:254
TList
Definition: TList.h:44
TTabCom::TTabCom
TTabCom()
Default constructor.
Definition: TTabCom.cxx:177
TTabCom::kCINT_Exec
@ kCINT_Exec
Definition: TTabCom.h:134
gROOT
#define gROOT
Definition: TROOT.h:406
TTabCom::fpPragmas
TSeqCollection * fpPragmas
Definition: TTabCom.h:214
int
Error
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition: TError.cxx:187
TError.h
c1
return c1
Definition: legend1.C:41