Florian Ragwitz <[EMAIL PROTECTED]> writes: >On Tue, Aug 08, 2006 at 02:10:04PM +0200, Vaclav Barta wrote: >> Florian Ragwitz wrote: >> >I wrote bindings for a small C library using XS. In those bindings I map >> >some c structures to a perl objects, which are blesed into >> >"Audio::XMMSClient". >> ... >> >DESTROY seems to be the way to do that. So I defined a DESTROY method in >> >my XS code: >> ... >> >Unfortunately DESTROY won't be called when the perl objects reference >> >count reaches zero as it seems to be the case in pure-perl world. What's >> >the difference between pure-perl code and XS code with regard to >> >DESTROY? How can I get my XS DESTROY method called properly? >> >> In that case, I'd just define DESTROY in perl and have it call the XS >> destructor - there might be less manual ways, but I'll leave that to the >> experts... :-) > >So you suggest something like this: > > package XSModule; > > use XSLoader; > XSLoader::load(__PACKAGE__, $VERSION); > > sub DESTROY { print "Destroying @_\n" } > > 1; > > >The destructor doesn't get called this way as well.
A further pointer that it is the XS new that is wonky. > > >-Flo