use Carp 'confess';
use Scalar::Util 'blessed';
-use Mouse::Util qw(load_class is_class_loaded not_supported);
+use Mouse::Util qw(load_class is_class_loaded get_code_package not_supported);
use Mouse::Meta::Module;
use Mouse::Meta::Class;
my $code;
if(exists $is_removable{$keyword}
&& ($code = $caller->can($keyword))
- && (Mouse::Util::get_code_info($code))[0] eq __PACKAGE__){
+ && get_code_package($code) eq __PACKAGE__){
delete $stash->{$keyword};
}
use Carp ();
use Scalar::Util qw/blessed weaken/;
-use Mouse::Util qw/:meta get_code_info not_supported load_class/;
+use Mouse::Util qw/:meta get_code_package not_supported load_class/;
{
my %METACLASS_CACHE;
*{ $pkg . '::' . $name } = $code;
}
-sub _code_is_mine { # taken from Class::MOP::Class
- my ( $self, $code ) = @_;
+# XXX: for backward compatibility
+my %foreign = map{ $_ => undef } qw(
+ Mouse Mouse::Role Mouse::Util Mouse::Util::TypeConstraints
+ Carp Scalar::Util
+);
+sub _code_is_mine{
+ my($self, $code) = @_;
- my ( $code_package, $code_name ) = get_code_info($code);
+ my $package = get_code_package($code);
- return $code_package && $code_package eq $self->{package}
- || ( $code_package eq 'constant' && $code_name eq '__ANON__' );
+ return !exists $foreign{$package};
}
sub has_method {
return 1 if $self->{methods}->{$method_name};
- my $code = $self->{package}->can($method_name);
+ my $code = do{ no strict 'refs'; *{$self->{package} . '::' . $method_name}{CODE} };
return $code && $self->_code_is_mine($code);
}
sub method_metaclass(){ 'Mouse::Meta::Role::Method' } # required for get_method()
-# XXX: for backward compatibility
-my %foreign = map{ $_ => undef } qw(Mouse::Role Carp Scalar::Util UNIVERSAL);
-sub _code_is_mine{
- my($self, $code) = @_;
-
- my($package, $name) = get_code_info($code);
-
- return $package && !exists $foreign{$package};
-}
-
-
sub _construct_meta {
my $class = shift;
use Carp 'confess';
use Scalar::Util 'blessed';
-use Mouse::Util qw(load_class not_supported);
+use Mouse::Util qw(load_class get_code_package not_supported);
use Mouse ();
our @ISA = qw(Exporter);
my $code;
if(exists $is_removable{$keyword}
&& ($code = $caller->can($keyword))
- && (Mouse::Util::get_code_info($code))[0] eq __PACKAGE__){
+ && get_code_package($code) eq __PACKAGE__){
delete $stash->{$keyword};
}
use Exporter;
use Carp qw(confess);
+use B ();
use constant _MOUSE_VERBOSE => !!$ENV{MOUSE_VERBOSE};
get_linear_isa
get_code_info
+ get_code_package
+
not_supported
does meta dump
my ($coderef) = @_;
ref($coderef) or return;
- require B;
-
my $cv = B::svref_2object($coderef);
$cv->isa('B::CV') or return;
return ($gv->STASH->NAME, $gv->NAME);
}
+
+ sub get_code_package{
+ my($coderef) = @_;
+
+ my $cv = B::svref_2object($coderef);
+ $cv->isa('B::CV') or return '';
+
+ my $gv = $cv->GV;
+ $gv->isa('B::GV') or return '';
+
+ return $gv->STASH->NAME;
+ }
}
# taken from Mouse::Util (0.90)