line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package perl5i::2::Signature; |
2
|
|
|
|
|
|
|
|
3
|
101
|
|
|
101
|
|
1483
|
use 5.010_000; |
|
101
|
|
|
|
|
243
|
|
|
101
|
|
|
|
|
3364
|
|
4
|
101
|
|
|
101
|
|
436
|
use strict; |
|
101
|
|
|
|
|
118
|
|
|
101
|
|
|
|
|
2633
|
|
5
|
101
|
|
|
101
|
|
368
|
use warnings; |
|
101
|
|
|
|
|
112
|
|
|
101
|
|
|
|
|
2357
|
|
6
|
|
|
|
|
|
|
|
7
|
101
|
|
|
101
|
|
37525
|
use perl5i::2::Signature::Method::None; |
|
101
|
|
|
|
|
210
|
|
|
101
|
|
|
|
|
2712
|
|
8
|
101
|
|
|
101
|
|
38751
|
use perl5i::2::Signature::Function::None; |
|
101
|
|
|
|
|
215
|
|
|
101
|
|
|
|
|
4642
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# A proxy class to hold a method's signature until its actually used. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use overload |
13
|
10
|
|
|
10
|
|
1275
|
q[""] => sub { return $_[0]->as_string }, |
14
|
101
|
|
|
|
|
651
|
fallback => 1 |
15
|
101
|
|
|
101
|
|
471
|
; |
|
101
|
|
|
|
|
133
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
1974
|
|
|
1974
|
0
|
4196
|
my $class = shift; |
20
|
1974
|
|
|
|
|
3273
|
my %args = @_; |
21
|
|
|
|
|
|
|
|
22
|
1974
|
|
50
|
|
|
3666
|
my $string = $args{signature} // ''; |
23
|
1974
|
|
100
|
|
|
3077
|
my $is_method = $args{is_method} // 0; |
24
|
|
|
|
|
|
|
|
25
|
1974
|
|
100
|
|
|
7937
|
my $no_params = !$string || $string !~ /\S/; |
26
|
1974
|
100
|
|
|
|
2798
|
if( $no_params ) { |
27
|
223
|
100
|
|
|
|
1967
|
return $is_method ? perl5i::2::Signature::Method::None->new( signature => $string ) |
28
|
|
|
|
|
|
|
: perl5i::2::Signature::Function::None->new( signature => $string ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
1751
|
|
|
|
|
7835
|
return bless { signature => $string, is_method => $is_method }, $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub as_string { |
36
|
10
|
|
|
10
|
0
|
14
|
my $self = shift; |
37
|
10
|
|
|
|
|
54
|
return $self->{signature}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub make_real { |
41
|
11
|
|
|
11
|
0
|
11
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
11
|
|
|
|
|
1120
|
require perl5i::2::Signature::Real; |
44
|
11
|
|
|
|
|
27
|
bless $self, "perl5i::2::Signature::Real"; |
45
|
|
|
|
|
|
|
|
46
|
11
|
|
|
|
|
28
|
$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
|
|
|
|
|
|
|
our $AUTOLOAD; |
53
|
|
|
|
|
|
|
sub AUTOLOAD { |
54
|
11
|
|
|
11
|
|
1372
|
my($method) = reverse split /::/, $AUTOLOAD; |
55
|
11
|
50
|
|
|
|
31
|
return if $method eq 'DESTROY'; |
56
|
|
|
|
|
|
|
|
57
|
11
|
|
|
|
|
14
|
my $self = $_[0]; # leave @_ alone |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Upgrade to a real object |
60
|
11
|
|
|
|
|
21
|
$self->make_real; |
61
|
|
|
|
|
|
|
|
62
|
11
|
|
|
|
|
46
|
goto $self->can($method); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |