line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Macro; |
2
|
1
|
|
|
1
|
|
6269
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings qw(FATAL all NONFATAL misc); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# use YATT::Lite::Macro; |
7
|
|
|
|
|
|
|
# use YATT::Lite::Macro qw(Macro=perl); |
8
|
|
|
|
|
|
|
# use YATT::Lite::Macro qw(Macro=js); |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
503
|
use YATT::Lite::Core qw(Template Part Widget Page Action); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
102
|
|
11
|
1
|
|
|
1
|
|
5
|
use YATT::Lite::Constants; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
209
|
|
12
|
1
|
|
|
1
|
|
6
|
use YATT::Lite::Util qw(globref lexpand); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
546
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw(Macro lexpand); |
15
|
|
|
|
|
|
|
our @EXPORT_OK = (@EXPORT, qw(Template Part Widget Page Action)); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Use cases: |
18
|
|
|
|
|
|
|
# (a) .htyattrc.pl から呼ばれて、 MyApp::INST1::CGEN_perl に macro_zzz を足す。 |
19
|
|
|
|
|
|
|
# (b) MyApp.pm から呼ばれて、 MyApp::CGEN_perl に... こっちがまだだよね。 |
20
|
|
|
|
|
|
|
# sub cgen_perl () {'...CGEN_perl'} を設定するべきか否か。<= ロード順問題を抱えるよね。 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub define_Macro { |
23
|
0
|
|
|
0
|
0
|
|
my ($myPack, $callpack, $type) = @_; |
24
|
0
|
|
0
|
|
|
|
my $destns = join('::', $callpack, 'CGEN_'.($type || 'perl')); |
25
|
0
|
|
|
|
|
|
my $macro = globref($callpack, 'Macro'); |
26
|
0
|
0
|
|
|
|
|
unless (*{$macro}{CODE}) { |
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
*$macro = sub { |
28
|
0
|
|
|
0
|
|
|
my ($name, $sub) = @_; |
29
|
0
|
|
|
|
|
|
*{globref($destns, "macro_$name")} = $sub; |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
0
|
|
sub default_export { @EXPORT } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub import { |
37
|
0
|
|
|
0
|
|
|
my ($pack, @opts) = @_; |
38
|
0
|
0
|
|
|
|
|
@opts = $pack->default_export unless @opts; |
39
|
0
|
|
|
|
|
|
my $callpack = caller; |
40
|
0
|
|
|
|
|
|
my (%opts, @task); |
41
|
0
|
|
|
|
|
|
foreach my $exp (@opts) { |
42
|
0
|
|
|
|
|
|
my ($name, $rest) = split /=/, $exp, 2; |
43
|
0
|
0
|
|
|
|
|
if (my $sub = $pack->can("define_$name")) { |
|
|
0
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
push @task, [$sub, $rest]; |
45
|
0
|
|
|
|
|
|
} elsif (grep {$_ eq $exp} @EXPORT_OK) { |
46
|
0
|
|
|
|
|
|
*{globref($callpack, $exp)} = *{globref($pack, $exp)}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
|
|
|
|
croak "Unknown export spec: $exp"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
|
foreach my $task (@task) { |
52
|
0
|
|
|
|
|
|
my ($sub, $rest) = @$task; |
53
|
0
|
|
|
|
|
|
$sub->($pack, $callpack, $rest); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |