In perl special tokens like __PACKAGE__, __SUB__, __FILE__, __LINE__ exists and available from script.
I may get value of __PACKAGE__ from XS as HvNAME( PL_currstash ), I suppose.
But how to access others?
Is there special interface to access all of them from XS? Like: CTX->package, CTX->sub etc.
Perl subroutines are represented in C with type
CV. TheCVfor the XSUB is passed in thecvargument:You can get the name of the XSUB with
GvNAME(CvGV(cv)). This is especially useful if you register an XSUB under multiple names, for example with theALIASorINTERFACEkeywords, or in typemaps.To get the current stash (
__PACKAGE__equivalent), I'd suggest to useCvSTASH(cv).__FILE__and__LINE__are provided by the C compiler as macro.