| 1 | package Type::Params; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 66 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 66 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 66 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 66 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 66 | $Type::Params::AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||
| 9 | 66 | $Type::Params::VERSION = '2.010001'; | |||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | 66 | $Type::Params::VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 66 | ▶ | use B qw(); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | 66 | ▶ | use Eval::TypeTiny qw( eval_closure set_subname ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 16 | 66 | ▶ | use Scalar::Util qw( refaddr ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 17 | 66 | ▶ | use Error::TypeTiny; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 18 | 66 | ▶ | use Error::TypeTiny::Assertion; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 19 | 66 | ▶ | use Error::TypeTiny::WrongNumberOfParameters; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 20 | 66 | ▶ | use Types::Standard (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 21 | 66 | ▶ | use Types::TypeTiny (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | 66 | require Exporter::Tiny; | |||||||||||||||||||||||||||||||||||||
| 24 | 66 | our @ISA = 'Exporter::Tiny'; | |||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 66 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||
| 27 | compile compile_named | ||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 66 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||
| 31 | compile_named_oo | ||||||||||||||||||||||||||||||||||||||
| 32 | validate validate_named | ||||||||||||||||||||||||||||||||||||||
| 33 | multisig | ||||||||||||||||||||||||||||||||||||||
| 34 | Invocant ArgsObject | ||||||||||||||||||||||||||||||||||||||
| 35 | wrap_subs wrap_methods | ||||||||||||||||||||||||||||||||||||||
| 36 | signature signature_for signature_for_func signature_for_method | ||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | 66 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||
| 40 | compile => [ qw( compile compile_named compile_named_oo ) ], | ||||||||||||||||||||||||||||||||||||||
| 41 | wrap => [ qw( wrap_subs wrap_methods ) ], | ||||||||||||||||||||||||||||||||||||||
| 42 | sigs => [ qw( signature signature_for ) ], | ||||||||||||||||||||||||||||||||||||||
| 43 | validate => [ qw( validate validate_named ) ], | ||||||||||||||||||||||||||||||||||||||
| 44 | sigplus => [ qw( signature signature_for signature_for_func signature_for_method ) ], | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | v1 => [ qw( compile compile_named ) ], # Old default | ||||||||||||||||||||||||||||||||||||||
| 47 | v2 => [ qw( signature signature_for ) ], # New recommendation | ||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||
| 50 | 66 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||
| 51 | 66 | my $pfx = $ENV{'PERL_TYPE_PARAMS_SUBNAME_PREFIX'}; | |||||||||||||||||||||||||||||||||||||
| 52 | 66 | ▶ | eval sprintf( | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $pfx and $pfx =~ /::\z/
MC/DC0%0/2
defined $pfx and $pfx =~ /::\z/
defined $pfx
$pfx =~ /::\z/
Truth table66%2/3
A and B
A= defined $pfxB= $pfx =~ /::\z/
| |||||||||||||||||||||||||||||||||||||||
| 53 | 'sub SIGNATURE_SUBNAME_PREFIX () { %s }', | ||||||||||||||||||||||||||||||||||||||
| 54 | B::perlstring( | ||||||||||||||||||||||||||||||||||||||
| 55 | ( defined $pfx and $pfx =~ /::\z/ ) ? $pfx : $pfx ? 'SIGNATURE_FOR::' : '', | ||||||||||||||||||||||||||||||||||||||
| 56 | ) | ||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | 66 | my $sfx = $ENV{'PERL_TYPE_PARAMS_SUBNAME_SUFFIX'}; | |||||||||||||||||||||||||||||||||||||
| 60 | 66 | ▶ | eval sprintf( | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $sfx and $sfx =~ /\A_/
MC/DC0%0/2
defined $sfx and $sfx =~ /\A_/
defined $sfx
$sfx =~ /\A_/
Truth table66%2/3
A and B
A= defined $sfxB= $sfx =~ /\A_/
| |||||||||||||||||||||||||||||||||||||||
| 61 | 'sub SIGNATURE_SUBNAME_SUFFIX () { %s }', | ||||||||||||||||||||||||||||||||||||||
| 62 | B::perlstring( | ||||||||||||||||||||||||||||||||||||||
| 63 | ( defined $sfx and $sfx =~ /\A_/ ) ? $sfx : $sfx ? '_SIGNATURE' : '', | ||||||||||||||||||||||||||||||||||||||
| 64 | ) | ||||||||||||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||||||||||||
| 66 | }; | ||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||
| 69 | 66 | my $Invocant; | |||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | sub Invocant () { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
Invocant: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | $Invocant ||= do { | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Invocant ||= do {
require Type::Tiny::Union;
"Type::Tiny::Union"->new("name", "Invocant", "type_constraints", [&Types::Standard::Object(), &Types::Standard::ClassName()])
}
MC/DC0%0/2
$Invocant ||= do {
require Type::Tiny::Union;
"Type::Tiny::Union"->new("name", "Invocant", "type_constraints", [&Types::Standard::Object(), &Types::Standard::ClassName()])
}
$Invocant
do {
require Type::Tiny::Union;
"Type::Tiny::Union"->new("name", "Invocant", "type_constraints", [&Types::Standard::Object(), &Types::Standard::ClassName()])
}
Truth table33%1/3
A ||= B
A= $InvocantB= do {
require Type::Tiny::Union;
"Type::Tiny::Union"->new("name", "Invocant", "type_constraints", [&Types::Standard::Object(), &Types::Standard::ClassName()])
}
| |||||||||||||||||||||||||||||||||||||||
| 73 | 1 | require Type::Tiny::Union; | |||||||||||||||||||||||||||||||||||||
| 74 | 1 | 'Type::Tiny::Union'->new( | |||||||||||||||||||||||||||||||||||||
| 75 | name => 'Invocant', | ||||||||||||||||||||||||||||||||||||||
| 76 | type_constraints => [ | ||||||||||||||||||||||||||||||||||||||
| 77 | Types::Standard::Object(), | ||||||||||||||||||||||||||||||||||||||
| 78 | Types::Standard::ClassName(), | ||||||||||||||||||||||||||||||||||||||
| 79 | ], | ||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||
| 81 | }; | ||||||||||||||||||||||||||||||||||||||
| 82 | } #/ sub Invocant | ||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||
| 84 | my $ArgsObject; | ||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | sub ArgsObject (;@) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ArgsObject: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 87 | 5 | ▶ | $ArgsObject ||= do { | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ArgsObject ||= do {
"Type::Tiny"->new("name", "ArgsObject", "parent", &Types::Standard::Object(), "constraint", " ref(\$_) =~ qr/^Type::Params::OO::/ ", "constraint_generator", sub {
Type::Tiny::check_parameter_count_for_parameterized_type("Type::Params", "ArgsObject", \@_, 1, 1);
my $param = Types::Standard::assert_Str(shift());
sub {
defined $_->{"~~caller"} and $_->{"~~caller"} eq $param;
}
;
}
, "inline_generator", sub {
my $param = shift();
my $quoted = B::perlstring($param);
sub {
my $var = pop();
return &Types::Standard::Object()->inline_check($var), sprintf(' ref(%s) =~ qr/^Type::Params::OO::/ ', $var), sprintf(q[ do { use Scalar::Util (); Scalar::Util::reftype(%s) eq 'HASH' } ], $var), sprintf(q[ defined((%s)->{'~~caller'}) && ((%s)->{'~~caller'} eq %s) ], $var, $var, $quoted);
}
;
}
)
}
MC/DC0%0/2
$ArgsObject ||= do {
"Type::Tiny"->new("name", "ArgsObject", "parent", &Types::Standard::Object(), "constraint", " ref(\$_) =~ qr/^Type::Params::OO::/ ", "constraint_generator", sub {
Type::Tiny::check_parameter_count_for_parameterized_type("Type::Params", "ArgsObject", \@_, 1, 1);
my $param = Types::Standard::assert_Str(shift());
sub {
defined $_->{"~~caller"} and $_->{"~~caller"} eq $param;
}
;
}
, "inline_generator", sub {
my $param = shift();
my $quoted = B::perlstring($param);
sub {
my $var = pop();
return &Types::Standard::Object()->inline_check($var), sprintf(' ref(%s) =~ qr/^Type::Params::OO::/ ', $var), sprintf(q[ do { use Scalar::Util (); Scalar::Util::reftype(%s) eq 'HASH' } ], $var), sprintf(q[ defined((%s)->{'~~caller'}) && ((%s)->{'~~caller'} eq %s) ], $var, $var, $quoted);
}
;
}
)
}
$ArgsObject
do {
"Type::Tiny"->new("name", "ArgsObject", "parent", &Types::Standard::Object(), "constraint", " ref(\$_) =~ qr/^Type::Params::OO::/ ", "constraint_generator", sub {
Type::Tiny::check_parameter_count_for_parameterized_type("Type::Params", "ArgsObject", \@_, 1, 1);
my $param = Types::Standard::assert_Str(shift());
sub {
defined $_->{"~~caller"} and $_->{"~~caller"} eq $param;
}
;
}
, "inline_generator", sub {
my $param = shift();
my $quoted = B::perlstring($param);
sub {
my $var = pop();
return &Types::Standard::Object()->inline_check($var), sprintf(' ref(%s) =~ qr/^Type::Params::OO::/ ', $var), sprintf(q[ do { use Scalar::Util (); Scalar::Util::reftype(%s) eq 'HASH' } ], $var), sprintf(q[ defined((%s)->{'~~caller'}) && ((%s)->{'~~caller'} eq %s) ], $var, $var, $quoted);
}
;
}
)
}
Truth table66%2/3
A ||= B
A= $ArgsObjectB= do {
"Type::Tiny"->new("name", "ArgsObject", "parent", &Types::Standard::Object(), "constraint", " ref(\$_) =~ qr/^Type::Params::OO::/ ", "constraint_generator", sub {
Type::Tiny::check_parameter_count_for_parameterized_type("Type::Params", "ArgsObject", \@_, 1, 1);
my $param = Types::Standard::assert_Str(shift());
sub {
defined $_->{"~~caller"} and $_->{"~~caller"} eq $param;
}
;
}
, "inline_generator", sub {
my $param = shift();
my $quoted = B::perlstring($param);
sub {
my $var = pop();
return &Types::Standard::Object()->inline_check($var), sprintf(' ref(%s) =~ qr/^Type::Params::OO::/ ', $var), sprintf(q[ do { use Scalar::Util (); Scalar::Util::reftype(%s) eq 'HASH' } ], $var), sprintf(q[ defined((%s)->{'~~caller'}) && ((%s)->{'~~caller'} eq %s) ], $var, $var, $quoted);
}
;
}
)
}
| |||||||||||||||||||||||||||||||||||||||
| 88 | 'Type::Tiny'->new( | ||||||||||||||||||||||||||||||||||||||
| 89 | name => 'ArgsObject', | ||||||||||||||||||||||||||||||||||||||
| 90 | parent => Types::Standard::Object(), | ||||||||||||||||||||||||||||||||||||||
| 91 | constraint => q{ ref($_) =~ qr/^Type::Params::OO::/ }, | ||||||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | constraint_generator => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 93 | 3 | Type::Tiny::check_parameter_count_for_parameterized_type( 'Type::Params', 'ArgsObject', \@_, 1, 1 ); | |||||||||||||||||||||||||||||||||||||
| 94 | 3 | my $param = Types::Standard::assert_Str( shift ); | |||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub { defined( $_->{'~~caller'} ) and $_->{'~~caller'} eq $param }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 96 | }, | ||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | inline_generator => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 98 | 3 | my $param = shift; | |||||||||||||||||||||||||||||||||||||
| 99 | 3 | my $quoted = B::perlstring( $param ); | |||||||||||||||||||||||||||||||||||||
| 100 | 3 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 101 | 3 | my $var = pop; | |||||||||||||||||||||||||||||||||||||
| 102 | return ( | ||||||||||||||||||||||||||||||||||||||
| 103 | 3 | Types::Standard::Object()->inline_check( $var ), | |||||||||||||||||||||||||||||||||||||
| 104 | sprintf( q{ ref(%s) =~ qr/^Type::Params::OO::/ }, $var ), | ||||||||||||||||||||||||||||||||||||||
| 105 | sprintf( | ||||||||||||||||||||||||||||||||||||||
| 106 | q{ do { use Scalar::Util (); Scalar::Util::reftype(%s) eq 'HASH' } }, $var | ||||||||||||||||||||||||||||||||||||||
| 107 | ), | ||||||||||||||||||||||||||||||||||||||
| 108 | sprintf( | ||||||||||||||||||||||||||||||||||||||
| 109 | q{ defined((%s)->{'~~caller'}) && ((%s)->{'~~caller'} eq %s) }, $var, $var, | ||||||||||||||||||||||||||||||||||||||
| 110 | $quoted | ||||||||||||||||||||||||||||||||||||||
| 111 | ), | ||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||
| 113 | 3 | }; | |||||||||||||||||||||||||||||||||||||
| 114 | }, | ||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ); | |||||||||||||||||||||||||||||||||||||
| 116 | }; | ||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | @_ ? $ArgsObject->parameterize( @{ $_[0] } ) : $ArgsObject; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 119 | } #/ sub ArgsObject (;@) | ||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||
| 121 | 66 | &Scalar::Util::set_prototype( \&ArgsObject, ';$' ) | |||||||||||||||||||||||||||||||||||||
| 122 | if Eval::TypeTiny::NICE_PROTOTYPES; | ||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | 255 | ▶ | sub signature { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
signature: called CC=9 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 126 | 255 | ▶ | if ( @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 127 | 1 | require Error::TypeTiny; | |||||||||||||||||||||||||||||||||||||
| 128 | 1 | Error::TypeTiny::croak( "Expected even-sized list of arguments" ); | |||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||
| 130 | 254 | my ( %opts ) = @_; | |||||||||||||||||||||||||||||||||||||
| 131 | 254 | ▶ | $opts{next} ||= delete $opts{goto_next} if exists $opts{goto_next}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"next"} ||= delete $opts{"goto_next"}
MC/DC0%0/2
$opts{"next"} ||= delete $opts{"goto_next"}
$opts{"next"}
delete $opts{"goto_next"}
Truth table0%0/3
A ||= B
A= $opts{"next"}B= delete $opts{"goto_next"}
| |||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||
| 133 | 254 | ▶ | my $for = [ caller( 1 + ( $opts{caller_level} || 0 ) ) ]->[3] || ( ( $opts{package} || '__ANON__' ) . '::__ANON__' ); | ||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
[caller 1 + ($opts{'caller_level'} || 0)]->[3] || ($opts{'package'} || '__ANON__') . '::__ANON__'
$opts{'caller_level'} || 0
$opts{'package'} || '__ANON__'
MC/DC100%1/1
[caller 1 + ($opts{'caller_level'} || 0)]->[3] || ($opts{'package'} || '__ANON__') . '::__ANON__'
[caller 1 + ($opts{'caller_level'} || 0)]->[3]
MC/DC100%1/1
$opts{'caller_level'} || 0
$opts{'caller_level'}
Truth table100%2/2
A
A= [caller 1 + ($opts{'caller_level'} || 0)]->[3]
Truth table100%2/2
A
A= $opts{'caller_level'}
| |||||||||||||||||||||||||||||||||||||||
| 134 | 254 | my ( $pkg, $sub ) = ( $for =~ /^(.+)::(\w+)$/ ); | |||||||||||||||||||||||||||||||||||||
| 135 | 254 | ▶ | $opts{package} ||= $pkg; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"package"} ||= $pkg
MC/DC0%0/2
$opts{"package"} ||= $pkg
$opts{"package"}
$pkg
Truth table66%2/3
A ||= B
A= $opts{"package"}B= $pkg
| |||||||||||||||||||||||||||||||||||||||
| 136 | 254 | ▶ | $opts{subname} ||= $sub; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"subname"} ||= $sub
MC/DC0%0/2
$opts{"subname"} ||= $sub
$opts{"subname"}
$sub
Truth table66%2/3
A ||= B
A= $opts{"subname"}B= $sub
| |||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||
| 138 | 254 | require Type::Params::Signature; | |||||||||||||||||||||||||||||||||||||
| 139 | 254 | 'Type::Params::Signature'->new_from_v2api( \%opts )->return_wanted; | |||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||
| 142 | 39 | ▶ | sub signature_for { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
signature_for: called CC=23 SCAR=31.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 143 | 39 | ▶ | if ( not @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 144 | 1 | require Error::TypeTiny; | |||||||||||||||||||||||||||||||||||||
| 145 | 1 | Error::TypeTiny::croak( "Expected odd-sized list of arguments; did you forget the function name?" ); | |||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||
| 147 | 38 | my ( $function, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||
| 148 | 38 | ▶ | my $package = $opts{package} || caller( $opts{caller_level} || 0 ); | ||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$opts{'package'} || caller($opts{'caller_level'} || 0)
$opts{'caller_level'} || 0
MC/DC50%1/2
$opts{'package'} || caller($opts{'caller_level'} || 0)
$opts{'package'}
$opts{'caller_level'}
Truth table66%2/3
A || B
A= $opts{'package'}B= $opts{'caller_level'}
| |||||||||||||||||||||||||||||||||||||||
| 149 | 38 | ▶ | $opts{next} ||= delete $opts{goto_next} if exists $opts{goto_next}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts{"next"} ||= delete $opts{"goto_next"}
MC/DC0%0/2
$opts{"next"} ||= delete $opts{"goto_next"}
$opts{"next"}
delete $opts{"goto_next"}
Truth table33%1/3
A ||= B
A= $opts{"next"}B= delete $opts{"goto_next"}
| |||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||
| 151 | 38 | ▶ | if ( ref($function) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 152 | 3 | $opts{package} = $package; | |||||||||||||||||||||||||||||||||||||
| 153 | 3 | return map { signature_for( $_, %opts ) } @$function; | |||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||
| 156 | 35 | $opts{_is_signature_for} = 1; | |||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||
| 158 | 35 | ▶ | my $fullname = ( $function =~ /::/ ) ? $function : "$package\::$function"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 159 | 35 | ▶ | $opts{package} ||= $package; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"package"} ||= $package
MC/DC0%0/2
$opts{"package"} ||= $package
$opts{"package"}
$package
Truth table66%2/3
A ||= B
A= $opts{"package"}B= $package
| |||||||||||||||||||||||||||||||||||||||
| 160 | 35 | ▶ | $opts{subname} ||= ( $function =~ /::(\w+)$/ ) ? $1 : $function; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts{"subname"} ||= $function =~ /::(\w+)$/ ? $1 : $function
MC/DC0%0/2
$opts{"subname"} ||= $function =~ /::(\w+)$/ ? $1 : $function
$opts{"subname"}
$function =~ /::(\w+)$/ ? $1 : $function
Truth table33%1/3
A ||= B
A= $opts{"subname"}B= $function =~ /::(\w+)$/ ? $1 : $function
| |||||||||||||||||||||||||||||||||||||||
| 161 | 66 | ▶ | $opts{next} ||= do { no strict 'refs'; exists(&$fullname) ? \&$fullname : undef; }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
$opts{"next"} ||= do {
no strict 'refs';
exists &$fullname ? \&$fullname : undef
}
MC/DC100%2/2
$opts{"next"} ||= do {
no strict 'refs';
exists &$fullname ? \&$fullname : undef
}
$opts{"next"}
do {
no strict 'refs';
exists &$fullname ? \&$fullname : undef
}
Truth table100%3/3
A ||= B
A= $opts{"next"}B= do {
no strict 'refs';
exists &$fullname ? \&$fullname : undef
}
| |||||||||||||||||||||||||||||||||||||||
| 162 | 35 | ▶ | if ( $opts{method} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 163 | 5 | ▶ | $opts{next} ||= eval { $package->can( $opts{subname} ) }; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"next"} ||= eval {
do {
$package->can($opts{"subname"})
}
}
MC/DC0%0/2
$opts{"next"} ||= eval {
do {
$package->can($opts{"subname"})
}
}
$opts{"next"}
eval {
do {
$package->can($opts{"subname"})
}
}
Truth table66%2/3
A ||= B
A= $opts{"next"}B= eval {
do {
$package->can($opts{"subname"})
}
}
| |||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||
| 165 | 35 | ▶ | if ( $opts{fallback} and not $opts{next} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opts{"fallback"} and not $opts{"next"}
MC/DC100%2/2
$opts{"fallback"} and not $opts{"next"}
$opts{"fallback"}
not $opts{"next"}
Truth table100%3/3
A and not(B)
A= $opts{"fallback"}B= not $opts{"next"}
| |||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | $opts{next} = ref( $opts{fallback} ) ? $opts{fallback} : sub {}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||
| 168 | 35 | ▶ | if ( not $opts{next} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 169 | 1 | require Error::TypeTiny; | |||||||||||||||||||||||||||||||||||||
| 170 | 1 | return Error::TypeTiny::croak( "Function '$function' not found to wrap!" ); | |||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||
| 173 | 34 | require Type::Params::Signature; | |||||||||||||||||||||||||||||||||||||
| 174 | 34 | my $sig = 'Type::Params::Signature'->new_from_v2api( \%opts ); | |||||||||||||||||||||||||||||||||||||
| 175 | # Delay compilation | ||||||||||||||||||||||||||||||||||||||
| 176 | 32 | my $compiled; | |||||||||||||||||||||||||||||||||||||
| 177 | 30 | ▶ | my $coderef = sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Subroutine
f: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||
| 178 | 30 | ▶ | $compiled ||= $sig->coderef->compile; | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$compiled ||= $sig->coderef->compile
$compiled ||= $sig->coderef->compile
MC/DC0%0/2
$compiled ||= $sig->coderef->compile
$compiled
$sig->coderef->compile
MC/DC0%0/2
$compiled ||= $sig->coderef->compile
$compiled
$sig->coderef->compile
Truth table33%1/3
A ||= B
A= $compiledB= $sig->coderef->compile
Truth table33%1/3
A ||= B
A= $compiledB= $sig->coderef->compile
| |||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||
| 180 | 66 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 181 | 66 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 182 | 30 | *$fullname = set_subname( SIGNATURE_SUBNAME_PREFIX . $fullname . SIGNATURE_SUBNAME_SUFFIX, $compiled ); | |||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||
| 184 | 30 | goto( $compiled ); | |||||||||||||||||||||||||||||||||||||
| 185 | 32 | }; | |||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||
| 187 | 32 | our ( %PRE_INSTALL, %POST_INSTALL ); | |||||||||||||||||||||||||||||||||||||
| 188 | 32 | ▶ | if ( my $cb = $PRE_INSTALL{$package} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 189 | 1 | Types::Standard::assert_ArrayRef( $cb ); | |||||||||||||||||||||||||||||||||||||
| 190 | 1 | $_->( $sig ) for @$cb; | |||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||
| 193 | 66 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 194 | 66 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 195 | 32 | *$fullname = set_subname( SIGNATURE_SUBNAME_PREFIX . $fullname . SIGNATURE_SUBNAME_SUFFIX, $coderef ); | |||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | 32 | ▶ | if ( my $cb = $POST_INSTALL{$package} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 198 | 1 | Types::Standard::assert_ArrayRef( $cb ); | |||||||||||||||||||||||||||||||||||||
| 199 | 1 | $_->( $sig ) for @$cb; | |||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||
| 202 | 32 | return $sig; | |||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | sub signature_for_func { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
signature_for_func: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | if ( not @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 207 | 1 | require Error::TypeTiny; | |||||||||||||||||||||||||||||||||||||
| 208 | 1 | Error::TypeTiny::croak( "Expected odd-sized list of arguments; did you forget the function name?" ); | |||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||
| 210 | 1 | my ( $function, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||
| 211 | 1 | my $N = !!$opts{named}; | |||||||||||||||||||||||||||||||||||||
| 212 | 1 | @_ = ( $function, method => 0, allow_dash => $N, list_to_named => $N, %opts ); | |||||||||||||||||||||||||||||||||||||
| 213 | 1 | goto \&signature_for; | |||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | sub signature_for_method { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
signature_for_method: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | if ( not @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 218 | 1 | require Error::TypeTiny; | |||||||||||||||||||||||||||||||||||||
| 219 | 1 | Error::TypeTiny::croak( "Expected odd-sized list of arguments; did you forget the function name?" ); | |||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||
| 221 | 1 | my ( $function, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||
| 222 | 1 | my $N = !!$opts{named}; | |||||||||||||||||||||||||||||||||||||
| 223 | 1 | @_ = ( $function, method => 1, allow_dash => $N, list_to_named => $N, %opts ); | |||||||||||||||||||||||||||||||||||||
| 224 | 1 | goto \&signature_for; | |||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||
| 227 | 83 | ▶ | sub compile { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
compile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 228 | 83 | my @args = @_; | |||||||||||||||||||||||||||||||||||||
| 229 | 83 | @_ = ( positional => \@args ); | |||||||||||||||||||||||||||||||||||||
| 230 | 83 | goto \&signature; | |||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||
| 233 | 85 | ▶ | sub compile_named { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
compile_named: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 234 | 85 | my @args = @_; | |||||||||||||||||||||||||||||||||||||
| 235 | 85 | @_ = ( bless => 0, named => \@args ); | |||||||||||||||||||||||||||||||||||||
| 236 | 85 | goto \&signature; | |||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||
| 239 | 20 | ▶ | sub compile_named_oo { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
compile_named_oo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 240 | 20 | my @args = @_; | |||||||||||||||||||||||||||||||||||||
| 241 | 20 | @_ = ( bless => 1, named => \@args ); | |||||||||||||||||||||||||||||||||||||
| 242 | 20 | goto \&signature; | |||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||
| 245 | # Would be faster to inline this into validate and validate_named, but | ||||||||||||||||||||||||||||||||||||||
| 246 | # that would complicate them. :/ | ||||||||||||||||||||||||||||||||||||||
| 247 | 933 | ▶ | sub _mk_key { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_key: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||
| 248 | 933 | local $_; | |||||||||||||||||||||||||||||||||||||
| 249 | join ':', map { | ||||||||||||||||||||||||||||||||||||||
| 250 | 933 | Types::Standard::is_HashRef( $_ ) ? do { | |||||||||||||||||||||||||||||||||||||
| 251 | 488 | my %h = %$_; | |||||||||||||||||||||||||||||||||||||
| 252 | 488 | ▶ | sprintf( '{%s}', _mk_key( map { ; $_ => $h{$_} } sort keys %h ) ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 253 | } : | ||||||||||||||||||||||||||||||||||||||
| 254 | 4623 | ▶ | Types::TypeTiny::is_TypeTiny( $_ ) ? sprintf( 'TYPE=%s', $_->{uniq} ) : | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 255 | Types::Standard::is_Ref( $_ ) ? sprintf( 'REF=%s', refaddr( $_ ) ) : | ||||||||||||||||||||||||||||||||||||||
| 256 | Types::Standard::is_Undef( $_ ) ? sprintf( 'UNDEF' ) : | ||||||||||||||||||||||||||||||||||||||
| 257 | B::perlstring( $_ ) | ||||||||||||||||||||||||||||||||||||||
| 258 | } @_; | ||||||||||||||||||||||||||||||||||||||
| 259 | } #/ sub _mk_key | ||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||
| 262 | 66 | my %compiled; | |||||||||||||||||||||||||||||||||||||
| 263 | 15 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 264 | 15 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||
| 265 | my $sub = ( | ||||||||||||||||||||||||||||||||||||||
| 266 | $compiled{ _mk_key( @_ ) } ||= signature( | ||||||||||||||||||||||||||||||||||||||
| 267 | caller_level => 1, | ||||||||||||||||||||||||||||||||||||||
| 268 | 15 | ▶ | %{ ref( $_[0] ) eq 'HASH' ? shift( @_ ) : +{} }, | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$compiled{_mk_key(@_)} ||= signature("caller_level", 1, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "positional", [@_])
MC/DC0%0/2
$compiled{_mk_key(@_)} ||= signature("caller_level", 1, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "positional", [@_])
$compiled{_mk_key(@_)}
signature("caller_level", 1, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "positional", [@_])
Truth table66%2/3
A ||= B
A= $compiled{_mk_key(@_)}B= signature("caller_level", 1, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "positional", [@_])
| |||||||||||||||||||||||||||||||||||||||
| 269 | positional => [ @_ ], | ||||||||||||||||||||||||||||||||||||||
| 270 | ) | ||||||||||||||||||||||||||||||||||||||
| 271 | ); | ||||||||||||||||||||||||||||||||||||||
| 272 | 15 | @_ = @$arg; | |||||||||||||||||||||||||||||||||||||
| 273 | 15 | goto $sub; | |||||||||||||||||||||||||||||||||||||
| 274 | } #/ sub validate | ||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||
| 278 | 66 | my %compiled; | |||||||||||||||||||||||||||||||||||||
| 279 | 430 | ▶ | sub validate_named { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_named: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 280 | 430 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||
| 281 | my $sub = ( | ||||||||||||||||||||||||||||||||||||||
| 282 | $compiled{ _mk_key( @_ ) } ||= signature( | ||||||||||||||||||||||||||||||||||||||
| 283 | caller_level => 1, | ||||||||||||||||||||||||||||||||||||||
| 284 | bless => 0, | ||||||||||||||||||||||||||||||||||||||
| 285 | 430 | ▶ | %{ ref( $_[0] ) eq 'HASH' ? shift( @_ ) : +{} }, | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$compiled{_mk_key(@_)} ||= signature("caller_level", 1, "bless", 0, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "named", [@_])
MC/DC0%0/2
$compiled{_mk_key(@_)} ||= signature("caller_level", 1, "bless", 0, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "named", [@_])
$compiled{_mk_key(@_)}
signature("caller_level", 1, "bless", 0, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "named", [@_])
Truth table66%2/3
A ||= B
A= $compiled{_mk_key(@_)}B= signature("caller_level", 1, "bless", 0, %{ref $_[0] eq "HASH" ? shift @_ : {};}, "named", [@_])
| |||||||||||||||||||||||||||||||||||||||
| 286 | named => [ @_ ], | ||||||||||||||||||||||||||||||||||||||
| 287 | ) | ||||||||||||||||||||||||||||||||||||||
| 288 | ); | ||||||||||||||||||||||||||||||||||||||
| 289 | 430 | @_ = @$arg; | |||||||||||||||||||||||||||||||||||||
| 290 | 430 | goto $sub; | |||||||||||||||||||||||||||||||||||||
| 291 | } #/ sub validate_named | ||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||
| 294 | 66 | ▶ | sub multisig { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
multisig: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 295 | 7 | ▶ | my %options = ( ref( $_[0] ) eq "HASH" ) ? %{ +shift } : (); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 296 | 7 | signature( | |||||||||||||||||||||||||||||||||||||
| 297 | %options, | ||||||||||||||||||||||||||||||||||||||
| 298 | multi => \@_, | ||||||||||||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||||||||||||
| 300 | } #/ sub multisig | ||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||
| 302 | 2 | ▶ | sub wrap_methods { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap_methods: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 303 | 2 | ▶ | my $opts = ref( $_[0] ) eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 304 | 2 | ▶ | $opts->{caller} ||= caller; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"caller"} ||= caller
MC/DC0%0/2
$opts->{"caller"} ||= caller
$opts->{"caller"}
caller
Truth table33%1/3
A ||= B
A= $opts->{"caller"}B= caller
| |||||||||||||||||||||||||||||||||||||||
| 305 | 2 | $opts->{skip_invocant} = 1; | |||||||||||||||||||||||||||||||||||||
| 306 | 2 | $opts->{use_can} = 1; | |||||||||||||||||||||||||||||||||||||
| 307 | 2 | unshift @_, $opts; | |||||||||||||||||||||||||||||||||||||
| 308 | 2 | goto \&_wrap_subs; | |||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | sub wrap_subs { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap_subs: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | my $opts = ref( $_[0] ) eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | $opts->{caller} ||= caller; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"caller"} ||= caller
MC/DC0%0/2
$opts->{"caller"} ||= caller
$opts->{"caller"}
caller
Truth table33%1/3
A ||= B
A= $opts->{"caller"}B= caller
| |||||||||||||||||||||||||||||||||||||||
| 314 | 1 | $opts->{skip_invocant} = 0; | |||||||||||||||||||||||||||||||||||||
| 315 | 1 | $opts->{use_can} = 0; | |||||||||||||||||||||||||||||||||||||
| 316 | 1 | unshift @_, $opts; | |||||||||||||||||||||||||||||||||||||
| 317 | 1 | goto \&_wrap_subs; | |||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||
| 320 | 3 | ▶ | sub _wrap_subs { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap_subs: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||
| 321 | 3 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||
| 322 | 3 | ▶ | while ( @_ ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 323 | 8 | my ( $name, $proto ) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||
| 324 | 8 | ▶ | my $fullname = ( $name =~ /::/ ) ? $name : sprintf( '%s::%s', $opts->{caller}, $name ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 325 | 8 | my $orig = do { | |||||||||||||||||||||||||||||||||||||
| 326 | 66 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 327 | exists &$fullname ? \&$fullname | ||||||||||||||||||||||||||||||||||||||
| 328 | 2 | ▶ | : $opts->{use_can} ? ( $opts->{caller}->can( $name ) || sub { } ) | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ▶ | : sub { } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 330 | 8 | ▶ | }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$opts->{"caller"}->can($name) or sub {
}
MC/DC0%0/2
$opts->{"caller"}->can($name) or sub {
}
$opts->{"caller"}->can($name)
sub {
}
Truth table66%2/3
A or B
A= $opts->{"caller"}->can($name)B= sub {
}
| |||||||||||||||||||||||||||||||||||||||
| 331 | 8 | my $new; | |||||||||||||||||||||||||||||||||||||
| 332 | 8 | ▶ | if ( ref $proto eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 333 | $new = $opts->{skip_invocant} | ||||||||||||||||||||||||||||||||||||||
| 334 | 4 | ▶ | ? sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 335 | 4 | my $s = shift; | |||||||||||||||||||||||||||||||||||||
| 336 | 4 | @_ = ( $s, &$proto ); | |||||||||||||||||||||||||||||||||||||
| 337 | 2 | goto $orig; | |||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||
| 339 | 2 | ▶ | : sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 340 | 2 | @_ = &$proto; | |||||||||||||||||||||||||||||||||||||
| 341 | 1 | goto $orig; | |||||||||||||||||||||||||||||||||||||
| 342 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||
| 344 | else { | ||||||||||||||||||||||||||||||||||||||
| 345 | $new = compile( | ||||||||||||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||||||||||||
| 347 | 'package' => $opts->{caller}, | ||||||||||||||||||||||||||||||||||||||
| 348 | 'subname' => $name, | ||||||||||||||||||||||||||||||||||||||
| 349 | 'next' => $orig, | ||||||||||||||||||||||||||||||||||||||
| 350 | 6 | ▶ | 'head' => $opts->{skip_invocant} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 351 | }, | ||||||||||||||||||||||||||||||||||||||
| 352 | @$proto, | ||||||||||||||||||||||||||||||||||||||
| 353 | ); | ||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||
| 355 | 66 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 356 | 66 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 357 | 8 | *$fullname = set_subname( $fullname, $new ); | |||||||||||||||||||||||||||||||||||||
| 358 | } #/ while ( @_ ) | ||||||||||||||||||||||||||||||||||||||
| 359 | 3 | 1; | |||||||||||||||||||||||||||||||||||||
| 360 | } #/ sub _wrap_subs | ||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||
| 362 | 66 | 1; | |||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||
| 364 | __END__ | ||||||||||||||||||||||||||||||||||||||