From: Rafael Garcia-Suarez Date: Fri, 14 May 2004 09:38:43 +0000 (+0000) Subject: Add new dUNDERBAR and UNDERBAR macros, to help XS writers to X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=88037a85d6a4b105a485a30b7ae673eff41a9098;p=p5sagit%2Fp5-mst-13.2.git Add new dUNDERBAR and UNDERBAR macros, to help XS writers to access the $_ variable, even when there is a lexical one in scope. p4raw-id: //depot/perl@22819 --- diff --git a/XSUB.h b/XSUB.h index b4c241a..a1e48dd 100644 --- a/XSUB.h +++ b/XSUB.h @@ -67,6 +67,14 @@ This is usually handled automatically by C. Sets up the C variable for an XSUB which has aliases. This is usually handled automatically by C. +=for apidoc Ams||dUNDERBAR +Sets up the C variable for an XSUB that wishes to use +C. + +=for apidoc AmU||UNDERBAR +The SV* corresponding to the $_ variable. Works even if there +is a lexical $_ in scope. + =cut */ @@ -106,6 +114,11 @@ handled automatically by C. #define XSINTERFACE_FUNC_SET(cv,f) \ CvXSUBANY(cv).any_dxptr = (void (*) (pTHX_ void*))(f) +#define dUNDERBAR I32 padoff_du = pad_findmy("$_") +#define UNDERBAR ((padoff_du == NOT_IN_PAD \ + || PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR) \ + ? DEFSV : PAD_SVl(padoff_du)) + /* Simple macros to put new mortal values onto the stack. */ /* Typically used to return values from XS functions. */ diff --git a/pod/perlapi.pod b/pod/perlapi.pod index b0381fe..27daa64 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5418,6 +5418,16 @@ This is usually handled automatically by C by calling C. =for hackers Found in file XSUB.h +=item dUNDERBAR + +Sets up the C variable for an XSUB that wishes to use +C. + + dUNDERBAR; + +=for hackers +Found in file XSUB.h + =item dXSARGS Sets up stack and mark pointers for an XSUB, calling dSP and dMARK. @@ -5498,6 +5508,14 @@ L. =for hackers Found in file XSUB.h +=item UNDERBAR + +The SV* corresponding to the $_ variable. Works even if there +is a lexical $_ in scope. + +=for hackers +Found in file XSUB.h + =item XS Macro to declare an XSUB and its C parameter list. This is handled by