From: Vincent Pit Date: Sun, 11 Jan 2009 11:27:15 +0000 (+0100) Subject: Sort up Upper.xs X-Git-Tag: v0.04~13 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=3f32b18f8a4dff0a90962760dd43e0e89e980f7a;p=perl%2Fmodules%2FScope-Upper.git Sort up Upper.xs --- diff --git a/Upper.xs b/Upper.xs index b7088ae..8e7356d 100644 --- a/Upper.xs +++ b/Upper.xs @@ -515,30 +515,7 @@ done: return depth; } -#define SU_GET_LEVEL(A) \ - if (items > A) { \ - SV *lsv = ST(A); \ - if (SvOK(lsv)) \ - level = SvUV(lsv); \ - if (level < 0) \ - XSRETURN(0); \ - } \ - if (level > cxstack_ix) \ - level = cxstack_ix; - -#define SU_DOPOPTOCX(t) \ - STMT_START { \ - I32 i, cxix = cxstack_ix, from = 0; \ - if (items) \ - from = SvIV(ST(0)); \ - for (i = cxix - from; i >= 0; --i) { \ - if (CxTYPE(&cxstack[i]) == t) { \ - ST(0) = sv_2mortal(newSViv(cxix - i)); \ - XSRETURN(1); \ - } \ - } \ - XSRETURN_UNDEF; \ - } STMT_END +/* --- Unwind stack -------------------------------------------------------- */ typedef struct { I32 cxix; @@ -580,6 +557,31 @@ STATIC void su_unwind(pTHX_ void *ud_) { /* --- XS ------------------------------------------------------------------ */ +#define SU_GET_LEVEL(A) \ + if (items > A) { \ + SV *lsv = ST(A); \ + if (SvOK(lsv)) \ + level = SvUV(lsv); \ + if (level < 0) \ + XSRETURN(0); \ + } \ + if (level > cxstack_ix) \ + level = cxstack_ix; + +#define SU_DOPOPTOCX(t) \ + STMT_START { \ + I32 i, cxix = cxstack_ix, from = 0; \ + if (items) \ + from = SvIV(ST(0)); \ + for (i = cxix - from; i >= 0; --i) { \ + if (CxTYPE(&cxstack[i]) == t) { \ + ST(0) = sv_2mortal(newSViv(cxix - i)); \ + XSRETURN(1); \ + } \ + } \ + XSRETURN_UNDEF; \ + } STMT_END + XS(XS_Scope__Upper_unwind); /* prototype to pass -Wmissing-prototypes */ XS(XS_Scope__Upper_unwind) {