X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xs%2FMOP.xs;h=0bf05dc605d0a6cfe0249e84aba8e0640489311a;hb=e0a39158e1eb71c04a75423568bf84544caf535b;hp=398ea4eca0c66c2415340b3885edb7b00f1c0be9;hpb=20a9a879c048729baab5890223682e21181f68a6;p=gitmo%2FMoose.git diff --git a/xs/MOP.xs b/xs/MOP.xs index 398ea4e..0bf05dc 100644 --- a/xs/MOP.xs +++ b/xs/MOP.xs @@ -1,45 +1,5 @@ #include "mop.h" -static bool -find_method (const char *key, STRLEN keylen, SV *val, void *ud) -{ - bool *found_method = (bool *)ud; - PERL_UNUSED_ARG(key); - PERL_UNUSED_ARG(keylen); - PERL_UNUSED_ARG(val); - *found_method = TRUE; - return FALSE; -} - -static bool -check_version (SV *klass, SV *required_version) -{ - bool ret = 0; - - dSP; - ENTER; - SAVETMPS; - PUSHMARK(SP); - EXTEND(SP, 2); - PUSHs(klass); - PUSHs(required_version); - PUTBACK; - - call_method("VERSION", G_DISCARD|G_VOID|G_EVAL); - - SPAGAIN; - - if (!SvTRUE(ERRSV)) { - ret = 1; - } - - PUTBACK; - FREETMPS; - LEAVE; - - return ret; -} - MODULE = Class::MOP PACKAGE = Class::MOP PROTOTYPES: DISABLE @@ -59,53 +19,3 @@ get_code_info(coderef) mPUSHs(newSVpv(pkg, 0)); mPUSHs(newSVpv(name, 0)); } - -void -is_class_loaded(klass, options=NULL) - SV *klass - HV *options - PREINIT: - HV *stash; - bool found_method = FALSE; - PPCODE: - SvGETMAGIC(klass); - if (!(SvPOKp(klass) && SvCUR(klass))) { /* XXX: SvPOK does not work with magical scalars */ - XSRETURN_NO; - } - - stash = gv_stashsv(klass, 0); - if (!stash) { - XSRETURN_NO; - } - - if (options && hv_exists_ent(options, KEY_FOR(_version), HASH_FOR(_version))) { - HE *required_version = hv_fetch_ent(options, KEY_FOR(_version), 0, HASH_FOR(_version)); - if (check_version (klass, HeVAL(required_version))) { - XSRETURN_YES; - } - - XSRETURN_NO; - } - - if (hv_exists_ent (stash, KEY_FOR(VERSION), HASH_FOR(VERSION))) { - HE *version = hv_fetch_ent(stash, KEY_FOR(VERSION), 0, HASH_FOR(VERSION)); - SV *version_sv; - if (version && HeVAL(version) && (version_sv = GvSV(HeVAL(version))) - && SvOK(version_sv)) { - XSRETURN_YES; - } - } - - if (hv_exists_ent (stash, KEY_FOR(ISA), HASH_FOR(ISA))) { - HE *isa = hv_fetch_ent(stash, KEY_FOR(ISA), 0, HASH_FOR(ISA)); - if (isa && HeVAL(isa) && GvAV(HeVAL(isa)) && av_len(GvAV(HeVAL(isa))) != -1) { - XSRETURN_YES; - } - } - - mop_get_package_symbols(stash, TYPE_FILTER_CODE, find_method, &found_method); - if (found_method) { - XSRETURN_YES; - } - - XSRETURN_NO;