| 1 | # -*- coding: utf-8 -*- | ||||||||||||||||||||||||||||||||||||
| 2 | package MOP4Import::Declare; | ||||||||||||||||||||||||||||||||||||
| 3 | 22 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 22 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | 22 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | 22 | ▶ | our $VERSION = '0.072_001'; BEGIN {$VERSION = '0.072_001'}; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | 22 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | 22 | ▶ | use mro qw/c3/; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||
| 10 | 22 | ▶ | use constant DEBUG => $ENV{DEBUG_MOP4IMPORT}; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 11 | BEGIN { | ||||||||||||||||||||||||||||||||||||
| 12 | 22 | ▶ | print STDERR "\nUsing ".__PACKAGE__. " = $VERSION (file '" | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 13 | . __FILE__ . "')\n" | ||||||||||||||||||||||||||||||||||||
| 14 | if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||
| 17 | 22 | ▶ | use Sub::Util (); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||
| 19 | use MOP4Import::Opts | ||||||||||||||||||||||||||||||||||||
| 20 | 22 | qw/ | |||||||||||||||||||||||||||||||||||
| 21 | Opts | ||||||||||||||||||||||||||||||||||||
| 22 | m4i_args | ||||||||||||||||||||||||||||||||||||
| 23 | m4i_opts | ||||||||||||||||||||||||||||||||||||
| 24 | 22 | ▶ | /; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 25 | 22 | ▶ | use MOP4Import::Util; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 26 | 22 | ▶ | use MOP4Import::FieldSpec; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 27 | use MOP4Import::NamedCodeAttributes | ||||||||||||||||||||||||||||||||||||
| 28 | 22 | qw(MODIFY_CODE_ATTRIBUTES | |||||||||||||||||||||||||||||||||||
| 29 | FETCH_CODE_ATTRIBUTES | ||||||||||||||||||||||||||||||||||||
| 30 | /^m4i_CODE_ATTR_/ | ||||||||||||||||||||||||||||||||||||
| 31 | declare_code_attributes | ||||||||||||||||||||||||||||||||||||
| 32 | 22 | ▶ | ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||
| 34 | #======================================== | ||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||
| 36 | 22 | our %FIELDS; | |||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||
| 38 | sub import :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 39 | 223 | ▶ | my ($myPack, @decls) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||
| 41 | 223 | m4i_log_start() if DEBUG; | |||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | 223 | my Opts $opts = m4i_opts([caller]); | |||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||
| 45 | 223 | ▶ | @decls = $myPack->default_exports($opts) unless @decls; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||
| 47 | 223 | $myPack->dispatch_declare($opts, $myPack->always_exports($opts), @decls); | |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | 223 | my $tasks; | |||||||||||||||||||||||||||||||||||
| 50 | 223 | ▶ | if ($tasks = $opts->{delayed_tasks} and @$tasks) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tasks = $opts->{"delayed_tasks"} and @$tasks
MC/DC50%1/2
$tasks = $opts->{"delayed_tasks"} and @$tasks
$tasks = $opts->{"delayed_tasks"}
@$tasks
Truth table66%2/3
A and B
A= $tasks = $opts->{"delayed_tasks"}B= @$tasks
| |||||||||||||||||||||||||||||||||||||
| 51 | 26 | print STDERR " Calling delayed tasks for $opts->{destpkg}\n" if DEBUG; | |||||||||||||||||||||||||||||||||||
| 52 | 26 | $_->($opts) for @$tasks; | |||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||
| 55 | 223 | m4i_log_end($opts->{callpack}) if DEBUG; | |||||||||||||||||||||||||||||||||||
| 56 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||
| 58 | sub m4i_file_line_of :method :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | (my $myPack, my Opts $opts) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
m4i_file_line_of: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 60 | 0 | " at $opts->{filename} line $opts->{line}"; | |||||||||||||||||||||||||||||||||||
| 61 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||
| 63 | sub m4i_stash :method :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | (my $myPack, my Opts $opts) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
m4i_stash: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $opts->{stash}{$myPack} //= +{}; | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts->{"stash"}{$myPack} //= {}
MC/DC0%0/1
$opts->{"stash"}{$myPack} //= {}
$opts->{"stash"}{$myPack}
Truth table0%0/2
A
A= $opts->{"stash"}{$myPack}
| |||||||||||||||||||||||||||||||||||||
| 66 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||
| 68 | # | ||||||||||||||||||||||||||||||||||||
| 69 | # `default_exports` is a hook to list exported symbols | ||||||||||||||||||||||||||||||||||||
| 70 | # when the module is used without arguments, like "use Foo". | ||||||||||||||||||||||||||||||||||||
| 71 | # Default implementation get them from `@EXPORT`. | ||||||||||||||||||||||||||||||||||||
| 72 | # | ||||||||||||||||||||||||||||||||||||
| 73 | sub default_exports { | ||||||||||||||||||||||||||||||||||||
| 74 | 10 | ▶ | (my $myPack, my Opts $opts) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
default_exports: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 75 | 10 | my $symtab = MOP4Import::Util::symtab($myPack); | |||||||||||||||||||||||||||||||||||
| 76 | 10 | my $sym = $symtab->{EXPORT}; | |||||||||||||||||||||||||||||||||||
| 77 | 10 | ▶ | if ($sym and my $export = *{$sym}{ARRAY}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$sym and my $export = *{$sym;}{"ARRAY"}
MC/DC100%1/1
$sym and my $export = *{$sym;}{"ARRAY"}
$sym
Truth table100%2/2
A
A= $sym
| |||||||||||||||||||||||||||||||||||||
| 78 | 3 | print STDERR "HAS \@EXPORT: $myPack" if DEBUG; | |||||||||||||||||||||||||||||||||||
| 79 | 3 | @$export | |||||||||||||||||||||||||||||||||||
| 80 | } else { | ||||||||||||||||||||||||||||||||||||
| 81 | 7 | print STDERR "NO \@EXPORT: $myPack" if DEBUG; | |||||||||||||||||||||||||||||||||||
| 82 | 7 | (); | |||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||
| 86 | sub declare_default_exports { | ||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | (my $myPack, my Opts $opts, my (@decls)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_default_exports: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||
| 89 | my $export = MOP4Import::Util::ensure_symbol_has_array( | ||||||||||||||||||||||||||||||||||||
| 90 | 0 | globref($opts->{objpkg}, 'EXPORT') | |||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||
| 93 | 0 | push @$export, @decls; | |||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||
| 96 | sub always_exports { | ||||||||||||||||||||||||||||||||||||
| 97 | 238 | ▶ | (my $myPack, my Opts $opts) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
always_exports: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 98 | 238 | qw(-strict); | |||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||
| 101 | sub dispatch_declare :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 102 | 287 | ▶ | (my $myPack, my Opts $opts, my (@decls)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_declare: called CC=7 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||
| 104 | 287 | print STDERR "$myPack->dispatch_declare(" | |||||||||||||||||||||||||||||||||||
| 105 | .terse_dump($opts, @decls).")\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||
| 107 | 287 | foreach my $declSpec (@decls) { | |||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||
| 109 | 827 | ▶ | croak "Undefined pragma!" unless defined $declSpec; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||
| 111 | 827 | ▶ | if (not ref $declSpec | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
not ref $declSpec or ref $declSpec eq "Regexp"
MC/DC50%1/2
not ref $declSpec or ref $declSpec eq "Regexp"
not ref $declSpec
ref $declSpec eq "Regexp"
Truth table66%2/3
not(A) or B
A= not ref $declSpecB= ref $declSpec eq "Regexp"
| |||||||||||||||||||||||||||||||||||||
| 112 | or ref $declSpec eq 'Regexp') { | ||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||
| 114 | 688 | $myPack->dispatch_import($opts, $declSpec); | |||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||
| 116 | } elsif (ref $declSpec eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||
| 118 | 139 | $myPack->dispatch_declare_pragma($opts, @$declSpec); | |||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||
| 120 | } elsif (ref $declSpec eq 'CODE') { | ||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||
| 122 | 0 | $declSpec->($myPack, $opts); | |||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||
| 125 | 0 | croak "Invalid pragma: ".terse_dump($declSpec); | |||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||
| 128 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||
| 130 | 22 | our %SIGIL_MAP = qw(* GLOB | |||||||||||||||||||||||||||||||||||
| 131 | $ SCALAR | ||||||||||||||||||||||||||||||||||||
| 132 | % HASH | ||||||||||||||||||||||||||||||||||||
| 133 | @ ARRAY | ||||||||||||||||||||||||||||||||||||
| 134 | & CODE); | ||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||
| 136 | sub dispatch_import :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 137 | 688 | ▶ | (my $myPack, my Opts $opts, my ($declSpec)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_import: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||
| 139 | 688 | my ($name, $exported); | |||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||
| 141 | 688 | ▶ | if (not ref $declSpec and $declSpec =~ /^-([A-Za-z]\w*)$/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $declSpec and $declSpec =~ /^-([A-Za-z]\w*)$/
MC/DC50%1/2
not ref $declSpec and $declSpec =~ /^-([A-Za-z]\w*)$/
not ref $declSpec
$declSpec =~ /^-([A-Za-z]\w*)$/
Truth table66%2/3
not(A) and B
A= not ref $declSpecB= $declSpec =~ /^-([A-Za-z]\w*)$/
| |||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||
| 143 | 487 | return $myPack->dispatch_declare_pragma($opts, $1); | |||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||
| 145 | } else { | ||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||
| 147 | 201 | $myPack->dispatch_import_no_pragma($opts, $declSpec); | |||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||
| 149 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||
| 151 | sub dispatch_import_no_pragma :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 152 | 201 | ▶ | (my $myPack, my Opts $opts, my (@declSpec)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_import_no_pragma: called CC=5 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 153 | 201 | foreach my $declSpec (@declSpec) { | |||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||
| 155 | 201 | ▶ | if (ref $declSpec eq 'Regexp') { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 156 | 0 | $myPack->import_by_regexp($opts, $declSpec); | |||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||
| 158 | elsif ($declSpec =~ /^([\*\$\%\@\&])?([A-Za-z]\w*)$/) { | ||||||||||||||||||||||||||||||||||||
| 159 | 201 | ▶ | if ($1) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $kind = $SIGIL_MAP{$1}; | |||||||||||||||||||||||||||||||||||
| 161 | 0 | $myPack->can("import_$kind") | |||||||||||||||||||||||||||||||||||
| 162 | ->($myPack, $opts, $1, $kind, $2); | ||||||||||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||||||||||
| 164 | 201 | $myPack->import_NAME($opts => $2); | |||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||
| 166 | } else { | ||||||||||||||||||||||||||||||||||||
| 167 | 0 | croak "Invalid import spec: $declSpec"; | |||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||
| 170 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||
| 172 | sub import_by_regexp :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | (my $myPack, my Opts $opts, my ($pattern)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
import_by_regexp: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $symtab = MOP4Import::Util::symtab($myPack); | |||||||||||||||||||||||||||||||||||
| 176 | 0 | foreach my $name (keys %$symtab) { | |||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | next unless $name =~ $pattern; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 178 | 0 | *{globref($opts->{destpkg}, $name)} = $symtab->{$name}; | |||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||
| 180 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||
| 182 | sub import_NAME :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 183 | 201 | ▶ | (my $myPack, my Opts $opts, my ($name)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
import_NAME: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||
| 185 | 201 | my $exported = safe_globref($myPack, $name); | |||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||
| 187 | 201 | print STDERR " Declaring $name in $opts->{destpkg} as " | |||||||||||||||||||||||||||||||||||
| 188 | .terse_dump($exported)."\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||
| 190 | 201 | *{globref($opts->{destpkg}, $name)} = $exported; | |||||||||||||||||||||||||||||||||||
| 191 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||
| 193 | sub import_GLOB :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | (my $myPack, my Opts $opts, my ($sigil, $kind, $name)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
import_GLOB: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $exported = safe_globref($myPack, $name); | |||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||
| 198 | 0 | print STDERR " Declaring $name in $opts->{destpkg} as " | |||||||||||||||||||||||||||||||||||
| 199 | .terse_dump($exported)."\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||
| 201 | 0 | *{globref($opts->{destpkg}, $name)} = $exported; | |||||||||||||||||||||||||||||||||||
| 202 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||
| 204 | sub import_SIGIL :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | (my $myPack, my Opts $opts, my ($sigil, $kind, $name)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
import_SIGIL: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $exported = *{safe_globref($myPack, $name)}{$kind}; | |||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||
| 209 | 0 | print STDERR " Declaring $sigil$opts->{destpkg}::$name" | |||||||||||||||||||||||||||||||||||
| 210 | . ", import from $sigil${myPack}::$name" | ||||||||||||||||||||||||||||||||||||
| 211 | . " (=".terse_dump($exported).")\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||
| 213 | 0 | *{globref($opts->{destpkg}, $name)} = $exported; | |||||||||||||||||||||||||||||||||||
| 214 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||
| 216 | 22 | *import_SCALAR = *import_SIGIL; *import_SCALAR = *import_SIGIL; | |||||||||||||||||||||||||||||||||||
| 217 | 22 | *import_ARRAY = *import_SIGIL; *import_ARRAY = *import_SIGIL; | |||||||||||||||||||||||||||||||||||
| 218 | 22 | *import_HASH = *import_SIGIL; *import_HASH = *import_SIGIL; | |||||||||||||||||||||||||||||||||||
| 219 | 22 | *import_CODE = *import_SIGIL; *import_CODE = *import_SIGIL; | |||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||
| 221 | sub dispatch_declare_pragma :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 222 | 646 | ▶ | (my $myPack, my Opts $opts, my ($pragma, @args)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_declare_pragma: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 223 | 646 | ▶ | if ($pragma =~ /^[A-Za-z]/ | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pragma =~ /^[A-Za-z]/ and my $sub = $myPack->can("declare_$pragma")
MC/DC0%0/2
$pragma =~ /^[A-Za-z]/ and my $sub = $myPack->can("declare_$pragma")
$pragma =~ /^[A-Za-z]/
my $sub = $myPack->can("declare_$pragma")
Truth table33%1/3
A and B
A= $pragma =~ /^[A-Za-z]/B= my $sub = $myPack->can("declare_$pragma")
| |||||||||||||||||||||||||||||||||||||
| 224 | and my $sub = $myPack->can("declare_$pragma")) { | ||||||||||||||||||||||||||||||||||||
| 225 | 646 | $sub->($myPack, $opts, @args); | |||||||||||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||||||||||
| 227 | 0 | croak "No such pragma: \`use $myPack\ [".terse_dump($pragma)."]`" | |||||||||||||||||||||||||||||||||||
| 228 | . $myPack->m4i_file_line_of($opts); | ||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||
| 230 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||
| 232 | #======================================== | ||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||
| 234 | # You may want to override these pragrams. | ||||||||||||||||||||||||||||||||||||
| 235 | sub declare_default_pragma :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 236 | 247 | ▶ | (my $myPack, my Opts $opts) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_default_pragma: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 237 | 247 | $myPack->declare_c3($opts); | |||||||||||||||||||||||||||||||||||
| 238 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||
| 240 | sub declare_strict :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 241 | 238 | ▶ | (my $myPack, my Opts $opts) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_strict: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 242 | 238 | $_->import for qw(strict warnings); # I prefer fatalized warnings, but... | |||||||||||||||||||||||||||||||||||
| 243 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||
| 245 | # Not enabled by default. | ||||||||||||||||||||||||||||||||||||
| 246 | sub declare_fatal :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 247 | 20 | ▶ | (my $myPack, my Opts $opts) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_fatal: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 248 | 20 | warnings->import(qw(FATAL all NONFATAL misc)); | |||||||||||||||||||||||||||||||||||
| 249 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||
| 251 | sub declare_c3 :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 252 | 247 | ▶ | (my $myPack, my Opts $opts) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_c3: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 253 | 247 | mro::set_mro($opts->{destpkg}, 'c3'); | |||||||||||||||||||||||||||||||||||
| 254 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||
| 256 | #======================================== | ||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||
| 258 | # | ||||||||||||||||||||||||||||||||||||
| 259 | # Just for readability | ||||||||||||||||||||||||||||||||||||
| 260 | # | ||||||||||||||||||||||||||||||||||||
| 261 | # use XXX [import => qw/X Y Z/]; | ||||||||||||||||||||||||||||||||||||
| 262 | # | ||||||||||||||||||||||||||||||||||||
| 263 | sub declare_import :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | (my $myPack, my Opts $opts, my (@import)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_import: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||
| 266 | 0 | $myPack->dispatch_import_no_pragma($opts, @import); | |||||||||||||||||||||||||||||||||||
| 267 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||
| 269 | #======================================== | ||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||
| 271 | sub declare_fileless_base :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 272 | 30 | ▶ | (my $myPack, my Opts $opts, my (@base)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_fileless_base: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||
| 274 | 30 | $myPack->declare___add_isa($opts->{objpkg}, @base); | |||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||
| 276 | 30 | $myPack->declare_fields($opts); | |||||||||||||||||||||||||||||||||||
| 277 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||
| 279 | 22 | *declare_base = *declare_parent; *declare_base = *declare_parent; | |||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||
| 281 | sub declare_parent :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | (my $myPack, my Opts $opts, my (@base)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_parent: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||
| 284 | 0 | foreach my $fn (@base) { | |||||||||||||||||||||||||||||||||||
| 285 | 0 | (my $cp = $fn) =~ s{::|\'}{/}g; | |||||||||||||||||||||||||||||||||||
| 286 | 0 | require "$cp.pm"; | |||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||
| 289 | 0 | $myPack->declare_fileless_base($opts, @base); | |||||||||||||||||||||||||||||||||||
| 290 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||
| 292 | sub declare_as_base :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 293 | 247 | ▶ | (my $myPack, my Opts $opts, my (@fields)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_as_base: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||
| 295 | 247 | print STDERR "Class $opts->{objpkg} inherits $myPack\n" | |||||||||||||||||||||||||||||||||||
| 296 | if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||
| 298 | 247 | $myPack->declare_default_pragma($opts); # strict, mro c3... | |||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||
| 300 | 247 | $myPack->declare___add_isa($opts->{objpkg}, $myPack); | |||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||
| 302 | 247 | $myPack->declare_fields($opts, @fields); | |||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||
| 304 | 247 | $myPack->declare_private_constant($opts, MY => $opts->{objpkg}, or_ignore => 1); | |||||||||||||||||||||||||||||||||||
| 305 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||
| 307 | sub declare___add_isa :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 308 | 277 | ▶ | my ($myPack, $objpkg, @parents) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare___add_isa: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||
| 310 | 277 | print STDERR "Class $objpkg extends ".terse_dump(@parents)."\n" | |||||||||||||||||||||||||||||||||||
| 311 | if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||
| 313 | 277 | my $isa = MOP4Import::Util::isa_array($objpkg); | |||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||
| 315 | 277 | my $using_c3 = mro::get_mro($objpkg) eq 'c3'; | |||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||
| 317 | 277 | if (DEBUG) { | |||||||||||||||||||||||||||||||||||
| 318 | print STDERR " $objpkg (MRO=",mro::get_mro($objpkg),") ISA " | ||||||||||||||||||||||||||||||||||||
| 319 | , terse_dump(mro::get_linear_isa($objpkg)), "\n"; | ||||||||||||||||||||||||||||||||||||
| 320 | print STDERR " Adding $_ (MRO=",mro::get_mro($_),") ISA " | ||||||||||||||||||||||||||||||||||||
| 321 | , terse_dump(mro::get_linear_isa($_)) | ||||||||||||||||||||||||||||||||||||
| 322 | , "\n" for @parents; | ||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||
| 325 | my @new = grep { | ||||||||||||||||||||||||||||||||||||
| 326 | 277 | my $parent = $_; | |||||||||||||||||||||||||||||||||||
| 327 | $parent ne $objpkg | ||||||||||||||||||||||||||||||||||||
| 328 | 277 | ▶ | and not grep {$parent eq $_} @$isa; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 329 | } @parents; | ||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||
| 331 | 277 | ▶ | if ($using_c3) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 332 | 247 | local $@; | |||||||||||||||||||||||||||||||||||
| 333 | 247 | foreach my $parent (@new) { | |||||||||||||||||||||||||||||||||||
| 334 | 247 | my $cur = mro::get_linear_isa($objpkg); | |||||||||||||||||||||||||||||||||||
| 335 | 247 | my $adding = mro::get_linear_isa($parent); | |||||||||||||||||||||||||||||||||||
| 336 | 247 | eval { | |||||||||||||||||||||||||||||||||||
| 337 | 247 | unshift @$isa, $parent; | |||||||||||||||||||||||||||||||||||
| 338 | # if ($] < 5.014) { | ||||||||||||||||||||||||||||||||||||
| 339 | # mro::method_changed_in($objpkg); | ||||||||||||||||||||||||||||||||||||
| 340 | # mro::get_linear_isa($objpkg); | ||||||||||||||||||||||||||||||||||||
| 341 | # } | ||||||||||||||||||||||||||||||||||||
| 342 | }; | ||||||||||||||||||||||||||||||||||||
| 343 | 247 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 344 | 0 | croak "Can't add base '$parent' to '$objpkg' (\n" | |||||||||||||||||||||||||||||||||||
| 345 | . " $objpkg ISA ".terse_dump($cur).")\n" | ||||||||||||||||||||||||||||||||||||
| 346 | . " Adding $parent ISA ".terse_dump($adding) | ||||||||||||||||||||||||||||||||||||
| 347 | ."\n) because of this error: " . $@; | ||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||
| 350 | } else { | ||||||||||||||||||||||||||||||||||||
| 351 | 30 | push @$isa, @new; | |||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||
| 353 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||
| 355 | # I'm afraid this 'as' pragma could invite ambiguous interpretation. | ||||||||||||||||||||||||||||||||||||
| 356 | # But in following case, I can't find any other pragma name. | ||||||||||||||||||||||||||||||||||||
| 357 | # | ||||||||||||||||||||||||||||||||||||
| 358 | # use XXX [as => 'YYY'] | ||||||||||||||||||||||||||||||||||||
| 359 | # | ||||||||||||||||||||||||||||||||||||
| 360 | # So, let's define `declare_as` as an alias of `declare_naming`. | ||||||||||||||||||||||||||||||||||||
| 361 | # | ||||||||||||||||||||||||||||||||||||
| 362 | 22 | *declare_as = *declare_naming; *declare_as = *declare_naming; | |||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||
| 364 | sub declare_naming :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | (my $myPack, my Opts $opts, my ($name)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_naming: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||
| 367 | 1 | ▶ | unless (defined $name and $name ne '') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and $name ne ""
MC/DC0%0/2
defined $name and $name ne ""
defined $name
$name ne ""
Truth table33%1/3
A and B
A= defined $nameB= $name ne ""
| |||||||||||||||||||||||||||||||||||||
| 368 | 0 | croak "Usage: use ${myPack} [naming => NAME]"; | |||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||
| 371 | 1 | $myPack->declare_constant($opts, $name => $myPack); | |||||||||||||||||||||||||||||||||||
| 372 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||
| 374 | sub declare_inc :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 375 | 2 | ▶ | (my $myPack, my Opts $opts, my ($pkg)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_inc: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 376 | 2 | ▶ | $pkg //= $opts->{objpkg}; | ||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$pkg //= $opts->{"objpkg"}
MC/DC0%0/2
$pkg //= $opts->{"objpkg"}
$pkg
$opts->{"objpkg"}
Truth table33%1/3
A //= B
A= $pkgB= $opts->{"objpkg"}
| |||||||||||||||||||||||||||||||||||||
| 377 | 2 | $pkg =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||
| 378 | 2 | $INC{$pkg . '.pm'} = 1; | |||||||||||||||||||||||||||||||||||
| 379 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||
| 381 | sub declare_constant :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 382 | 13 | ▶ | (my $myPack, my Opts $opts, my ($name, $value, %opts)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_constant: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||
| 384 | 13 | $myPack->declare_private_constant($opts, $name, $value, %opts); | |||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||
| 386 | my $export = MOP4Import::Util::ensure_symbol_has_array( | ||||||||||||||||||||||||||||||||||||
| 387 | 13 | globref($opts->{objpkg}, 'EXPORT') | |||||||||||||||||||||||||||||||||||
| 388 | ); | ||||||||||||||||||||||||||||||||||||
| 389 | 13 | push @$export, $name; | |||||||||||||||||||||||||||||||||||
| 390 | print STDERR " constant $name is added to default exports of " | ||||||||||||||||||||||||||||||||||||
| 391 | 13 | . $opts->{objpkg}. "\n" if DEBUG; | |||||||||||||||||||||||||||||||||||
| 392 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||
| 394 | sub declare_private_constant :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 395 | 310 | ▶ | (my $myPack, my Opts $opts, my ($name, $value, %opts)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_private_constant: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||
| 397 | 310 | my $or_ignore = delete $opts{or_ignore}; | |||||||||||||||||||||||||||||||||||
| 398 | 310 | ▶ | if (keys %opts) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 399 | 0 | Carp::croak("Unknown options: ". join ", ", sort keys(%opts)); | |||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||
| 402 | 310 | my $my_sym = globref($opts->{objpkg}, $name); | |||||||||||||||||||||||||||||||||||
| 403 | 310 | ▶ | if (*{$my_sym}{CODE}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 404 | 56 | ▶ | return if $or_ignore; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 405 | 0 | croak "constant $opts->{objpkg}::$name is already defined"; | |||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||
| 408 | 254 | MOP4Import::Util::define_constant($my_sym, $value); | |||||||||||||||||||||||||||||||||||
| 409 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||
| 411 | sub declare_fields :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 412 | 372 | ▶ | (my $myPack, my Opts $opts, my (@fields)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_fields: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||
| 414 | 372 | my $extended = fields_hash($opts->{objpkg}); | |||||||||||||||||||||||||||||||||||
| 415 | 372 | my $fields_array = fields_array($opts->{objpkg}); | |||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||
| 417 | 372 | my $isFirst = not $myPack->JSON_TYPE_HANDLER->lookup_json_type($opts->{objpkg}); | |||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||
| 419 | # Import all fields from super class | ||||||||||||||||||||||||||||||||||||
| 420 | 372 | foreach my $super_class (@{*{globref($opts->{objpkg}, 'ISA')}{ARRAY}}) { | |||||||||||||||||||||||||||||||||||
| 421 | 409 | my $super = fields_hash($super_class); | |||||||||||||||||||||||||||||||||||
| 422 | 409 | ▶ | next unless $super; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||
| 425 | 409 | my $super_names = fields_array($super_class); | |||||||||||||||||||||||||||||||||||
| 426 | 409 | ▶ | my @names = @$super_names ? @$super_names : keys %$super; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 427 | 409 | foreach my $name (@names) { | |||||||||||||||||||||||||||||||||||
| 428 | 846 | ▶ | next if defined $extended->{$name}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 429 | 443 | print STDERR " Field $opts->{objpkg}.$name is inherited " | |||||||||||||||||||||||||||||||||||
| 430 | . "from $super_class.\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 431 | 443 | my $anyFieldSpec = $extended->{$name} = do { | |||||||||||||||||||||||||||||||||||
| 432 | 443 | my $origin = $super->{$name}; | |||||||||||||||||||||||||||||||||||
| 433 | # XXX: mark origin in this clone? | ||||||||||||||||||||||||||||||||||||
| 434 | 443 | ▶ | ref $origin ? $origin->clone : $origin; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 435 | }; | ||||||||||||||||||||||||||||||||||||
| 436 | 443 | push @$fields_array, $name; | |||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||
| 439 | 409 | ▶ | $myPack->JSON_TYPE_HANDLER->inherit_json_type($opts->{objpkg}, $super_class) if $isFirst; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||
| 443 | { | ||||||||||||||||||||||||||||||||||||
| 444 | 372 | my %dup; | |||||||||||||||||||||||||||||||||||
| 445 | 372 | foreach my $spec (@fields) { | |||||||||||||||||||||||||||||||||||
| 446 | 332 | ▶ | my ($name) = ref $spec ? @$spec : $spec; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 447 | 332 | ▶ | if ($dup{$name}++) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 448 | 0 | croak "Duplicate field decl! $name"; | |||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||
| 454 | 372 | my $field_class = do { | |||||||||||||||||||||||||||||||||||
| 455 | # XXX: objpkg? destpkg? | ||||||||||||||||||||||||||||||||||||
| 456 | 372 | ▶ | if (my $sub = $opts->{destpkg}->can("FieldSpec")) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 457 | 365 | $sub->(); | |||||||||||||||||||||||||||||||||||
| 458 | } else { | ||||||||||||||||||||||||||||||||||||
| 459 | 7 | $myPack->FieldSpec; | |||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||
| 461 | }; | ||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||
| 463 | 372 | print STDERR " FieldSpec is: $field_class\n" if DEBUG; | |||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||
| 465 | 372 | $myPack->JSON_TYPE_HANDLER->declare_json_type_record($opts->{objpkg}); | |||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||
| 467 | 372 | ▶ | $myPack->declare___field($opts, $field_class, ref $_ ? @$_ : $_) for @fields; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||
| 469 | 372 | $opts->{objpkg}; # XXX: | |||||||||||||||||||||||||||||||||||
| 470 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||
| 472 | sub declare___field :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 473 | 332 | ▶ | (my $myPack, my Opts $opts, my ($field_class, $name, @rest)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare___field: called CC=16 SCAR=30.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 474 | 332 | print STDERR " Declaring field $opts->{objpkg}.$name " if DEBUG; | |||||||||||||||||||||||||||||||||||
| 475 | 332 | my $extended = fields_hash($opts->{objpkg}); | |||||||||||||||||||||||||||||||||||
| 476 | 332 | my $fields_array = fields_array($opts->{objpkg}); | |||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||
| 478 | 332 | my $spec = fields_hash($field_class); | |||||||||||||||||||||||||||||||||||
| 479 | 332 | my (@early, @delayed); | |||||||||||||||||||||||||||||||||||
| 480 | 332 | ▶ | while (my ($k, $v) = splice @rest, 0, 2) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 481 | 552 | ▶ | unless (defined $k) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 482 | 0 | croak "Undefined field spec key for $opts->{objpkg}.$name in $opts->{callpack}"; | |||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||
| 484 | 552 | ▶ | if ($k =~ /^[A-Za-z]/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 485 | 552 | ▶ | if (my $sub = $myPack->can("declare___field_with_$k")) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 486 | 50 | push @delayed, [$sub, $k, $v]; | |||||||||||||||||||||||||||||||||||
| 487 | 50 | next; | |||||||||||||||||||||||||||||||||||
| 488 | } elsif (exists $spec->{$k}) { | ||||||||||||||||||||||||||||||||||||
| 489 | 502 | push @early, $k, $v; | |||||||||||||||||||||||||||||||||||
| 490 | 502 | next; | |||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||
| 493 | 0 | croak "Unknown option for $opts->{objpkg}.$name in $opts->{callpack}: " | |||||||||||||||||||||||||||||||||||
| 494 | . ".$k"; | ||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||
| 497 | 332 | my FieldSpec $fs = $extended->{$name} | |||||||||||||||||||||||||||||||||||
| 498 | = $field_class->new(@early, name => $name); | ||||||||||||||||||||||||||||||||||||
| 499 | 332 | $fs->{package} = $opts->{objpkg}; | |||||||||||||||||||||||||||||||||||
| 500 | 332 | print STDERR " with $myPack $field_class => ", terse_dump($fs), "\n" | |||||||||||||||||||||||||||||||||||
| 501 | if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 502 | 332 | push @$fields_array, $name; | |||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||
| 504 | # Create accessor for all public fields. | ||||||||||||||||||||||||||||||||||||
| 505 | 332 | ▶ | if ($name =~ /^[a-z]/i and not $fs->{no_getter}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name =~ /^[a-z]/i and not $fs->{"no_getter"}
MC/DC50%1/2
$name =~ /^[a-z]/i and not $fs->{"no_getter"}
$name =~ /^[a-z]/i
not $fs->{"no_getter"}
Truth table66%2/3
A and not(B)
A= $name =~ /^[a-z]/iB= not $fs->{"no_getter"}
| |||||||||||||||||||||||||||||||||||||
| 506 | 318 | ▶ | if (my $entry = MOP4Import::Util::symtab($opts->{objpkg})->{$name}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if (ref $entry eq 'CODE' | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
ref $entry eq "CODE" or ref \$entry eq "GLOB" and *{$entry;}{"CODE"}
ref \$entry eq "GLOB" and *{$entry;}{"CODE"}
MC/DC0%0/2
ref $entry eq "CODE" or ref \$entry eq "GLOB" and *{$entry;}{"CODE"}
ref $entry eq "CODE"
ref \$entry eq "GLOB"
Truth table0%0/3
A or B
A= ref $entry eq "CODE"B= ref \$entry eq "GLOB"
| |||||||||||||||||||||||||||||||||||||
| 508 | 0 | or ref \$entry eq 'GLOB' and *{$entry}{CODE}) { | |||||||||||||||||||||||||||||||||||
| 509 | 0 | croak "Accessor $opts->{objpkg}::$name is redefined!\nIf you really want to define the accessor by hand, please specify fields spec like: [$name => no_getter => 1, ...]."; | |||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||
| 513 | 318 | *{globref($opts->{objpkg}, $name)} | |||||||||||||||||||||||||||||||||||
| 514 | 318 | = Sub::Util::set_subname(join("::", $opts->{objpkg}, $name) | |||||||||||||||||||||||||||||||||||
| 515 | , $myPack->declare___accessor($opts, $name)); | ||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||
| 518 | 332 | foreach my $delayed (@delayed) { | |||||||||||||||||||||||||||||||||||
| 519 | 50 | my ($sub, $k, $v) = @$delayed; | |||||||||||||||||||||||||||||||||||
| 520 | 50 | $sub->($myPack, $opts, $fs, $k, $v); | |||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||
| 523 | 332 | ▶ | if ($fs->{name} !~ /^_/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 524 | $myPack->JSON_TYPE_HANDLER->register_json_type_of_field( | ||||||||||||||||||||||||||||||||||||
| 525 | $opts, $opts->{objpkg}, $fs->{name}, | ||||||||||||||||||||||||||||||||||||
| 526 | 318 | ▶ | $fs->{json_type} || $opts->{default_json_type} || 'string' | ||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$fs->{'json_type'} || $opts->{'default_json_type'} || 'string'
$fs->{"json_type"} or $opts->{"default_json_type"}
MC/DC50%1/2
$fs->{'json_type'} || $opts->{'default_json_type'} || 'string'
$fs->{"json_type"}
$opts->{"default_json_type"}
Truth table66%2/3
A or B
A= $fs->{"json_type"}B= $opts->{"default_json_type"}
| |||||||||||||||||||||||||||||||||||||
| 527 | ); | ||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||
| 530 | 332 | $fs; | |||||||||||||||||||||||||||||||||||
| 531 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||
| 533 | sub declare___accessor :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 534 | 318 | ▶ | (my $myPack, my Opts $opts, my ($name)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare___accessor: called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 535 | 318 | ▶ | return sub :method { $_[0]->{$name} }; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
Subroutine
null: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||
| 536 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||
| 538 | sub declare___field_with_default :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 539 | 50 | ▶ | (my $myPack, my Opts $opts, my FieldSpec $fs, my ($k, $v)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare___field_with_default: called CC=2 SCAR=7.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||
| 541 | 50 | $fs->{$k} = $v; | |||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||
| 543 | 50 | ▶ | if (ref $v eq 'CODE') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 544 | 0 | *{globref($opts->{objpkg}, "default_$fs->{name}")} = $v; | |||||||||||||||||||||||||||||||||||
| 545 | } else { | ||||||||||||||||||||||||||||||||||||
| 546 | 50 | $myPack->declare_private_constant($opts, "default_$fs->{name}", $v); | |||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||
| 548 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||
| 550 | sub JSON_TYPE_HANDLER { | ||||||||||||||||||||||||||||||||||||
| 551 | 1309 | ▶ | require MOP4Import::Util::JSON_TYPE; | ||||||||||||||||||||||||||||||||||
|
Subroutine
JSON_TYPE_HANDLER: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 552 | 1309 | 'MOP4Import::Util::JSON_TYPE'; | |||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||
| 555 | sub declare_alias :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 556 | 49 | ▶ | (my $myPack, my Opts $opts, my ($name, $alias)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_alias: called CC=2 SCAR=7.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 557 | 49 | print STDERR " Declaring alias $name in $opts->{destpkg} as $alias\n" if DEBUG; | |||||||||||||||||||||||||||||||||||
| 558 | 49 | my $sym = globref($opts->{destpkg}, $name); | |||||||||||||||||||||||||||||||||||
| 559 | 49 | ▶ | if (*{$sym}{CODE}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 560 | 0 | croak "Subroutine (alias) $opts->{destpkg}::$name redefined"; | |||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||
| 562 | 49 | ▶ | *$sym = sub () {$alias}; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||
| 563 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||
| 565 | # Set(override) default value for inherited fields | ||||||||||||||||||||||||||||||||||||
| 566 | # | ||||||||||||||||||||||||||||||||||||
| 567 | # [defaults => | ||||||||||||||||||||||||||||||||||||
| 568 | # fieldName => defaultValue, ... | ||||||||||||||||||||||||||||||||||||
| 569 | # ] | ||||||||||||||||||||||||||||||||||||
| 570 | # | ||||||||||||||||||||||||||||||||||||
| 571 | sub declare_defaults :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | (my $myPack, my Opts $opts, my (@kvlist)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_defaults: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $fields = fields_hash($opts->{objpkg}); | |||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | while (my ($k, $v) = splice @kvlist, 0, 2) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | my FieldSpec $fs = $fields->{$k} | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 578 | or Carp::croak "No such field: $k"; | ||||||||||||||||||||||||||||||||||||
| 579 | 0 | $fs->{default} = $v; | |||||||||||||||||||||||||||||||||||
| 580 | 0 | my $fn = "default_$k"; | |||||||||||||||||||||||||||||||||||
| 581 | 0 | $myPack->declare_private_constant($opts, $fn, $v); | |||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||
| 583 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 584 | 22 | *declare_override_defaults = *declare_defaults; | |||||||||||||||||||||||||||||||||||
| 585 | 22 | *declare_override_defaults = *declare_defaults; | |||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||
| 587 | sub declare_map_methods :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | (my $myPack, my Opts $opts, my (@pairs)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_map_methods: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||
| 590 | 0 | foreach my $pair (@pairs) { | |||||||||||||||||||||||||||||||||||
| 591 | 0 | my ($from, $to) = @$pair; | |||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | my $sub = $opts->{objpkg}->can($to) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 593 | or croak "Can't find method $to in (parent of) $opts->{objpkg}"; | ||||||||||||||||||||||||||||||||||||
| 594 | 0 | *{globref($opts->{objpkg}, $from)} = $sub; | |||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||
| 596 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||
| 598 | sub declare_carp_not :MetaOnly { | ||||||||||||||||||||||||||||||||||||
| 599 | 22 | ▶ | (my $myPack, my Opts $opts, my (@carp_not)) = m4i_args(@_); | ||||||||||||||||||||||||||||||||||
|
Subroutine
declare_carp_not: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||
| 601 | 22 | ▶ | unless (@carp_not) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 602 | 0 | push @carp_not, $myPack; | |||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||
| 605 | 22 | my $name = 'CARP_NOT'; | |||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||
| 607 | 22 | print STDERR "Declaring \@$opts->{objpkg}.$name = ".terse_dump(@carp_not) | |||||||||||||||||||||||||||||||||||
| 608 | if DEBUG; | ||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||
| 610 | 22 | *{globref($opts->{objpkg}, $name)} = \@carp_not; | |||||||||||||||||||||||||||||||||||
| 611 | 22 | ▶ | } | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||
| 613 | { | ||||||||||||||||||||||||||||||||||||
| 614 | # | ||||||||||||||||||||||||||||||||||||
| 615 | # Below does equiv of `our @CARP_NOT = qw/ MOP4Import::Util /;` | ||||||||||||||||||||||||||||||||||||
| 616 | # | ||||||||||||||||||||||||||||||||||||
| 617 | 22 | __PACKAGE__->declare_carp_not(MOP4Import::Opts::m4i_fake_opts(__PACKAGE__), | |||||||||||||||||||||||||||||||||||
| 618 | qw/ | ||||||||||||||||||||||||||||||||||||
| 619 | MOP4Import::Util | ||||||||||||||||||||||||||||||||||||
| 620 | / | ||||||||||||||||||||||||||||||||||||
| 621 | ); | ||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||
| 624 | 22 | 1; | |||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||