X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs-src%2FMouseTypeConstraints.xs;h=6f69f2fdc03ae357c5e018bb0f924d2f80d93b78;hb=80aa5731d6763d8f38ba0fa057729af7026e6580;hp=225e1fe434d1607b3aef0aef7b869d3b4f642d32;hpb=19462c576ac247d86627100677cac7d78b14f49e;p=gitmo%2FMouse.git diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs index 225e1fe..6f69f2f 100644 --- a/xs-src/MouseTypeConstraints.xs +++ b/xs-src/MouseTypeConstraints.xs @@ -188,19 +188,19 @@ mouse_tc_ScalarRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { int mouse_tc_ArrayRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { assert(sv); - return SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVAV; + return IsArrayRef(sv); } int mouse_tc_HashRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { assert(sv); - return SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVHV; + return IsHashRef(sv); } int mouse_tc_CodeRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { assert(sv); - return SvROK(sv) && !SvOBJECT(SvRV(sv))&& SvTYPE(SvRV(sv)) == SVt_PVCV; + return IsCodeRef(sv); } int @@ -244,7 +244,7 @@ mouse_tc_Object(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { static int mouse_parameterized_ArrayRef(pTHX_ SV* const param, SV* const sv) { - if(mouse_tc_ArrayRef(aTHX_ NULL, sv)){ + if(IsArrayRef(sv)){ AV* const av = (AV*)SvRV(sv); I32 const len = av_len(av) + 1; I32 i; @@ -546,7 +546,7 @@ CODE: { check_fptr_t fptr; SV* const tc_code = mcall0s(param, "_compiled_type_constraint"); - if(!(SvROK(tc_code) && SvTYPE(SvRV(tc_code)) == SVt_PVCV)){ + if(!IsCodeRef(tc_code)){ croak("_compiled_type_constraint didn't return a CODE reference"); } @@ -567,6 +567,16 @@ OUTPUT: MODULE = Mouse::Util::TypeConstraints PACKAGE = Mouse::Meta::TypeConstraint +BOOT: + INSTALL_SIMPLE_READER(TypeConstraint, name); + INSTALL_SIMPLE_READER(TypeConstraint, parent); + INSTALL_SIMPLE_READER(TypeConstraint, message); + + INSTALL_SIMPLE_READER_WITH_KEY(TypeConstraint, _compiled_type_constraint, compiled_type_constraint); + INSTALL_SIMPLE_READER(TypeConstraint, _compiled_type_coercion); /* Mouse specific */ + + INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, has_coercion, _compiled_type_coercion); + void compile_type_constraint(SV* self) CODE: @@ -615,7 +625,7 @@ CODE: I32 len; I32 i; - if(!mouse_tc_ArrayRef(aTHX_ NULL, types_ref)){ + if(!IsArrayRef(types_ref)){ croak("Not an ARRAY reference"); } types = (AV*)SvRV(types_ref);