line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::NSBuilder; sub MY () {__PACKAGE__} |
2
|
14
|
|
|
14
|
|
19948
|
use strict; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
421
|
|
3
|
14
|
|
|
14
|
|
68
|
use warnings qw(FATAL all NONFATAL misc); |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
474
|
|
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
448
|
use YATT::Lite::Util qw(lexpand); |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
666
|
|
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
|
14
|
|
|
14
|
|
108
|
use parent qw(YATT::Lite::Object); |
|
14
|
|
|
|
|
645
|
|
|
14
|
|
|
|
|
92
|
|
16
|
14
|
|
|
14
|
|
726
|
use Carp; |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
667
|
|
17
|
14
|
|
|
14
|
|
71
|
use YATT::Lite::Util qw(ckeval ckrequire set_inc symtab globref); |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
872
|
|
18
|
|
|
|
|
|
|
our %SEEN_NS; |
19
|
14
|
|
|
|
|
96
|
use YATT::Lite::MFields qw/cf_app_ns app_ns |
20
|
|
|
|
|
|
|
cf_default_app default_app |
21
|
14
|
|
|
14
|
|
800
|
subns/; |
|
14
|
|
|
|
|
28
|
|
22
|
|
|
|
|
|
|
sub _before_after_new { |
23
|
42
|
|
|
42
|
|
115
|
(my MY $self) = @_; |
24
|
42
|
|
|
|
|
227
|
$self->SUPER::_before_after_new; |
25
|
42
|
50
|
66
|
|
|
371
|
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
|
42
|
|
|
|
|
214
|
$self->init_default_app; |
29
|
42
|
|
|
|
|
259
|
$self->init_app_ns; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
0
|
4
|
sub default_subns {'INST'} |
33
|
16
|
|
|
16
|
0
|
53
|
sub default_default_app {'YATT::Lite'} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub init_default_app { |
36
|
42
|
|
|
42
|
0
|
107
|
(my MY $self) = @_; |
37
|
|
|
|
|
|
|
# This usually loads YATT::Lite (or YATT::Lite::WebMVC0::DirApp) |
38
|
|
|
|
|
|
|
$self->{default_app} |
39
|
42
|
|
66
|
|
|
294
|
= $self->{cf_default_app} || $self->default_default_app; |
40
|
42
|
|
|
|
|
195
|
ckrequire($self->{default_app}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
sub init_app_ns { |
43
|
42
|
|
|
42
|
0
|
101
|
(my MY $self) = @_; |
44
|
|
|
|
|
|
|
# This usually set 'MyApp' |
45
|
|
|
|
|
|
|
$self->{app_ns} = my $app_ns = $self->{cf_app_ns} |
46
|
42
|
|
66
|
|
|
267
|
// $self->{default_app}->default_app_ns; |
47
|
42
|
|
|
|
|
159
|
try_require($app_ns); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $site_entns = $self->{default_app}->ensure_entns |
50
|
42
|
|
|
|
|
430
|
(ref $self, $self->{default_app}->list_entns(ref $self)); |
51
|
|
|
|
|
|
|
|
52
|
42
|
|
|
|
|
242
|
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
|
42
|
100
|
|
|
|
457
|
unless ($app_ns->isa($self->{default_app})) { |
58
|
41
|
|
|
|
|
230
|
$self->define_base_of($app_ns, $self->{default_app}); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Then MyApp::EntNS is composed |
62
|
42
|
|
|
|
|
274
|
$self->{default_app}->ensure_entns($app_ns, @base_entns); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
sub try_require { |
66
|
75
|
|
|
75
|
0
|
177
|
my ($app_ns) = @_; |
67
|
75
|
|
|
|
|
255
|
(my $modfn = $app_ns) =~ s|::|/|g; |
68
|
75
|
|
|
|
|
143
|
local $@; |
69
|
75
|
|
|
|
|
3550
|
eval qq{require $app_ns}; |
70
|
75
|
50
|
|
|
|
14195
|
unless ($@) { |
|
|
100
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# $app_ns.pm is loaded successfully. |
72
|
0
|
|
|
|
|
0
|
} 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
|
75
|
|
|
75
|
0
|
636
|
(my MY $self, my ($subns, $baselist, $path)) = @_; |
80
|
|
|
|
|
|
|
# This usually creates MyApp::INST$n and set it's ISA. |
81
|
75
|
|
66
|
|
|
230
|
$subns ||= $self->default_subns; |
82
|
75
|
50
|
|
|
|
191
|
my @base = map {ref $_ || $_} @$baselist; |
|
33
|
|
|
|
|
154
|
|
83
|
75
|
100
|
|
|
|
233
|
if (@base) { |
84
|
26
|
|
|
|
|
84
|
try_require($_) for @base; |
85
|
26
|
100
|
|
|
|
59
|
unless (grep {$_->isa($self->{default_app})} @base) { |
|
33
|
|
|
|
|
372
|
|
86
|
1
|
|
|
|
|
208
|
croak "None of baseclass inherits $self->{default_app}: @base"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
my $newns = sprintf q{%s::%s%d}, $self->{app_ns}, $subns |
90
|
74
|
|
|
|
|
678
|
, ++$self->{subns}{$subns}; |
91
|
74
|
100
|
|
|
|
485
|
$self->define_base_of($newns, @base ? @base : $self->{app_ns}); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
YATT::Lite::Util::globref_default(globref($newns, 'filename') |
94
|
74
|
|
|
114
|
|
292
|
, sub { $path }); |
|
114
|
|
|
|
|
906
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $entns = $self->{default_app}->ensure_entns($newns, map { |
97
|
81
|
|
|
|
|
574
|
$_->EntNS |
98
|
74
|
100
|
|
|
|
321
|
} @base ? @base : $self->{app_ns}); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
YATT::Lite::Util::globref_default(globref($entns, 'filename') |
101
|
74
|
|
|
0
|
|
260
|
, sub { $path }); |
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
|
103
|
74
|
|
|
|
|
252
|
set_inc($newns, 1); |
104
|
74
|
|
|
|
|
256
|
$newns; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
sub define_base_of { |
107
|
115
|
|
|
115
|
0
|
340
|
(my MY $self, my ($newns, @base)) = @_; |
108
|
115
|
|
|
|
|
650
|
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; |