From: Perl 5 Porters Date: Sun, 17 Mar 1996 09:52:33 +0000 (+0000) Subject: Incorporate single-statement macros X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=80b92232e4d4ad8078e12cd15b5399299c7f9f9b;p=p5sagit%2Fp5-mst-13.2.git Incorporate single-statement macros --- diff --git a/XSUB.h b/XSUB.h index f8d3107..af452ea 100644 --- a/XSUB.h +++ b/XSUB.h @@ -26,19 +26,19 @@ #define XST_mYES(i) (ST(i) = &sv_yes ) #define XST_mUNDEF(i) (ST(i) = &sv_undef) -#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) +#define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END +#define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END +#define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END +#define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END +#define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END +#define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END +#define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END #define newXSproto(a,b,c,d) sv_setpv((SV*)newXS(a,b,c), d) #ifdef XS_VERSION # define XS_VERSION_BOOTCHECK \ - do { \ + STMT_START { \ char vn[255], *module = SvPV(ST(0),na); \ if (items >= 2) /* version supplied as bootstrap arg */ \ Sv=ST(1); \ @@ -49,7 +49,7 @@ if (Sv && (!SvOK(Sv) || strNE(XS_VERSION, SvPV(Sv,na))) ) \ croak("%s object version %s does not match %s.pm $VERSION %s", \ module,XS_VERSION, module,(Sv && SvOK(Sv))?SvPV(Sv,na):"(undef)");\ - } while (0) + } STMT_END #else # define XS_VERSION_BOOTCHECK #endif diff --git a/sv.h b/sv.h index 4e5592d..c586de4 100644 --- a/sv.h +++ b/sv.h @@ -424,23 +424,23 @@ struct xpvio { #define SvSTASH(sv) ((XPVMG*) SvANY(sv))->xmg_stash #define SvIV_set(sv, val) \ - do { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ - (((XPVIV*) SvANY(sv))->xiv_iv = val); } while (0) + STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ + (((XPVIV*) SvANY(sv))->xiv_iv = val); } STMT_END #define SvNV_set(sv, val) \ - do { assert(SvTYPE(sv) == SVt_NV || SvTYPE(sv) >= SVt_PVNV); \ - (((XPVNV*) SvANY(sv))->xnv_nv = val); } while (0) + STMT_START { assert(SvTYPE(sv) == SVt_NV || SvTYPE(sv) >= SVt_PVNV); \ + (((XPVNV*) SvANY(sv))->xnv_nv = val); } STMT_END #define SvPV_set(sv, val) \ - do { assert(SvTYPE(sv) >= SVt_PV); \ - (((XPV*) SvANY(sv))->xpv_pv = val); } while (0) + STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ + (((XPV*) SvANY(sv))->xpv_pv = val); } STMT_END #define SvCUR_set(sv, val) \ - do { assert(SvTYPE(sv) >= SVt_PV); \ - (((XPV*) SvANY(sv))->xpv_cur = val); } while (0) + STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ + (((XPV*) SvANY(sv))->xpv_cur = val); } STMT_END #define SvLEN_set(sv, val) \ - do { assert(SvTYPE(sv) >= SVt_PV); \ - (((XPV*) SvANY(sv))->xpv_len = val); } while (0) + STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ + (((XPV*) SvANY(sv))->xpv_len = val); } STMT_END #define SvEND_set(sv, val) \ - do { assert(SvTYPE(sv) >= SVt_PV); \ - (((XPV*) SvANY(sv))->xpv_cur = val - SvPVX(sv)); } while (0) + STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ + (((XPV*) SvANY(sv))->xpv_cur = val - SvPVX(sv)); } STMT_END #define BmRARE(sv) ((XPVBM*) SvANY(sv))->xbm_rare #define BmUSEFUL(sv) ((XPVBM*) SvANY(sv))->xbm_useful