On Friday, 12 September 2014 at 06:56:29 UTC, Jacob Carlborg
wrote:
On 12/09/14 05:25, deadalnix wrote:
Yes, that is pretty why I limited myself to the "unwind
properly but do
not catch" option. This one would require to mess with the
innards of
various C++ runtime.
On 64bit Objective-C can catch C++ exceptions. But I don't
think you can do anything with the exception, i.e. it uses the
following catch syntax:
@catch(...) {}
Would that be easier?
I think the trick is setting up the stack frame in such a way
that the C++ exception mechanism knows there's a catch block
available at all. From there, we should be able to use the
standard interface-to-class method to call virtual functions on
the exception object, and hopefully the C++ runtime will handle
cleanup for us.
I imagine the easiest thing would be to find a platform where we
already know how exceptions are thrown in C++ (DMC on Windows?)
and figure out how to make it work in D. With inner functions
and inline asm, I'm sure it's possible to make this work without
compiler changes. I don't know whether the unwinding mechanism
differs across compilers or even compiler versions for a
particular platform though. This may all end up being a bit
brittle.