line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::AutoClass::Root; |
2
|
38
|
|
|
38
|
|
13965
|
use strict; |
|
38
|
|
|
|
|
48
|
|
|
38
|
|
|
|
|
1157
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# NG 09-11-02: This class is deprecated and will go away in a future release |
5
|
|
|
|
|
|
|
|
6
|
38
|
|
|
38
|
|
121
|
use vars qw(@ISA $DEBUG $ID $Revision $VERSION $VERBOSITY $ERRORLOADED @EXPORT); |
|
38
|
|
|
|
|
43
|
|
|
38
|
|
|
|
|
2432
|
|
7
|
38
|
|
|
38
|
|
135
|
use strict; |
|
38
|
|
|
|
|
701
|
|
|
38
|
|
|
|
|
2192
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
|
|
|
|
|
|
|
11
|
38
|
|
|
38
|
|
57
|
$ID = 'Class::AutoClass::Root'; |
12
|
38
|
|
|
|
|
44
|
$VERSION = 1.0; |
13
|
38
|
|
|
|
|
39
|
$Revision = ''; |
14
|
38
|
|
|
|
|
40
|
$DEBUG = 0; |
15
|
38
|
|
|
|
|
38
|
$VERBOSITY = 0; |
16
|
38
|
|
|
|
|
27898
|
$ERRORLOADED = 0; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
1
|
|
|
1
|
0
|
7
|
my $class = shift; |
23
|
1
|
|
|
|
|
2
|
my $self = {}; |
24
|
1
|
|
33
|
|
|
5
|
bless $self, ref($class) || $class; |
25
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
|
|
3
|
if(@_ > 1) { |
27
|
|
|
|
|
|
|
# if the number of arguments is odd but at least 3, we'll give |
28
|
|
|
|
|
|
|
# it a try to find -verbose |
29
|
0
|
0
|
|
|
|
0
|
shift if @_ % 2; |
30
|
0
|
|
|
|
|
0
|
my %param = @_; |
31
|
0
|
|
0
|
|
|
0
|
$self->verbose($param{'-VERBOSE'} || $param{'-verbose'}); |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
|
|
2
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub verbose { |
37
|
3
|
|
|
3
|
0
|
4
|
my ($self,$value) = @_; |
38
|
|
|
|
|
|
|
# allow one to set global verbosity flag |
39
|
3
|
50
|
|
|
|
8
|
return $DEBUG if $DEBUG; |
40
|
3
|
50
|
|
|
|
8
|
return $VERBOSITY unless ref $self; |
41
|
|
|
|
|
|
|
|
42
|
3
|
100
|
66
|
|
|
21
|
if (defined $value || ! defined $self->{'_root_verbose'}) { |
43
|
1
|
|
50
|
|
|
6
|
$self->{'_root_verbose'} = $value || 0; |
44
|
|
|
|
|
|
|
} |
45
|
3
|
|
|
|
|
8
|
return $self->{'_root_verbose'}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _register_for_cleanup { |
49
|
0
|
|
|
0
|
|
0
|
my ($self,$method) = @_; |
50
|
0
|
0
|
|
|
|
0
|
if($method) { |
51
|
0
|
0
|
|
|
|
0
|
if(! exists($self->{'_root_cleanup_methods'})) { |
52
|
0
|
|
|
|
|
0
|
$self->{'_root_cleanup_methods'} = []; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
0
|
push(@{$self->{'_root_cleanup_methods'}},$method); |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _unregister_for_cleanup { |
59
|
0
|
|
|
0
|
|
0
|
my ($self,$method) = @_; |
60
|
0
|
|
|
|
|
0
|
my @methods = grep {$_ ne $method} $self->_cleanup_methods; |
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
|
|
0
|
$self->{'_root_cleanup_methods'} = \@methods; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _cleanup_methods { |
66
|
612
|
|
|
612
|
|
454
|
my $self = shift; |
67
|
612
|
50
|
33
|
|
|
2982
|
return unless ref $self && $self->isa('HASH'); |
68
|
612
|
50
|
|
|
|
4636
|
my $methods = $self->{'_root_cleanup_methods'} or return; |
69
|
0
|
|
|
|
|
0
|
@$methods; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub throw{ |
74
|
1
|
|
|
1
|
0
|
167
|
my ($self,$string) = @_; |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
2
|
my $std = $self->_stack_trace_dump(); |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
6
|
my $out = "\n-------------------- EXCEPTION --------------------\n". |
79
|
|
|
|
|
|
|
"MSG: ".$string."\n".$std."-------------------------------------------\n"; |
80
|
1
|
|
|
|
|
5
|
die $out; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub stack_trace{ |
85
|
3
|
|
|
3
|
0
|
220
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
3
|
|
|
|
|
2
|
my $i = 0; |
88
|
3
|
|
|
|
|
4
|
my @out; |
89
|
|
|
|
|
|
|
my $prev; |
90
|
3
|
|
|
|
|
18
|
while( my @call = caller($i++)) { |
91
|
|
|
|
|
|
|
# major annoyance that caller puts caller context as |
92
|
|
|
|
|
|
|
# function name. Hence some monkeying around... |
93
|
9
|
|
|
|
|
10
|
$prev->[3] = $call[3]; |
94
|
9
|
|
|
|
|
7
|
push(@out,$prev); |
95
|
9
|
|
|
|
|
29
|
$prev = \@call; |
96
|
|
|
|
|
|
|
} |
97
|
3
|
|
|
|
|
1
|
$prev->[3] = 'toplevel'; |
98
|
3
|
|
|
|
|
4
|
push(@out,$prev); |
99
|
3
|
|
|
|
|
5
|
return @out; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _stack_trace_dump{ |
103
|
2
|
|
|
2
|
|
8
|
my ($self) = @_; |
104
|
|
|
|
|
|
|
|
105
|
2
|
|
|
|
|
5
|
my @stack = $self->stack_trace(); |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
3
|
shift @stack; |
108
|
2
|
|
|
|
|
2
|
shift @stack; |
109
|
2
|
|
|
|
|
3
|
shift @stack; |
110
|
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
3
|
my $out; |
112
|
2
|
|
|
|
|
2
|
my ($module,$function,$file,$position); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
2
|
|
|
|
|
3
|
foreach my $stack ( @stack) { |
116
|
4
|
|
|
|
|
3
|
($module,$file,$position,$function) = @{$stack}; |
|
4
|
|
|
|
|
5
|
|
117
|
4
|
|
|
|
|
9
|
$out .= "STACK $function $file:$position\n"; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
2
|
|
|
|
|
8
|
return $out; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub deprecated{ |
124
|
1
|
|
|
1
|
0
|
421
|
my ($self,$msg) = @_; |
125
|
1
|
50
|
|
|
|
4
|
if( $self->verbose >= 0 ) { |
126
|
1
|
|
|
|
|
4
|
print STDERR $msg, "\n", $self->_stack_trace_dump; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub warn{ |
131
|
2
|
|
|
2
|
0
|
409
|
my ($self,$string) = @_; |
132
|
|
|
|
|
|
|
|
133
|
2
|
|
|
|
|
2
|
my $verbose; |
134
|
2
|
50
|
|
|
|
20
|
if( $self->can('verbose') ) { |
135
|
2
|
|
|
|
|
7
|
$verbose = $self->verbose; |
136
|
|
|
|
|
|
|
} else { |
137
|
0
|
|
|
|
|
0
|
$verbose = 0; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
2
|
50
|
|
|
|
9
|
if( $verbose == 2 ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
141
|
0
|
|
|
|
|
0
|
$self->throw($string); |
142
|
|
|
|
|
|
|
} elsif( $verbose == -1 ) { |
143
|
0
|
|
|
|
|
0
|
return; |
144
|
|
|
|
|
|
|
} elsif( $verbose == 1 ) { |
145
|
0
|
|
|
|
|
0
|
my $out = "\n-------------------- WARNING ---------------------\n". |
146
|
|
|
|
|
|
|
"MSG: ".$string."\n"; |
147
|
0
|
|
|
|
|
0
|
$out .= $self->_stack_trace_dump; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
0
|
print STDERR $out; |
150
|
0
|
|
|
|
|
0
|
return; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
2
|
|
|
|
|
5
|
my $out = "\n-------------------- WARNING ---------------------\n". |
154
|
|
|
|
|
|
|
"MSG: ".$string."\n". |
155
|
|
|
|
|
|
|
"---------------------------------------------------\n"; |
156
|
2
|
|
|
|
|
6
|
print STDERR $out; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub debug{ |
160
|
0
|
|
|
0
|
0
|
0
|
my ($self,@msgs) = @_; |
161
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
0
|
if( $self->verbose > 0 ) { |
163
|
0
|
|
|
|
|
0
|
print STDERR join("", @msgs); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub DESTROY { |
168
|
612
|
|
|
612
|
|
88317
|
my $self = shift; |
169
|
612
|
50
|
|
|
|
2599
|
my @cleanup_methods = $self->_cleanup_methods or return; |
170
|
0
|
|
|
|
|
|
for my $method (@cleanup_methods) { |
171
|
0
|
|
|
|
|
|
$method->($self); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
178
|
|
|
|
|
|
|
|