line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Unload; |
2
|
|
|
|
|
|
|
# ABSTRACT: Unload a class |
3
|
|
|
|
|
|
|
$Class::Unload::VERSION = '0.10'; # TRIAL |
4
|
2
|
|
|
2
|
|
26378
|
use warnings; |
|
2
|
|
|
1
|
|
5
|
|
|
2
|
|
|
|
|
52
|
|
|
1
|
|
|
|
|
15816
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
1
|
|
3
|
|
|
2
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
6
|
2
|
|
|
2
|
|
7
|
no strict 'refs'; # we're fiddling with the symbol table |
|
2
|
|
|
1
|
|
6
|
|
|
2
|
|
|
|
|
47
|
|
|
1
|
|
|
|
|
21
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
803
|
use Class::Inspector; |
|
2
|
|
|
1
|
|
4956
|
|
|
2
|
|
|
|
|
326
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
173
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub unload { |
12
|
2
|
|
|
2
|
1
|
2332
|
my ($self, $class) = @_; |
|
5
|
|
|
5
|
|
3441
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
50
|
|
|
|
9
|
return unless Class::Inspector->loaded( $class ); |
|
5
|
100
|
|
|
|
16
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Flush inheritance caches |
17
|
2
|
|
|
|
|
84
|
@{$class . '::ISA'} = (); |
|
2
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
91
|
|
|
4
|
|
|
|
|
33
|
|
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
7
|
my $symtab = $class.'::'; |
|
4
|
|
|
|
|
10
|
|
20
|
|
|
|
|
|
|
# Delete all symbols except other namespaces |
21
|
2
|
|
|
|
|
7
|
for my $symbol (keys %$symtab) { |
|
4
|
|
|
|
|
13
|
|
22
|
9
|
50
|
|
|
|
22
|
next if $symbol =~ /\A[^:]+::\z/; |
|
14
|
100
|
|
|
|
35
|
|
23
|
9
|
|
|
|
|
38
|
delete $symtab->{$symbol}; |
|
12
|
|
|
|
|
47
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
15
|
my $inc_file = join( '/', split /(?:'|::)/, $class ) . '.pm'; |
|
4
|
|
|
|
|
24
|
|
27
|
2
|
|
|
|
|
6
|
delete $INC{ $inc_file }; |
|
4
|
|
|
|
|
9
|
|
28
|
|
|
|
|
|
|
|
29
|
2
|
50
|
|
|
|
6
|
if (Class::Inspector->loaded('Class::MOP')) { |
|
4
|
50
|
|
|
|
11
|
|
30
|
0
|
|
|
|
|
0
|
Class::MOP::remove_metaclass_by_name($class); |
|
0
|
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
121
|
return 1; |
|
4
|
|
|
|
|
526
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; # End of Class::Unload |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |