line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Data::Accessor; |
2
|
2
|
|
|
2
|
|
56404
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
84
|
|
3
|
2
|
|
|
2
|
|
92
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
263
|
|
5
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
566
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.04004'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub mk_classaccessor { |
9
|
7
|
|
|
7
|
1
|
16
|
my ($declaredclass, $attribute, $data) = @_; |
10
|
|
|
|
|
|
|
|
11
|
7
|
100
|
|
|
|
16
|
if( ref $declaredclass ) { |
12
|
2
|
|
|
|
|
274
|
croak("mk_classaccessor() is a class method, not an object method"); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
5
|
100
|
|
|
|
12
|
if( $attribute eq 'DESTROY' ) { |
16
|
1
|
|
|
|
|
104
|
carp("Having a data accessor named DESTROY in '$declaredclass' is unwise."); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $accessor = sub { |
20
|
17
|
100
|
|
17
|
|
2347
|
if (ref $_[0]) { |
21
|
2
|
100
|
|
|
|
11
|
return $_[0]->{$attribute} = $_[1] if @_ > 1; |
22
|
1
|
50
|
|
|
|
9
|
return $_[0]->{$attribute} if exists $_[0]->{$attribute}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
16
|
|
66
|
|
|
42
|
my $wantclass = ref($_[0]) || $_[0]; |
26
|
|
|
|
|
|
|
|
27
|
16
|
100
|
100
|
|
|
63
|
return $wantclass->mk_classaccessor($attribute)->(@_) |
28
|
|
|
|
|
|
|
if @_>1 && $wantclass ne $declaredclass; |
29
|
|
|
|
|
|
|
|
30
|
14
|
100
|
|
|
|
25
|
$data = $_[1] if @_>1; |
31
|
14
|
|
|
|
|
53
|
return $data; |
32
|
5
|
|
|
|
|
28
|
}; |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
11
|
no warnings qw/redefine/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
35
|
2
|
|
|
2
|
|
10
|
no strict qw/refs/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
300
|
|
36
|
5
|
|
|
|
|
9
|
my $alias = "_${attribute}_accessor"; |
37
|
5
|
|
|
|
|
7
|
*{$declaredclass.'::'.$attribute} = $accessor; |
|
5
|
|
|
|
|
28
|
|
38
|
5
|
|
|
|
|
6
|
*{$declaredclass.'::'.$alias} = $accessor; |
|
5
|
|
|
|
|
31
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub mk_classaccessors { |
42
|
1
|
|
|
1
|
1
|
18
|
my ($declaredclass, @attributes) = @_; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
3
|
foreach my $attribute (@attributes) { |
45
|
1
|
|
|
|
|
8
|
$declaredclass->mk_classaccessor($attribute); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |