perl5
perl5 copied to clipboard
Define a `CvREFCOUNTED_ANYSV` flag
If this flag is set, then the CvXSUBANY(cv).any_sv pointer will have its reference count decremented when the CV itself is freed. This is useful for XS extensions that wish to store extra data in here. Without this flag, such extensions have to resort to using magic with a 'free' function to perform this work.
As discussed in https://www.nntp.perl.org/group/perl.perl5.porters/2022/08/msg264572.html
One small doc nit.
Wording fixed.
Otherwise, it'd be nice to have tests...
Yeeeah. Hrm. A test could be written but that's basically going to be a lot of lines added in probably XS-APItest. We don't have much existing framework for testing this kind of thing - even no equivalent of Test::Refcount in core until I recently added it.
There is the awkward bit where you can either use this or aliases, but not both. I'm wondering if ParseXS should do something slightly smarter with that.
Related to that, this should also update the CvXSUB method in ext/B/B.xs, Perl_do_sv_dump and Perl_dump_sub_perl in dump.c; for better debuggability of CvXSUBANY.
I've added an entry to perldelta.pod as well, before merge.
Thanks for the tests!