From 5b36e9450efc47317616775e6c3eb0daba56035c Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Tue, 11 Oct 2011 23:02:41 -0700 Subject: Improve documentation of XS autoloading --- pod/perlguts.pod | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'pod/perlguts.pod') diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 38ed3e1926..97b97589e1 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -1498,6 +1498,26 @@ C macros instead; see L. For more information, consult L and L. +=head2 Autoloading with XSUBs + +If an AUTOLOAD routine is an XSUB, as with Perl subroutines, Perl puts the +fully-qualified name of the autoloaded subroutine in the $AUTOLOAD variable +of the XSUB's package. + +But it also puts the same information in certain fields of the XSUB itself: + + HV *stash = CvSTASH(cv); + const char *subname = SvPVX(cv); + STRLEN name_length = SvCUR(cv); /* in bytes */ + U32 is_utf8 = SvUTF8(cv); + +C contains just the sub name itself, not including the package. + +B: Setting $AUTOLOAD stopped working in 5.6.1, which did not support +XS AUTOLOAD subs at all. Perl 5.8.0 introduced the use of fields in the +XSUB itself. Perl 5.16.0 restored the setting of $AUTOLOAD. If you need +to support 5.8-5.14, use the XSUB's fields. + =head2 Calling Perl Routines from within C Programs There are four routines that can be used to call a Perl subroutine from -- cgit v1.2.1