X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=xs-src%2FMouseTypeConstraints.xs;h=605c9237378da215bfdb6d953ea66a794b864306;hp=41a1d795a7167897eac91491ff11b76e07feb3a0;hb=fc83f4cf2ef7708120a216bddc285b93082d7958;hpb=1b3644156b3851b66b0ede7cbbd127ce441ccc9a diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs index 41a1d79..605c923 100644 --- a/xs-src/MouseTypeConstraints.xs +++ b/xs-src/MouseTypeConstraints.xs @@ -16,11 +16,15 @@ typedef int (*check_fptr_t)(pTHX_ SV* const data, SV* const sv); +/* + NOTE: mouse_tc_check() handles GETMAGIC +*/ int mouse_tc_check(pTHX_ SV* const tc_code, SV* const sv) { CV* const cv = (CV*)SvRV(tc_code); assert(SvTYPE(cv) == SVt_PVCV); + SvGETMAGIC(sv); if(CvXSUB(cv) == XS_Mouse_constraint_check){ /* built-in type constraints */ MAGIC* const mg = (MAGIC*)CvXSUBANY(cv).any_ptr; @@ -44,7 +48,7 @@ mouse_tc_check(pTHX_ SV* const tc_code, SV* const sv) { call_sv(tc_code, G_SCALAR); SPAGAIN; - ok = SvTRUEx(POPs); + ok = sv_true(POPs); PUTBACK; FREETMPS; @@ -69,7 +73,7 @@ int mouse_tc_Bool(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { assert(sv); - if(SvTRUE(sv)){ + if(sv_true(sv)){ if(SvIOKp(sv)){ return SvIVX(sv) == 1; } @@ -244,7 +248,6 @@ mouse_parameterized_ArrayRef(pTHX_ SV* const param, SV* const sv) { I32 i; for(i = 0; i < len; i++){ SV* const value = *av_fetch(av, i, TRUE); - SvGETMAGIC(value); if(!mouse_tc_check(aTHX_ param, value)){ return FALSE; } @@ -263,7 +266,6 @@ mouse_parameterized_HashRef(pTHX_ SV* const param, SV* const sv) { hv_iterinit(hv); while((he = hv_iternext(hv))){ SV* const value = hv_iterval(hv, he); - SvGETMAGIC(value); if(!mouse_tc_check(aTHX_ param, value)){ hv_iterinit(hv); /* reset */ return FALSE; @@ -409,9 +411,7 @@ mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance){ call_sv((SV*)instance_isa, G_SCALAR); SPAGAIN; - - retval = SvTRUEx(POPs); - + retval = sv_true(POPs); PUTBACK; FREETMPS; @@ -462,8 +462,7 @@ mouse_can_methods(pTHX_ AV* const methods, SV* const instance){ call_method("can", G_SCALAR); SPAGAIN; - ok = SvTRUE(TOPs); - (void)POPs; + ok = sv_true(POPs); PUTBACK; FREETMPS; @@ -660,10 +659,13 @@ BOOT: INSTALL_SIMPLE_READER(TypeConstraint, parent); INSTALL_SIMPLE_READER(TypeConstraint, message); + INSTALL_SIMPLE_READER(TypeConstraint, type_parameter); + 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); + INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, __is_parameterized, type_parameter); /* Mouse specific */ void compile_type_constraint(SV* self) @@ -739,6 +741,6 @@ CODE: else{ check = newRV_inc((SV*)mouse_tc_generate(aTHX_ NULL, (check_fptr_t)mouse_types_check, (SV*)checks)); } - set_slots(self, "compiled_type_constraint", check); + (void)set_slots(self, "compiled_type_constraint", check); }