X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs-src%2FMouseTypeConstraints.xs;h=420703e3808aaa7c9f3f3e1f07edfd01ad9c74af;hb=8fcdb9973a1df1958b61059c8cef572780daf91d;hp=09cf92c616240c5286cd1ae37d69c7bfa81c8b0f;hpb=0cfe08a4504e91d95d50e654b470b4d0fedd4e3b;p=gitmo%2FMouse.git diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs index 09cf92c..420703e 100644 --- a/xs-src/MouseTypeConstraints.xs +++ b/xs-src/MouseTypeConstraints.xs @@ -117,7 +117,7 @@ mouse_tc_Num(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { return LooksLikeNumber(sv); } -int +static int S_nv_is_integer(pTHX_ NV const nv) { if(nv == (NV)(IV)nv){ return TRUE; @@ -725,8 +725,7 @@ CODE: SV* const tc = *av_fetch(types, i, TRUE); SV* const c = get_slots(tc, "compiled_type_constraint"); if(!(c && mouse_tc_CodeRef(aTHX_ NULL, c))){ - sv_dump(self); - croak("'%"SVf"' has no compiled type constraint", self); + mouse_throw_error(self, c, "'%"SVf"' has no compiled type constraint", self); } av_push(union_checks, newSVsv(c)); } @@ -744,3 +743,16 @@ CODE: (void)set_slots(self, "compiled_type_constraint", check); } +bool +check(SV* self, SV* sv) +CODE: +{ + SV* const check = get_slots(self, "compiled_type_constraint"); + if(!(check && mouse_tc_CodeRef(aTHX_ NULL, check))){ + mouse_throw_error(self, check, "'%"SVf"' has no compiled type constraint", self); + } + RETVAL = mouse_tc_check(aTHX_ check, sv) ? TRUE : FALSE; +} +OUTPUT: + RETVAL +