| 1 | package perl5i::2::Signature; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 109 | ▶ | use 5.010_000; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 109 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 109 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 109 | ▶ | use perl5i::2::Signature::Method::None; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 109 | ▶ | use perl5i::2::Signature::Function::None; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | # A proxy class to hold a method's signature until its actually used. | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | use overload | ||||||||||||||||||||
| 13 | 0 | ▶ | q[""] => sub { return $_[0]->as_string }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 14 | 109 | fallback => 1 | |||||||||||||||||||
| 15 | 109 | ▶ | ; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | sub new { | ||||||||||||||||||||
| 19 | 2071 | ▶ | my $class = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||
| 20 | 2071 | my %args = @_; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 2071 | ▶ | my $string = $args{signature} // ''; | ||||||||||||||||||
|
Condition50%1/2
$args{"signature"} // ""
MC/DC0%0/1
$args{"signature"} // ""
$args{"signature"}
Truth table50%1/2
A
A= $args{"signature"}
| |||||||||||||||||||||
| 23 | 2071 | ▶ | my $is_method = $args{is_method} // 0; | ||||||||||||||||||
|
Condition50%1/2
$args{"is_method"} // 0
MC/DC0%0/1
$args{"is_method"} // 0
$args{"is_method"}
Truth table50%1/2
A
A= $args{"is_method"}
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 2071 | ▶ | my $no_params = !$string || $string !~ /\S/; | ||||||||||||||||||
|
Condition66%2/3
$string && $string =~ /\S/
MC/DC50%1/2
$string && $string =~ /\S/
$string
$string =~ /\S/
Truth table66%2/3
A && B
A= $stringB= $string =~ /\S/
| |||||||||||||||||||||
| 26 | 2071 | ▶ | if( $no_params ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 218 | ▶ | return $is_method ? perl5i::2::Signature::Method::None->new( signature => $string ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | : perl5i::2::Signature::Function::None->new( signature => $string ); | ||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | else { | ||||||||||||||||||||
| 31 | 1853 | return bless { signature => $string, is_method => $is_method }, $class; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | sub as_string { | ||||||||||||||||||||
| 36 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 37 | 0 | return $self->{signature}; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | sub make_real { | ||||||||||||||||||||
| 41 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
make_real: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | require perl5i::2::Signature::Real; | |||||||||||||||||||
| 44 | 0 | bless $self, "perl5i::2::Signature::Real"; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | $self->__parse_signature; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | # Upgrade to a real signature object | ||||||||||||||||||||
| 50 | # and call the original method. | ||||||||||||||||||||
| 51 | # This should only be called once per object. | ||||||||||||||||||||
| 52 | 109 | our $AUTOLOAD; | |||||||||||||||||||
| 53 | sub AUTOLOAD { | ||||||||||||||||||||
| 54 | 0 | ▶ | my($method) = reverse split /::/, $AUTOLOAD; | ||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 55 | 0 | ▶ | return if $method eq 'DESTROY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | my $self = $_[0]; # leave @_ alone | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | # Upgrade to a real object | ||||||||||||||||||||
| 60 | 0 | $self->make_real; | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | goto $self->can($method); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 109 | 1; | |||||||||||||||||||