package Mouse::Meta::Module;
-use Mouse::Util qw/:meta get_code_package get_code_ref not_supported/; # enables strict and warnings
+use Mouse::Util qw/:meta/; # enables strict and warnings
use Carp ();
use Scalar::Util ();
($package_name && !ref($package_name))
|| $class->throw_error("You must pass a package name and it cannot be blessed");
+ if(exists $METAS{$package_name}) {
+ unshift @args, %{ $METAS{$package_name} };
+ }
delete $METAS{$package_name};
return $class->initialize($package_name, @args);
}
sub _code_is_mine{
# my($self, $code) = @_;
- return !exists $foreign{ get_code_package($_[1]) };
+ return !exists $foreign{ Mouse::Util::get_code_package($_[1]) };
}
sub add_method;
or $self->throw_error('You must define a method name');
return defined($self->{methods}{$method_name}) || do{
- my $code = get_code_ref($self->{package}, $method_name);
+ my $code = Mouse::Util::get_code_ref($self->{package}, $method_name);
$code && $self->_code_is_mine($code);
};
}
or $self->throw_error('You must define a method name');
return $self->{methods}{$method_name} ||= do{
- my $code = get_code_ref($self->{package}, $method_name);
+ my $code = Mouse::Util::get_code_ref($self->{package}, $method_name);
$code && $self->_code_is_mine($code) ? $code : undef;
};
}
my $subname = ( caller(1) )[3];
$meta->throw_error(
sprintf(
- 'Methods passed to %s must be provided as a list, ArrayRef or regular expression, not %s',
+ 'Methods passed to %s must be provided as a list,'
+ . ' ArrayRef or regular expression, not %s',
$subname,
$type,
)
return if $Mouse::Util::in_global_destruction;
my $serial_id = $self->{anon_serial_id};
-
return if !$serial_id;
- # mortal anonymous class
- # XXX: cleaning stash with threads causes panic/SEGV.
+ # XXX: cleaning stash with threads causes panic/SEGV on legacy perls.
if(exists $INC{'threads.pm'}) {
# (caller)[2] indicates the caller's line number,
- # which is zero when the current thread is joining.
+ # which is zero when the current thread is joining (destroying).
return if( (caller)[2] == 0);
}
- # @ISA is a magical variable, so we clear it manually.
+ # clean up mortal anonymous class stuff
+
+ # @ISA is a magical variable, so we must clear it manually.
@{$self->{superclasses}} = () if exists $self->{superclasses};
# Then, clear the symbol table hash
$name =~ s/ $serial_id \z//xms;
no strict 'refs';
delete ${$name}{ $serial_id . '::' };
-
return;
}
-sub throw_error{
- my($self, $message, %args) = @_;
-
- local $Carp::CarpLevel = $Carp::CarpLevel + 1 + ($args{depth} || 0);
- local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though
-
- if(exists $args{longmess} && !$args{longmess}){ # intentionaly longmess => 0
- Carp::croak($message);
- }
- else{
- Carp::confess($message);
- }
-}
1;
__END__
=head1 NAME
-Mouse::Meta::Module - The base class for Mouse::Meta::Class and Mouse::Meta::Role
+Mouse::Meta::Module - The common base class of Mouse::Meta::Class and Mouse::Meta::Role
=head1 VERSION
-This document describes Mouse version 0.69
+This document describes Mouse version 0.75
=head1 DESCRIPTION
-This class is a base class of Mouse classes and roles,
-which is a subset of Class::MOP::Class.
+This class is an abstract base class of meta classes and meta roles.
=head1 SEE ALSO