Re: [ROOT] CINT embedded in my own code?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jul 17 2000 - 17:04:18 MEST


Hi Christoph,

CINT is the C++ interpreter used by the ROOT system. You can use CINT
stand alone or use it in the Root context.

I agree with your requirements that is is very important to be able to call
interpreted code from the compiled code and vice-versa.
Calling interpreted code, in turn, may have different meanings.

 - you can call a special API (eg in Root, do gROOT->ProcessLine(".x file.C")
   the string passed to ProcessLine will be interpreted by CINT.
 - You may also want to do something like:
   gROOT->ProcessLine(".L myCode.C").
   This statement will instruct CINT to precompile some byte code that you want
   to use later (likely in a loop) in a very efficient way without having to do
   any string manipulation.
 - a variant of the second case is the use of the Root script compiler.
   gROOT->ProcessLine(".L myCode.C++") will compile the CINT macro myCode.C with
   the native C++ compiler and will link the generated object file with the
current
   executable module.
There are several examples in ROOT where we call interpreted code (in the two
ways I have mentionned above) see for examples classes TF1 and TMinuit.
I am currently working on extensions to the class TTree where there are many
more
examples of these combinations.
You can find examples of API in the CINT class G__CallFunc (CallFunc.cxx)
or in the Root meta classes TClass, TDictionary, TMethod, TMethodArg, etc.

Rene Brun

  
Christoph Bugel wrote:
> 
> By mistake I submitted my mail as a reply to another thread.
> I was basically asking if and how I can use CINT in my own code to
> interpret a c++-like script. also, is it thread safe? (I guess not)
> this was my mail:
> 
> Hi,
> I am looking at CINT to see if it can be useful for a system we are
> building. We need to execute 'scripts' from within our code, and we like
> those scripts to have C++ syntax.
> so I compiled CINT on my slackware box (I commented out "CINTSYSDIR=." in
> Makefile.Base to get it to compile, BTW), and now it runs perfectly, and I
> think it is very cool :)
> from what I have seen so far, the main use of CINT is as a standalone
> executable which runs some script -- interactively or not.
> but I need to execute the scripts from my own code, not from a standalone
> executable. so I need some api function (such as G__loadfile I guess?),
> that I can call to run an arbitrary script. (G__calc won't do as it is
> limited to expressions)
> 
> I didn't figure out exactly how the system works. I would appreciate if
> someone could help to get me started with a hello world application:
> how can I get something like this:
> int main()
> {
>         G__loadfile(argv[1]); //or whatever needed to run a given script
> }
> to compile with _my_ favorite compiler? (i.e. not with makecint)
> which includes would I need and how would my makefile look?
> 
> thanks,
> Christoph



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET