| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Class::Lite; |
|
2
|
|
|
|
|
|
|
# Choose minimum perl interpreter version; delete the rest. |
|
3
|
|
|
|
|
|
|
# Do you want to enforce the bugfix level? |
|
4
|
|
|
|
|
|
|
#~ use 5.008008; # 5.8.8 # 2006 # oldest sane version |
|
5
|
|
|
|
|
|
|
#~ use 5.008009; # 5.8.9 # 2008 # latest 5.8 |
|
6
|
|
|
|
|
|
|
#~ use 5.010001; # 5.10.1 # 2009 # say, state, switch |
|
7
|
|
|
|
|
|
|
#~ use 5.012003; # 5.12.5 # 2011 # yada |
|
8
|
|
|
|
|
|
|
#~ use 5.014002; # 5.14.3 # 2012 # pop $arrayref, copy s///r |
|
9
|
|
|
|
|
|
|
#~ use 5.016002; # 5.16.2 # 2012 # __SUB__ |
|
10
|
15
|
|
|
15
|
|
304502
|
use strict; |
|
|
15
|
|
|
|
|
38
|
|
|
|
15
|
|
|
|
|
1007
|
|
|
11
|
15
|
|
|
15
|
|
83
|
use warnings; |
|
|
15
|
|
|
|
|
33
|
|
|
|
15
|
|
|
|
|
479
|
|
|
12
|
15
|
|
|
15
|
|
14532
|
use version; our $VERSION = qv('v0.1.0'); |
|
|
15
|
|
|
|
|
45517
|
|
|
|
15
|
|
|
|
|
107
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Alternate uses |
|
15
|
|
|
|
|
|
|
#~ use Devel::Comments '###', ({ -file => 'debug.log' }); #~ |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## use |
|
18
|
|
|
|
|
|
|
#============================================================================# |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#=========# CLASS METHOD |
|
21
|
|
|
|
|
|
|
#~ my $self = My::Class->new(@_); |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
# Classic hashref-based-object constructor. |
|
24
|
|
|
|
|
|
|
# Passes any arguments to init(). |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
11
|
|
|
11
|
1
|
11321
|
my $class = shift; |
|
28
|
11
|
|
|
|
|
34
|
my $self = {}; |
|
29
|
11
|
|
|
|
|
41
|
bless ( $self => $class ); |
|
30
|
11
|
|
|
|
|
843
|
$self->init(@_); |
|
31
|
11
|
|
|
|
|
35
|
return $self; |
|
32
|
|
|
|
|
|
|
}; ## new |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
|
35
|
|
|
|
|
|
|
#~ $self->init(@_); |
|
36
|
|
|
|
|
|
|
# |
|
37
|
|
|
|
|
|
|
# Abstract method does nothing. Override in your class. |
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
sub init { |
|
40
|
11
|
|
|
11
|
1
|
42
|
return shift; |
|
41
|
|
|
|
|
|
|
}; ## init |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#=========# CLASS METHOD |
|
44
|
|
|
|
|
|
|
#~ use Class::Lite qw| attr1 attr2 attr3 |; |
|
45
|
|
|
|
|
|
|
#~ use Class::Lite qw| # Simple base class with get/put accessors |
|
46
|
|
|
|
|
|
|
#~ attr1 |
|
47
|
|
|
|
|
|
|
#~ attr2 |
|
48
|
|
|
|
|
|
|
#~ attr3 |
|
49
|
|
|
|
|
|
|
#~ |; |
|
50
|
|
|
|
|
|
|
# |
|
51
|
|
|
|
|
|
|
# @ |
|
52
|
|
|
|
|
|
|
# |
|
53
|
|
|
|
|
|
|
sub import { |
|
54
|
15
|
|
|
15
|
|
2898
|
no warnings 'uninitialized'; |
|
|
15
|
|
|
|
|
33
|
|
|
|
15
|
|
|
|
|
7092
|
|
|
55
|
25
|
|
|
25
|
|
3321
|
my $class = shift; |
|
56
|
25
|
|
|
|
|
65
|
my $caller = caller; |
|
57
|
25
|
|
|
|
|
62
|
my $bridge = qq{Class::Lite::$caller}; |
|
58
|
|
|
|
|
|
|
### $class |
|
59
|
|
|
|
|
|
|
### $bridge |
|
60
|
|
|
|
|
|
|
### $caller |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# In case caller is eager. |
|
63
|
25
|
|
|
|
|
444
|
my @args = $class->fore_import(@_); |
|
64
|
|
|
|
|
|
|
### @args |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Do most work in the bridge class. |
|
67
|
60
|
100
|
100
|
|
|
768
|
eval join qq{\n}, |
|
|
|
|
100
|
|
|
|
|
|
68
|
|
|
|
|
|
|
qq* package $bridge; *, |
|
69
|
|
|
|
|
|
|
qq* our \@ISA; *, |
|
70
|
|
|
|
|
|
|
qq* push \@ISA, '$class'; *, |
|
71
|
|
|
|
|
|
|
map { |
|
72
|
25
|
|
|
7
|
|
355
|
defined and ! ref and /^[^\W\d]\w*\z/s |
|
|
7
|
|
|
7
|
|
4334
|
|
|
|
7
|
|
|
5
|
|
4231
|
|
|
|
5
|
|
|
8
|
|
2612
|
|
|
|
8
|
|
|
6
|
|
11671
|
|
|
|
6
|
|
|
7
|
|
23
|
|
|
|
6
|
|
|
6
|
|
4770
|
|
|
|
6
|
|
|
2
|
|
20
|
|
|
|
7
|
|
|
2
|
|
3723
|
|
|
|
7
|
|
|
|
|
23
|
|
|
|
6
|
|
|
|
|
3680
|
|
|
|
6
|
|
|
|
|
1140
|
|
|
|
2
|
|
|
|
|
1474
|
|
|
73
|
|
|
|
|
|
|
or die "Invalid accessor name '$_'"; |
|
74
|
54
|
|
|
|
|
4980
|
qq* sub get_$_ { return \$_[0]->{$_} }; * |
|
75
|
|
|
|
|
|
|
. qq* sub put_$_ { \$_[0]->{$_} = \$_[1]; return \$_[0] }; * |
|
76
|
|
|
|
|
|
|
} @args, |
|
77
|
|
|
|
|
|
|
; |
|
78
|
|
|
|
|
|
|
# I cannot figure out a way to make this eval fail. |
|
79
|
|
|
|
|
|
|
# When you find out, please let me know. |
|
80
|
|
|
|
|
|
|
# uncoverable branch true |
|
81
|
19
|
50
|
|
|
|
86
|
die "Failed to generate $bridge: $@" if $@; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Make caller inherit from bridge. |
|
84
|
19
|
|
|
|
|
1674
|
eval join qq{\n}, |
|
85
|
|
|
|
|
|
|
qq* package $caller; *, |
|
86
|
|
|
|
|
|
|
qq* our \@ISA; *, |
|
87
|
|
|
|
|
|
|
qq* push \@ISA, '$bridge'; *, |
|
88
|
|
|
|
|
|
|
; |
|
89
|
|
|
|
|
|
|
# This second eval fails in case recursive inheritance is attempted. |
|
90
|
19
|
100
|
|
|
|
136
|
die "Failed to generate $caller: $@" if $@; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# In case caller must get the last word. |
|
93
|
18
|
|
|
|
|
76
|
$class->rear_import(@_); |
|
94
|
|
|
|
|
|
|
|
|
95
|
18
|
|
|
|
|
13195
|
return 1; |
|
96
|
|
|
|
|
|
|
}; ## import |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Dummy methods do nothing. |
|
99
|
25
|
|
|
25
|
1
|
675
|
sub fore_import { shift; return @_ }; |
|
|
25
|
|
|
|
|
94
|
|
|
100
|
20
|
|
|
20
|
1
|
1029
|
sub rear_import { shift; return @_ }; |
|
|
20
|
|
|
|
|
59
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
## END MODULE |
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
#============================================================================# |
|
105
|
|
|
|
|
|
|
__END__ |