X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FPackage.pm;h=f2c8e4417dcabe2b54f45ab1a6d83f581e74a1a8;hb=c8fd7a1e8d0bd8db0b3d7ea745c491e2ce24decd;hp=92463aa08921943a19d074c120193a980b51f1c5;hpb=122aa3d6bbb1cc8f7bcb45254e2d7f62c8bb1e0e;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm index 92463aa..f2c8e44 100644 --- a/lib/Class/MOP/Package.pm +++ b/lib/Class/MOP/Package.pm @@ -100,6 +100,7 @@ sub namespace { # we could just store a ref and it would # Just Work, but oh well :\ no strict 'refs'; + no warnings 'uninitialized'; \%{$_[0]->{'package'} . '::'} } @@ -140,84 +141,9 @@ sub _method_map { $_[0]->{'methods'} } # ... these functions have to touch the symbol table itself,.. yuk -sub add_package_symbol { - my ($self, $variable, $initial_value) = @_; - - my ($name, $sigil, $type) = ref $variable eq 'HASH' - ? @{$variable}{qw[name sigil type]} - : $self->_deconstruct_variable_name($variable); - - my $pkg = $self->{'package'}; - - no strict 'refs'; - no warnings 'redefine', 'misc', 'prototype'; - *{$pkg . '::' . $name} = ref $initial_value ? $initial_value : \$initial_value; -} - sub remove_package_glob { my ($self, $name) = @_; - no strict 'refs'; - delete ${$self->name . '::'}{$name}; -} - -# ... these functions deal with stuff on the namespace level - -sub has_package_symbol { - my ( $self, $variable ) = @_; - - my ( $name, $sigil, $type ) - = ref $variable eq 'HASH' - ? @{$variable}{qw[name sigil type]} - : $self->_deconstruct_variable_name($variable); - - my $namespace = $self->namespace; - - return 0 unless exists $namespace->{$name}; - - my $entry_ref = \$namespace->{$name}; - if ( reftype($entry_ref) eq 'GLOB' ) { - if ( $type eq 'SCALAR' ) { - return defined( ${ *{$entry_ref}{SCALAR} } ); - } - else { - return defined( *{$entry_ref}{$type} ); - } - } - else { - - # a symbol table entry can be -1 (stub), string (stub with prototype), - # or reference (constant) - return $type eq 'CODE'; - } -} - -sub get_package_symbol { - my ($self, $variable) = @_; - - my ($name, $sigil, $type) = ref $variable eq 'HASH' - ? @{$variable}{qw[name sigil type]} - : $self->_deconstruct_variable_name($variable); - - my $namespace = $self->namespace; - - # FIXME - $self->add_package_symbol($variable) - unless exists $namespace->{$name}; - - my $entry_ref = \$namespace->{$name}; - - if ( ref($entry_ref) eq 'GLOB' ) { - return *{$entry_ref}{$type}; - } - else { - if ( $type eq 'CODE' ) { - no strict 'refs'; - return \&{ $self->name . '::' . $name }; - } - else { - return undef; - } - } + delete $self->namespace->{$name}; } sub remove_package_symbol {