X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs-src%2FMouseTypeConstraints.xs;h=e19cd99adc8cab360c5ea667281537306df190d5;hb=8ab2c6ab8d7a229539e3464298c59a8823a18cec;hp=fb8a5213fcb9823d00c8a5bfdf326b0e795a6d65;hpb=a901dc2e35564c80a917b1a7dbe3ca9d968770c4;p=gitmo%2FMouse.git diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs index fb8a521..e19cd99 100644 --- a/xs-src/MouseTypeConstraints.xs +++ b/xs-src/MouseTypeConstraints.xs @@ -123,9 +123,10 @@ mouse_tc_Int(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { if(SvIOKp(sv)){ return TRUE; } - else if(SvNOKp(sv)){ + else if(SvNOKp(sv)) { NV const nv = SvNVX(sv); - return nv > 0 ? (nv == (NV)(UV)nv) : (nv == (NV)(IV)nv); + NV mod = Perl_fmod( nv, 1 ); + return mod == 0; } else if(SvPOKp(sv)){ int const num_type = grok_number(SvPVX(sv), SvCUR(sv), NULL); @@ -387,37 +388,28 @@ mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance){ if(IsObject(instance)){ dMY_CXT; HV* const instance_stash = SvSTASH(SvRV(instance)); - GV* const instance_isa = find_method_pvs(instance_stash, "isa"); + GV* const myisa = find_method_pvs(instance_stash, "isa"); /* the instance has no own isa method */ - if(instance_isa == NULL || GvCV(instance_isa) == GvCV(MY_CXT.universal_isa)){ + if(myisa == NULL || GvCV(myisa) == GvCV(MY_CXT.universal_isa)){ return stash == instance_stash || mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); } /* the instance has its own isa method */ else { - int retval; - dSP; + SV* package; + int ok; ENTER; SAVETMPS; - PUSHMARK(SP); - EXTEND(SP, 2); - PUSHs(instance); - mPUSHp(HvNAME_get(stash), HvNAMELEN_get(stash)); - PUTBACK; - - call_sv((SV*)instance_isa, G_SCALAR); - - SPAGAIN; - retval = sv_true(POPs); - PUTBACK; + package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); + ok = sv_true(mcall1s(instance, "isa", sv_2mortal(package))); FREETMPS; LEAVE; - return retval; + return ok; } } return FALSE; @@ -448,22 +440,11 @@ mouse_can_methods(pTHX_ AV* const methods, SV* const instance){ } else{ bool ok; - dSP; ENTER; SAVETMPS; - PUSHMARK(SP); - EXTEND(SP, 2); - PUSHs(instance); - PUSHs(sv_mortalcopy(name)); - PUTBACK; - - call_method("can", G_SCALAR); - - SPAGAIN; - ok = sv_true(POPs); - PUTBACK; + ok = sv_true(mcall1s(instance, "can", sv_mortalcopy(name))); FREETMPS; LEAVE;