From: gfx Date: Thu, 16 Jul 2009 08:15:29 +0000 (+0900) Subject: Remove pure perl implementations X-Git-Tag: 0.92_01~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6db52969e33fb27e053c6d367bdc447234a802d3;p=gitmo%2FClass-MOP.git Remove pure perl implementations --- diff --git a/lib/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm index b4dce2c..bfbf974 100644 --- a/lib/Class/MOP/Package.pm +++ b/lib/Class/MOP/Package.pm @@ -130,88 +130,12 @@ sub namespace { # ... 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; - } - } -} - sub remove_package_symbol { my ($self, $variable) = @_;