This patch removes spurious semicolons, makes returning yes/no/undef
more efficient, adds an XSRETURN_EMPTY and a comment reminding people
to use braces around the XSRETURN_* macros.
(Guess what bug I just found in my code :-)
*** ./XSUB.h.1m Wed Aug 16 18:45:11 1995
--- ./XSUB.h Fri Aug 25 13:50:42 1995
***************
*** 20,30 ****
/* Simple macros to put new mortal values onto the stack. */
/* Typically used to return values from XS functions. */
! #define XST_mIV(i,v) ST(i)=sv_2mortal(newSViv(v));
! #define XST_mNV(i,v) ST(i)=sv_2mortal(newSVnv(v));
! #define XST_mPV(i,v) ST(i)=sv_2mortal(newSVpv(v,0));
! #define XST_mNO(i) ST(i)=sv_mortalcopy(&sv_no);
! #define XST_mYES(i) ST(i)=sv_mortalcopy(&sv_yes);
! #define XST_mUNDEF(i) ST(i)=sv_newmortal();
#define XSRETURN_IV(v) XST_mIV(0,v); XSRETURN(1)
#define XSRETURN_NV(v) XST_mNV(0,v); XSRETURN(1)
--- 20,32 ----
/* Simple macros to put new mortal values onto the stack. */
/* Typically used to return values from XS functions. */
! #define XST_mIV(i,v) ST(i)=sv_2mortal(newSViv(v))
! #define XST_mNV(i,v) ST(i)=sv_2mortal(newSVnv(v))
! #define XST_mPV(i,v) ST(i)=sv_2mortal(newSVpv(v,0))
! #define XST_mNO(i) ST(i)=&sv_no
! #define XST_mYES(i) ST(i)=&sv_yes
! #define XST_mUNDEF(i) ST(i)=&sv_undef
+ /* Note that these are not single statements. Remember to use */
+ /* braces around them if needed. Don't say: if (foo) XSRETURN.. */
#define XSRETURN_IV(v) XST_mIV(0,v); XSRETURN(1)
#define XSRETURN_NV(v) XST_mNV(0,v); XSRETURN(1)
***************
*** 33,34 ****
--- 35,37 ----
#define XSRETURN_YES XST_mYES(0); XSRETURN(1)
#define XSRETURN_UNDEF XST_mUNDEF(0); XSRETURN(1)
+ #define XSRETURN_EMPTY XSRETURN(0)
Tim.
p.s. Larry, this patch supersedes the earlier XSUB.h patch I sent you
which just had the yes/no/undef changes.
more efficient, adds an XSRETURN_EMPTY and a comment reminding people
to use braces around the XSRETURN_* macros.
(Guess what bug I just found in my code :-)
*** ./XSUB.h.1m Wed Aug 16 18:45:11 1995
--- ./XSUB.h Fri Aug 25 13:50:42 1995
***************
*** 20,30 ****
/* Simple macros to put new mortal values onto the stack. */
/* Typically used to return values from XS functions. */
! #define XST_mIV(i,v) ST(i)=sv_2mortal(newSViv(v));
! #define XST_mNV(i,v) ST(i)=sv_2mortal(newSVnv(v));
! #define XST_mPV(i,v) ST(i)=sv_2mortal(newSVpv(v,0));
! #define XST_mNO(i) ST(i)=sv_mortalcopy(&sv_no);
! #define XST_mYES(i) ST(i)=sv_mortalcopy(&sv_yes);
! #define XST_mUNDEF(i) ST(i)=sv_newmortal();
#define XSRETURN_IV(v) XST_mIV(0,v); XSRETURN(1)
#define XSRETURN_NV(v) XST_mNV(0,v); XSRETURN(1)
--- 20,32 ----
/* Simple macros to put new mortal values onto the stack. */
/* Typically used to return values from XS functions. */
! #define XST_mIV(i,v) ST(i)=sv_2mortal(newSViv(v))
! #define XST_mNV(i,v) ST(i)=sv_2mortal(newSVnv(v))
! #define XST_mPV(i,v) ST(i)=sv_2mortal(newSVpv(v,0))
! #define XST_mNO(i) ST(i)=&sv_no
! #define XST_mYES(i) ST(i)=&sv_yes
! #define XST_mUNDEF(i) ST(i)=&sv_undef
+ /* Note that these are not single statements. Remember to use */
+ /* braces around them if needed. Don't say: if (foo) XSRETURN.. */
#define XSRETURN_IV(v) XST_mIV(0,v); XSRETURN(1)
#define XSRETURN_NV(v) XST_mNV(0,v); XSRETURN(1)
***************
*** 33,34 ****
--- 35,37 ----
#define XSRETURN_YES XST_mYES(0); XSRETURN(1)
#define XSRETURN_UNDEF XST_mUNDEF(0); XSRETURN(1)
+ #define XSRETURN_EMPTY XSRETURN(0)
Tim.
p.s. Larry, this patch supersedes the earlier XSUB.h patch I sent you
which just had the yes/no/undef changes.