line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Exporter::Meta; |
2
|
109
|
|
|
109
|
|
1054
|
use strict; |
|
109
|
|
|
|
|
1242
|
|
|
109
|
|
|
|
|
2707
|
|
3
|
109
|
|
|
109
|
|
508
|
use warnings; |
|
109
|
|
|
|
|
173
|
|
|
109
|
|
|
|
|
3461
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my %EXPORT_META; |
6
|
|
|
|
|
|
|
|
7
|
109
|
|
|
109
|
|
517
|
use Carp qw/croak confess/; |
|
109
|
|
|
|
|
159
|
|
|
109
|
|
|
|
|
40474
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub EXPORTS() { 'exports' } |
10
|
|
|
|
|
|
|
sub PACKAGE() { 'package' } |
11
|
|
|
|
|
|
|
sub DEFAULT() { 'default' } |
12
|
|
|
|
|
|
|
|
13
|
8640
|
|
|
8640
|
1
|
21855
|
sub exports { $_[0]->{+EXPORTS} } |
14
|
4310
|
|
|
4310
|
1
|
16975
|
sub default { $_[0]->{+DEFAULT} } |
15
|
1
|
|
|
1
|
0
|
10
|
sub package { $_[0]->{+PACKAGE} } |
16
|
|
|
|
|
|
|
|
17
|
12038
|
|
|
12038
|
1
|
352106
|
sub get { $EXPORT_META{$_[-1]} } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
10322
|
|
|
10322
|
1
|
16678
|
my ($class, $pkg) = @_; |
21
|
|
|
|
|
|
|
|
22
|
10322
|
100
|
|
|
|
21531
|
confess "Package is required!" |
23
|
|
|
|
|
|
|
unless $pkg; |
24
|
|
|
|
|
|
|
|
25
|
10321
|
|
|
|
|
15706
|
my $meta = $EXPORT_META{$pkg}; |
26
|
10321
|
100
|
|
|
|
36755
|
return $meta if $meta; |
27
|
|
|
|
|
|
|
|
28
|
1685
|
|
|
|
|
8500
|
$meta = bless({ |
29
|
|
|
|
|
|
|
EXPORTS() => {}, |
30
|
|
|
|
|
|
|
DEFAULT() => [], |
31
|
|
|
|
|
|
|
PACKAGE() => $pkg, |
32
|
|
|
|
|
|
|
}, $class); |
33
|
|
|
|
|
|
|
|
34
|
1685
|
|
|
|
|
19290
|
return $EXPORT_META{$pkg} = $meta; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub add { |
38
|
1151
|
|
|
1151
|
1
|
2469
|
my ($self, $default, $name, $ref) = @_; |
39
|
|
|
|
|
|
|
|
40
|
1151
|
100
|
|
|
|
2763
|
confess "Name is mandatory" unless $name; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
confess "$name is already exported" |
43
|
1150
|
100
|
|
|
|
3320
|
if $self->{+EXPORTS}->{$name}; |
44
|
|
|
|
|
|
|
|
45
|
1149
|
|
|
|
|
2015
|
my $pkg = $self->{+PACKAGE}; |
46
|
|
|
|
|
|
|
|
47
|
1149
|
100
|
|
|
|
2610
|
unless ($ref) { |
48
|
109
|
|
|
109
|
|
628
|
no strict 'refs'; |
|
109
|
|
|
|
|
208
|
|
|
109
|
|
|
|
|
21230
|
|
49
|
3
|
|
|
|
|
5
|
$ref = *{"$pkg\::$name"}{CODE}; |
|
3
|
|
|
|
|
20
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
1149
|
100
|
66
|
|
|
5888
|
confess "No reference or package sub found for '$name' in '$pkg'" |
53
|
|
|
|
|
|
|
unless $ref && ref $ref; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Add the export ref |
56
|
1148
|
|
|
|
|
2812
|
$self->{+EXPORTS}->{$name} = $ref; |
57
|
1148
|
100
|
|
|
|
4058
|
push @{$self->{+DEFAULT}} => $name if $default; |
|
346
|
|
|
|
|
1704
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub add_bulk { |
61
|
1861
|
|
|
1861
|
1
|
3004
|
my $self = shift; |
62
|
1861
|
|
|
|
|
2624
|
my $default = shift; |
63
|
|
|
|
|
|
|
|
64
|
1861
|
|
|
|
|
3654
|
my $pkg = $self->{+PACKAGE}; |
65
|
|
|
|
|
|
|
|
66
|
1861
|
|
|
|
|
3953
|
for my $name (@_) { |
67
|
|
|
|
|
|
|
confess "$name is already exported" |
68
|
11942
|
100
|
|
|
|
27650
|
if $self->{+EXPORTS}->{$name}; |
69
|
|
|
|
|
|
|
|
70
|
109
|
|
|
109
|
|
620
|
no strict 'refs'; |
|
109
|
|
|
|
|
257
|
|
|
109
|
|
|
|
|
12857
|
|
71
|
|
|
|
|
|
|
$self->{+EXPORTS}->{$name} = *{"$pkg\::$name"}{CODE} |
72
|
11941
|
|
66
|
|
|
12817
|
|| confess "No reference or package sub found for '$name' in '$pkg'"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
1859
|
100
|
|
|
|
6558
|
push @{$self->{+DEFAULT}} => @_ if $default; |
|
826
|
|
|
|
|
4437
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |