line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Data::Inheritable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24136
|
use strict qw(vars subs); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
284
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.08'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub mk_classdata { |
8
|
5
|
|
|
5
|
1
|
32
|
my ($declaredclass, $attribute, $data) = @_; |
9
|
|
|
|
|
|
|
|
10
|
5
|
100
|
|
|
|
16
|
if( ref $declaredclass ) { |
11
|
1
|
|
|
|
|
12
|
require Carp; |
12
|
1
|
|
|
|
|
179
|
Carp::croak("mk_classdata() is a class method, not an object method"); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $accessor = sub { |
16
|
15
|
|
66
|
15
|
|
1952
|
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
|
|
|
|
32
|
$data = $_[1] if @_>1; |
22
|
13
|
|
|
|
|
56
|
return $data; |
23
|
4
|
|
|
|
|
19
|
}; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
11
|
my $alias = "_${attribute}_accessor"; |
26
|
4
|
|
|
|
|
6
|
*{$declaredclass.'::'.$attribute} = $accessor; |
|
4
|
|
|
|
|
25
|
|
27
|
4
|
|
|
|
|
6
|
*{$declaredclass.'::'.$alias} = $accessor; |
|
4
|
|
|
|
|
34
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |