| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package AutoCode::ModuleLoader; |
|
2
|
3
|
|
|
3
|
|
16784
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
90
|
|
|
3
|
3
|
|
|
3
|
|
1017
|
use AutoCode::ModuleFactory; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
|
|
our $SCHEMA; |
|
5
|
|
|
|
|
|
|
our $FACTORY; |
|
6
|
|
|
|
|
|
|
our %LOADED; # Cache |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# In the previous design, the method 'import' can load any specific type. And |
|
9
|
|
|
|
|
|
|
# we forbid the feature, since it cannot return virtual package we want, and |
|
10
|
|
|
|
|
|
|
# the users should not guess/predict what the virtual package is, which is the |
|
11
|
|
|
|
|
|
|
# internal business to decide the VP of this AutoCode. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
|
14
|
3
|
|
|
3
|
|
19
|
my $pkg=shift; |
|
15
|
3
|
100
|
|
|
|
83
|
$pkg->load_schema(@_) if @_; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub load_schema { |
|
19
|
3
|
|
|
3
|
0
|
7
|
my ($pkg, $schema, $prefix)=@_; |
|
20
|
3
|
|
|
|
|
26
|
AutoCode::Root->_load_module($schema); |
|
21
|
3
|
100
|
66
|
|
|
26
|
my @args = (defined $prefix and $prefix ne 'default') |
|
22
|
|
|
|
|
|
|
? (-package_prefix => $prefix):(); |
|
23
|
3
|
|
|
|
|
34
|
$SCHEMA= $schema->new(@args); |
|
24
|
3
|
|
|
|
|
34
|
$FACTORY=AutoCode::ModuleFactory->new( |
|
25
|
|
|
|
|
|
|
-schema => $SCHEMA |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Cache is at work. |
|
30
|
|
|
|
|
|
|
sub load { |
|
31
|
4
|
|
|
4
|
0
|
1001
|
my ($pkg, $type, $prefix)=@_; |
|
32
|
4
|
50
|
|
|
|
21
|
return $LOADED{$type} if(exists $LOADED{$type}); |
|
33
|
4
|
|
|
|
|
24
|
my $vp = $FACTORY->make_module($type); |
|
34
|
4
|
|
|
|
|
13
|
$LOADED{$type}=$vp; |
|
35
|
4
|
|
|
|
|
14
|
return $vp; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub load_all { |
|
40
|
0
|
|
|
0
|
0
|
|
my ($pkg)=@_; |
|
41
|
0
|
|
|
|
|
|
my @types=$SCHEMA->get_all_types; |
|
42
|
0
|
|
|
|
|
|
foreach(@types){ |
|
43
|
0
|
|
|
|
|
|
$pkg->load($_); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
|
49
|
|
|
|
|
|
|
__END__ |