line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Package::Subroutine; |
2
|
|
|
|
|
|
|
# ************************** |
3
|
|
|
|
|
|
|
$VERSION = '0.22.001'; |
4
|
|
|
|
|
|
|
# **************** |
5
|
6
|
|
|
|
|
180
|
; no strict 'refs' |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
147042
|
; use Class::ISA () |
|
6
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
5800
|
; sub export_to_caller |
|
6
|
|
|
|
|
23511
|
|
|
6
|
|
|
|
|
6366
|
|
10
|
1
|
|
|
1
|
1
|
20
|
{ my ($self,$level) = @_ |
11
|
1
|
|
|
|
|
13
|
; my $namespace = (caller($level))[0] |
12
|
|
|
|
|
|
|
; return sub |
13
|
1
|
|
|
1
|
|
4
|
{ my ($from,@methods) = @_ |
14
|
1
|
50
|
|
|
|
7
|
; $from = caller if $from eq '_' |
15
|
1
|
|
|
|
|
5
|
; exporter($namespace,$from,@methods) |
16
|
|
|
|
|
|
|
} |
17
|
1
|
|
|
|
|
15
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
; sub export_to |
20
|
0
|
|
|
0
|
1
|
0
|
{ my ($self,$namespace) = @_ |
21
|
|
|
|
|
|
|
; return sub |
22
|
0
|
|
|
0
|
|
0
|
{ my ($from,@methods) = @_ |
23
|
0
|
0
|
|
|
|
0
|
; $from = caller if $from eq '_' |
24
|
0
|
|
|
|
|
0
|
; exporter($namespace,$from,@methods) |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
0
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
; sub export |
29
|
0
|
|
|
0
|
1
|
0
|
{ my $ns = (caller(1))[0] |
30
|
|
|
|
|
|
|
; shift() # rm package |
31
|
|
|
|
|
|
|
# working shortcut for __PACKAGE__ |
32
|
0
|
0
|
|
|
|
0
|
; splice(@_,0,1,"".caller) if $_[0] eq '_' |
|
0
|
|
|
|
|
0
|
|
33
|
0
|
|
|
|
|
0
|
; exporter($ns,@_) |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
; sub import |
37
|
7
|
|
|
7
|
|
33901
|
{ my $ns = (caller(0))[0] |
38
|
|
|
|
|
|
|
; shift() # rm package |
39
|
7
|
|
|
|
|
20
|
; exporter($ns,@_) |
|
7
|
|
|
|
|
232
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
; sub mixin |
43
|
1
|
|
|
1
|
1
|
20
|
{ my $ns = (caller(0))[0] |
44
|
1
|
|
|
|
|
4
|
; my $pkg = shift() |
45
|
1
|
50
|
|
|
|
4
|
; if(@_==1) |
46
|
1
|
|
|
|
|
8
|
{ push @_, $pkg->findsubs($_[0]) |
47
|
|
|
|
|
|
|
} |
48
|
1
|
|
|
|
|
6
|
; exporter($ns,@_) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
; sub exporter |
52
|
9
|
|
|
9
|
1
|
21
|
{ my $namespace = shift |
53
|
9
|
|
|
|
|
37
|
; my $from = shift |
54
|
9
|
|
|
|
|
25
|
; my @methods = @_ |
55
|
9
|
|
|
|
|
21
|
; local $_ |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
4049
|
; for ( @methods ) |
58
|
25
|
|
|
|
|
39
|
{ my $srcm = my $trgm = $_ |
59
|
25
|
50
|
|
|
|
59
|
; ($srcm,$trgm) = @$_ if ref eq 'ARRAY' |
60
|
25
|
|
|
|
|
37
|
; my $target = "${namespace}::${trgm}" |
61
|
25
|
|
|
|
|
39
|
; my $source = "${from}::${srcm}" |
62
|
25
|
|
|
|
|
240
|
; *$target = \&$source |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
; sub version |
67
|
0
|
|
|
0
|
1
|
0
|
{ my ($f,$pkg,$num)=@_ |
68
|
0
|
0
|
|
|
|
0
|
; if( defined($num) ) |
69
|
0
|
|
|
|
|
0
|
{ $num=eval { UNIVERSAL::VERSION($pkg,$num) } |
|
0
|
|
|
|
|
0
|
|
70
|
0
|
0
|
|
|
|
0
|
; return $@ ? undef : $num |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
0
|
; eval { UNIVERSAL::VERSION($pkg) } |
|
0
|
|
|
|
|
0
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
; sub install |
76
|
0
|
|
|
0
|
1
|
0
|
{ my ($pkg,$target,$name,$coderef)=@_ |
77
|
0
|
|
|
|
|
0
|
; $target="${target}::${name}" |
78
|
0
|
|
|
|
|
0
|
; *$target = $coderef |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
; sub isdefined |
82
|
2
|
|
|
2
|
1
|
766
|
{ my ($pkg,$namespace,$subname)=@_ |
83
|
2
|
50
|
|
|
|
7
|
; unless($subname) |
84
|
0
|
|
|
|
|
0
|
{ my @ns = split /\'|\:\:/, $namespace |
85
|
0
|
|
|
|
|
0
|
; $subname = pop @ns |
86
|
0
|
|
|
|
|
0
|
; $namespace = join "::",@ns |
87
|
|
|
|
|
|
|
} |
88
|
2
|
100
|
|
|
|
2
|
; *{"${namespace}::${subname}"}{CODE} || undef |
|
2
|
|
|
|
|
25
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
; sub findsubs |
92
|
7
|
|
|
7
|
1
|
32
|
{ my ($self,$class)=@_ |
93
|
7
|
|
|
|
|
7
|
; grep { *{"${class}::${_}"}{CODE} } keys %{"${class}::"} |
|
64
|
|
|
|
|
52
|
|
|
64
|
|
|
|
|
156
|
|
|
7
|
|
|
|
|
33
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
; sub findmethods |
97
|
2
|
|
|
2
|
1
|
1132
|
{ my ($self,$class)=@_ |
98
|
30
|
|
|
|
|
62
|
; my %methods = map { $_ => 1 } |
|
5
|
|
|
|
|
69
|
|
99
|
2
|
|
|
|
|
11
|
map { $self->findsubs($_) } |
100
|
|
|
|
|
|
|
reverse (Class::ISA::self_and_super_path($class),'UNIVERSAL') |
101
|
2
|
|
|
|
|
28
|
; return keys %methods |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
; 1 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |