From: gfx Date: Sat, 31 Oct 2009 05:56:47 +0000 (+0900) Subject: Remove an old utility, mouse_is_instance_of() X-Git-Tag: 0.40_04~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=016e46812a519214fa28c597955ceb0b0bccc43a;p=gitmo%2FMouse.git Remove an old utility, mouse_is_instance_of() --- diff --git a/mouse.h b/mouse.h index a86c32f..66c4735 100644 --- a/mouse.h +++ b/mouse.h @@ -57,8 +57,7 @@ mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const cha #define is_class_loaded(sv) mouse_is_class_loaded(aTHX_ sv) bool mouse_is_class_loaded(pTHX_ SV*); -#define is_instance_of(sv, klass) mouse_is_instance_of(aTHX_ sv, klass) -bool mouse_is_instance_of(pTHX_ SV* const sv, SV* const klass); +#define is_an_instance_of(klass, sv) mouse_is_an_instance_of(aTHX_ gv_stashpvs(klass, GV_ADD), (sv)) #define IsObject(sv) (SvROK(sv) && SvOBJECT(SvRV(sv))) @@ -178,6 +177,8 @@ int mouse_tc_Object (pTHX_ SV* const sv); CV* mouse_generate_isa_predicate_for(pTHX_ SV* const klass, const char* const predicate_name); +int mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance); + XS(XS_Mouse_parameterized_check); #endif /* !MOUSE_H */ diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs index 31d7c46..08e49af 100644 --- a/xs-src/MouseTypeConstraints.xs +++ b/xs-src/MouseTypeConstraints.xs @@ -184,7 +184,7 @@ mouse_tc_RoleName(pTHX_ SV* const sv) { meta = POPs; PUTBACK; - ok = is_instance_of(meta, newSVpvs_flags("Mouse::Meta::Role", SVs_TEMP)); + ok = is_an_instance_of("Mouse::Meta::Role", meta); FREETMPS; LEAVE; @@ -252,7 +252,7 @@ mouse_tc_FileHandle(pTHX_ SV* const sv) { } } - return is_instance_of(sv, newSVpvs_flags("IO::Handle", SVs_TEMP)); + return is_an_instance_of("IO::Handle", sv); } int @@ -312,7 +312,7 @@ mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance){ assert(stash); assert(SvTYPE(stash) == SVt_PVHV); - if(SvROK(instance) && SvOBJECT(SvRV(instance))){ + if(IsObject(instance)){ dMY_CXT; HV* const instance_stash = SvSTASH(SvRV(instance)); GV* const instance_isa = gv_fetchmeth_autoload(instance_stash, "isa", sizeof("isa")-1, 0); diff --git a/xs-src/MouseUtil.xs b/xs-src/MouseUtil.xs index dab2907..4aa3c1c 100644 --- a/xs-src/MouseUtil.xs +++ b/xs-src/MouseUtil.xs @@ -112,31 +112,6 @@ mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const cha } } - -/* equivalent to "blessed($x) && $x->isa($klass)" */ -bool -mouse_is_instance_of(pTHX_ SV* const sv, SV* const klass){ - assert(sv); - assert(klass); - - if(IsObject(sv) && SvOK(klass)){ - bool ok; - - ENTER; - SAVETMPS; - - ok = SvTRUEx(mcall1s(sv, "isa", klass)); - - FREETMPS; - LEAVE; - - return ok; - } - - return FALSE; -} - - bool mouse_is_class_loaded(pTHX_ SV * const klass){ HV *stash;