X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=xs-src%2Fmouse_util.xs;h=f0419511b811d4ec5542692589b7a6601c9c17af;hp=9df1f65c4f8370613254974f808c8c15ec7eb2ae;hb=935400114c35ad1b2481c48ff471e180e9c93d93;hpb=ef20630593cf958f60d61c37ca16f322d9516ef5 diff --git a/xs-src/mouse_util.xs b/xs-src/mouse_util.xs index 9df1f65..f041951 100644 --- a/xs-src/mouse_util.xs +++ b/xs-src/mouse_util.xs @@ -69,6 +69,49 @@ mouse_mro_get_linear_isa(pTHX_ HV* const stash){ } #endif /* !no_mor_get_linear_isa */ +#ifdef DEBUGGING +SV** +mouse_av_at_safe(pTHX_ AV* const av, I32 const ix){ + assert(av); + assert(SvTYPE(av) == SVt_PVAV); + assert(AvMAX(av) >= ix); + return &AvARRAY(av)[ix]; +} +#endif + +void +mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const char* const fmt, ...){ + dTHX; + va_list args; + SV* message; + + PERL_UNUSED_ARG(data); /* for moose-compat */ + + assert(metaobject); + assert(fmt); + + va_start(args, fmt); + message = vnewSVpvf(fmt, &args); + va_end(args); + + { + dSP; + PUSHMARK(SP); + EXTEND(SP, 4); + + PUSHs(metaobject); + mPUSHs(message); + + mPUSHs(newSVpvs("depth")); + mPUSHi(-1); + + PUTBACK; + + call_method("throw_error", G_VOID); + croak("throw_error() did not throw the error (%"SVf")", message); + } +} + /* equivalent to "blessed($x) && $x->isa($klass)" */ bool