From: Dave Rolsky Date: Sun, 8 Feb 2009 16:41:11 +0000 (+0000) Subject: Make the XS version of is_class_loaded smarter about handling corner X-Git-Tag: 0.77~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7e6420bf68286bbff4b84891e318baae1e34537;p=gitmo%2FClass-MOP.git Make the XS version of is_class_loaded smarter about handling corner cases where a VERSION entry in the stash exists but we haven't _really_ loaded the class yet. --- diff --git a/MOP.xs b/MOP.xs index 38994c5..07b2fb8 100644 --- a/MOP.xs +++ b/MOP.xs @@ -364,8 +364,18 @@ is_class_loaded(klass=&PL_sv_undef) if (hv_exists_ent (stash, key_VERSION, hash_VERSION)) { HE *version = hv_fetch_ent(stash, key_VERSION, 0, hash_VERSION); - if (version && HeVAL(version) && GvSV(HeVAL(version))) { - XSRETURN_YES; + SV *version_sv; + if (version && HeVAL(version) && (version_sv = GvSV(HeVAL(version)))) { + if (SvROK(version_sv)) { + SV *version_sv_ref = SvRV(version_sv); + + if (SvOK(version_sv_ref)) { + XSRETURN_YES; + } + } + else if (SvOK(version_sv)) { + XSRETURN_YES; + } } }