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