line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
package Exporter::Lite; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
require 5.004; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Using strict or vars almost doubles our load time. Turn them back |
7
|
|
|
|
|
|
|
# on when debugging. |
8
|
|
|
|
|
|
|
#use strict 'vars'; # we're going to be doing a lot of sym refs |
9
|
|
|
|
|
|
|
#use vars qw($VERSION @EXPORT); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = 0.02; |
12
|
|
|
|
|
|
|
@EXPORT = qw(import); # we'll know pretty fast if it doesn't work :) |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
12
|
|
|
12
|
|
2147
|
sub import { |
17
|
12
|
|
|
|
|
42
|
my($exporter, @imports) = @_; |
18
|
|
|
|
|
|
|
my($caller, $file, $line) = caller; |
19
|
12
|
100
|
|
|
|
51
|
|
20
|
9
|
|
|
|
|
18
|
unless( @imports ) { # Default import. |
|
9
|
|
|
|
|
39
|
|
21
|
|
|
|
|
|
|
@imports = @{$exporter.'::EXPORT'}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
else { |
24
|
|
|
|
|
|
|
# Because @EXPORT_OK = () would indicate that nothing is |
25
|
|
|
|
|
|
|
# to be exported, we cannot simply check the length of @EXPORT_OK. |
26
|
|
|
|
|
|
|
# We must to oddness to see if the variable exists at all as |
27
|
|
|
|
|
|
|
# well as avoid autovivification. |
28
|
3
|
|
|
|
|
6
|
# XXX idea stolen from base.pm, this might be all unnecessary |
29
|
3
|
50
|
50
|
|
|
5
|
my $eokglob; |
|
3
|
|
|
|
|
29
|
|
30
|
0
|
0
|
|
|
|
0
|
if( $eokglob = ${$exporter.'::'}{EXPORT_OK} and *$eokglob{ARRAY} ) { |
|
0
|
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
if( @{$exporter.'::EXPORT_OK'} ) { |
32
|
0
|
|
|
|
|
0
|
# This can also be cached. |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
33
|
0
|
|
|
|
|
0
|
my %ok = map { s/^&//; $_ => 1 } @{$exporter.'::EXPORT_OK'}, |
34
|
|
|
|
|
|
|
@{$exporter.'::EXPORT'}; |
35
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
36
|
0
|
0
|
|
|
|
0
|
my($denied) = grep {s/^&//; !$ok{$_}} @imports; |
37
|
|
|
|
|
|
|
_not_exported($denied, $exporter, $file, $line) if $denied; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
else { # We don't export anything. |
40
|
|
|
|
|
|
|
_not_exported($imports[0], $exporter, $file, $line); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
12
|
|
|
|
|
43
|
|
45
|
|
|
|
|
|
|
_export($caller, $exporter, @imports); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
12
|
|
|
12
|
|
27
|
sub _export { |
51
|
|
|
|
|
|
|
my($caller, $exporter, @imports) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Stole this from Exporter::Heavy. I'm sure it can be written better |
54
|
12
|
|
|
|
|
25
|
# but I'm lazy at the moment. |
55
|
|
|
|
|
|
|
foreach my $sym (@imports) { |
56
|
18
|
50
|
|
|
|
75
|
# shortcut for the common case of no type character |
|
18
|
|
|
|
|
383
|
|
|
18
|
|
|
|
|
62
|
|
57
|
|
|
|
|
|
|
(*{$caller.'::'.$sym} = \&{$exporter.'::'.$sym}, next) |
58
|
|
|
|
|
|
|
unless $sym =~ s/^(\W)//; |
59
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $type = $1; |
61
|
0
|
|
|
|
|
|
my $caller_sym = $caller.'::'.$sym; |
62
|
0
|
|
|
|
|
|
my $export_sym = $exporter.'::'.$sym; |
|
0
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
*{$caller_sym} = |
64
|
0
|
|
|
|
|
|
$type eq '&' ? \&{$export_sym} : |
65
|
0
|
|
|
|
|
|
$type eq '$' ? \${$export_sym} : |
66
|
0
|
|
|
|
|
|
$type eq '@' ? \@{$export_sym} : |
67
|
|
|
|
|
|
|
$type eq '%' ? \%{$export_sym} : |
68
|
0
|
0
|
|
|
|
|
$type eq '*' ? *{$export_sym} : |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
69
|
|
|
|
|
|
|
do { require Carp; Carp::croak("Can't export symbol: $type$sym") }; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#"# |
75
|
0
|
|
|
0
|
|
|
sub _not_exported { |
76
|
0
|
|
|
|
|
|
my($thing, $exporter, $file, $line) = @_; |
77
|
|
|
|
|
|
|
die sprintf qq|"%s" is not exported by the %s module at %s line %d\n|, |
78
|
|
|
|
|
|
|
$thing, $exporter, $file, $line; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |