X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FPackage%2FStash%2FPP.pm;h=653eeafb9a23218a1b5a8ff11c4a902b8d260994;hb=eb53b1bd771d2bed902655654014680ea64cf8d4;hp=55dfddd225d6646dd159f3142b562dbfa140c293;hpb=4723417a0e4c38ba9bf00a95d70e6872535c4d4c;p=gitmo%2FPackage-Stash.git diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm index 55dfddd..653eeaf 100644 --- a/lib/Package/Stash/PP.pm +++ b/lib/Package/Stash/PP.pm @@ -4,7 +4,7 @@ use warnings; # ABSTRACT: pure perl implementation of the Package::Stash API use Carp qw(confess); -use Scalar::Util qw(blessed reftype); +use Scalar::Util qw(blessed reftype weaken); use Symbol; # before 5.12, assigning to the ISA glob would make it lose its magical ->isa # powers @@ -24,15 +24,8 @@ sub new { my $class = shift; my ($package) = @_; my $namespace; - { - no strict 'refs'; - # supposedly this caused a bug in earlier perls, but I can't reproduce - # it, so re-enabling the caching - $namespace = \%{$package . '::'}; - } return bless { - 'package' => $package, - 'namespace' => $namespace, + 'package' => $package, }, $class; } @@ -45,6 +38,17 @@ sub name { sub namespace { confess "Can't call namespace as a class method" unless blessed($_[0]); + return $_[0]->{namespace} if defined $_[0]->{namespace}; + + { + no strict 'refs'; + # supposedly this caused a bug in earlier perls, but I can't reproduce + # it, so re-enabling the caching + $_[0]->{namespace} = \%{$_[0]->name . '::'}; + } + + weaken($_[0]->{namespace}); + return $_[0]->{namespace}; } @@ -345,6 +349,12 @@ considered a feature in some cases (this is how L works, for instance), but should not be relied upon - use C directly if you want this behavior. +=item * Some minor memory leaks + +The pure perl implementation has a couple minor memory leaks (see the TODO +tests in t/20-leaks.t) that I'm having a hard time tracking down - these may be +core perl bugs, it's hard to tell. + =back Please report any bugs through RT: email @@ -396,6 +406,22 @@ Jesse Luehrs Mostly copied from code from L, by Stevan Little and the Moose Cabal. +=begin Pod::Coverage + +BROKEN_ISA_ASSIGNMENT +add_symbol +get_all_symbols +get_or_add_symbol +get_symbol +has_symbol +list_all_symbols +name +namespace +new +remove_glob + +=end Pod::Coverage + =cut 1;