| 1 | package Class::MOP::Mixin::HasMethods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 459 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 459 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 459 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 459 | ▶ | use Class::MOP::Method::Meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 459 | ▶ | use Scalar::Util 'blessed', 'reftype'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 459 | ▶ | use Sub::Util 1.40 'set_subname'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 459 | ▶ | use parent 'Class::MOP::Mixin'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 10224 | ▶ | sub _meta_method_class { 'Class::MOP::Method::Meta' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_meta_method_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 13244 | ▶ | sub _add_meta_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_meta_method: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 13244 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 13244 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 13244 | ▶ | my $existing_method = $self->can('find_method_by_name') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ? $self->find_method_by_name($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | : $self->get_method($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 13244 | ▶ | return if $existing_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$existing_method and $existing_method->isa($self->_meta_method_class)
MC/DC100%2/2
$existing_method and $existing_method->isa($self->_meta_method_class)
$existing_method
$existing_method->isa($self->_meta_method_class)
Truth table100%3/3
A and B
A= $existing_methodB= $existing_method->isa($self->_meta_method_class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | && $existing_method->isa($self->_meta_method_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 13141 | $self->add_method( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | $name => $self->_meta_method_class->wrap( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | package_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | associated_metaclass => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 30717 | ▶ | sub wrap_method_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap_method_body: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 30717 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ( $args{body} && 'CODE' eq reftype $args{body} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 30717 | ▶ | || $self->_throw_exception( CodeBlockMustBeACodeRef => instance => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"body"} and "CODE" eq builtin::reftype($args{"body"})
MC/DC50%1/2
$args{"body"} and "CODE" eq builtin::reftype($args{"body"})
$args{"body"}
"CODE" eq builtin::reftype($args{"body"})
Truth table66%2/3
A and B
A= $args{"body"}B= "CODE" eq builtin::reftype($args{"body"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | params => \%args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 30716 | $self->method_metaclass->wrap( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | package_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | %args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 182437 | ▶ | sub add_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_method: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 182437 | my ( $self, $method_name, $method ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 182437 | ▶ | ( defined $method_name && length $method_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $method_name and length $method_name
MC/DC100%2/2
defined $method_name and length $method_name
defined $method_name
length $method_name
Truth table100%3/3
A and B
A= defined $method_nameB= length $method_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 182434 | my $package_name = $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 182432 | my $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 182432 | ▶ | if ( blessed($method) && $method->isa('Class::MOP::Method') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($method) and $method->isa("Class::MOP::Method")
MC/DC100%2/2
builtin::blessed($method) and $method->isa("Class::MOP::Method")
builtin::blessed($method)
$method->isa("Class::MOP::Method")
Truth table100%3/3
A and B
A= builtin::blessed($method)B= $method->isa("Class::MOP::Method")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 173409 | $body = $method->body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 173409 | ▶ | if ( $method->package_name ne $package_name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 18514 | $method = $method->clone( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | package_name => $package_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | name => $method_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 173409 | $method->attach_to_class($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # If a raw code reference is supplied, its method object is not created. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # The method object won't be created until required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 9023 | $body = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 182432 | $self->_method_map->{$method_name} = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 182432 | my ($current_package, $current_name) = Class::MOP::get_code_info($body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 182432 | ▶ | set_subname($package_name . '::' . $method_name, $body) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $current_name and not $current_name =~ /^__ANON__/
MC/DC50%1/2
defined $current_name and not $current_name =~ /^__ANON__/
defined $current_name
not $current_name =~ /^__ANON__/
Truth table66%2/3
A and not(B)
A= defined $current_nameB= not $current_name =~ /^__ANON__/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | unless defined $current_name && $current_name !~ /^__ANON__/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 182432 | $self->add_package_symbol("&$method_name", $body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # we added the method to the method map too, so it's still valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 182432 | $self->update_package_cache_flag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 54729 | ▶ | sub _code_is_mine { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_code_is_mine: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 54729 | my ( $self, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 54729 | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 54729 | ▶ | return ( $code_package && $code_package eq $self->name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition55%5/9
$code_package && $code_package eq $self->name || $code_package eq 'constant' && $code_name eq '__ANON__'
$code_package and $code_package eq $self->name
$code_package eq "constant" and $code_name eq "__ANON__"
MC/DC25%1/4
$code_package && $code_package eq $self->name || $code_package eq 'constant' && $code_name eq '__ANON__'
$code_package
$code_package eq $self->name
$code_package eq "constant"
$code_name eq "__ANON__"
Truth table28%2/7
A and B || C and D
A= $code_packageB= $code_package eq $self->nameC= $code_package eq "constant"D= $code_name eq "__ANON__"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | || ( $code_package eq 'constant' && $code_name eq '__ANON__' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 26094 | ▶ | sub has_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_method: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 26094 | my ( $self, $method_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 26094 | ▶ | ( defined $method_name && length $method_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $method_name and length $method_name
MC/DC100%2/2
defined $method_name and length $method_name
defined $method_name
length $method_name
Truth table100%3/3
A and B
A= defined $method_nameB= length $method_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 26090 | my $method = $self->_get_maybe_raw_method($method_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 26090 | ▶ | return if not $method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1460 | return defined($self->_method_map->{$method_name} = $method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 275535 | ▶ | sub get_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_method: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 275535 | my ( $self, $method_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 275535 | ▶ | ( defined $method_name && length $method_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $method_name and length $method_name
MC/DC100%2/2
defined $method_name and length $method_name
defined $method_name
length $method_name
Truth table100%3/3
A and B
A= defined $method_nameB= length $method_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 275532 | my $method = $self->_get_maybe_raw_method($method_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 275532 | ▶ | return if not $method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 84147 | ▶ | return $method if blessed($method) && $method->isa('Class::MOP::Method'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($method) and $method->isa("Class::MOP::Method")
MC/DC100%2/2
builtin::blessed($method) and $method->isa("Class::MOP::Method")
builtin::blessed($method)
$method->isa("Class::MOP::Method")
Truth table100%3/3
A and B
A= builtin::blessed($method)B= $method->isa("Class::MOP::Method")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 30716 | return $self->_method_map->{$method_name} = $self->wrap_method_body( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | body => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | name => $method_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | associated_metaclass => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 301622 | ▶ | sub _get_maybe_raw_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_maybe_raw_method: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 301622 | my ( $self, $method_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 301622 | my $map_entry = $self->_method_map->{$method_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 301622 | ▶ | return $map_entry if defined $map_entry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 246717 | my $code = $self->get_package_symbol("&$method_name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 246717 | ▶ | return unless $code && $self->_code_is_mine($code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$code and $self->_code_is_mine($code)
MC/DC100%2/2
$code and $self->_code_is_mine($code)
$code
$self->_code_is_mine($code)
Truth table100%3/3
A and B
A= $codeB= $self->_code_is_mine($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 30702 | return $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 86 | ▶ | sub remove_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_method: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 86 | my ( $self, $method_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 86 | ▶ | ( defined $method_name && length $method_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $method_name and length $method_name
MC/DC100%2/2
defined $method_name and length $method_name
defined $method_name
length $method_name
Truth table100%3/3
A and B
A= defined $method_nameB= length $method_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 83 | my $removed_method = delete $self->_method_map->{$method_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 83 | $self->remove_package_symbol("&$method_name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 83 | ▶ | $removed_method->detach_from_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($removed_method) and $removed_method->isa("Class::MOP::Method")
MC/DC50%1/2
builtin::blessed($removed_method) and $removed_method->isa("Class::MOP::Method")
builtin::blessed($removed_method)
$removed_method->isa("Class::MOP::Method")
Truth table66%2/3
A and B
A= builtin::blessed($removed_method)B= $removed_method->isa("Class::MOP::Method")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | if blessed($removed_method) && $removed_method->isa('Class::MOP::Method'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # still valid, since we just removed the method from the map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 83 | $self->update_package_cache_flag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 83 | return $removed_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 215 | ▶ | sub get_method_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_method_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 215 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 215 | return keys %{ $self->_full_method_map }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 7814 | ▶ | sub _get_local_methods { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_local_methods: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 7814 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 7814 | return values %{ $self->_full_method_map }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 131 | ▶ | sub _restore_metamethods_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_restore_metamethods_from: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 131 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 131 | my ($old_meta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 131 | my $package_name = $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # Check if Perl debugger is enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 131 | my $debugger_enabled = ($^P & 0x10); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 131 | my $debug_method_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 131 | for my $method ($old_meta->_get_local_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 163 | my $method_name = $method->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # Track DB::sub information for this method if debugger is enabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # This contains original method filename and line numbers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 163 | $debug_method_info = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 163 | ▶ | if ($debugger_enabled) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 8 | $debug_method_info = $DB::sub{$package_name . "::" . $method_name} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 163 | $method->_make_compatible_with($self->method_metaclass); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 160 | $self->add_method($method_name => $method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # Restore method debug information, which can be clobbered by add_method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # Note that we handle this here instead of in add_method, because we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # only want to preserve the original debug info in cases where we are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # restoring a method, not overwriting a method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 160 | ▶ | if ($debugger_enabled && $debug_method_info) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$debugger_enabled and $debug_method_info
MC/DC50%1/2
$debugger_enabled and $debug_method_info
$debugger_enabled
$debug_method_info
Truth table66%2/3
A and B
A= $debugger_enabledB= $debug_method_info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 8 | $DB::sub{$package_name . "::" . $method_name} = $debug_method_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1588 | ▶ | sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_package_cache_flag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 182515 | ▶ | sub update_package_cache_flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_package_cache_flag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 182515 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # we can manually update the cache number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # since we are actually adding the method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # to our cache as well. This avoids us | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # having to regenerate the method_map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # - SL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 182515 | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 8029 | ▶ | sub _full_method_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_full_method_map: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 8029 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 8029 | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 8029 | ▶ | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{'_package_cache_flag_full'} || -1
MC/DC100%1/1
$self->{'_package_cache_flag_full'} || -1
$self->{'_package_cache_flag_full'}
Truth table100%2/2
A
A= $self->{'_package_cache_flag_full'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # forcibly reify all method map entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | $self->get_method($_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3467 | for $self->list_all_package_symbols('CODE'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3467 | $self->{_package_cache_flag_full} = $pkg_gen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 8029 | return $self->_method_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 459 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # ABSTRACT: Methods for metaclasses which have methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||