4 find_method (const char *key, STRLEN keylen, SV *val, void *ud)
6 bool *found_method = (bool *)ud;
8 PERL_UNUSED_ARG(keylen);
15 check_version (SV *klass, SV *required_version)
25 PUSHs(required_version);
28 call_method("VERSION", G_DISCARD|G_VOID|G_EVAL);
43 MODULE = Class::MOP PACKAGE = Class::MOP
47 # use prototype here to be compatible with get_code_info from Sub::Identify
49 get_code_info(coderef)
57 if (mop_get_code_info(coderef, &pkg, &name)) {
59 mPUSHs(newSVpv(pkg, 0));
60 mPUSHs(newSVpv(name, 0));
64 is_class_loaded(klass, options=NULL)
69 bool found_method = FALSE;
72 if (!(SvPOKp(klass) && SvCUR(klass))) { /* XXX: SvPOK does not work with magical scalars */
76 stash = gv_stashsv(klass, 0);
81 if (options && hv_exists_ent(options, KEY_FOR(_version), HASH_FOR(_version))) {
82 HE *required_version = hv_fetch_ent(options, KEY_FOR(_version), 0, HASH_FOR(_version));
83 if (check_version (klass, HeVAL(required_version))) {
90 if (hv_exists_ent (stash, KEY_FOR(VERSION), HASH_FOR(VERSION))) {
91 HE *version = hv_fetch_ent(stash, KEY_FOR(VERSION), 0, HASH_FOR(VERSION));
93 if (version && HeVAL(version) && (version_sv = GvSV(HeVAL(version)))) {
94 if (SvROK(version_sv)) {
95 SV *version_sv_ref = SvRV(version_sv);
97 if (SvOK(version_sv_ref)) {
101 else if (SvOK(version_sv)) {
107 if (hv_exists_ent (stash, KEY_FOR(ISA), HASH_FOR(ISA))) {
108 HE *isa = hv_fetch_ent(stash, KEY_FOR(ISA), 0, HASH_FOR(ISA));
109 if (isa && HeVAL(isa) && GvAV(HeVAL(isa)) && av_len(GvAV(HeVAL(isa))) != -1) {
114 mop_get_package_symbols(stash, TYPE_FILTER_CODE, find_method, &found_method);