[libxml++] Re: [xml] -fexceptions



On Thu, Jul 31, 2003 at 07:35:37AM +0200, Murray Cumming Comneon com
wrote:
> > > > From: Graham Bennett [mailto:graham-libxml simulcra org] It
> > > > would be very useful to
> > > > > > be able to throw from SAX callbacks when using libxml 
> > from C++.
> > > 
> > > libxml++ has a solution for this without rebuilding libxml:
> > > http://libxmlplusplus.sourceforge.net.
> > 
> > I have looked at this and there are a few problems with libxml++
> > from my point of view (these might not hold any longer).
> 
> I am CCing this to the libxml++ list for you:

Thanks, apologies for taking so long to reply.
 
> >  - exception handling solution requires callbacks to throw only
> >  exceptions that derive from the libxml++ exception type.  If
> >  anything else is thrown then problems will occur if -fexceptions
> >  isn't turned on.  I think at least libxml++ should catch (...) and
> >  throw a generic exception, for safety's sake.  In my environment
> >  it's not practical to catch all possible exceptions and rethrow
> >  without losing information about the original exception.
> > 
> >  - the sax callback interface doesn't expose quite as much
> >  information as I can get from using libxml directly.
> 
> What do you need exactly?

I would like to be able to hook on to entity declarations, that's about
it I think.  My main reason for not using it is that my project already
involves implementing a level of abstraction between the parser and my
own library.  It doesn't really make sense for me to use another wrapper
around libxml unless there is some big advantage in it.

> >  - in the libxml++ design, I am paying for virtual function calls
> >  for every callback, which I would rather avoid.
> 
> It's just one more function call. I wouldn't worry about it unless you
> can prove that it's significant.

As I mention above, I don't want to incur this penalty unless I get
something back for it.

> >  - libxml++ doesn't treat extern "C" properly.  the functions it
> >  registers in the libxml sax handler struct should be declared
> >  extern "C" but aren't.  This seems to be fine with g++, but other
> >  compilers (correctly) report that the type of the function pointer
> >  in the struct is different to the type of the function pointer
> >  being passed.
> 
> A patch would be welcome.

I'm not really in a position to do a patch atm, but basically it just
involves declaring all the callback functions within extern "C".  The
problem is that this imposes some restrictions on what kind of function
you can use, because of name mangling (it basically has to be a free
function).

> >  - finally I couldn't get libxml++ to compile with the sun c++
> >  compiler, although I didn't try too hard.
> 
> Details would help us. I'd really like libxml++ to work with Forte.

Ok I ran the compile quickly from the latest sources, it seems to mostly
work until the linking stage.  There are warnings about extern "C" as
already mentioned, and an extra semicolon at nodes/node.h line 45.

The actual errors seem to come at the linking stage involve passing the
wrong args to grep.

Hope that's vaguely useful,

Graham.

-- 
Graham Bennett




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]