| 1 | package Moose::Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 399 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 399 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 399 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 399 | ▶ | use Class::Load qw(is_class_loaded); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 399 | ▶ | use Class::MOP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 399 | ▶ | use List::Util 1.45 qw( uniq ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 399 | ▶ | use Moose::Util::MetaRole; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 399 | ▶ | use Scalar::Util 1.40 qw(reftype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 399 | ▶ | use Sub::Exporter 0.980; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 399 | ▶ | use Sub::Util 1.40 qw(set_subname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 399 | ▶ | use Moose::Util 'throw_exception'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 399 | my %EXPORT_SPEC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1111 | ▶ | sub setup_import_methods { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_import_methods: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1111 | my ( $class, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1111 | ▶ | $args{exporting_package} ||= caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{"exporting_package"} ||= caller()
MC/DC0%0/2
$args{"exporting_package"} ||= caller()
$args{"exporting_package"}
caller()
Truth table66%2/3
A ||= B
A= $args{"exporting_package"}B= caller()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1111 | $class->build_import_methods( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | %args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | install => [qw(import unimport init_meta)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # A reminder to intrepid Moose hackers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # there may be more than one level of exporter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # don't make doy cry. -- perigrin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1113 | ▶ | sub build_import_methods { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_import_methods: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1113 | my ( $class, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1113 | ▶ | my $exporting_package = $args{exporting_package} ||= caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{"exporting_package"} ||= caller()
MC/DC0%0/2
$args{"exporting_package"} ||= caller()
$args{"exporting_package"}
caller()
Truth table66%2/3
A ||= B
A= $args{"exporting_package"}B= caller()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1113 | ▶ | my $meta_lookup = $args{meta_lookup} || sub { Class::MOP::class_of(shift) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Condition66%2/3
$args{'meta_lookup'} || sub {
Class::MOP::class_of(shift());
}
MC/DC0%0/2
$args{'meta_lookup'} || sub {
Class::MOP::class_of(shift());
}
$args{'meta_lookup'}
sub {
Class::MOP::class_of(shift());
}
Truth table66%2/3
A || B
A= $args{'meta_lookup'}B= sub {
Class::MOP::class_of(shift());
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1113 | $EXPORT_SPEC{$exporting_package} = \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1113 | my @exports_from = $class->_follow_also($exporting_package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1107 | my $export_recorder = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1107 | my $is_reexport = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | my $exports = $class->_make_sub_exporter_params( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | [ $exporting_package, @exports_from ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | $export_recorder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $is_reexport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | $args{meta_lookup}, # so that we don't pass through the default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1107 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1106 | my $exporter = $class->_make_exporter( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $exports, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $is_reexport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | $meta_lookup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1106 | my %methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1106 | $methods{import} = $class->_make_import_sub( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | $exporting_package, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | $exporter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | \@exports_from, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | $is_reexport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $meta_lookup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1106 | $methods{unimport} = $class->_make_unimport_sub( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | $exporting_package, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $exports, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | $export_recorder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | $is_reexport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $meta_lookup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1106 | $methods{init_meta} = $class->_make_init_meta( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $exporting_package, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | \%args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | $meta_lookup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1106 | my $package = Class::MOP::Package->initialize($exporting_package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1106 | ▶ | for my $to_install ( @{ $args{install} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'install'} || []
MC/DC0%0/1
$args{'install'} || []
$args{'install'}
Truth table50%1/2
A
A= $args{'install'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3316 | my $symbol = '&' . $to_install; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 3316 | ▶ | unless $methods{$to_install} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$methods{$to_install} and not $package->has_package_symbol($symbol)
MC/DC50%1/2
$methods{$to_install} and not $package->has_package_symbol($symbol)
$methods{$to_install}
not $package->has_package_symbol($symbol)
Truth table66%2/3
A and not(B)
A= $methods{$to_install}B= not $package->has_package_symbol($symbol)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | && !$package->has_package_symbol($symbol); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $package->add_package_symbol( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | $symbol, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | set_subname( $exporting_package . '::' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2219 | . $to_install => $methods{$to_install} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1106 | return ( $methods{import}, $methods{unimport}, $methods{init_meta} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1106 | ▶ | sub _make_exporter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_exporter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1106 | my ($class, $exports, $is_reexport, $meta_lookup) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | return Sub::Exporter::build_exporter( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | exports => $exports, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | groups => { default => [':all'] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 3639 | ▶ | installer => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 3639 | my ($arg, $to_export) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3639 | my $meta = $meta_lookup->($arg->{into}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3639 | ▶ | goto &Sub::Exporter::default_installer unless $meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # don't overwrite existing symbols with our magically flagged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # version of it if we would install the same sub that's already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # in the importer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2930 | my @filtered_to_export; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | my %installed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2930 | ▶ | for (my $i = 0; $i < @{ $to_export }; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 38124 | my ($as, $cv) = @{ $to_export }[$i, $i + 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 38121 | ▶ | next if !ref($as) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not ref $as and $meta->has_package_symbol('&' . $as) and $meta->get_package_symbol('&' . $as) == $cv
not ref $as and $meta->has_package_symbol('&' . $as)
MC/DC100%3/3
not ref $as and $meta->has_package_symbol('&' . $as) and $meta->get_package_symbol('&' . $as) == $cv
not ref $as
$meta->has_package_symbol('&' . $as)
$meta->get_package_symbol('&' . $as) == $cv
Truth table100%4/4
not(A) and B and C
A= not ref $asB= $meta->has_package_symbol('&' . $as)C= $meta->get_package_symbol('&' . $as) == $cv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | && $meta->has_package_symbol('&' . $as) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | && $meta->get_package_symbol('&' . $as) == $cv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 37678 | push @filtered_to_export, $as, $cv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 37678 | ▶ | $installed{$as} = 1 unless ref $as; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2965 | Sub::Exporter::default_installer($arg, \@filtered_to_export); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2930 | for my $name ( keys %{$is_reexport} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 399 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 399 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5627 | ▶ | next unless exists $installed{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 5391 | _flag_as_reexport( \*{ join q{::}, $arg->{into}, $name } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 1106 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1113 | ▶ | sub _follow_also { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_follow_also: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1119 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1113 | my $exporting_package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1113 | _die_if_cycle_found_in_also_list_for_package($exporting_package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1107 | return uniq( _follow_also_real($exporting_package) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1185 | ▶ | sub _follow_also_real { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_follow_also_real: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1185 | my $exporting_package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1185 | my @also = _also_list_for_package($exporting_package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1185 | return map { $_, _follow_also_real($_) } @also; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2382 | ▶ | sub _also_list_for_package { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_also_list_for_package: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2382 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2382 | ▶ | if ( !exists $EXPORT_SPEC{$package} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | my $loaded = is_class_loaded($package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | throw_exception( PackageDoesNotUseMooseExporter => package => $package, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | is_loaded => $loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2379 | my $also = $EXPORT_SPEC{$package}{also}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2379 | ▶ | return unless defined $also; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 132 | ▶ | return ref $also ? @$also : $also; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # this is no Tarjan algorithm, but for the list sizes expected, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # brute force will probably be fine (and more maintainable) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1113 | ▶ | sub _die_if_cycle_found_in_also_list_for_package { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_die_if_cycle_found_in_also_list_for_package: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1113 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1113 | _die_if_also_list_cycles_back_to_existing_stack( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | [ _also_list_for_package($package) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | [$package], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1194 | ▶ | sub _die_if_also_list_cycles_back_to_existing_stack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_die_if_also_list_cycles_back_to_existing_stack: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1194 | my ( $also_list, $existing_stack ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1194 | ▶ | return unless @$also_list && @$existing_stack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$also_list and @$existing_stack
MC/DC50%1/2
@$also_list and @$existing_stack
@$also_list
@$existing_stack
Truth table66%2/3
A and B
A= @$also_listB= @$existing_stack
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 69 | for my $also_member (@$also_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 87 | for my $stack_member (@$existing_stack) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 121 | ▶ | next unless $also_member eq $stack_member; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | throw_exception( CircularReferenceInAlso => also_parameter => $also_member, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | stack => $existing_stack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | _die_if_also_list_cycles_back_to_existing_stack( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 84 | [ _also_list_for_package($also_member) ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | [ $also_member, @$existing_stack ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1167 | ▶ | sub _parse_trait_aliases { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_trait_aliases: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1167 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1167 | my ($package, $aliases) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1167 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1167 | for my $alias (@$aliases) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | my $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | ▶ | if (ref($alias)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | reftype($alias) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | or throw_exception( InvalidArgumentsToTraitAliases => class_name => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | package_name => $package, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | alias => $alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ($alias, $name) = @$alias; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ($name = $alias) =~ s/.*:://; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | ▶ | push @ret, set_subname( "${package}::${name}" => sub () {$alias} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1166 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1107 | ▶ | sub _make_sub_exporter_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_sub_exporter_params: called CC=19 SCAR=29.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1107 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1107 | my $packages = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1107 | my $export_recorder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1107 | my $is_reexport = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1107 | my $meta_lookup_override = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1107 | my %exports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | my $current_meta_lookup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1107 | for my $package ( @{$packages} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1167 | ▶ | my $args = $EXPORT_SPEC{$package} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | or die "The $package package does not use Moose::Exporter\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1167 | ▶ | $current_meta_lookup = $meta_lookup_override || $args->{meta_lookup}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$meta_lookup_override || $args->{'meta_lookup'}
MC/DC100%2/2
$meta_lookup_override || $args->{'meta_lookup'}
$meta_lookup_override
$args->{'meta_lookup'}
Truth table100%3/3
A || B
A= $meta_lookup_overrideB= $args->{'meta_lookup'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1167 | $meta_lookup_override = $current_meta_lookup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | my $meta_lookup = $current_meta_lookup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1167 | ▶ | || sub { Class::MOP::class_of(shift) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Condition66%2/3
$current_meta_lookup || sub {
Class::MOP::class_of(shift());
}
MC/DC0%0/2
$current_meta_lookup || sub {
Class::MOP::class_of(shift());
}
$current_meta_lookup
sub {
Class::MOP::class_of(shift());
}
Truth table66%2/3
A || B
A= $current_meta_lookupB= sub {
Class::MOP::class_of(shift());
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1167 | for my $name ( @{ $args->{with_meta} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 5582 | ▶ | my $sub = $class->_sub_from_package( $package, $name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 5594 | my $fq_name = $package . '::' . $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | $exports{$name} = $class->_make_wrapped_sub_with_meta( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | $fq_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | $sub, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | $export_recorder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | $meta_lookup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 5594 | ▶ | ) unless exists $exports{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1180 | for my $name ( @{ $args->{with_caller} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | ▶ | my $sub = $class->_sub_from_package( $package, $name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | my $fq_name = $package . '::' . $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | $exports{$name} = $class->_make_wrapped_sub( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | $fq_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | $sub, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | $export_recorder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | ▶ | ) unless exists $exports{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | my @extra_exports = $class->_parse_trait_aliases( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | $package, $args->{trait_aliases}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1164 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1166 | for my $name ( @{ $args->{as_is} }, @extra_exports ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 10472 | my ( $sub, $coderef_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 10497 | ▶ | if ( ref $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 31 | $sub = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | my $coderef_pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | ( $coderef_pkg, $coderef_name ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | = Class::MOP::get_code_info($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | ▶ | if ( $coderef_pkg ne $package ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $is_reexport->{$coderef_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | elsif ( $name =~ /^(.*)::([^:]+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1385 | ▶ | $sub = $class->_sub_from_package( "$1", "$2" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1389 | $coderef_name = "$2"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1389 | ▶ | if ( $1 ne $package ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1389 | $is_reexport->{$coderef_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 9085 | ▶ | $sub = $class->_sub_from_package( $package, $name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 9105 | $coderef_name = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 10493 | $export_recorder->{$sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 28325 | ▶ | $exports{$coderef_name} = sub { $sub } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 10497 | ▶ | unless exists $exports{$coderef_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1131 | return \%exports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 16091 | ▶ | sub _sub_from_package { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sub_from_package: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 16091 | my $sclass = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 16091 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 16091 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 16091 | my $sub = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 399 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 16091 | \&{ $package . '::' . $name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 16091 | ▶ | return $sub if defined &$sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | Carp::cluck "Trying to export undefined sub ${package}::${name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 399 | our $CALLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | ▶ | sub _make_wrapped_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_wrapped_sub: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | my $fq_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | my $sub = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | my $export_recorder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # We need to set the package at import time, so that when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # package Foo imports has(), we capture "Foo" as the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # package. This lets other packages call Foo::has() and get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # the right package. This is done for backwards compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # with existing production code, not because this is a good | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # idea ;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | my $caller = $CALLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | my $sub = set_subname( $fq_name => $wrapper ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | $export_recorder->{$sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 2 | return $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 5577 | ▶ | sub _make_wrapped_sub_with_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_wrapped_sub_with_meta: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 5577 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 5577 | my $fq_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 5577 | my $sub = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5577 | my $export_recorder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 5577 | my $meta_lookup = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 22523 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 22523 | my $caller = $CALLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 22523 | my $wrapper = $self->_late_curry_wrapper( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | $sub, $fq_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | $meta_lookup => $caller | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 22523 | my $sub = set_subname( $fq_name => $wrapper ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 22523 | $export_recorder->{$sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 22523 | return $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 5577 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | ▶ | sub _curry_wrapper { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_curry_wrapper: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 2 | my $sub = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | my $fq_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 2 | my @extra = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 2 | ▶ | my $wrapper = sub { $sub->( @extra, @_ ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 2 | ▶ | if ( my $proto = prototype $sub ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # ignore the fact that we're passing "private variables" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | &Scalar::Util::set_prototype( $wrapper, $proto ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 2 | return $wrapper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 22523 | ▶ | sub _late_curry_wrapper { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_late_curry_wrapper: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 22523 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 22523 | my $sub = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 22523 | my $fq_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 22523 | my $extra = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 22523 | my @ex_args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 388 | ▶ | my $wrapper = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has: called CC=1 SCAR=0.0
Subroutine
augment: called CC=1 SCAR=0.0
Pod
documented
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # resolve curried arguments at runtime via this closure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 388 | my @curry = ( $extra->(@ex_args) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 388 | return $sub->( @curry, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 22523 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 22523 | ▶ | if ( my $proto = prototype $sub ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # ignore the fact that we're passing "private variables" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | &Scalar::Util::set_prototype( $wrapper, $proto ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 22523 | return $wrapper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 1106 | ▶ | sub _make_import_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_import_sub: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 1106 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1106 | my $exporting_package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1106 | my $exporter = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 1106 | my $exports_from = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1106 | my $is_reexport = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1106 | my $meta_lookup = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2760 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=11 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # I think we could use Sub::Exporter's collector feature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # to do this, but that would be rather gross, since that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # feature isn't really designed to return a value to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # caller of the exporter sub. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # Also, this makes sure we preserve backwards compat for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # _get_caller, so it always sees the arguments in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # expected order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 2760 | my $traits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2760 | ( $traits, @_ ) = _strip_traits(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2760 | my $metaclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2760 | ( $metaclass, @_ ) = _strip_metaclass(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 2760 | ▶ | $metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
defined $metaclass and length $metaclass
defined $metaclass and length $metaclass
MC/DC50%1/2
defined $metaclass and length $metaclass
defined $metaclass
length $metaclass
MC/DC50%1/2
defined $metaclass and length $metaclass
defined $metaclass
length $metaclass
Truth table66%2/3
A and B
A= defined $metaclassB= length $metaclass
Truth table66%2/3
A and B
A= defined $metaclassB= length $metaclass
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | if defined $metaclass && length $metaclass; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 2760 | my $meta_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2760 | ( $meta_name, @_ ) = _strip_meta_name(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # Normally we could look at $_[0], but in some weird cases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # (involving goto &Moose::import), $_[0] ends as something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # else (like Squirrel). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 2760 | my $class = $exporting_package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 2760 | $CALLER = _get_caller(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # this works because both pragmas set $^H (see perldoc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # perlvar) which affects the current compilation - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # i.e. the file who use'd us - which is why we don't need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # to do anything special to make it affect that file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # rather than this one (which is already compiled) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 2760 | strict->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 2760 | warnings->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 2760 | my $did_init_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # init_meta can apply a role, which when loaded uses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # to protect against that. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | local $CALLER = $CALLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 2169 | $c->init_meta( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | for_class => $CALLER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | metaclass => $metaclass, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | meta_name => $meta_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 2166 | $did_init_meta = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # The metaroles will use Moose::Role, which in turn uses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # to protect against that. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 2757 | local $CALLER = $CALLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2757 | _apply_metaroles( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | $CALLER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | [$class, @$exports_from], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | $meta_lookup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2757 | ▶ | if ( $did_init_meta && @{$traits} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition83%5/6
$did_init_meta and @{$traits;}
$did_init_meta and @{$traits;}
MC/DC100%2/2
$did_init_meta and @{$traits;}
$did_init_meta
@{$traits;}
MC/DC0%0/2
$did_init_meta and @{$traits;}
$did_init_meta
@{$traits;}
Truth table100%3/3
A and B
A= $did_init_metaB= @{$traits;}
Truth table66%2/3
A and B
A= $did_init_metaB= @{$traits;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # The traits will use Moose::Role, which in turn uses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # to protect against that. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 38 | local $CALLER = $CALLER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 38 | _apply_meta_traits( $CALLER, $traits, $meta_lookup ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 2719 | elsif ( @{$traits} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 2 | throw_exception( ClassDoesNotHaveInitMeta => class_name => $class, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | traits => $traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 2754 | my ( undef, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 2754 | ▶ | my $extra = shift @args if ref $args[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 2754 | ▶ | $extra ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$extra ||= {}
$extra ||= {}
MC/DC100%1/1
$extra ||= {}
$extra
MC/DC100%1/1
$extra ||= {}
$extra
Truth table100%2/2
A
A= $extra
Truth table100%2/2
A
A= $extra
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 2754 | ▶ | if ( !$extra->{into} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 2754 | ▶ | $extra->{into_level} ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$extra->{"into_level"} ||= 0
$extra->{"into_level"} ||= 0
MC/DC100%1/1
$extra->{"into_level"} ||= 0
$extra->{"into_level"}
MC/DC0%0/1
$extra->{"into_level"} ||= 0
$extra->{"into_level"}
Truth table100%2/2
A
A= $extra->{"into_level"}
Truth table50%1/2
A
A= $extra->{"into_level"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 2754 | $extra->{into_level}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 2754 | $class->$exporter( $extra, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 1106 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 10935 | ▶ | sub _strip_option { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_option: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 10935 | my $option_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 10935 | my $default = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 10935 | for my $i ( 0 .. $#_ - 1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 185 | ▶ | if (($_[$i] || '') eq $option_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$_[$i] || ''
MC/DC0%0/1
$_[$i] || ''
$_[$i]
Truth table50%1/2
A
A= $_[$i]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 54 | (undef, my $value) = splice @_, $i, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 54 | return ( $value, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 10881 | return ( $default, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 3645 | ▶ | sub _strip_traits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_traits: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 3645 | my ($traits, @other) = _strip_option('-traits', [], @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 3645 | ▶ | $traits = ref $traits ? $traits : [ $traits ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 3645 | return ( $traits, @other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 3645 | ▶ | sub _strip_metaclass { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_metaclass: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 3645 | _strip_option('-metaclass', undef, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 3645 | ▶ | sub _strip_meta_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_meta_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 3645 | _strip_option('-meta_name', 'meta', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 3642 | ▶ | sub _apply_metaroles { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_metaroles: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 3642 | my ($class, $exports_from, $meta_lookup) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 3642 | my $metaroles = _collect_metaroles($exports_from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 3642 | my $base_class_roles = delete $metaroles->{base_class_roles}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 3642 | my $meta = $meta_lookup->($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # for instance, Moose.pm uses Moose::Util::TypeConstraints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 3642 | ▶ | return unless $meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 2931 | ▶ | Moose::Util::MetaRole::apply_metaroles( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | for => $meta, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | %$metaroles, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | ) if keys %$metaroles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 2931 | ▶ | Moose::Util::MetaRole::apply_base_class_roles( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$meta->isa("Class::MOP::Class") and $base_class_roles and @$base_class_roles
$meta->isa("Class::MOP::Class") and $base_class_roles
MC/DC66%2/3
$meta->isa("Class::MOP::Class") and $base_class_roles and @$base_class_roles
$meta->isa("Class::MOP::Class")
$base_class_roles
@$base_class_roles
Truth table75%3/4
A and B and C
A= $meta->isa("Class::MOP::Class")B= $base_class_rolesC= @$base_class_roles
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | for => $meta, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | roles => $base_class_roles, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | ) if $meta->isa('Class::MOP::Class') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | && $base_class_roles && @$base_class_roles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 3642 | ▶ | sub _collect_metaroles { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collect_metaroles: called CC=15 SCAR=27.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 3642 | my ($exports_from) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 3642 | my @old_style_role_types = map { "${_}_roles" } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | attribute_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | method_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | wrapped_method_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | instance_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | constructor_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | destructor_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | error_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 3642 | my %class_metaroles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | my %role_metaroles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 3642 | my @base_class_roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 3642 | my %old_style_roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 3642 | for my $exporter (@$exports_from) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 3676 | my $data = $EXPORT_SPEC{$exporter}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 3676 | ▶ | if (exists $data->{class_metaroles}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 13 | for my $type (keys %{ $data->{class_metaroles} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 11 | ▶ | push @{ $class_metaroles{$type} ||= [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$class_metaroles{$type} ||= []
MC/DC0%0/1
$class_metaroles{$type} ||= []
$class_metaroles{$type}
Truth table50%1/2
A
A= $class_metaroles{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 11 | @{ $data->{class_metaroles}{$type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 3671 | ▶ | if (exists $data->{role_metaroles}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 8 | for my $type (keys %{ $data->{role_metaroles} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 4 | ▶ | push @{ $role_metaroles{$type} ||= [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$role_metaroles{$type} ||= []
MC/DC0%0/1
$role_metaroles{$type} ||= []
$role_metaroles{$type}
Truth table50%1/2
A
A= $role_metaroles{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 4 | @{ $data->{role_metaroles}{$type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 3671 | ▶ | if (exists $data->{base_class_roles}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 9 | push @base_class_roles, @{ $data->{base_class_roles} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 3671 | for my $type (@old_style_role_types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 29373 | ▶ | if (exists $data->{$type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | push @{ $old_style_roles{$type} ||= [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$old_style_roles{$type} ||= []
MC/DC0%0/1
$old_style_roles{$type} ||= []
$old_style_roles{$type}
Truth table0%0/2
A
A= $old_style_roles{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | @{ $data->{$type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 3637 | ▶ | (keys(%class_metaroles) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | ? (class_metaroles => \%class_metaroles) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | (keys(%role_metaroles) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | ? (role_metaroles => \%role_metaroles) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | (@base_class_roles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | ? (base_class_roles => \@base_class_roles) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | %old_style_roles, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 38 | ▶ | sub _apply_meta_traits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_meta_traits: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 43 | my ( $class, $traits, $meta_lookup ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 38 | ▶ | return unless @{$traits}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 38 | my $meta = $meta_lookup->($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 38 | ▶ | my $type = $meta->isa('Moose::Meta::Role') ? 'Role' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | : $meta->isa('Class::MOP::Class') ? 'Class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | : confess('Cannot determine metaclass type for ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | . 'trait application. Meta isa ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | . ref $meta); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | my @resolved_traits = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 38 | ▶ | ref $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | ? $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | : Moose::Util::resolve_metatrait_alias( $type => $_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } @$traits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 38 | ▶ | return unless @resolved_traits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 38 | my %args = ( for => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 38 | ▶ | if ( $meta->isa('Moose::Meta::Role') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | $args{role_metaroles} = { role => \@resolved_traits }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 37 | $args{class_metaroles} = { class => \@resolved_traits }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 38 | Moose::Util::MetaRole::apply_metaroles(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 4272 | ▶ | sub _get_caller { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_caller: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # 1 extra level because it's called by import so there's a layer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # of indirection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 4272 | my $offset = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | : ( ref $_[1] && defined $_[1]->{into_level} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | ? caller( $offset + $_[1]->{into_level} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 4272 | ▶ | : caller($offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
ref $_[1] and defined $_[1]{"into"}
ref $_[1] and defined $_[1]{"into_level"}
MC/DC0%0/2
ref $_[1] and defined $_[1]{"into"}
ref $_[1]
defined $_[1]{"into"}
MC/DC50%1/2
ref $_[1] and defined $_[1]{"into_level"}
ref $_[1]
defined $_[1]{"into_level"}
Truth table66%2/3
A and B
A= ref $_[1]B= defined $_[1]{"into"}
Truth table66%2/3
A and B
A= ref $_[1]B= defined $_[1]{"into_level"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 1106 | ▶ | sub _make_unimport_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_unimport_sub: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 1106 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 1106 | my $exporting_package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 1106 | my $exports = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 1106 | my $export_recorder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 1106 | my $is_reexport = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 1106 | my $meta_lookup = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 485 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unimport: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 485 | my $caller = _get_caller(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | Moose::Exporter->_remove_keywords( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | $caller, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 485 | [ keys %{$exports} ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | $export_recorder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | $is_reexport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 1106 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 627 | ▶ | sub _remove_keywords { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_keywords: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 627 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 627 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 627 | my $keywords = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 627 | my $recorded_exports = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 627 | my $is_reexport = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 399 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 627 | foreach my $name ( @{$keywords} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 8886 | ▶ | if ( defined &{ $package . '::' . $name } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 8874 | my $sub = \&{ $package . '::' . $name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # make sure it is from us | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 8874 | ▶ | next unless $recorded_exports->{$sub}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 8874 | ▶ | if ( $is_reexport->{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 399 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | unless _export_is_flagged( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 1143 | ▶ | \*{ join q{::} => $package, $name } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # and if it is from us, then undef the slot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 8775 | delete ${ $package . '::' }{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | # maintain this for now for backcompat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # make sure to return a sub to install in the same circumstances as previously | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | # but this functionality now happens at the end of ->import | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1106 | ▶ | sub _make_init_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_init_meta: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 1106 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 1106 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 1106 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 1106 | my $meta_lookup = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 1106 | my %old_style_roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 1106 | for my $role ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 8848 | map {"${_}_roles"} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | attribute_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | method_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | wrapped_method_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | instance_metaclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | constructor_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | destructor_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | error_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | $old_style_roles{$role} = $args->{$role} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 8848 | ▶ | if exists $args->{$role}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 1106 | my %base_class_roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | %base_class_roles = ( roles => $args->{base_class_roles} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 1106 | ▶ | if exists $args->{base_class_roles}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 9 | my %new_style_roles = map { $_ => $args->{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 1106 | grep { exists $args->{$_} } qw( class_metaroles role_metaroles ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 1106 | ▶ | return unless %new_style_roles || %old_style_roles || %base_class_roles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
%new_style_roles or %old_style_roles or %base_class_roles
%new_style_roles or %old_style_roles
MC/DC66%2/3
%new_style_roles or %old_style_roles or %base_class_roles
%new_style_roles
%old_style_roles
%base_class_roles
Truth table75%3/4
A or B or C
A= %new_style_rolesB= %old_style_rolesC= %base_class_roles
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 4 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 4 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 4 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 4 | $meta_lookup->($opts{for_class}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1084 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 1084 | strict->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1084 | warnings->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 399 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # ABSTRACT: make an import() and unimport() just like Moose.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||