Re: Checking user-entered expressions for validity

From: <WLavrijsen_at_lbl.gov>
Date: Mon, 15 Jan 2007 17:40:27 -0800 (PST)


Tom,

not sure whether the following will help, however, since you write:

> Any help would be appreciated

I'll risk it. :) For PyROOT, I use CINT's error message callbacks to take control of error messages and what happens afterwards. In my case, that is a translation into a python exception, with a somewhat different markup. That should alleviate this problem that you mention:

> > This works fine as long as the expressions are valid. Unfortunately, if
> > any expression is invalid, Cint prints an error message to stderr and
> > never returns from ProcessLineSync(). To the user this is disconcerting,
> > as no sensible error message is presented (the user probably won't watch
> > stderr, which may not be visible in a graphical environment).

You can find my callback code in root/pyroot/src/Utility.cxx, and the function name is: void "PyROOT::Utility::ErrMsgCallback( char* msg )". It is installed with a call: "G__set_errmsgcallback( (void*)&Utility::ErrMsgCallback );" which you'll find in root/pyroot/src/TPyROOTApplication.cxx. I hope that'll work as an example.

As for getting out of the context of a function that doesn't seem to return, a setjmp/longjmp (see root/include/TException.h) should do the trick.

Best regards,

           Wim

--
Wim.Lavrijsen_at_cern.ch   --   WLavrijsen_at_lbl.gov   --   www.lavrijsen.net

"Stop making excuses for your software."    --first step towards quality
   "GIGO is not a valid design pattern."         --corollary
Received on Tue Jan 16 2007 - 02:40:37 CET

This archive was generated by hypermail 2.2.0 : Tue Jan 16 2007 - 17:50:01 CET