From: Shawn M Moore Date: Sun, 18 May 2008 12:49:29 +0000 (+0000) Subject: use Sub::Identify instead of XS get_code_info X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=716c46df4d912f7e73ae36c3aad6b57339092f40;p=gitmo%2FClass-MOP.git use Sub::Identify instead of XS get_code_info --- diff --git a/MOP.xs b/MOP.xs index 6f1e2f6..30e5fca 100644 --- a/MOP.xs +++ b/MOP.xs @@ -8,11 +8,6 @@ check_method_cache_flag: check the PL_sub_generation ISA/method cache thing - -get_code_info: - Pass in a coderef, returns: - [ $pkg_name, $coderef_name ] ie: - [ 'Foo::Bar', 'new' ] */ MODULE = Class::MOP PACKAGE = Class::MOP @@ -27,20 +22,3 @@ check_package_cache_flag(pkg) OUTPUT: RETVAL -void -get_code_info(coderef) - SV* coderef - PREINIT: - char* name; - char* pkg; - PPCODE: - if( SvOK(coderef) && SvROK(coderef) && SvTYPE(SvRV(coderef)) == SVt_PVCV){ - coderef = SvRV(coderef); - name = GvNAME( CvGV(coderef) ); - pkg = HvNAME( GvSTASH(CvGV(coderef)) ); - - EXTEND(SP, 2); - PUSHs(newSVpvn(pkg, strlen(pkg))); - PUSHs(newSVpvn(name, strlen(name))); - } - diff --git a/Makefile.PL b/Makefile.PL index 065acd5..4f88932 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -6,10 +6,11 @@ name 'Class-MOP'; all_from 'lib/Class/MOP.pm'; license 'perl'; -requires 'Scalar::Util' => '1.18'; -requires 'Sub::Name' => '0.02'; -requires 'MRO::Compat' => '0.05'; -requires 'Carp' => '0'; +requires 'Scalar::Util' => '1.18'; +requires 'Sub::Name' => '0.02'; +requires 'MRO::Compat' => '0.05'; +requires 'Carp' => '0'; +requires 'Sub::Identify' => '0.02'; build_requires 'Test::More' => '0.62'; build_requires 'Test::Exception' => '0.21'; diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 9cb52e9..f4a261d 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -8,6 +8,7 @@ use MRO::Compat; use Carp 'confess'; use Scalar::Util 'weaken'; +use Sub::Identify 'sub_name', 'stash_name'; use Class::MOP::Class; use Class::MOP::Attribute; @@ -33,6 +34,10 @@ BEGIN { } } +sub get_code_info { + (&stash_name, &sub_name) +} + # sub subname { $_[1] } BEGIN {