[ROOT] Finding functions, methods, macros, etc in the ROOT source tree. (was Re: [ROOT] TSQLServer::Query enhancement request: FORM ??)

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Mon Mar 11 2002 - 13:33:45 MET


Hi Christian, 

On Sun, 10 Mar 2002 18:53:41 +0100
"cstrato@EUnet.at" <cstrato@EUnet.at> wrote
concerning "Re: [ROOT] TSQLServer::Query enhancement request: FORM ??":
> Dear Christian
> 
> Thank you for this extensive answer, I have now enough possibilities
> to try.

You're welcome. 

> Thanks to your grep samples I will first try grep.

Try also `egrep' or `grep -e', which gives you extented regular
expressions. 
 
> Since I am not a unix person but a Mac person, I realized that I do
> not like Emacs.

Disbeliever! :-)

I know Linus Thorvalds doesn't like Emacs either, but that's because
he likes Vi (which I like too, but I prefer Emacs).  Here's what the
jargon file say on Emacs [1]: 

  ... Indeed, some hackers find EMACS too heavyweight and baroque for
  their taste, and expand the name as `Escape Meta Alt Control Shift'
  to spoof its heavy reliance on keystrokes decorated with bucky
  bits. Other spoof expansions include `Eight Megabytes And Constantly
  Swapping' (from when that was a lot of core), `Eventually malloc()s
  All Computer Storage', and `EMACS Makes A Computer Slow' (see
  recursive acronym). See also vi. 

But, on the other hand it says about Vi [2]: 

  ...  Tends to frustrate new users no end, as it will neither take
  commands while expecting input text nor vice versa, and the default 
  setup on older versions provides no indication of which mode the
  editor is in (years ago, a correspondent reported that he has often 
  heard the editor's name pronounced /vi:l/; there is now a vi clone 
  named `vile'). Nevertheless vi (and variants such as vim and elvis)
  is still widely used (about half the respondents in a 1991 Usenet
  poll preferred it), and even EMACS fans often resort to it as a mail
  editor and for small editing jobs (mainly because it starts up
  faster than the bulkier versions of EMACS). See holy wars.

Of course, that's just a really good example of a `Holy War' [3]: 

  ... The characteristic that distinguishes holy wars from normal
  technical disputes is that in a holy war most of the participants 
  spend their time trying to pass off personal value choices and 
  cultural attachments as objective technical evaluations. This
  happens precisely because in a true holy war, the actual substantive 
  differences between the sides are relatively minor.  

The Jargon File [4], is a great resource for many hours of
entertainment.  Look-up you're favorite computing term, follow links,
and you'll get no work done that day :-)

Oh, and a book any Mac user should read is `In the Beginning was the
Command Line' [5].  It's actually well writen :-)

> For this reason I use NEdit as my editor of choice.

Have you tried Emacs?  I've often seen people using NEdit, after
trying Emacs for a few weeks completly switch to Emacs, and saying
NEdit was a mistake :-) 

Anyway, there's also a program called `ctags' which NEdit supports
too.  Try that.  

Yours, 

Christian Holm Christensen -------------------------------------------
Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
         DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
         Denmark                             Office: (+45) 353  25 305 
Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm

[1] http://www.tuxedo.org/~esr/jargon/html/entry/EMACS.html
[2] http://www.tuxedo.org/~esr/jargon/html/entry/vi.html
[3] http://www.tuxedo.org/~esr/jargon/html/entry/holy-wars.html
[4] http://www.tuxedo.org/~esr/jargon/
[5] http://www.cryptonomicon.com/beginning.html

> Best regards
> Christian
> 
> 
> Christian Holm Christensen wrote:
> 
> > Hi Name-brother, et al,
> >
> > On Fri, 08 Mar 2002 20:08:15 +0100
> > "cstrato@EUnet.at" <cstrato@EUnet.at> wrote
> > concerning "Re: [ROOT] TSQLServer::Query enhancement request: FORM ??":
> > > Dear Rooters
> > >
> > > The mail below is a good starting point for my questions:
> > >
> > > When trying to understand root code from the source, it is often hard
> > > for me to find the code of different functions:
> > >
> > > As example:
> > > 1, SafeDelete:  In the ClassIndex it is not crossreferenced, so it took
> > > me some time to find that it was a macro.
> > > (Until recently, I did not know that lxr exists. Furthermore, I am
> > > offline most of the time at home and thus do not have immediate
> > > access to online-information, so I have to rely on the sourcecode)
> > >
> > > 2, Form: I still do not know what Form does and where to find it.
> > > In this case, even the following site is not very helpful:
> > > http://root.cern.ch/lxr/source/base/inc/TString.h#412
> > > Is this a Root function or a general C function? I cannot find it in
> > > any of my C books?
> >
> > It's a function defined by ROOT.  It's a bit tricky to use, since it
> > uses an internal buffer to construct the return string.  Hence, the
> > pointer you get back is a pointer pointing to statically allocated
> > memory, and if you need to keep it, you must copy it somewhere
> > _immediatly_, since another `Form' (or `Format') may come along and
> > overwrite the memory.  So, usually it's a good idea to use it like
> >
> >   TString s(Form("pi is %f, and e is %g", TMath::Pi(), TMath::E()));
> >
> > BTW, ROOT team, is `Form' thread-safe?  It doesn't look it.  A mutex
> > (marco?) would probably be a good idea.
> >
> > > Maybe root could  contain in the sourcecode somewhere a file,
> > > which lists all non-method and other functions and where to find
> > > their definitions?
> >
> > I know it's a pain in the ..., but sometimes the easiest way to find
> > such stuff, is to `grep' for it:
> >
> >   prompt% grep 'Form' root/*/src/*.cxx | less
> >   prompt% grep 'SafeDelete' root/*/src/*.cxx | less
> >
> > The later will probably bare no fruit, as SafeDelete is a macro,
> > defined in a header, so you'll have to try
> >
> >   prompt% grep 'SafeDelete' root/*/inc/*.h | less
> >
> > You can also try to `grep' the `LinkDef*.h' files for defintions,
> > though that will not help you with macros.
> >
> >   prompt% grep Form root/*/inc/LinkDef*.h
> >   root/base/inc/LinkDef1.h:#pragma link C++ function Form;
> >
> > This gives you at least an idea which directory to look in.  Finally,
> > there exists numerous tools to index source trees.  There's an Emacs
> > library called `oo-browser' which can do quite a lot of stuff.  You
> > can ofcourse also make an Emacs tag file, like
> >
> >   prompt% find root -name "*.h" -or -name "*.cxx" \
> >            -or -name "*.C"  -or -name "*.c" | xargs etags
> >
> > and use that from inside Emacs to look for functions, ladida, doing
> >
> >   M-x tags-search RET <search term> RET
> >
> > The package doc++ also does a fairly good job at indexing source
> > tree's.  Unfortunately, the way doc++ and ROOT markes up the code for
> > documetation is not compatible, so you need to `docify' the source
> > tree first.   `doc++' uses a Java like syntax:
> >
> >   /** This is a long documentation of the class HelloWorld, that is a
> >       simple class to write out the string `hello world' */
> >   class HelloWorld {
> >   private:
> >     /// Short documentatation of a a member: The message of the class
> >     const char* fMessage;
> >   public:
> >     /// HelloWorld constructor.  You can change the message if you like
> >     HelloWorld(const char* msg="hello world") : fMessage(msg) {}
> >
> >     /// Do the stuff
> >     void DoIt() { cout << fMessage << endl; }
> >
> >     /** Main method.  If this looks a bit Java like to you, then it's
> >         because it is :-).  In doc++ we can use a subset of \LaTeX
> >         commands, {\Large great} \emph{fun} */
> >     static int Main(int argc, char** argv) {
> >       HelloWorld* h = 0;
> >       if (argc > 1)
> >         h = new HelloWorld(argv[1]);
> >       else
> >         h = new HelloWorld();
> >       h->DoIt();
> >       return 0;
> >     }
> >   };
> >
> >   /// We can also document functions if we like
> >   int main(int argc, char** argv) {
> >     return HelloWorld::Main(argc, argv);
> >   }
> >
> > Just a few ideas.
> >
> > Yours,
> >
> > Christian Holm Christensen -------------------------------------------
> > Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91
> >          DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
> >          Denmark                             Office: (+45) 353  25 305
> > Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:45 MET