X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FClass-C3.git;a=blobdiff_plain;f=lib%2FClass%2FC3.pm;h=eea78b051de42d98d77238ff81ca443f382db748;hp=0978941b816d3651a67f36ce7ae18d46bf5814a0;hb=e861fe165783d50b227da184c2c80fea5442c611;hpb=7eb04689343a6339aa05446bda353d2902195c00 diff --git a/lib/Class/C3.pm b/lib/Class/C3.pm index 0978941..eea78b0 100644 --- a/lib/Class/C3.pm +++ b/lib/Class/C3.pm @@ -4,7 +4,7 @@ package Class::C3; use strict; use warnings; -our $VERSION = '0.22'; +our $VERSION = '0.23'; our $C3_IN_CORE; our $C3_XS; @@ -14,17 +14,27 @@ BEGIN { $C3_IN_CORE = 1; require mro; } - else { - eval "require Class::C3::XS"; - my $error = $@; - if(!$error) { - $C3_XS = 1; - } - else { + elsif($C3_XS or not defined $C3_XS) { + my $error = do { + local $@; + eval { require Class::C3::XS }; + $@; + }; + + if ($error) { die $error if $error !~ /\blocate\b/; + + if ($C3_XS) { + require Carp; + Carp::croak( "XS explicitly requested but Class::C3::XS is not available" ); + } + require Algorithm::C3; require Class::C3::next; } + else { + $C3_XS = 1; + } } } @@ -497,7 +507,7 @@ If your software is meant to work on earlier Perls, use L as document =head1 Class::C3::XS -This module will load L if it's installed and you are running on a Perl version older than 5.9.5. Installing this is recommended when possible, as it results in significant performance improvements (but unlike the 5.9.5+ core support, it still has all of the same caveats as L). +This module will load L if it's installed and you are running on a Perl version older than 5.9.5. The optional module will be automatically installed for you if a C compiler is available, as it results in significant performance improvements (but unlike the 5.9.5+ core support, it still has all of the same caveats as L). =head1 CODE COVERAGE