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