adding XS stuff; removing stale branches
Stevan Little [Sat, 14 Oct 2006 15:14:02 +0000 (15:14 +0000)]
MANIFEST
lib/Class/MOP.pm
lib/Class/MOP/Attribute.pm
lib/Class/MOP/Package.pm
t/010_self_introspection.t

index 9053a56..611ec2b 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -22,6 +22,7 @@ lib/Class/MOP/Method.pm
 lib/Class/MOP/Module.pm
 lib/Class/MOP/Object.pm
 lib/Class/MOP/Package.pm
+lib/Class/MOP/Package.xs
 lib/Class/MOP/Class/Immutable.pm
 scripts/class_browser.pl
 t/000_load.t
index 05d08dd..ef93245 100644 (file)
@@ -4,6 +4,8 @@ package Class::MOP;
 use strict;
 use warnings;
 
+use 5.006; # min. perl version
+
 use Carp         'confess';
 use Scalar::Util 'weaken';
 
index c14eca3..cec9e7b 100644 (file)
@@ -238,16 +238,6 @@ sub generate_predicate_method {
     };
 }
 
-sub generate_clearer_method {
-    my $self = shift;
-    my $attr_name  = $self->name;
-    return sub { 
-        Class::MOP::Class->initialize(Scalar::Util::blessed($_[0]))
-                         ->get_meta_instance
-                         ->deinitialize_slot($_[0], $attr_name);
-    };
-}
-
 sub generate_predicate_method_inline {
     my $self          = shift; 
     my $attr_name     = $self->name;
@@ -261,6 +251,16 @@ sub generate_predicate_method_inline {
     return $code;
 }
 
+sub generate_clearer_method {
+    my $self = shift;
+    my $attr_name  = $self->name;
+    return sub { 
+        Class::MOP::Class->initialize(Scalar::Util::blessed($_[0]))
+                         ->get_meta_instance
+                         ->deinitialize_slot($_[0], $attr_name);
+    };
+}
+
 sub generate_clearer_method_inline {
     my $self          = shift; 
     my $attr_name     = $self->name;
index 2e507fe..0711206 100644 (file)
@@ -7,9 +7,12 @@ use warnings;
 use Scalar::Util 'blessed';
 use Carp         'confess';
 
-our $VERSION   = '0.05';
+our $VERSION   = '0.35';
 our $AUTHORITY = 'cpan:STEVAN';
 
+use XSLoader;
+XSLoader::load( 'Class::MOP::Package', $VERSION );
+
 use base 'Class::MOP::Object';
 
 # introspection
@@ -144,48 +147,6 @@ sub get_package_symbol {
     return *{$self->namespace->{$name}}{$type};
 }
 
-sub remove_package_symbol {
-    my ($self, $variable) = @_;
-
-    my ($name, $sigil, $type) = $self->_deconstruct_variable_name($variable); 
-
-    # FIXME:
-    # no doubt this is grossly inefficient and 
-    # could be done much easier and faster in XS
-
-    my ($scalar, $array, $hash, $code);
-    if ($type eq 'SCALAR') {
-        $array  = $self->get_package_symbol('@' . $name) if $self->has_package_symbol('@' . $name);
-        $hash   = $self->get_package_symbol('%' . $name) if $self->has_package_symbol('%' . $name);     
-        $code   = $self->get_package_symbol('&' . $name) if $self->has_package_symbol('&' . $name);     
-    }
-    elsif ($type eq 'ARRAY') {
-        $scalar = $self->get_package_symbol('$' . $name) if $self->has_package_symbol('$' . $name);
-        $hash   = $self->get_package_symbol('%' . $name) if $self->has_package_symbol('%' . $name);     
-        $code   = $self->get_package_symbol('&' . $name) if $self->has_package_symbol('&' . $name);
-    }
-    elsif ($type eq 'HASH') {
-        $scalar = $self->get_package_symbol('$' . $name) if $self->has_package_symbol('$' . $name);
-        $array  = $self->get_package_symbol('@' . $name) if $self->has_package_symbol('@' . $name);        
-        $code   = $self->get_package_symbol('&' . $name) if $self->has_package_symbol('&' . $name);      
-    }
-    elsif ($type eq 'CODE') {
-        $scalar = $self->get_package_symbol('$' . $name) if $self->has_package_symbol('$' . $name);
-        $array  = $self->get_package_symbol('@' . $name) if $self->has_package_symbol('@' . $name);        
-        $hash   = $self->get_package_symbol('%' . $name) if $self->has_package_symbol('%' . $name);        
-    }    
-    else {
-        confess "This should never ever ever happen";
-    }
-        
-    $self->remove_package_glob($name);
-    
-    $self->add_package_symbol(('$' . $name) => $scalar) if defined $scalar;      
-    $self->add_package_symbol(('@' . $name) => $array)  if defined $array;    
-    $self->add_package_symbol(('%' . $name) => $hash)   if defined $hash;
-    $self->add_package_symbol(('&' . $name) => $code)   if defined $code;            
-}
-
 sub list_all_package_symbols {
     my ($self, $type_filter) = @_;
     return keys %{$self->namespace} unless defined $type_filter;
index 7f42a40..d5b28b2 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 189;
+use Test::More tests => 191;
 use Test::Exception;
 
 BEGIN {
@@ -35,7 +35,7 @@ my @class_mop_package_methods = qw(
     name
     namespace
     
-    add_package_symbol get_package_symbol has_package_symbol remove_package_symbol 
+    add_package_symbol bootstrap get_package_symbol has_package_symbol remove_package_symbol 
     list_all_package_symbols remove_package_glob
     
     _deconstruct_variable_name