X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs-src%2FMouseUtil.xs;h=8d0c51a702d05394b7f9f58f970bd272715d062b;hb=dcce2592fe68fba003835495db169f6f9ee2646a;hp=8587b6457403fcac4f2cda16d9f1241077b66f25;hpb=25ba356eb567d89ae015ad0789960b460c3ebf02;p=gitmo%2FMouse.git diff --git a/xs-src/MouseUtil.xs b/xs-src/MouseUtil.xs index 8587b64..8d0c51a 100644 --- a/xs-src/MouseUtil.xs +++ b/xs-src/MouseUtil.xs @@ -112,14 +112,41 @@ 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 Perl-RT #69939 */ +I32 +mouse_call_sv_safe(pTHX_ SV* const sv, I32 const 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 mouse_must_defined(pTHX_ SV* const value, const char* const name) { assert(value); @@ -199,7 +226,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; @@ -219,7 +246,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; @@ -324,7 +351,7 @@ mouse_install_sub(pTHX_ GV* const gv, SV* const code_ref) { } } - CvGV(cv) = gv; + CvGV_set(cv, gv); CvANON_off(cv); } }