line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::NSBuilder; sub MY () {__PACKAGE__} |
2
|
8
|
|
|
8
|
|
24988
|
use strict; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
239
|
|
3
|
8
|
|
|
8
|
|
39
|
use warnings qw(FATAL all NONFATAL misc); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
374
|
|
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
731
|
use YATT::Lite::Util qw(lexpand); |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
493
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
# bootscript が決まれば、root NS も一つに決まる、としよう。 MyApp 、と。 |
9
|
|
|
|
|
|
|
# instpkg の系列も決まる、と。 MyApp::INST1, 2, ... だと。 |
10
|
|
|
|
|
|
|
# XXX: INST を越えて共有される *.ytmpl/ は、 TMPL1, 2, ... と名づけたいが、... |
11
|
|
|
|
|
|
|
# それ以下のディレクトリ名・ファイル名はそのまま pkgname に使う。 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# MyApp::INST1::dir::dir::dir::file |
14
|
|
|
|
|
|
|
# MyApp::TMPL1::dir::dir::dir::file |
15
|
8
|
|
|
8
|
|
77
|
use parent qw(YATT::Lite::Object); |
|
8
|
|
|
|
|
1045
|
|
|
8
|
|
|
|
|
58
|
|
16
|
8
|
|
|
8
|
|
422
|
use Carp; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
466
|
|
17
|
8
|
|
|
8
|
|
218
|
use YATT::Lite::Util qw(ckeval ckrequire set_inc symtab globref); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
661
|
|
18
|
|
|
|
|
|
|
our %SEEN_NS; |
19
|
8
|
|
|
|
|
61
|
use YATT::Lite::MFields qw/cf_app_ns app_ns |
20
|
|
|
|
|
|
|
cf_default_app default_app |
21
|
8
|
|
|
8
|
|
1208
|
subns/; |
|
8
|
|
|
|
|
15
|
|
22
|
|
|
|
|
|
|
sub _before_after_new { |
23
|
23
|
|
|
23
|
|
56
|
(my MY $self) = @_; |
24
|
23
|
|
|
|
|
133
|
$self->SUPER::_before_after_new; |
25
|
23
|
50
|
66
|
|
|
203
|
if ($self->{cf_app_ns} and $SEEN_NS{$self->{cf_app_ns}}++) { |
26
|
0
|
|
|
|
|
0
|
confess "app_ns '$self->{cf_app_ns}' is already used!"; |
27
|
|
|
|
|
|
|
} |
28
|
23
|
|
|
|
|
122
|
$self->init_default_app; |
29
|
23
|
|
|
|
|
139
|
$self->init_app_ns; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
0
|
3
|
sub default_subns {'INST'} |
33
|
13
|
|
|
13
|
0
|
58
|
sub default_default_app {'YATT::Lite'} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub init_default_app { |
36
|
23
|
|
|
23
|
0
|
45
|
(my MY $self) = @_; |
37
|
|
|
|
|
|
|
# This usually loads YATT::Lite (or YATT::Lite::WebMVC0::DirApp) |
38
|
|
|
|
|
|
|
$self->{default_app} |
39
|
23
|
|
66
|
|
|
154
|
= $self->{cf_default_app} || $self->default_default_app; |
40
|
23
|
|
|
|
|
100
|
ckrequire($self->{default_app}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
sub init_app_ns { |
43
|
23
|
|
|
23
|
0
|
44
|
(my MY $self) = @_; |
44
|
|
|
|
|
|
|
# This usually set 'MyApp' |
45
|
|
|
|
|
|
|
$self->{app_ns} = my $app_ns = $self->{cf_app_ns} |
46
|
23
|
|
66
|
|
|
141
|
// $self->{default_app}->default_app_ns; |
47
|
23
|
|
|
|
|
80
|
try_require($app_ns); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $site_entns = $self->{default_app}->ensure_entns |
50
|
23
|
|
|
|
|
209
|
(ref $self, $self->{default_app}->list_entns(ref $self)); |
51
|
|
|
|
|
|
|
|
52
|
23
|
|
|
|
|
160
|
my @base_entns = ($self->{default_app}->EntNS, $site_entns); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# print "default_app is $self->{default_app}\n"; |
55
|
|
|
|
|
|
|
# print "base entns for $app_ns is: @base_entns\n"; |
56
|
|
|
|
|
|
|
|
57
|
23
|
100
|
|
|
|
386
|
unless ($app_ns->isa($self->{default_app})) { |
58
|
22
|
|
|
|
|
123
|
$self->define_base_of($app_ns, $self->{default_app}); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Then MyApp::EntNS is composed |
62
|
23
|
|
|
|
|
134
|
$self->{default_app}->ensure_entns($app_ns, @base_entns); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
sub try_require { |
66
|
42
|
|
|
42
|
0
|
74
|
my ($app_ns) = @_; |
67
|
42
|
|
|
|
|
129
|
(my $modfn = $app_ns) =~ s|::|/|g; |
68
|
42
|
|
|
|
|
74
|
local $@; |
69
|
42
|
|
|
|
|
2431
|
eval qq{require $app_ns}; |
70
|
42
|
100
|
|
|
|
12409
|
unless ($@) { |
|
|
50
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# $app_ns.pm is loaded successfully. |
72
|
|
|
|
|
|
|
} elsif ($@ =~ m{^Can't locate $modfn}) { |
73
|
|
|
|
|
|
|
# $app_ns.pm can be missing. |
74
|
|
|
|
|
|
|
} else { |
75
|
0
|
|
|
|
|
0
|
die $@; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
sub buildns { |
79
|
40
|
|
|
40
|
0
|
490
|
(my MY $self, my ($subns, $baselist, $path)) = @_; |
80
|
|
|
|
|
|
|
# This usually creates MyApp::INST$n and set it's ISA. |
81
|
40
|
|
66
|
|
|
125
|
$subns ||= $self->default_subns; |
82
|
40
|
50
|
|
|
|
97
|
my @base = map {ref $_ || $_} @$baselist; |
|
19
|
|
|
|
|
103
|
|
83
|
40
|
100
|
|
|
|
111
|
if (@base) { |
84
|
19
|
|
|
|
|
70
|
try_require($_) for @base; |
85
|
19
|
100
|
|
|
|
38
|
unless (grep {$_->isa($self->{default_app})} @base) { |
|
19
|
|
|
|
|
274
|
|
86
|
1
|
|
|
|
|
238
|
croak "None of baseclass inherits $self->{default_app}: @base"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
my $newns = sprintf q{%s::%s%d}, $self->{app_ns}, $subns |
90
|
39
|
|
|
|
|
264
|
, ++$self->{subns}{$subns}; |
91
|
39
|
100
|
|
|
|
164
|
$self->define_base_of($newns, @base ? @base : $self->{app_ns}); |
92
|
|
|
|
|
|
|
my $entns = $self->{default_app}->ensure_entns($newns, map { |
93
|
39
|
|
|
|
|
264
|
$_->EntNS |
94
|
39
|
100
|
|
|
|
169
|
} @base ? @base : $self->{app_ns}); |
95
|
|
|
|
|
|
|
|
96
|
39
|
|
|
|
|
95
|
foreach my $ns ($entns, $newns) { |
97
|
78
|
|
|
|
|
219
|
my $sym = globref($ns, 'filename'); |
98
|
78
|
100
|
|
|
|
117
|
unless (*{$sym}{CODE}) { |
|
78
|
|
|
|
|
218
|
|
99
|
76
|
|
|
2
|
|
387
|
*$sym = sub { $path }; |
|
2
|
|
|
|
|
254
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
39
|
|
|
|
|
125
|
set_inc($newns, 1); |
104
|
39
|
|
|
|
|
162
|
$newns; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
sub define_base_of { |
107
|
61
|
|
|
61
|
0
|
179
|
(my MY $self, my ($newns, @base)) = @_; |
108
|
61
|
|
|
|
|
350
|
YATT::Lite::MFields->add_isa_to($newns, @base) |
109
|
|
|
|
|
|
|
->define_fields($newns); |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
0
|
0
|
|
sub lineinfo { shift; sprintf qq{#line %d "%s"\n}, @_} |
|
0
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |