line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Data::Inheritable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
76615
|
use strict qw(vars subs); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
284
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.09'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub mk_classdata { |
8
|
5
|
|
|
5
|
1
|
124
|
my ($declaredclass, $attribute, $data) = @_; |
9
|
|
|
|
|
|
|
|
10
|
5
|
100
|
|
|
|
17
|
if( ref $declaredclass ) { |
11
|
1
|
|
|
|
|
9
|
require Carp; |
12
|
1
|
|
|
|
|
199
|
Carp::croak("mk_classdata() is a class method, not an object method"); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $accessor = sub { |
16
|
15
|
|
66
|
15
|
|
2064
|
my $wantclass = ref($_[0]) || $_[0]; |
17
|
|
|
|
|
|
|
|
18
|
15
|
100
|
100
|
|
|
61
|
return $wantclass->mk_classdata($attribute)->(@_) |
19
|
|
|
|
|
|
|
if @_>1 && $wantclass ne $declaredclass; |
20
|
|
|
|
|
|
|
|
21
|
13
|
100
|
|
|
|
40
|
$data = $_[1] if @_>1; |
22
|
13
|
|
|
|
|
62
|
return $data; |
23
|
4
|
|
|
|
|
24
|
}; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
12
|
my $alias = "_${attribute}_accessor"; |
26
|
4
|
|
|
|
|
7
|
*{$declaredclass.'::'.$attribute} = $accessor; |
|
4
|
|
|
|
|
24
|
|
27
|
4
|
|
|
|
|
8
|
*{$declaredclass.'::'.$alias} = $accessor; |
|
4
|
|
|
|
|
26
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |