blib/lib/YATT/Lite/Macro.pm

filter: Statementstmt 42.0% 21 / 50 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 2 totaltotal 36.4% 27 / 74 CC 9 SCAR 28.4
CC
9
Cov
34%
import
42.0
define_Macro
12.0
__ANON__
6.0
CRAP 17.1
« blib/bin/yatt-langserver.pl ↑ Summary blib/lib/YATT/Lite/LanguageServer.pm »
1 package YATT::Lite::Macro;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # use YATT::Lite::Macro;
7  
8 1 ▶use YATT::Lite::Core qw(Template Part Widget Page Action);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use YATT::Lite::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use YATT::Lite::Util qw(globref lexpand);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @EXPORT = qw(Macro lexpand);
13 1 our @EXPORT_OK = (@EXPORT, qw(Template Part Widget Page Action));
14  
15 # Use cases:
16 # (a) .htyattrc.pl から呼ばれて、 MyYATT::INST1::CGEN_perl に macro_zzz を足す。
17 # (b) MyYATT.pm から呼ばれて、 MyYATT::CGEN_perl に... こっちがまだだよね。
18 # sub cgen_perl () {'...CGEN_perl'} を設定するべきか否か。<= ロード順問題を抱えるよね。
19  
20 0 ▶sub define_Macro {
Subroutine define_Macro: not called CC=3 SCAR=24.8
Pod undocumented
21 0 ▶ if (@_ >= 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ >= 3) 0 0 0
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 ▶ unless (*{$macro}{CODE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (*{$macro;}{"CODE"}) 0 0 0
27 0 ▶ *$macro = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
28 0 my ($nameSpec, $sub) = @_;
29 0 ▶ my ($type, $name) = ref $nameSpec ? @$nameSpec : (perl => $nameSpec);
Branch: 1 branch
BranchTrueFalseTotal
ref $nameSpec ? : 0 0 0
30  
31 0 my $destns = $callpack->ensure_cgen_for($type, $callpack);
32  
33 0 *{globref($destns, "macro_$name")} = $sub;
34 0 };
35 }
36 }
37  
38 0 ▶sub default_export { @EXPORT }
Subroutine default_export: not called CC=1 SCAR=6.9
Pod undocumented
39  
40 0 ▶sub import {
Subroutine import: not called CC=6 SCAR=37.4
41 0 my ($pack, @opts) = @_;
42 0 ▶ @opts = $pack->default_export unless @opts;
Branch: 1 branch
BranchTrueFalseTotal
unless @opts 0 0 0
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 ▶ if (my $sub = $pack->can("define_$name")) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $sub = $pack->can("define_$name")) { } 0 0 0
elsif (grep {$_ eq $exp;} @YATT::Lite::Macro::EXPORT_OK) { } 0 0 0
48 0 push @task, [$sub, @rest];
49 0 } elsif (grep {$_ eq $exp} @EXPORT_OK) {
50 0 *{globref($callpack, $exp)} = *{globref($pack, $exp)};
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 1;
« blib/bin/yatt-langserver.pl ↑ Summary blib/lib/YATT/Lite/LanguageServer.pm »