X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs-src%2FMouseUtil.xs;h=8d0c51a702d05394b7f9f58f970bd272715d062b;hb=dcce2592fe68fba003835495db169f6f9ee2646a;hp=e56274888ec9e2d365df1d5cff74444e5a479f62;hpb=9a87d68a97aa8d1dd0d14c1e63c0edcd03f0a13a;p=gitmo%2FMouse.git diff --git a/xs-src/MouseUtil.xs b/xs-src/MouseUtil.xs index e562748..8d0c51a 100644 --- a/xs-src/MouseUtil.xs +++ b/xs-src/MouseUtil.xs @@ -112,35 +112,39 @@ mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const cha mPUSHs(newSVpvs("depth")); mPUSHi(-1); } - PUTBACK; - - call_method("throw_error", G_VOID); + if(SvOK(metaobject)) { + call_method("throw_error", G_VOID); + } + else { + call_pv("Mouse::Util::throw_error", G_VOID); + } croak("throw_error() did not throw the error (%"SVf")", message); } } -/* workaround RT #69939 */ +/* workaround Perl-RT #69939 */ I32 mouse_call_sv_safe(pTHX_ SV* const sv, I32 const flags) { - const PERL_CONTEXT* const cx = &cxstack[cxstack_ix]; - assert( (flags & G_EVAL) == 0 ); - //warn("%d 0x%x 0x%x", (int)cx->cx_type, (int)cx->cx_type, (int)PL_in_eval); - if(!(cx->cx_type & (CXt_EVAL|CXp_TRYBLOCK))) { - 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); + I32 count; + ENTER; + /* Don't do SAVETMPS */ + + SAVESPTR(ERRSV); + ERRSV = sv_newmortal(); + + count = Perl_call_sv(aTHX_ sv, flags | G_EVAL); + + if(sv_true(ERRSV)){ + SV* const err = sv_mortalcopy(ERRSV); + LEAVE; + sv_setsv(ERRSV, err); + croak(NULL); /* rethrow */ } + + LEAVE; + + return count; } void @@ -347,7 +351,7 @@ mouse_install_sub(pTHX_ GV* const gv, SV* const code_ref) { } } - CvGV(cv) = gv; + CvGV_set(cv, gv); CvANON_off(cv); } }