From: Doug MacEachern Date: Sat, 6 Jan 2001 09:30:05 +0000 (-0800) Subject: [patch] xsub AUTOLOAD fix/optimization X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=adb5a9ae91a0bed93d396bb0abda99831f9e2e6f;p=p5sagit%2Fp5-mst-13.2.git [patch] xsub AUTOLOAD fix/optimization Message-ID: Allow AUTOLOAD to be an xsub and allow such xsubs to avoid use of $AUTOLOAD. p4raw-id: //depot/perl@8362 --- diff --git a/gv.c b/gv.c index 04a365f..f2931ae 100644 --- a/gv.c +++ b/gv.c @@ -412,7 +412,7 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) return Nullgv; cv = GvCV(gv); - if (!CvROOT(cv)) + if (!(CvROOT(cv) || CvXSUB(cv))) return Nullgv; /* @@ -424,6 +424,20 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) "Use of inherited AUTOLOAD for non-method %s::%.*s() is deprecated", HvNAME(stash), (int)len, name); +#ifndef USE_THREADS + if (CvXSUB(cv)) { + /* rather than lookup/init $AUTOLOAD here + * only to have the XSUB do another lookup for $AUTOLOAD + * and split that value on the last '::', + * pass along the same data via some unused fields in the CV + */ + CvSTASH(cv) = stash; + SvPVX(cv) = (char *)name; /* cast to loose constness warning */ + SvCUR(cv) = len; + return gv; + } +#endif + /* * Given &FOO::AUTOLOAD, set $FOO::AUTOLOAD to desired function name. * The subroutine's original name may not be "AUTOLOAD", so we don't