Ticket #230 (closed defect: fixed)

Opened 12 months ago

Last modified 3 weeks ago

C++-exceptions are not wrapped for Perl

Reported by: andreas Owned by: olly
Priority: normal Milestone: 1.1.0
Component: Search::Xapian Version: SVN trunk
Severity: normal Keywords:
Cc: Blocked By:
Operating System: All Blocking:

Description (last modified by olly) (diff)

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

Attachments

search-xapian-generate-errors.03.patch (12.9 kB) - added by andreas 12 months ago.
First stab at a patch to begin solving this
search-xapian-generate-errors.04.patch (29.2 kB) - added by andreas 12 months ago.
Second stab

Change History

Changed 12 months ago by olly

  • owner changed from newbugs to olly

Changed 12 months ago by olly

  • status changed from new to assigned
  • summary changed from C++-exceptions are not wrapped to C++-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.

Changed 12 months ago by andreas

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

Changed 12 months ago by andreas

Changed 12 months ago by andreas

  • attachments.isobsolete changed from 0 to 1

Changed 12 months ago by andreas

Second stab

Changed 12 months ago by trac

  • platform set to All

Changed 11 months ago by olly

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.

Changed 11 months ago by andreas

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

Changed 11 months ago by andreas

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

Changed 8 months ago by olly

  • description modified (diff)
  • milestone set to 1.1.0

We should try to get this in for 1.1.0.

Changed 3 weeks ago by olly

  • status changed from assigned to closed
  • resolution set to fixed

Applied (with some reworking) to trunk as r11714.

Note: See TracTickets for help on using tickets.