X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs-src%2Fmouse_util.xs;h=94239c86eba82042e6e1c986e75301cf950dc64c;hb=3e44140bf0332cf0e44055fd76c2ba43cd898161;hp=9df1f65c4f8370613254974f808c8c15ec7eb2ae;hpb=cccb83dea141cc50ab03aedefda36c5822a7b98f;p=gitmo%2FMouse.git diff --git a/xs-src/mouse_util.xs b/xs-src/mouse_util.xs index 9df1f65..94239c8 100644 --- a/xs-src/mouse_util.xs +++ b/xs-src/mouse_util.xs @@ -2,7 +2,7 @@ #define ISA_CACHE "::LINEALIZED_ISA_CACHE::" -#ifndef no_mro_get_linear_isa +#ifdef no_mro_get_linear_isa AV* mouse_mro_get_linear_isa(pTHX_ HV* const stash){ GV* const cachegv = *(GV**)hv_fetchs(stash, ISA_CACHE, TRUE); @@ -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