line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Exporter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.006; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Be lean. |
6
|
|
|
|
|
|
|
#use strict; |
7
|
|
|
|
|
|
|
#no strict 'refs'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $Debug = 0; |
10
|
|
|
|
|
|
|
our $ExportLevel = 0; |
11
|
|
|
|
|
|
|
our $Verbose ||= 0; |
12
|
|
|
|
|
|
|
our $VERSION = '5.73'; |
13
|
|
|
|
|
|
|
our (%Cache); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub as_heavy { |
16
|
0
|
|
|
0
|
0
|
|
require Exporter::Heavy; |
17
|
|
|
|
|
|
|
# Unfortunately, this does not work if the caller is aliased as *name = \&foo |
18
|
|
|
|
|
|
|
# Thus the need to create a lot of identical subroutines |
19
|
0
|
|
|
|
|
|
my $c = (caller(1))[3]; |
20
|
0
|
|
|
|
|
|
$c =~ s/.*:://; |
21
|
0
|
|
|
|
|
|
\&{"Exporter::Heavy::heavy_$c"}; |
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub export { |
25
|
0
|
|
|
0
|
0
|
|
goto &{as_heavy()}; |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub import { |
29
|
0
|
|
|
0
|
|
|
my $pkg = shift; |
30
|
0
|
|
|
|
|
|
my $callpkg = caller($ExportLevel); |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
0
|
|
|
|
if ($pkg eq "Exporter" and @_ and $_[0] eq "import") { |
|
|
|
0
|
|
|
|
|
33
|
0
|
|
|
|
|
|
*{$callpkg."::import"} = \&import; |
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-( |
38
|
0
|
|
|
|
|
|
my $exports = \@{"$pkg\::EXPORT"}; |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# But, avoid creating things if they don't exist, which saves a couple of |
40
|
|
|
|
|
|
|
# hundred bytes per package processed. |
41
|
0
|
|
0
|
|
|
|
my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"}; |
42
|
0
|
0
|
0
|
|
|
|
return export $pkg, $callpkg, @_ |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
43
|
|
|
|
|
|
|
if $Verbose or $Debug or $fail && @$fail > 1; |
44
|
0
|
|
0
|
|
|
|
my $export_cache = ($Cache{$pkg} ||= {}); |
45
|
0
|
0
|
|
|
|
|
my $args = @_ or @_ = @$exports; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
0
|
|
|
|
if ($args and not %$export_cache) { |
48
|
|
|
|
|
|
|
s/^&//, $export_cache->{$_} = 1 |
49
|
0
|
|
|
|
|
|
foreach (@$exports, @{"$pkg\::EXPORT_OK"}); |
|
0
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
|
my $heavy; |
52
|
|
|
|
|
|
|
# Try very hard not to use {} and hence have to enter scope on the foreach |
53
|
|
|
|
|
|
|
# We bomb out of the loop with last as soon as heavy is set. |
54
|
0
|
0
|
0
|
|
|
|
if ($args or $fail) { |
55
|
|
|
|
|
|
|
($heavy = (/\W/ or $args and not exists $export_cache->{$_} |
56
|
|
|
|
|
|
|
or $fail and @$fail and $_ eq $fail->[0])) and last |
57
|
0
|
|
0
|
|
|
|
foreach (@_); |
|
|
|
0
|
|
|
|
|
58
|
|
|
|
|
|
|
} else { |
59
|
|
|
|
|
|
|
($heavy = /\W/) and last |
60
|
0
|
|
0
|
|
|
|
foreach (@_); |
61
|
|
|
|
|
|
|
} |
62
|
0
|
0
|
|
|
|
|
return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy; |
|
|
0
|
|
|
|
|
|
63
|
|
|
|
|
|
|
local $SIG{__WARN__} = |
64
|
0
|
0
|
|
0
|
|
|
sub {require Carp; &Carp::carp} if not $SIG{__WARN__}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# shortcut for the common case of no type character |
66
|
0
|
|
|
|
|
|
*{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Default methods |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub export_fail { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
@_; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Unfortunately, caller(1)[3] "does not work" if the caller is aliased as |
77
|
|
|
|
|
|
|
# *name = \&foo. Thus the need to create a lot of identical subroutines |
78
|
|
|
|
|
|
|
# Otherwise we could have aliased them to export(). |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub export_to_level { |
81
|
0
|
|
|
0
|
0
|
|
goto &{as_heavy()}; |
|
0
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub export_tags { |
85
|
0
|
|
|
0
|
0
|
|
goto &{as_heavy()}; |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub export_ok_tags { |
89
|
0
|
|
|
0
|
0
|
|
goto &{as_heavy()}; |
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub require_version { |
93
|
0
|
|
|
0
|
0
|
|
goto &{as_heavy()}; |
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
__END__ |