From: gfx Date: Wed, 22 Jul 2009 08:39:35 +0000 (+0900) Subject: Implement naming routine in add_package_symbol(xsub) to avoid type-glob duplication X-Git-Tag: 0.92_01~29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b0b8bade301c07713b45a885e98a427ad8e70a6;p=gitmo%2FClass-MOP.git Implement naming routine in add_package_symbol(xsub) to avoid type-glob duplication --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 2a975e8..1f5ec44 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -636,14 +636,6 @@ sub add_method { $body = $method; } - - my ( $current_package, $current_name ) = Class::MOP::get_code_info($body); - - if ( !defined $current_name || $current_name eq '__ANON__' ) { - my $full_method_name = ($self->name . '::' . $method_name); - subname($full_method_name => $body); - } - $self->add_package_symbol( { sigil => '&', type => 'CODE', name => $method_name }, $body, diff --git a/xs/Package.xs b/xs/Package.xs index c552f56..e7e444a 100644 --- a/xs/Package.xs +++ b/xs/Package.xs @@ -197,7 +197,7 @@ CODE: gv = gv_fetchpv(fq_name, ix | (flags & GLOB_CREATE ? GV_ADDMULTI : 0), type); } - + assert(isGV_with_GP(gv)); if(SvOK(ref)){ /* add_package_symbol with a value */ @@ -217,6 +217,17 @@ CODE: GvCV(gv) = NULL; } sv_setsv_mg((SV*)gv, ref); /* *glob = $ref */ + + if(type == SVt_PVCV){ + CV* const subr = (CV*)SvRV(ref); + if(CvANON(subr) + && CvGV(subr) + && isGV(CvGV(subr)) + && strEQ(GvNAME(CvGV(subr)), "__ANON__")){ + CvGV(subr) = gv; + CvANON_off(subr); + } + } RETVAL = ref; } else { /* no values */