On Tue, Aug 08, 2006 at 12:37:03PM +0000, Jeremy White wrote: > There should be no difference between a Perl or XS DESTROY method (in terms > of when it's called). How are you creating the object?
I wrote a function which packs the c data structure into a perl object: SV* perl_xmmsclient_new_sv_from_ptr(void* ptr, const char* class) { SV* obj; SV* sv; HV* stash; obj = (SV*)newHV(); sv_magic(obj, 0, PERL_MAGIC_ext, (const char*)ptr, 0); sv = newRV_inc(obj); stash = gv_stashpv(class, 1); sv_bless(sv, stash); return sv; } Which is invoked in the XS new method: void new(class, clientname) const char* class const char* clientname PREINIT: xmmsc_connection_t* con = NULL; PPCODE: con = xmmsc_init(clientname); if (con == NULL) { ST(0) = &PL_sv_undef; } else { ST(0) = perl_xmmsclient_new_sv_from_ptr(con, class); } sv_2mortal(ST(0)); XSRETURN(1);
signature.asc
Description: Digital signature