X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FC3%2Fnext.pm;h=ae7b38ed8b7045baa6cb79f94e588b91620fbb6f;hb=10d61eda6b8d59b2183b783da40608b0c6afe175;hp=61ef3377d2e81be3c32ff6aea36d77e537bf24f3;hpb=8d45f443f7bad158e1a37618b9370c554439e557;p=gitmo%2FClass-C3.git diff --git a/lib/Class/C3/next.pm b/lib/Class/C3/next.pm index 61ef337..ae7b38e 100644 --- a/lib/Class/C3/next.pm +++ b/lib/Class/C3/next.pm @@ -1,12 +1,13 @@ package # hide me from PAUSE - next; + next; use strict; use warnings; +no warnings 'redefine'; # for 00load.t w/ core support use Scalar::Util 'blessed'; -our $VERSION = '0.06'; +our $VERSION = '0.23'; our %METHOD_CACHE; @@ -15,7 +16,7 @@ sub method { my $class = blessed($self) || $self; my $indirect = caller() =~ /^(?:next|maybe::next)$/; my $level = $indirect ? 2 : 1; - + my ($method_caller, $label, @label); while ($method_caller = (caller($level++))[3]) { @label = (split '::', $method_caller); @@ -27,25 +28,25 @@ sub method { my $method; - my $caller = join '::' => @label; - + my $caller = join '::' => @label; + $method = $METHOD_CACHE{"$class|$caller|$label"} ||= do { - + my @MRO = Class::C3::calculateMRO($class); - + my $current; while ($current = shift @MRO) { last if $caller eq $current; } - + no strict 'refs'; my $found; foreach my $class (@MRO) { - next if (defined $Class::C3::MRO{$class} && - defined $Class::C3::MRO{$class}{methods}{$label}); + next if (defined $Class::C3::MRO{$class} && + defined $Class::C3::MRO{$class}{methods}{$label}); last if (defined ($found = *{$class . '::' . $label}{CODE})); } - + $found; }; @@ -59,10 +60,11 @@ sub method { sub can { method($_[0]) } package # hide me from PAUSE - maybe::next; + maybe::next; use strict; use warnings; +no warnings 'redefine'; # for 00load.t w/ core support our $VERSION = '0.02'; @@ -99,6 +101,6 @@ Copyright 2005, 2006 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =cut