X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fbase.pm;h=37f220f63a9641bc68eae51b062d49259587419a;hb=4750257bd21f5a4355221e101326277c013826ec;hp=b8d210e745b2d4fde2e2d8ecd3429ae9002b553f;hpb=4f470f63ec19cae10190b8f3ed622153f261d3b1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/base.pm b/lib/base.pm index b8d210e..37f220f 100644 --- a/lib/base.pm +++ b/lib/base.pm @@ -30,7 +30,7 @@ Cs them. Whether to C a base class package is determined by the absence of a global $VERSION in the base package. If $VERSION is not detected even after loading it, will define $VERSION in the base package, setting it to the string -C<-1, defined by base.pm>. +C<-1, set by base.pm>. =head1 HISTORY @@ -44,38 +44,33 @@ L package base; -use 5.005_64; -our $VERSION = "1.01"; +use 5.006_001; +our $VERSION = "1.03"; sub import { my $class = shift; my $fields_base; my $pkg = caller(0); - my @attrs; - my $isa = \@{"$pkg\::ISA"}; - foreach my $base (@_) { - if ($base =~ /^[-+]/) { #attribute - push @attrs, $base; - next; - } next if $pkg->isa($base); - push @$isa, $base; - unless (exists ${"$base\::"}{VERSION}) { + my $vglob; + if ($vglob = ${"$base\::"}{VERSION} and *$vglob{SCALAR}) { + $$vglob = "-1, set by base.pm" unless defined $$vglob; + } else { eval "require $base"; # Only ignore "Can't locate" errors from our eval require. # Other fatal errors (syntax etc) must be reported. - die if $@ && $@ !~ /^Can\'t locate .*? at \(eval /; + die if $@ && $@ !~ /^Can't locate .*? at \(eval /; unless (%{"$base\::"}) { require Carp; Carp::croak("Base class package \"$base\" is empty.\n", "\t(Perhaps you need to 'use' the module ", "which defines that package first.)"); } - ${"$base\::VERSION"} = "-1, set by base.pm" - unless exists ${"$base\::"}{VERSION}; + ${"$base\::VERSION"} = "-1, set by base.pm" unless defined ${"$base\::VERSION"}; } + push @{"$pkg\::ISA"}, $base; # A simple test like (defined %{"$base\::FIELDS"}) will # sometimes produce typo warnings because it would create @@ -94,10 +89,6 @@ sub import { require fields; fields::inherit($pkg, $fields_base); } - if (@attrs) { - require attributes; - attributes::->import($pkg, $isa, @attrs); - } } 1;