#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)))
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 */
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;
}
}
- return is_instance_of(sv, newSVpvs_flags("IO::Handle", SVs_TEMP));
+ return is_an_instance_of("IO::Handle", sv);
}
int
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);
}
}
-
-/* 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;