line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Member::GLOB; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
50845
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
116
|
|
4
|
|
|
|
|
|
|
our $VERSION='1.6'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use Carp 'confess'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
178
|
|
7
|
2
|
|
|
2
|
|
2725
|
use IO::Handle; |
|
2
|
|
|
|
|
16917
|
|
|
2
|
|
|
|
|
146
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $get_class_members; |
10
|
|
|
|
|
|
|
$get_class_members=sub { |
11
|
|
|
|
|
|
|
my $pack=$_[0]; |
12
|
2
|
|
|
2
|
|
16
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
909
|
|
13
|
|
|
|
|
|
|
my %cm; |
14
|
|
|
|
|
|
|
@cm{@{$pack.'::CLASS_MEMBERS'}}=(); |
15
|
|
|
|
|
|
|
foreach my $p (@{$pack.'::ISA'}) { |
16
|
|
|
|
|
|
|
@cm{$get_class_members->($p)}=(); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
return keys %cm; |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub import { |
22
|
3
|
|
|
3
|
|
26
|
my $pack=shift; |
23
|
3
|
|
|
|
|
8
|
($pack)=caller; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $getset=sub : lvalue { |
26
|
26
|
|
|
26
|
|
31
|
my $I=shift; |
27
|
26
|
|
|
|
|
30
|
my $what=shift; |
28
|
26
|
100
|
|
|
|
76
|
unless( UNIVERSAL::isa( $I, 'GLOB' ) ) { |
29
|
1
|
|
|
|
|
446
|
confess "$pack\::$what must be called as instance method\n"; |
30
|
|
|
|
|
|
|
} |
31
|
25
|
|
|
|
|
50
|
$what=$pack.'::'.$what; |
32
|
25
|
100
|
|
|
|
60
|
if( $#_>=0 ) { |
33
|
2
|
|
|
|
|
3
|
${*$I}{$what}=shift; |
|
2
|
|
|
|
|
7
|
|
34
|
|
|
|
|
|
|
} |
35
|
25
|
|
|
|
|
29
|
${*$I}{$what}; |
|
25
|
|
|
|
|
142
|
|
36
|
3
|
|
|
|
|
13
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $new=sub { |
39
|
2
|
|
|
2
|
|
25
|
my $parent=shift; |
40
|
2
|
|
66
|
|
|
14
|
my $class=ref($parent) || $parent; |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
15
|
my $I=bless IO::Handle->new=>$class; |
43
|
2
|
|
|
|
|
54
|
my %o=@_; |
44
|
2
|
|
|
|
|
6
|
my @CLASS_MEMBERS=$get_class_members->($class); |
45
|
|
|
|
|
|
|
|
46
|
2
|
100
|
|
|
|
8
|
if( ref($parent) ) { # inherit first |
47
|
1
|
|
|
|
|
2
|
foreach my $m (@CLASS_MEMBERS) { |
48
|
3
|
|
|
|
|
7
|
$I->$m=$parent->$m; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# then override with named parameters |
53
|
2
|
|
|
|
|
4
|
foreach my $m (@CLASS_MEMBERS) { |
54
|
6
|
100
|
|
|
|
28
|
$I->$m=$o{$m} if( exists $o{$m} ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
14
|
my $init=$I->can('I N I T'); |
58
|
2
|
50
|
|
|
|
7
|
if( $init ) { |
59
|
2
|
|
|
|
|
6
|
$init=$init->(); |
60
|
2
|
|
|
|
|
9
|
$I->$init; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
10
|
return $I; |
64
|
3
|
|
|
|
|
14
|
}; |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
8
|
foreach my $name (@_) { |
67
|
10
|
100
|
|
|
|
34
|
if( $name=~/^-(.*)/ ) { # reserved name, aka option |
68
|
5
|
|
|
|
|
11
|
my $o=$1; |
69
|
5
|
100
|
|
|
|
18
|
if( $o eq 'CLASS_MEMBERS' ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
70
|
3
|
|
|
|
|
3
|
local $_; |
71
|
2
|
|
|
2
|
|
13
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
208
|
|
72
|
3
|
|
|
|
|
6
|
*{$pack.'::CLASS_MEMBERS'}=[grep {!/^-/} @_]; |
|
3
|
|
|
|
|
44
|
|
|
10
|
|
|
|
|
28
|
|
73
|
|
|
|
|
|
|
} elsif( $o=~/^NEW=(.+)/ ) { |
74
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
173
|
|
75
|
0
|
|
|
|
|
0
|
*{$pack.'::'.$1}=$new; |
|
0
|
|
|
|
|
0
|
|
76
|
|
|
|
|
|
|
} elsif( $o eq 'NEW' ) { |
77
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
95
|
|
78
|
1
|
|
|
|
|
1
|
*{$pack.'::new'}=$new; |
|
1
|
|
|
|
|
40
|
|
79
|
|
|
|
|
|
|
} elsif( $o=~/^INIT=(.+)/ ) { |
80
|
2
|
|
|
2
|
|
10
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
170
|
|
81
|
1
|
|
|
|
|
19
|
my $init="$1"; |
82
|
1
|
|
|
0
|
|
8
|
*{$pack.'::I N I T'}=sub(){$init}; |
|
1
|
|
|
|
|
32
|
|
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} elsif( $o eq 'INIT' ) { |
84
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
141
|
|
85
|
0
|
|
|
|
|
0
|
*{$pack.'::I N I T'}=sub(){"init"}; |
|
0
|
|
|
|
|
0
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} else { |
88
|
2
|
|
|
2
|
|
26
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
253
|
|
89
|
5
|
|
|
|
|
31
|
*{$pack.'::'.$name}=sub:lvalue { |
90
|
26
|
|
|
26
|
|
1020
|
my $I=shift; |
91
|
26
|
|
|
|
|
36
|
&{$getset}( $I, $name, @_ ); |
|
26
|
|
|
|
|
52
|
|
92
|
5
|
|
|
|
|
15
|
}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |