line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MakeMethods::Autoload; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
20052
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
142
|
|
4
|
2
|
|
|
2
|
|
17
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
166
|
|
5
|
|
|
|
|
|
|
require Exporter; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1906
|
use Class::MakeMethods; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
15
|
|
8
|
2
|
|
|
2
|
|
1687
|
use Class::MakeMethods::Utility::Inheritable 'get_vvalue'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
17
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
14
|
use vars qw( $VERSION @ISA @EXPORT_OK ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
293
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = 1.000; |
13
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
14
|
|
|
|
|
|
|
@EXPORT_OK = qw( AUTOLOAD ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
######################################################################## |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
12
|
use vars qw( $AUTOLOAD %DefaultType ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1622
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub import { |
21
|
2
|
|
|
2
|
|
83
|
my $class = shift; |
22
|
2
|
|
|
|
|
21
|
my $target_class = ( caller(0) )[0]; |
23
|
|
|
|
|
|
|
|
24
|
2
|
50
|
33
|
|
|
29
|
if ( scalar @_ and $_[0] =~ m/^\d/ ) { |
25
|
0
|
|
|
|
|
0
|
Class::MakeMethods::_import_version( $class, shift ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
2
|
50
|
|
|
|
8
|
if ( scalar @_ == 1 ) { |
29
|
2
|
|
|
|
|
7
|
$DefaultType{ $target_class } = shift; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
2650
|
__PACKAGE__->Exporter::export_to_level(1, $class, 'AUTOLOAD'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub AUTOLOAD { |
36
|
6
|
|
|
6
|
|
2100
|
my $sym = $AUTOLOAD; |
37
|
6
|
|
|
|
|
51
|
my ($package, $func) = ($sym =~ /(.*)::([^:]+)$/); |
38
|
|
|
|
|
|
|
|
39
|
6
|
100
|
|
|
|
31
|
unless ( $DefaultType{$package} ) { |
40
|
1
|
|
|
|
|
6
|
local $_ = get_vvalue( \%DefaultType, $package ); |
41
|
1
|
50
|
|
|
|
4
|
$DefaultType{$package} = $_ if ( $_ ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
6
|
50
|
|
|
|
24
|
my $type = $DefaultType{$package} |
45
|
|
|
|
|
|
|
or croak(__PACKAGE__ . ": No default method type for $package; can't auto-generate $func"); |
46
|
|
|
|
|
|
|
|
47
|
6
|
100
|
|
|
|
27
|
if ( ref $type eq 'HASH' ) { |
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $n_type = $type->{ $func } || |
49
|
3
|
50
|
33
|
|
|
34
|
( map $type->{$_}, grep { $func =~ m/\A$_\Z/ } sort { length($b) <=> length($a) } keys %$type )[0] || |
50
|
|
|
|
|
|
|
$type->{ '' } |
51
|
|
|
|
|
|
|
or croak(__PACKAGE__ . ": Can't find best match for '$func' in type map (" . join(', ', keys %$type ) . ")"); |
52
|
3
|
|
|
|
|
9
|
$type = $n_type; |
53
|
|
|
|
|
|
|
} elsif ( ref $type eq 'CODE' ) { |
54
|
0
|
0
|
|
|
|
0
|
$type = &$type( $func ) |
55
|
|
|
|
|
|
|
or croak(__PACKAGE__ . ": Can't find match for '$func' in type map ($type)"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# warn "Autoload $func ($type)"; |
59
|
|
|
|
|
|
|
Class::MakeMethods->make( |
60
|
6
|
|
|
|
|
76
|
-TargetClass => $package, |
61
|
|
|
|
|
|
|
-ForceInstall => 1, |
62
|
|
|
|
|
|
|
$type => $func |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
6
|
50
|
|
|
|
50
|
if ( my $sub = $package->can( $func ) ) { |
66
|
6
|
|
|
|
|
30
|
goto &$sub; |
67
|
|
|
|
|
|
|
} else { |
68
|
0
|
|
|
|
|
|
croak(__PACKAGE__ . ": Construction of $type method ${package}::$func failed to produce usable method") |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |