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
. TheCV
for the XSUB is passed in thecv
argument: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 theALIAS
orINTERFACE
keywords, 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.