X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FPackage.pm;h=d2cc02136b4357d651418086ca65ae65f2339b55;hb=ec9e38e5fd24916a3b5a4b67b5e7c7d20674d0f5;hp=4057138cfd11ed9fbb14c2a4182793220de9f74f;hpb=b3d2484f6cb8c2a5caa190eb242449f0c6289ab6;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm index 4057138..d2cc021 100644 --- a/lib/Class/MOP/Package.pm +++ b/lib/Class/MOP/Package.pm @@ -4,11 +4,10 @@ package Class::MOP::Package; use strict; use warnings; -use B; use Scalar::Util 'blessed'; use Carp 'confess'; -our $VERSION = '0.78'; +our $VERSION = '0.89'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -59,18 +58,25 @@ sub reinitialize { sub _new { my $class = shift; - my $options = @_ == 1 ? $_[0] : {@_}; + return Class::MOP::Class->initialize($class)->new_object(@_) + if $class ne __PACKAGE__; - # NOTE: - # because of issues with the Perl API - # to the typeglob in some versions, we - # need to just always grab a new - # reference to the hash in the accessor. - # Ideally we could just store a ref and - # it would Just Work, but oh well :\ - $options->{namespace} ||= \undef; + my $params = @_ == 1 ? $_[0] : {@_}; - bless $options, $class; + return bless { + package => $params->{package}, + + # NOTE: + # because of issues with the Perl API + # to the typeglob in some versions, we + # need to just always grab a new + # reference to the hash in the accessor. + # Ideally we could just store a ref and + # it would Just Work, but oh well :\ + + namespace => \undef, + + } => $class; } # Attributes @@ -128,13 +134,13 @@ sub add_package_symbol { my ($name, $sigil, $type) = ref $variable eq 'HASH' ? @{$variable}{qw[name sigil type]} - : $self->_deconstruct_variable_name($variable); + : $self->_deconstruct_variable_name($variable); my $pkg = $self->{'package'}; no strict 'refs'; - no warnings 'redefine', 'misc'; - *{$pkg . '::' . $name} = ref $initial_value ? $initial_value : \$initial_value; + no warnings 'redefine', 'misc', 'prototype'; + *{$pkg . '::' . $name} = ref $initial_value ? $initial_value : \$initial_value; } sub remove_package_glob {