On Mon, 07 May 2012 15:09:34 -0400, Mehrdad <[email protected]> wrote:

Oh, and ditto with the destructor: I need to be able to call the destructor manually, because the C does that inside a callback on my behalf.

You definitely can do this. I think it's just __dtor. But I'm not sure if that calls the whole chain. rt_finalize, the function that actually calls the dtors calls each dtor in the chain individually. You can see how it works here:

https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d#L1161

However, if C is calling your dtor, I'd highly recommend *not* using GC memory for your class data, you can std.conv.emplace it in C-malloced memory. If it has any references to GC data, use GC.addRoot to make sure that data isn't accidentally collected, and use GC.removeRoot before destruction.

-Steve

Reply via email to