line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Member::Dynamic; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20038
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
|
|
|
|
|
|
our $VERSION='1.6'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp 'confess'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
272
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub import { |
9
|
1
|
|
|
1
|
|
7
|
my $pack=shift; |
10
|
1
|
|
|
|
|
2
|
($pack)=caller; |
11
|
1
|
|
|
|
|
2
|
my $dummy; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $getset=sub : lvalue { |
14
|
17
|
|
|
17
|
|
25
|
my $I=shift; |
15
|
17
|
|
|
|
|
19
|
my $what=shift; |
16
|
17
|
|
|
|
|
24
|
my $rc=\$dummy; |
17
|
|
|
|
|
|
|
|
18
|
17
|
100
|
|
|
|
90
|
if( UNIVERSAL::isa( $I, 'HASH' ) ) { |
|
|
100
|
|
|
|
|
|
19
|
8
|
|
|
|
|
18
|
$what=$pack.'::'.$what; |
20
|
8
|
100
|
|
|
|
21
|
if( $#_>=0 ) { |
21
|
2
|
|
|
|
|
5
|
$I->{$what}=shift; |
22
|
|
|
|
|
|
|
} |
23
|
8
|
|
|
|
|
23
|
$rc=\$I->{$what}; |
24
|
|
|
|
|
|
|
} elsif( UNIVERSAL::isa( $I, 'GLOB' ) ) { |
25
|
8
|
|
|
|
|
19
|
$what=$pack.'::'.$what; |
26
|
8
|
100
|
|
|
|
25
|
if( $#_>=0 ) { |
27
|
2
|
|
|
|
|
4
|
${*$I}{$what}=shift; |
|
2
|
|
|
|
|
6
|
|
28
|
|
|
|
|
|
|
} |
29
|
8
|
|
|
|
|
12
|
$rc=\${*$I}{$what}; |
|
8
|
|
|
|
|
33
|
|
30
|
|
|
|
|
|
|
} else { |
31
|
1
|
|
|
|
|
322
|
confess "$pack\::$what must be called as instance method\n"; |
32
|
|
|
|
|
|
|
} |
33
|
16
|
|
|
|
|
72
|
$$rc; |
34
|
1
|
|
|
|
|
4
|
}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
2
|
foreach my $name (@_) { |
37
|
3
|
100
|
|
|
|
9
|
if( $name=~/^-(.*)/ ) { # reserved name, aka option |
38
|
1
|
50
|
|
|
|
5
|
if( $1 eq 'CLASS_MEMBERS' ) { |
39
|
1
|
|
|
|
|
2
|
local $_; |
40
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
41
|
1
|
|
|
|
|
1
|
*{$pack.'::CLASS_MEMBERS'}=[grep {!/^-/} @_]; |
|
1
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
6
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} else { |
44
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
45
|
2
|
|
|
|
|
11
|
*{$pack.'::'.$name}=sub:lvalue { |
46
|
17
|
|
|
17
|
|
1032
|
my $I=shift; |
47
|
17
|
|
|
|
|
27
|
&{$getset}( $I, $name, @_ ); |
|
17
|
|
|
|
|
39
|
|
48
|
2
|
|
|
|
|
4
|
}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |