X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs-src%2FMouseUtil.xs;h=5b01e404c0d56e99c0f45b6451c0d2e1954fa2e3;hb=b3cd4c14b73eb0160d29f7d76828de0060c0b522;hp=fad81d0575059ae38d5c256ad1bf1aa9b677e04d;hpb=d06d926635763fa5687c429b5ad39938c564fbed;p=gitmo%2FMouse.git diff --git a/xs-src/MouseUtil.xs b/xs-src/MouseUtil.xs index fad81d0..5b01e40 100644 --- a/xs-src/MouseUtil.xs +++ b/xs-src/MouseUtil.xs @@ -120,6 +120,28 @@ mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const cha } } +/* workaround RT #69939 */ +I32 +mouse_call_sv_safe(pTHX_ SV* const sv, I32 const flags) { + assert( (flags & G_EVAL) == 0 ); + + if(!PL_in_eval) { + I32 count; + SAVESPTR(ERRSV); + ERRSV = sv_newmortal(); + + count = Perl_call_sv(aTHX_ sv, flags | G_EVAL); + + if(sv_true(ERRSV)){ + croak(NULL); /* rethrow */ + } + return count; + } + else { + return Perl_call_sv(aTHX_ sv, flags); + } +} + void mouse_must_defined(pTHX_ SV* const value, const char* const name) { assert(value); @@ -176,11 +198,13 @@ mouse_is_class_loaded(pTHX_ SV * const klass){ GV* const gv = (GV*)HeVAL(he); if(isGV(gv)){ - if(GvCVu(gv)){ + if(GvCVu(gv)){ /* is GV and has CV */ + hv_iterinit(stash); /* reset */ return TRUE; } } - else if(SvOK(gv)){ + else if(SvOK(gv)){ /* is a stub or constant */ + hv_iterinit(stash); /* reset */ return TRUE; } } @@ -197,7 +221,7 @@ mouse_call0 (pTHX_ SV* const self, SV* const method) { XPUSHs(self); PUTBACK; - call_sv(method, G_SCALAR | G_METHOD); + call_sv_safe(method, G_SCALAR | G_METHOD); SPAGAIN; ret = POPs; @@ -217,7 +241,7 @@ mouse_call1 (pTHX_ SV* const self, SV* const method, SV* const arg1) { PUSHs(arg1); PUTBACK; - call_sv(method, G_SCALAR | G_METHOD); + call_sv_safe(method, G_SCALAR | G_METHOD); SPAGAIN; ret = POPs; @@ -348,7 +372,9 @@ CODE: } { dMY_CXT; - if(MY_CXT.metas) croak("Cannot set metaclass storage more than once"); + if(MY_CXT.metas && ckWARN(WARN_REDEFINE)){ + Perl_warner(aTHX_ packWARN(WARN_REDEFINE), "Metaclass storage more than once"); + } MY_CXT.metas = metas; SvREFCNT_inc_simple_void_NN(metas); }