3 SV *mop_method_metaclass;
4 SV *mop_associated_metaclass;
8 mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stash, HV *const map)
10 const char *const class_name_pv = HvNAME(stash); /* must be HvNAME(stash), not SvPV_nolen_const(class_name) */
16 symbols = mop_get_all_package_symbols(stash, TYPE_FILTER_CODE);
17 sv_2mortal((SV*)symbols);
18 (void)hv_iterinit(symbols);
19 while ( (coderef = hv_iternextsv(symbols, &method_name, &method_name_len)) ) {
20 CV *cv = (CV *)SvRV(coderef);
25 if (!mop_get_code_info(coderef, &cvpkg_name, &cv_name)) {
29 /* this checks to see that the subroutine is actually from our package */
30 if ( !(strEQ(cvpkg_name, "constant") && strEQ(cv_name, "__ANON__")) ) {
31 if ( strNE(cvpkg_name, class_name_pv) ) {
36 method_slot = *hv_fetch(map, method_name, method_name_len, TRUE);
37 if ( SvOK(method_slot) ) {
40 if ( sv_isobject(method_slot) ) {
41 body = mop_call0(aTHX_ method_slot, KEY_FOR(body)); /* $method_object->body() */
47 if ( SvROK(body) && ((CV *) SvRV(body)) == cv ) {
51 /* $map->{$method_name} = undef */
52 sv_setsv(method_slot, &PL_sv_undef);
58 MODULE = Class::MOP::Mixin::HasMethods PACKAGE = Class::MOP::Mixin::HasMethods
66 HV *const obj = (HV *)SvRV(self);
67 SV *const class_name = HeVAL( hv_fetch_ent(obj, KEY_FOR(package), 0, HASH_FOR(package)) );
68 HV *const stash = gv_stashsv(class_name, 0);
74 mXPUSHs(newRV_noinc((SV *)newHV()));
78 current = mop_check_package_cache_flag(aTHX_ stash);
79 cache_flag = HeVAL( hv_fetch_ent(obj, KEY_FOR(package_cache_flag), TRUE, HASH_FOR(package_cache_flag)));
80 map_ref = HeVAL( hv_fetch_ent(obj, KEY_FOR(methods), TRUE, HASH_FOR(methods)));
82 /* $self->{methods} does not yet exist (or got deleted) */
83 if ( !SvROK(map_ref) || SvTYPE(SvRV(map_ref)) != SVt_PVHV ) {
84 SV *new_map_ref = newRV_noinc((SV *)newHV());
85 sv_2mortal(new_map_ref);
86 sv_setsv(map_ref, new_map_ref);
89 if ( !SvOK(cache_flag) || SvUV(cache_flag) != current ) {
90 mop_update_method_map(aTHX_ self, class_name, stash, (HV *)SvRV(map_ref));
91 sv_setuv(cache_flag, mop_check_package_cache_flag(aTHX_ stash)); /* update_cache_flag() */
97 mop_method_metaclass = newSVpvs("method_metaclass");
98 mop_associated_metaclass = newSVpvs("associated_metaclass");
99 mop_wrap = newSVpvs("wrap");