Opened 17 years ago

Closed 16 years ago

#230 closed defect (fixed)

C++-exceptions are not wrapped for Perl

Reported by: Andreas Marienborg Owned by: Olly Betts
Priority: normal Milestone: 1.1.0
Component: Search::Xapian Version: SVN trunk
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: All

Description (last modified by Olly Betts)

This results in exceptions being uncatchable, or catchable as string-exceptions.

Attachments (2)

search-xapian-generate-errors.03.patch (12.9 KB ) - added by Andreas Marienborg 17 years ago.
First stab at a patch to begin solving this
search-xapian-generate-errors.04.patch (29.2 KB ) - added by Andreas Marienborg 17 years ago.
Second stab

Download all attachments as: .zip

Change History (10)

comment:1 by Olly Betts, 17 years ago

Owner: changed from New Bugs to Olly Betts

comment:2 by Olly Betts, 17 years ago

Status: newassigned
Summary: C++-exceptions are not wrappedC++-exceptions are not wrapped for Perl

I suspect you're likely to get better generated code if you wrap the whole of the possible exception-causing part of each XS wrapper in a try/catch rather than each case of a switch statement individually. Certainly worth checking before wrapping every method by hand!

Also, (@baseclasses, @classes) should already be in dependency order (this may not be documented but other users require it so it can definitely be relied on), so sticking it into a hash and then carefully building a dependency order isn't necessary.

comment:3 by Andreas Marienborg, 17 years ago

yes, the Enquire.xs is just a test basicly, and I agree that having the try/catch further out might be better.

I could have sworn the sorting was there for a reason, but I can't remember it now :) I'll try it without it, and see what breaks

by Andreas Marienborg, 17 years ago

Second stab

comment:4 by Andreas Marienborg, 17 years ago

attachments.isobsolete: 01
Operating System: All

comment:5 by Olly Betts, 17 years ago

Note that none of the Weight object constructors will actually throw exceptions...

BTW, in the longer term, I'm hoping to move the Perl bindings to use SWIG so that they don't need manually updating for every API change. However, SWIG currently lacks support for "directors" in Perl (directors allow subclassing C++ classes in the wrapping language). So someone (possibly me) needs to sort that out first (there is an old patch for it, which never got merged for some reason).

I'm not trying to discourage work on this (it's certainly useful) but I thought you should be aware of this plan. I'd probably suggest wrapping the methods which matter most to you to start with.

comment:6 by Andreas Marienborg, 17 years ago

any easy way to know what methods can throw exceptions and which can not?

I don't mind it being replaced down the road, it's not like its a lot of work :)

As long as I won't have to keep maintaining my own local copy of this, I'm happy

comment:7 by Andreas Marienborg, 17 years ago

I think I have wrapped the most essential ones for me in Database and Enquire, so if everything looks a-ok, feel free to apply, and I can just make smaller patches with more wrappings later, if thats ok

comment:9 by Olly Betts, 17 years ago

Description: modified (diff)
Milestone: 1.1.0

We should try to get this in for 1.1.0.

comment:10 by Olly Betts, 16 years ago

Resolution: fixed
Status: assignedclosed

Applied (with some reworking) to trunk as r11714.

Note: See TracTickets for help on using tickets.