« /usr/local/lib/perl5/5.44.0/x86_64-linux/Config_heavy.pl
↑ Summary
/usr/local/lib/perl5/5.44.0/experimental.pm »
| 1 | package attributes 0.37; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use v5.40; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | our @EXPORT_OK = qw(get reftype); | |||||||||||||||||||||||||||
| 6 | 7 | our @EXPORT = (); | |||||||||||||||||||||||||||
| 7 | 7 | our %EXPORT_TAGS = (ALL => [@EXPORT, @EXPORT_OK]); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # Older versions of this module provided a `reftype` in attributes.xs, and | ||||||||||||||||||||||||||||
| 10 | # there may exist code out there that relies on being able to find it. | ||||||||||||||||||||||||||||
| 11 | 7 | *reftype = \&builtin::reftype; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub croak { | ||||||||||||||||||||||||||
|
Subroutine
croak: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 0 | require Carp; | |||||||||||||||||||||||||||
| 15 | 0 | goto &Carp::croak; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub carp { | ||||||||||||||||||||||||||
|
Subroutine
carp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | require Carp; | |||||||||||||||||||||||||||
| 20 | 0 | goto &Carp::carp; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Hash of SV type (CODE, SCALAR, etc.) to regex matching deprecated | ||||||||||||||||||||||||||||
| 24 | # attributes for that type. | ||||||||||||||||||||||||||||
| 25 | 7 | my %deprecated; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 7 | my %msg = ( | |||||||||||||||||||||||||||
| 28 | lvalue => 'lvalue attribute applied to already-defined subroutine', | ||||||||||||||||||||||||||||
| 29 | -lvalue => 'lvalue attribute removed from already-defined subroutine', | ||||||||||||||||||||||||||||
| 30 | const => 'Useless use of attribute "const"', | ||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 7 | ▶ | my sub modify_attrs_and_deprecate ($svtype, @args) { | ||||||||||||||||||||||||||
|
Subroutine
modify_attrs_and_deprecate: called CC=5 SCAR=32.4
| |||||||||||||||||||||||||||||
| 34 | # After we've removed a deprecated attribute from the XS code, we need to | ||||||||||||||||||||||||||||
| 35 | # remove it here, else it ends up in @badattrs. (If we do the deprecation in | ||||||||||||||||||||||||||||
| 36 | # XS, we can't control the warning based on *our* caller's lexical settings, | ||||||||||||||||||||||||||||
| 37 | # and the warned line is in this package) | ||||||||||||||||||||||||||||
| 38 | grep { | ||||||||||||||||||||||||||||
| 39 | 7 | $deprecated{$svtype} && /$deprecated{$svtype}/ ? do { | |||||||||||||||||||||||||||
| 40 | 0 | warnings::warnif('deprecated', "Attribute \"$1\" is deprecated, " . | |||||||||||||||||||||||||||
| 41 | "and will disappear in Perl 5.28"); | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$svtype eq "CODE" and exists $msg{$_}
MC/DC0%0/2
$svtype eq "CODE" and exists $msg{$_}
$svtype eq "CODE"
exists $msg{$_}
Truth table0%0/3
A and B
A= $svtype eq "CODE"B= exists $msg{$_}
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | } : $svtype eq 'CODE' && exists $msg{$_} ? do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$deprecated{$svtype} and /$deprecated{$svtype}/u
MC/DC0%0/2
$deprecated{$svtype} and /$deprecated{$svtype}/u
$deprecated{$svtype}
/$deprecated{$svtype}/u
Truth table0%0/3
A and B
A= $deprecated{$svtype}B= /$deprecated{$svtype}/u
| |||||||||||||||||||||||||||||
| 44 | warnings::warnif( | ||||||||||||||||||||||||||||
| 45 | 'misc', | ||||||||||||||||||||||||||||
| 46 | 0 | $msg{$_} | |||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | 0 | 0; | |||||||||||||||||||||||||||
| 49 | } : 1 | ||||||||||||||||||||||||||||
| 50 | } _modify_attrs(@args); | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 7 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=14 SCAR=44.2
| |||||||||||||||||||||||||||||
| 54 | 7 | ▶ | @_ > 2 && ref $_[2] or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ > 2 and ref $_[2]
MC/DC0%0/2
@_ > 2 and ref $_[2]
@_ > 2
ref $_[2]
Truth table33%1/3
A and B
A= @_ > 2B= ref $_[2]
| |||||||||||||||||||||||||||||
| 55 | 0 | require Exporter; | |||||||||||||||||||||||||||
| 56 | 0 | goto &Exporter::import; | |||||||||||||||||||||||||||
| 57 | }; | ||||||||||||||||||||||||||||
| 58 | 7 | my (undef,$home_stash,$svref,@attrs) = @_; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 7 | my $svtype = uc reftype($svref); | |||||||||||||||||||||||||||
| 61 | 7 | my $pkgmeth; | |||||||||||||||||||||||||||
| 62 | 7 | ▶ | $pkgmeth = UNIVERSAL::can($home_stash, "MODIFY_${svtype}_ATTRIBUTES") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $home_stash and $home_stash ne ""
MC/DC0%0/2
defined $home_stash and $home_stash ne ""
defined $home_stash
$home_stash ne ""
Truth table33%1/3
A and B
A= defined $home_stashB= $home_stash ne ""
| |||||||||||||||||||||||||||||
| 63 | if defined $home_stash && $home_stash ne ''; | ||||||||||||||||||||||||||||
| 64 | 7 | my @badattrs; | |||||||||||||||||||||||||||
| 65 | 7 | ▶ | if ($pkgmeth) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | my @pkgattrs = modify_attrs_and_deprecate($svtype, $svref, @attrs); | |||||||||||||||||||||||||||
| 67 | 0 | @badattrs = $pkgmeth->($home_stash, $svref, @pkgattrs); | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | if (!@badattrs && @pkgattrs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not @badattrs and @pkgattrs
MC/DC0%0/2
not @badattrs and @pkgattrs
not @badattrs
@pkgattrs
Truth table0%0/3
not(A) and B
A= not @badattrsB= @pkgattrs
| |||||||||||||||||||||||||||||
| 69 | 0 | require warnings; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | return unless warnings::enabled('reserved'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | @pkgattrs = grep { m/\A[[:lower:]]+(?:\z|\()/ } @pkgattrs; | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | if (@pkgattrs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | for my $attr (@pkgattrs) { | |||||||||||||||||||||||||||
| 74 | 0 | $attr =~ s/\(.+\z//s; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my $s = ((@pkgattrs == 1) ? '' : 's'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | carp "$svtype package attribute$s " . | |||||||||||||||||||||||||||
| 78 | "may clash with future reserved word$s: " . | ||||||||||||||||||||||||||||
| 79 | join(' : ' , @pkgattrs); | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | else { | ||||||||||||||||||||||||||||
| 84 | 7 | @badattrs = modify_attrs_and_deprecate($svtype, $svref, @attrs); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 7 | ▶ | if (@badattrs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | croak "Invalid $svtype attribute" . | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | (( @badattrs == 1 ) ? '' : 's') . | ||||||||||||||||||||||||||||
| 89 | ": " . | ||||||||||||||||||||||||||||
| 90 | join(' : ', @badattrs); | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub get :prototype($) ($svref) { | ||||||||||||||||||||||||||
|
Subroutine
get: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | ref $svref or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | croak 'Usage: '.__PACKAGE__.'::get $ref'; | ||||||||||||||||||||||||||||
| 97 | 0 | my $svtype = uc reftype($svref); | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $stash = _guess_stash($svref) // scalar caller; | ||||||||||||||||||||||||||
|
Condition0%0/2
&_guess_stash($svref) // scalar caller
MC/DC0%0/1
&_guess_stash($svref) // scalar caller
&_guess_stash($svref)
Truth table0%0/2
A
A= &_guess_stash($svref)
| |||||||||||||||||||||||||||||
| 99 | 0 | my $pkgmeth; | |||||||||||||||||||||||||||
| 100 | 0 | ▶ | $pkgmeth = UNIVERSAL::can($stash, "FETCH_${svtype}_ATTRIBUTES") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $stash and $stash ne ""
MC/DC0%0/2
defined $stash and $stash ne ""
defined $stash
$stash ne ""
Truth table0%0/3
A and B
A= defined $stashB= $stash ne ""
| |||||||||||||||||||||||||||||
| 101 | if defined $stash && $stash ne ''; | ||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return $pkgmeth ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | (_fetch_attrs($svref), $pkgmeth->($stash, $svref)) : | ||||||||||||||||||||||||||||
| 104 | (_fetch_attrs($svref)) | ||||||||||||||||||||||||||||
| 105 | ; | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub require_version { goto &UNIVERSAL::VERSION } | ||||||||||||||||||||||||||
|
Subroutine
require_version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 7 | require XSLoader; | |||||||||||||||||||||||||||
| 111 | 7 | XSLoader::load(); | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | __END__ | ||||||||||||||||||||||||||||