line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Accessor::Lazy::Fast;
|
2
|
1
|
|
|
1
|
|
6
|
use strict; use warnings FATAL => 'all';
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
3
|
1
|
|
|
1
|
|
6
|
use Exporter 'import';
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
719
|
use Class::Accessor::Fast;
|
|
1
|
|
|
|
|
546
|
|
|
1
|
|
|
|
|
10
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.000';
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new
|
9
|
|
|
|
|
|
|
{
|
10
|
0
|
|
|
0
|
0
|
0
|
my( $proto, @args ) = @_;
|
11
|
0
|
|
0
|
|
|
0
|
$proto = ref $proto || $proto;
|
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
0
|
my $self = $proto->SUPER::new(@args);
|
14
|
0
|
|
|
|
|
0
|
$self->{'__lazy_inits'} = {};
|
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
0
|
return $self;
|
17
|
|
|
|
|
|
|
}
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT;
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
push @EXPORT, 'fast_accessors';
|
22
|
|
|
|
|
|
|
sub fast_accessors{
|
23
|
1
|
|
|
1
|
0
|
2
|
my $self = shift;
|
24
|
1
|
|
33
|
|
|
4
|
my $class = ref $self || $self;
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
161
|
no strict 'refs';
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
689
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
2
|
*{"${class}::make_accessor"} = \&Class::Accessor::Fast::make_accessor;
|
|
1
|
|
|
|
|
4
|
|
29
|
1
|
|
|
|
|
2
|
*{"${class}::make_ro_accessor"} = \&Class::Accessor::Fast::make_ro_accessor;
|
|
1
|
|
|
|
|
2
|
|
30
|
1
|
|
|
|
|
2
|
*{"${class}::make_wo_accessor"} = \&Class::Accessor::Fast::make_wo_accessor;
|
|
1
|
|
|
|
|
3
|
|
31
|
1
|
|
|
|
|
1
|
*{"${class}::make_lazy_accessor"} = \&Class::Accessor::Lazy::Fast::make_accessor;
|
|
1
|
|
|
|
|
3
|
|
32
|
1
|
|
|
|
|
2
|
*{"${class}::make_lazy_ro_accessor"} = \&Class::Accessor::Lazy::Fast::make_ro_accessor;
|
|
1
|
|
|
|
|
3
|
|
33
|
1
|
|
|
|
|
2
|
*{"${class}::make_lazy_wo_accessor"} = \&Class::Accessor::Lazy::Fast::make_wo_accessor;
|
|
1
|
|
|
|
|
6
|
|
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
5
|
return $self;
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub make_accessor {
|
40
|
0
|
|
|
0
|
0
|
0
|
my ($class, $field) = @_;
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
return sub {
|
43
|
0
|
|
|
0
|
|
0
|
my $self = shift;
|
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
0
|
if(@_)
|
46
|
|
|
|
|
|
|
{
|
47
|
0
|
|
|
|
|
0
|
$self->{'__lazy_inits'}->{$field} = 1;
|
48
|
0
|
|
|
|
|
0
|
return $self->{$field} = $_[0];
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
else
|
51
|
|
|
|
|
|
|
{
|
52
|
0
|
0
|
|
|
|
0
|
if( not exists $self->{'__lazy_inits'}->{$field} )
|
53
|
|
|
|
|
|
|
{
|
54
|
0
|
|
|
|
|
0
|
my $init_method = "_lazy_init_$field";
|
55
|
0
|
|
|
|
|
0
|
$self->$init_method();
|
56
|
0
|
|
|
|
|
0
|
$self->{'__lazy_inits'}->{$field} = 1;
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
return $self->{$field};
|
60
|
|
|
|
|
|
|
}
|
61
|
0
|
|
|
|
|
0
|
};
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub make_ro_accessor {
|
65
|
2
|
|
|
2
|
0
|
3
|
my($class, $field) = @_;
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return sub {
|
68
|
8
|
|
|
8
|
|
6609
|
my $self = shift;
|
69
|
|
|
|
|
|
|
|
70
|
8
|
50
|
|
|
|
19
|
if (@_)
|
71
|
|
|
|
|
|
|
{
|
72
|
0
|
|
|
|
|
0
|
my $caller = caller;
|
73
|
0
|
|
|
|
|
0
|
$self->_croak("'$caller' cannot alter the value of '$field' on objects of class '$class'");
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
else
|
76
|
|
|
|
|
|
|
{
|
77
|
8
|
100
|
|
|
|
23
|
if( not exists $self->{'__lazy_inits'}->{$field} )
|
78
|
|
|
|
|
|
|
{
|
79
|
4
|
|
|
|
|
9
|
my $init_method = "_lazy_init_$field";
|
80
|
4
|
|
|
|
|
15
|
$self->$init_method();
|
81
|
4
|
|
|
|
|
22
|
$self->{'__lazy_inits'}->{$field} = 1;
|
82
|
|
|
|
|
|
|
}
|
83
|
8
|
|
|
|
|
27
|
return $self->{$field};
|
84
|
|
|
|
|
|
|
}
|
85
|
2
|
|
|
|
|
8
|
};
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# requires only for best_practice rw acessors
|
89
|
|
|
|
|
|
|
sub make_wo_accessor {
|
90
|
1
|
|
|
1
|
0
|
2
|
my($class, $field) = @_;
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return sub {
|
93
|
2
|
|
|
2
|
|
4
|
my $self = shift;
|
94
|
|
|
|
|
|
|
|
95
|
2
|
50
|
|
|
|
7
|
if( not scalar @_)
|
96
|
|
|
|
|
|
|
{
|
97
|
0
|
|
|
|
|
0
|
my $caller = caller;
|
98
|
0
|
|
|
|
|
0
|
$self->_croak("'$caller' cannot access the value of '$field' on objects of class '$class'");
|
99
|
|
|
|
|
|
|
}
|
100
|
|
|
|
|
|
|
else
|
101
|
|
|
|
|
|
|
{
|
102
|
2
|
50
|
|
|
|
7
|
$self->{'__lazy_inits'}->{$field} = 1 unless exists $self->{'__lazy_inits'}->{$field};
|
103
|
2
|
|
|
|
|
5
|
return $self->{$field} = $_[0];
|
104
|
|
|
|
|
|
|
}
|
105
|
1
|
|
|
|
|
4
|
};
|
106
|
|
|
|
|
|
|
}
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |