| 1 | package MOP4Import::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 23 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 23 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 23 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 23 | ▶ | use Exporter qw/import/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 23 | ▶ | use Sub::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 23 | ▶ | use constant DEBUG => $ENV{DEBUG_MOP4IMPORT}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 23 | ▶ | print STDERR "Using (file '" . __FILE__ . "')\n" if DEBUG and DEBUG >= 2 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | sub globref { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 6287 | ▶ | my $pack = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
globref: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 6287 | ▶ | unless (defined $pack) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | Carp::croak "undef is given to globref()"; | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 6287 | my $symname = join("::", $pack, @_); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 23 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 6287 | \*{$symname}; | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | sub symtab { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 662 | *{globref(shift, '')}{HASH} | |||||||||||||||||||||||||||||||||||||||||
| 29 | 662 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symtab: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | sub maybe_symtab { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 91 | ▶ | my ($pack) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maybe_symtab: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 91 | ▶ | my @name = split /::/, $pack | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 91 | ▶ | shift @name if $name[0] eq ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 91 | my $symtab = \%::; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 91 | foreach my $name (@name) { | |||||||||||||||||||||||||||||||||||||||||
| 38 | 151 | ▶ | my $glob = $symtab->{$name . "::"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 149 | $symtab = *{$glob}{HASH} | |||||||||||||||||||||||||||||||||||||||||
| 41 | 149 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 89 | $symtab; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | sub safe_globref { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 203 | ▶ | my ($pack_or_obj, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
safe_globref: called CC=3 SCAR=16.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 203 | ▶ | unless (defined symtab($pack_or_obj)->{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $pack = ref $pack_or_obj || $pack_or_obj; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $pack_or_obj || $pack_or_obj
MC/DC0%0/2
ref $pack_or_obj || $pack_or_obj
ref $pack_or_obj
$pack_or_obj
Truth table0%0/3
A || B
A= ref $pack_or_objB= $pack_or_obj
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | croak "No such symbol '$name' in package $pack"; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 203 | globref($pack_or_obj, $name); | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | sub maybe_globref { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 32 | ▶ | my ($pack_or_obj, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maybe_globref: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 32 | ▶ | unless (defined symtab($pack_or_obj)->{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 32 | globref($pack_or_obj, $name); | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | sub fields_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 1912 | ▶ | my $sym = fields_symbol(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | # XXX: return \%{*$sym}; # If we use this, we get "used only once" warning. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 1912 | ensure_symbol_has_hash($sym); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | sub maybe_fields_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 32 | ▶ | my $sym = maybe_globref($_[0], 'FIELDS') | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maybe_fields_hash: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 32 | *{$sym}{HASH}; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | sub safe_fields_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | my $sym = safe_globref($_[0], 'FIELDS'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
safe_fields_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | ensure_symbol_has_hash($sym); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | sub fields_array { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 1115 | ▶ | my $sym = fields_symbol(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields_array: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1115 | ensure_symbol_has_array($sym); | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | sub fields_symbol { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 3042 | ▶ | globref(ref $_[0] || $_[0], 'FIELDS'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields_symbol: called CC=2 SCAR=7.2
Pod
undocumented
Condition66%2/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table66%2/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # Just lock_keys with fields_hash | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # | ||||||||||||||||||||||||||||||||||||||||||
| 92 | sub lock_keys_as { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | my ($myPack, $typeName, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lock_keys_as: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | require Hash::Util; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | $hash //= +{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$hash //= {}
MC/DC0%0/1
$hash //= {}
$hash
Truth table50%1/2
A
A= $hash
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | if (ref $typeName) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | Carp::croak "Typename must be a package name: " | |||||||||||||||||||||||||||||||||||||||||
| 98 | . terse_dump($typeName); | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | my $fields = safe_fields_hash($typeName); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | if (not Hash::Util::hashref_locked($hash)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | Hash::Util::lock_ref_keys($hash, keys %$fields); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | if (my @unk = grep {not exists $fields->{$_}} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | Hash::Util::legal_ref_keys($hash)) { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | Carp::croak "HASH contains illegal keys wrt type $typeName: " | |||||||||||||||||||||||||||||||||||||||||
| 107 | . join(" ", sort @unk); | ||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # OK; | ||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | $hash; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | sub isa_array { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 278 | ▶ | my $sym = globref($_[0], 'ISA'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa_array: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 278 | ensure_symbol_has_array($sym); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | sub ensure_symbol_has_array { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 1455 | ▶ | my ($sym) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_symbol_has_array: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1455 | ▶ | unless (*{$sym}{ARRAY}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 330 | *$sym = []; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 1455 | *{$sym}{ARRAY}; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | sub ensure_symbol_has_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 1914 | ▶ | my ($sym) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_symbol_has_hash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 1914 | ▶ | unless (*{$sym}{HASH}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 240 | *$sym = {}; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 1914 | *{$sym}{HASH}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | sub define_constant { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 452 | ▶ | my ($name_or_glob, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
define_constant: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 452 | ▶ | my $glob = ref $name_or_glob ? $name_or_glob : globref($name_or_glob); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 452 | ▶ | *$glob = my $const_sub = sub () { $value }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 452 | $const_sub; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | # MOP4Import::Util::extract_fields_as(BASE_CLASS => $obj) | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # => returns name, value pairs found in BASE_CLASS and defined in $obj. | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # Note: this only extracts fields starting with [a-z]. | ||||||||||||||||||||||||||||||||||||||||||
| 145 | sub extract_fields_as ($$) { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | my ($asPack, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_fields_as: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | my $fields = fields_hash($asPack); | |||||||||||||||||||||||||||||||||||||||||
| 148 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | if (/^[a-z]/ and defined $obj->{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
/^[a-z]/ and defined $obj->{$_}
MC/DC0%0/2
/^[a-z]/ and defined $obj->{$_}
/^[a-z]/
defined $obj->{$_}
Truth table33%1/3
A and B
A= /^[a-z]/B= defined $obj->{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 8 | ($_ => $obj->{$_}) | |||||||||||||||||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 152 | () | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 154 | } keys %$fields | ||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | # | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # For (shallow) copy constructor. | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # | ||||||||||||||||||||||||||||||||||||||||||
| 160 | sub shallow_copy { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 693 | ▶ | if (ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shallow_copy: called CC=6 SCAR=24.2
Pod
undocumented
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | +{%{$_[0]}}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } elsif (ref $_[0] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 18 | +[@{$_[0]}]; | |||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | } elsif (ref $_[0] eq 'Regexp' | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_[0] eq "Regexp" or not ref $_[0]
MC/DC0%0/2
ref $_[0] eq "Regexp" or not ref $_[0]
ref $_[0] eq "Regexp"
not ref $_[0]
Truth table33%1/3
A or not(B)
A= ref $_[0] eq "Regexp"B= not ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | or not ref $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 675 | my $copy = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } elsif ($_[1]) { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # Pass thru unknown refs if 2nd arg is true. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | croak "Unsupported data type for shallow_copy: " . ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | # | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # Expand given item as list. | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # | ||||||||||||||||||||||||||||||||||||||||||
| 179 | sub lexpand { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 105 | ▶ | if (not defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lexpand: called CC=3 SCAR=11.0
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | return | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | } elsif (ref $_[0] eq 'ARRAY') { | |||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | @{$_[0]} | |||||||||||||||||||||||||||||||||||||||||
| 184 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 102 | $_[0] | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | sub terse_dump { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | join ", ", map { | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 61 | ▶ | Data::Dumper->new([$_])->Terse(1)->Indent(0)->Dump; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
terse_dump: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | } @_; | ||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | # | ||||||||||||||||||||||||||||||||||||||||||
| 196 | # This may be useful to parse/take subcommand option/hash. | ||||||||||||||||||||||||||||||||||||||||||
| 197 | # | ||||||||||||||||||||||||||||||||||||||||||
| 198 | sub take_hash_opts_maybe { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | ▶ | my ($pack, $list, $result, $alias) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
take_hash_opts_maybe: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | if (@$list and ref $list->[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$list and ref $list->[0] eq "HASH"
MC/DC100%2/2
@$list and ref $list->[0] eq "HASH"
@$list
ref $list->[0] eq "HASH"
Truth table100%3/3
A and B
A= @$listB= ref $list->[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | # If first element of $list is HASH, take it. | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | shift @$list; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | # Otherwise, take --posix_style=options. | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | $pack->parse_opts($list, $result, $alias); | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | sub take_locked_opts_of { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | ▶ | my ($myPack, $typeName, $list, $alias, $sink) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
take_locked_opts_of: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | $myPack->lock_keys_as($typeName, scalar take_hash_opts_maybe( | |||||||||||||||||||||||||||||||||||||||||
| 215 | $myPack, | ||||||||||||||||||||||||||||||||||||||||||
| 216 | $list, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | $sink, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | $alias, | ||||||||||||||||||||||||||||||||||||||||||
| 219 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | # | ||||||||||||||||||||||||||||||||||||||||||
| 223 | # posix_style long option. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | # | ||||||||||||||||||||||||||||||||||||||||||
| 225 | sub parse_opts { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 148 | ▶ | my ($pack, $list, $result, $alias, $converter, %opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_opts: called CC=21 SCAR=30.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 148 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 148 | ▶ | unless (defined $result) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 42 | ▶ | $result = $wantarray ? [] : {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 148 | ▶ | my $preserve_hyphen = delete $opts{preserve_hyphen} // do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
delete $opts{"preserve_hyphen"} // do {
my $sub = $pack->can("parse_opts__preserve_hyphen");
$sub and &$sub($pack)
}
MC/DC100%2/2
delete $opts{"preserve_hyphen"} // do {
my $sub = $pack->can("parse_opts__preserve_hyphen");
$sub and &$sub($pack)
}
delete $opts{"preserve_hyphen"}
do {
my $sub = $pack->can("parse_opts__preserve_hyphen");
$sub and &$sub($pack)
}
Truth table100%3/3
A // B
A= delete $opts{"preserve_hyphen"}B= do {
my $sub = $pack->can("parse_opts__preserve_hyphen");
$sub and &$sub($pack)
}
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 147 | my $sub = $pack->can("parse_opts__preserve_hyphen"); | |||||||||||||||||||||||||||||||||||||||||
| 233 | 147 | ▶ | $sub && $sub->($pack); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 148 | ▶ | if (keys %opts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | Carp::croak("Unknown option for parse_opts(): ".join(", ", keys %opts)); | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 147 | ▶ | while (@$list and defined $list->[0] and my ($n, $v) = $list->[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@$list and defined $list->[0] and () = $list->[0] =~ /^--$ | ^(?:--? ([\w:\-\.]+) (?: =(.*))?)$/sx
@$list and defined $list->[0]
MC/DC100%3/3
@$list and defined $list->[0] and () = $list->[0] =~ /^--$ | ^(?:--? ([\w:\-\.]+) (?: =(.*))?)$/sx
@$list
defined $list->[0]
() = $list->[0] =~ /^--$ | ^(?:--? ([\w:\-\.]+) (?: =(.*))?)$/sx
Truth table100%4/4
A and B and C
A= @$listB= defined $list->[0]C= () = $list->[0] =~ /^--$ | ^(?:--? ([\w:\-\.]+) (?: =(.*))?)$/sx
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | =~ m{^--$ | ^(?:--? ([\w:\-\.]+) (?: =(.*))?)$}xs) { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 168 | shift @$list; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 168 | ▶ | last unless defined $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 166 | ▶ | $n =~ s/-/_/g unless $preserve_hyphen; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 166 | ▶ | $n = $alias->{$n} if $alias and $alias->{$n}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$alias and $alias->{$n}
MC/DC100%2/2
$alias and $alias->{$n}
$alias
$alias->{$n}
Truth table100%3/3
A and B
A= $aliasB= $alias->{$n}
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 166 | ▶ | $v = 1 unless defined $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 166 | ▶ | if (ref $result eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | ▶ | $result->{$n} = $converter ? $converter->($v) : $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 158 | ▶ | push @$result, $n, $converter ? $converter->($v) : $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 147 | ▶ | if ($converter) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 24 | $_ = $converter->($_) for @$list; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 147 | ▶ | $wantarray && ref $result ne 'HASH' ? @$result : $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$wantarray and ref $result ne "HASH"
MC/DC100%2/2
$wantarray and ref $result ne "HASH"
$wantarray
ref $result ne "HASH"
Truth table100%3/3
A and B
A= $wantarrayB= ref $result ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | # | ||||||||||||||||||||||||||||||||||||||||||
| 258 | # posix_style long option with JSON support. | ||||||||||||||||||||||||||||||||||||||||||
| 259 | # | ||||||||||||||||||||||||||||||||||||||||||
| 260 | sub parse_json_opts { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 24 | ▶ | my ($pack, $list, $result, $alias) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_json_opts: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 24 | require JSON::MaybeXS; | |||||||||||||||||||||||||||||||||||||||||
| 263 | parse_opts($pack, $list, $result, $alias, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 112 | ▶ | if (not defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.1
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | undef | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 8 | } elsif ($_[0] =~ /^(?:\[.*?\]|\{.*?\})\z/s) { | |||||||||||||||||||||||||||||||||||||||||
| 267 | # Arguments might be already decoded. | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 32 | my $copy = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 32 | ▶ | Encode::_utf8_off($copy) if Encode::is_utf8($copy); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 32 | JSON::MaybeXS::JSON()->new->utf8->relaxed->decode($copy); | |||||||||||||||||||||||||||||||||||||||||
| 271 | ▶ | } elsif (not Encode::is_utf8($_[0]) and $_[0] =~ /\P{ASCII}/) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
not &Encode::is_utf8($_[0]) and $_[0] =~ /\P{ASCII}/
MC/DC0%0/2
not &Encode::is_utf8($_[0]) and $_[0] =~ /\P{ASCII}/
not &Encode::is_utf8($_[0])
$_[0] =~ /\P{ASCII}/
Truth table33%1/3
not(A) and B
A= not &Encode::is_utf8($_[0])B= $_[0] =~ /\P{ASCII}/
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | Encode::decode(utf8 => $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 273 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 72 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 24 | }); | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | # | ||||||||||||||||||||||||||||||||||||||||||
| 280 | # make style KEY=VALUE list | ||||||||||||||||||||||||||||||||||||||||||
| 281 | # | ||||||||||||||||||||||||||||||||||||||||||
| 282 | sub parse_pairlist { | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 6 | ▶ | my ($pack, $aref, $do_box) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_pairlist: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 6 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 6 | ▶ | while (@$aref and defined $aref->[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@$aref and defined $aref->[0] and $aref->[0] =~ /^([\w:\-\.]+)=(.*)/
@$aref and defined $aref->[0]
MC/DC100%3/3
@$aref and defined $aref->[0] and $aref->[0] =~ /^([\w:\-\.]+)=(.*)/
@$aref
defined $aref->[0]
$aref->[0] =~ /^([\w:\-\.]+)=(.*)/
Truth table100%4/4
A and B and C
A= @$arefB= defined $aref->[0]C= $aref->[0] =~ /^([\w:\-\.]+)=(.*)/
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | and $aref->[0] =~ /^([\w:\-\.]+)=(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 6 | my $item = shift @$aref; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 6 | ▶ | push @res, $do_box ? [$1, $2] : ($1, $2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 6 | @res; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | sub function_names { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 67 | ▶ | my (%opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
function_names: called CC=15 SCAR=28.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 67 | ▶ | my $packname = delete $opts{from} // caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $opts{"from"} // caller
MC/DC0%0/2
delete $opts{"from"} // caller
delete $opts{"from"}
caller
Truth table66%2/3
A // B
A= delete $opts{"from"}B= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 67 | ▶ | my $pattern = delete $opts{matching} || qr{^[A-Za-z]\w+$}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $opts{'matching'} || qr/^[A-Za-z]\w+$/
MC/DC0%0/2
delete $opts{'matching'} || qr/^[A-Za-z]\w+$/
delete $opts{'matching'}
qr/^[A-Za-z]\w+$/
Truth table66%2/3
A || B
A= delete $opts{'matching'}B= qr/^[A-Za-z]\w+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 67 | ▶ | my $except = delete $opts{except} // qr{^import$}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $opts{"except"} // qr/^import$/
MC/DC0%0/2
delete $opts{"except"} // qr/^import$/
delete $opts{"except"}
qr/^import$/
Truth table66%2/3
A // B
A= delete $opts{"except"}B= qr/^import$/
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 67 | my $grep = delete $opts{grep}; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 67 | ▶ | if (keys %opts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | croak "Unknown arguments: ".join(", ", keys %opts); | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 67 | my $symtab = *{globref($packname, '')}{HASH}; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 67 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 67 | foreach (sort keys %$symtab) { | |||||||||||||||||||||||||||||||||||||||||
| 305 | 2353 | my $item = $symtab->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | defined (my $code = ref $item eq 'CODE' ? $item : | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 2286 | ref \$item eq 'GLOB' ? *{$item}{CODE} : undef) | |||||||||||||||||||||||||||||||||||||||||
| 308 | 2353 | ▶ | or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 1993 | my $realName = Sub::Util::subname($code); | |||||||||||||||||||||||||||||||||||||||||
| 310 | 1993 | my ($stash) = $realName =~ m/^(.+)::(.*?)$/; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 1993 | ▶ | next unless $stash eq $packname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 1459 | ▶ | next unless $_ =~ $pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 1063 | ▶ | next if $except and $_ =~ $except; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$except and $_ =~ /$except/
MC/DC0%0/2
$except and $_ =~ /$except/
$except
$_ =~ /$except/
Truth table33%1/3
A and B
A= $exceptB= $_ =~ /$except/
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 1063 | ▶ | next if $grep and not $grep->($realName, $code); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$grep and not &$grep($realName, $code)
MC/DC0%0/2
$grep and not &$grep($realName, $code)
$grep
not &$grep($realName, $code)
Truth table33%1/3
A and not(B)
A= $grepB= not &$grep($realName, $code)
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 1063 | push @result, $_; | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 67 | @result; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | sub has_method_attr { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | grep {$_ eq 'method'} attributes::get($_[0]) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_method_attr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 23 | ▶ | use MOP4Import::FieldSpec qw(FieldSpec); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | sub list_validator { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ▶ | my ($typeName) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_validator: called CC=7 SCAR=21.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | ▶ | my $fields = maybe_fields_hash($typeName) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | or Carp::croak "Can't find type spec for $typeName"; | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | my $names = fields_array($typeName); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | ▶ | my @names = $names ? @$names : sort keys %$fields; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | my FieldSpec $spec = $fields->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | ▶ | if (not UNIVERSAL::isa($spec, FieldSpec)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | () | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 339 | elsif ($spec->{validator}) { | ||||||||||||||||||||||||||||||||||||||||||
| 340 | ($_ => $spec->{validator}) | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 342 | elsif ($spec->{isa}) { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 1 | ▶ | ($_ => +{isa => $spec->{isa}, (exists $spec->{default} ? (default => $spec->{default}) : ())}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | () | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 348 | } @names; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | sub m4i_log_start { | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | ▶ | my $m4i_meta = caller; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
m4i_log_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | my $m4i_dest = caller(1); | |||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | print STDERR "\n", "START of $m4i_meta->import() for $m4i_dest.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | sub m4i_log_end { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | ▶ | my ($m4i_dest) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
m4i_log_end: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 2 | my $m4i_meta = caller; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | ▶ | $m4i_dest //= caller(1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$m4i_dest //= caller 1
MC/DC0%0/2
$m4i_dest //= caller 1
$m4i_dest
caller 1
Truth table66%2/3
A //= B
A= $m4i_destB= caller 1
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | print STDERR "END of $m4i_meta->import() for $m4i_dest.\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 23 | our @EXPORT = qw/globref | |||||||||||||||||||||||||||||||||||||||||
| 367 | safe_globref | ||||||||||||||||||||||||||||||||||||||||||
| 368 | fields_hash fields_symbol lexpand terse_dump | ||||||||||||||||||||||||||||||||||||||||||
| 369 | fields_array | ||||||||||||||||||||||||||||||||||||||||||
| 370 | m4i_log_start | ||||||||||||||||||||||||||||||||||||||||||
| 371 | m4i_log_end | ||||||||||||||||||||||||||||||||||||||||||
| 372 | /; | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 23 | our @EXPORT_OK = function_names(from => __PACKAGE__ | |||||||||||||||||||||||||||||||||||||||||
| 374 | , except => qr/^(import|c\w*)$/ | ||||||||||||||||||||||||||||||||||||||||||
| 375 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 23 | 1; | |||||||||||||||||||||||||||||||||||||||||