diff options
Diffstat (limited to 'XSUB.h')
-rw-r--r-- | XSUB.h | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -1,4 +1,4 @@ -#define ST(off) stack_base[ax + off] +#define ST(off) stack_base[ax + (off)] #ifdef CAN_PROTOTYPE #define XS(name) void name(CV* cv) @@ -19,16 +19,17 @@ /* 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 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) -#define XSRETURN_IV(v) XST_mIV(0,v); XSRETURN(1) -#define XSRETURN_NV(v) XST_mNV(0,v); XSRETURN(1) -#define XSRETURN_PV(v) XST_mPV(0,v); XSRETURN(1) -#define XSRETURN_NO XST_mNO(0); XSRETURN(1) -#define XSRETURN_YES XST_mYES(0); XSRETURN(1) -#define XSRETURN_UNDEF XST_mUNDEF(0); XSRETURN(1) +#define XSRETURN_IV(v) do { XST_mIV(0,v); XSRETURN(1); } while (0) +#define XSRETURN_NV(v) do { XST_mNV(0,v); XSRETURN(1); } while (0) +#define XSRETURN_PV(v) do { XST_mPV(0,v); XSRETURN(1); } while (0) +#define XSRETURN_NO do { XST_mNO(0); XSRETURN(1); } while (0) +#define XSRETURN_YES do { XST_mYES(0); XSRETURN(1); } while (0) +#define XSRETURN_UNDEF do { XST_mUNDEF(0); XSRETURN(1); } while (0) +#define XSRETURN_EMPTY do { XSRETURN(0); } while (0) |