X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FClass.pm;h=2cb803c7d8aaa444c3ee6ac53e46cf075f3f9501;hb=d499b013d778b1880738b23c77ccdfed44b8c568;hp=d35f33e3cb652b5a70eb81cd8ee73b95489a7262;hpb=c8fd7a1e8d0bd8db0b3d7ea745c491e2ce24decd;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index d35f33e..2cb803c 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -14,7 +14,7 @@ use Scalar::Util 'blessed', 'reftype', 'weaken'; use Sub::Name 'subname'; use Devel::GlobalDestruction 'in_global_destruction'; -our $VERSION = '0.92'; +our $VERSION = '0.92_01'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -41,12 +41,6 @@ sub initialize { || $class->_construct_class_instance(package => $package_name, @_); } -sub construct_class_instance { - Carp::cluck('The construct_class_instance method has been made private.' - . " The public version is deprecated and will be removed in a future release.\n"); - shift->_construct_class_instance(@_); -} - # NOTE: (meta-circularity) # this is a special form of _construct_instance # (see below), which is used to construct class @@ -75,7 +69,7 @@ sub _construct_class_instance { # get the name of the class appropriately $class = (ref($class) ? ($class->is_immutable - ? $class->get_mutable_metaclass_name() + ? $class->_get_mutable_metaclass_name() : ref($class)) : $class); @@ -170,13 +164,6 @@ sub update_package_cache_flag { $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); } - -sub check_metaclass_compatibility { - Carp::cluck('The check_metaclass_compatibility method has been made private.' - . " The public version is deprecated and will be removed in a future release.\n"); - shift->_check_metaclass_compatibility(@_); -} - sub _check_metaclass_compatibility { my $self = shift; @@ -196,7 +183,7 @@ sub _check_metaclass_compatibility { # get the name of the class appropriately my $super_meta_type = $super_meta->is_immutable - ? $super_meta->get_mutable_metaclass_name() + ? $super_meta->_get_mutable_metaclass_name() : ref($super_meta); ($self->isa($super_meta_type)) @@ -264,19 +251,13 @@ sub _check_metaclass_compatibility { my $current_meta = Class::MOP::get_metaclass_by_name($name); return if $current_meta ne $self; - if(my $isa_ref = $self->get_package_symbol('@ISA')){ - @{$isa_ref} = (); - } - - %{ $self->namespace } = (); - my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o); - - Class::MOP::remove_metaclass_by_name($name); - no strict 'refs'; + @{$name . '::ISA'} = (); + %{$name . '::'} = (); delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'}; - return; + + Class::MOP::remove_metaclass_by_name($name); } } @@ -370,12 +351,6 @@ sub new_object { return $class->_construct_instance(@_); } -sub construct_instance { - Carp::cluck('The construct_instance method has been made private.' - . " The public version is deprecated and will be removed in a future release.\n"); - shift->_construct_instance(@_); -} - sub _construct_instance { my $class = shift; my $params = @_ == 1 ? $_[0] : {@_}; @@ -409,12 +384,6 @@ sub get_meta_instance { $self->{'_meta_instance'} ||= $self->_create_meta_instance(); } -sub create_meta_instance { - Carp::cluck('The create_meta_instance method has been made private.' - . " The public version is deprecated and will be removed in a future release.\n"); - shift->_create_meta_instance(@_); -} - sub _create_meta_instance { my $self = shift; @@ -443,12 +412,6 @@ sub clone_object { $class->_clone_instance($instance, @_); } -sub clone_instance { - Carp::cluck('The clone_instance method has been made private.' - . " The public version is deprecated and will be removed in a future release.\n"); - shift->_clone_instance(@_); -} - sub _clone_instance { my ($class, $instance, %params) = @_; (blessed($instance)) @@ -510,9 +473,10 @@ sub rebless_instance_away { sub superclasses { my $self = shift; + my $var_spec = { sigil => '@', type => 'ARRAY', name => 'ISA' }; if (@_) { my @supers = @_; - @{$self->get_package_symbol('@ISA', create => 1)} = @supers; + @{$self->get_package_symbol($var_spec)} = @supers; # NOTE: # on 5.8 and below, we need to call @@ -531,7 +495,7 @@ sub superclasses { $self->_check_metaclass_compatibility(); $self->_superclasses_updated(); } - @{$self->get_package_symbol('@ISA', create => 1)}; + @{$self->get_package_symbol($var_spec)}; } sub _superclasses_updated { @@ -673,12 +637,6 @@ sub class_precedence_list { # to, and so don't need the fully qualified name. } -sub alias_method { - Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n"); - - shift->add_method(@_); -} - sub find_method_by_name { my ($self, $method_name) = @_; (defined $method_name && $method_name) @@ -696,19 +654,6 @@ sub get_all_methods { return values %methods; } -sub compute_all_applicable_methods { - Carp::cluck('The compute_all_applicable_methods method is deprecated.' - . " Use get_all_methods instead.\n"); - - return map { - { - name => $_->name, - class => $_->package_name, - code => $_, # sigh, overloading - }, - } shift->get_all_methods(@_); -} - sub get_all_method_names { my $self = shift; my %uniq; @@ -899,13 +844,6 @@ sub get_all_attributes { return values %attrs; } -sub compute_all_applicable_attributes { - Carp::cluck('The compute_all_applicable_attributes method has been deprecated.' - . " Use get_all_attributes instead.\n"); - - shift->get_all_attributes(@_); -} - sub find_attribute_by_name { my ($self, $attr_name) = @_; foreach my $class ($self->linearized_isa) { @@ -941,6 +879,8 @@ sub is_pristine { sub is_mutable { 1 } sub is_immutable { 0 } +sub immutable_options { %{ $_[0]{__immutable}{options} || {} } } + sub _immutable_options { my ( $self, @args ) = @_; @@ -1027,7 +967,7 @@ sub _immutable_metaclass { # example of where this matters). my $meta_name = $meta->is_immutable - ? $meta->get_mutable_metaclass_name + ? $meta->_get_mutable_metaclass_name : ref $meta; my $immutable_meta = $meta_name->create( @@ -1090,7 +1030,7 @@ sub _install_inlined_code { sub _rebless_as_mutable { my $self = shift; - bless $self, $self->get_mutable_metaclass_name; + bless $self, $self->_get_mutable_metaclass_name; return $self; } @@ -1556,7 +1496,7 @@ object instances created for this class, not existing instances. =item B<< $metaclass->attribute_metaclass >> Returns the class name of the attribute metaclass for this class. By -default, this is L. for more information on +default, this is L. =back @@ -1639,6 +1579,13 @@ replaced when inlining a destructor. This defaults to false. =back +=item B<< $metaclass->immutable_options >> + +Returns a hash of the options used when making the class immutable, including +both defaults and anything supplied by the user in the call to C<< +$metaclass->make_immutable >>. This is useful if you need to temporarily make +a class mutable and then restore immutability as it was before. + =item B<< $metaclass->make_mutable >> Calling this method reverse the immutabilization transformation.