line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::VarTypes; sub MY () {__PACKAGE__} |
2
|
17
|
|
|
17
|
|
109
|
use strict; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
524
|
|
3
|
17
|
|
|
17
|
|
86
|
use warnings qw(FATAL all NONFATAL misc); |
|
17
|
|
|
|
|
44
|
|
|
17
|
|
|
|
|
656
|
|
4
|
17
|
|
|
17
|
|
95
|
use Exporter qw(import); |
|
17
|
|
|
|
|
35
|
|
|
17
|
|
|
|
|
812
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub Base () {'YATT::Lite::VarTypes::Base'} |
7
|
17
|
|
|
17
|
|
94
|
use YATT::Lite::Util qw(globref define_const); |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
4752
|
|
8
|
|
|
|
|
|
|
require Scalar::Util; |
9
|
|
|
|
|
|
|
our @EXPORT_OK; |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub add_slot_to { |
13
|
187
|
|
|
187
|
0
|
365
|
my ($pkg, $name, $i) = @_; |
14
|
187
|
|
|
|
|
531
|
*{globref($pkg, $name)} = sub { |
15
|
3925
|
|
|
3925
|
|
6685
|
my $self = shift; |
16
|
3925
|
100
|
|
|
|
7295
|
if (@_) { $self->[$i] = shift; $self; } else { $self->[$i] } |
|
33
|
|
|
|
|
76
|
|
|
33
|
|
|
|
|
80
|
|
|
3892
|
|
|
|
|
15727
|
|
17
|
187
|
|
|
|
|
713
|
}; |
18
|
187
|
|
|
|
|
501
|
my $constName = 'VSLOT_'.uc($name); |
19
|
187
|
|
|
|
|
458
|
my $sub = define_const(globref($pkg, $constName), $i); |
20
|
187
|
|
|
|
|
450
|
($constName => $sub); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
BEGIN { |
24
|
17
|
|
|
17
|
|
97
|
our @fields = qw(type |
25
|
|
|
|
|
|
|
varname argno |
26
|
|
|
|
|
|
|
lineno quote dflag default |
27
|
|
|
|
|
|
|
from_route |
28
|
|
|
|
|
|
|
); |
29
|
17
|
|
|
|
|
39
|
my $slotNum = 0; |
30
|
17
|
|
|
|
|
55
|
foreach my $name (@fields) { |
31
|
|
|
|
|
|
|
# accessor |
32
|
136
|
|
|
|
|
319
|
my ($constName, $sub) = add_slot_to(Base, $name, $slotNum); |
33
|
|
|
|
|
|
|
# constant |
34
|
136
|
|
|
|
|
300
|
push @EXPORT_OK, $constName; |
35
|
136
|
|
|
|
|
211
|
push @{$EXPORT_TAGS{VSLOT}}, $constName; |
|
136
|
|
|
|
|
278
|
|
36
|
136
|
|
|
|
|
265
|
*{globref(MY, $constName)} = $sub; |
|
136
|
|
|
|
|
360
|
|
37
|
|
|
|
|
|
|
} continue { |
38
|
136
|
|
|
|
|
6940
|
$slotNum++; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
# our @EXPORT = our @EXPORT_OK; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
# new(\@type |
45
|
|
|
|
|
|
|
# , $varname, $argno |
46
|
|
|
|
|
|
|
# , $quote, $dflag, $default, widget) |
47
|
|
|
|
|
|
|
sub YATT::Lite::VarTypes::Base::new { |
48
|
1733
|
|
|
1733
|
|
2987
|
my $pack = shift; |
49
|
1733
|
|
|
|
|
5402
|
bless [@_], $pack; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
sub YATT::Lite::VarTypes::Base::is_required { |
52
|
328
|
|
|
328
|
|
654
|
my $dflag = shift->[VSLOT_DFLAG]; |
53
|
328
|
100
|
100
|
|
|
1717
|
return 1 if defined $dflag and $dflag eq '!'; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
3
|
|
23
|
sub YATT::Lite::VarTypes::Base::flag { undef } |
57
|
0
|
|
|
0
|
|
0
|
sub YATT::Lite::VarTypes::Base::callable { 0 } |
58
|
29
|
|
|
29
|
|
110
|
sub YATT::Lite::VarTypes::Base::already_escaped { 0 } |
59
|
|
|
|
|
|
|
sub YATT::Lite::VarTypes::Base::is_type { |
60
|
6
|
|
|
6
|
|
20
|
my $type = shift->[VSLOT_TYPE]; |
61
|
6
|
|
|
|
|
14
|
my $want = shift; |
62
|
6
|
|
|
|
|
24
|
$type->[0] eq $want; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
BEGIN { |
67
|
|
|
|
|
|
|
# export する理由は無い? |
68
|
17
|
|
|
17
|
|
177
|
our @types = (qw(text list scalar) |
69
|
|
|
|
|
|
|
, [attr => {callable => 1}] |
70
|
|
|
|
|
|
|
, [bool => {flag => 1}] |
71
|
|
|
|
|
|
|
, [html => {already_escaped => 1}] |
72
|
|
|
|
|
|
|
, [code => {callable => 1}, qw(widget)] |
73
|
|
|
|
|
|
|
, [delegate => {callable => 1}, qw(widget delegate_vars)]); |
74
|
17
|
|
|
|
|
58
|
foreach my $spec (@types) { |
75
|
136
|
100
|
|
|
|
447
|
my ($type, $consts, @slots) = ref $spec ? @$spec : $spec; |
76
|
136
|
|
|
|
|
382
|
my $shortName = "t_$type"; |
77
|
136
|
|
|
|
|
335
|
my $fullName = join '::', MY, $shortName; |
78
|
136
|
|
|
|
|
257
|
*{globref($fullName, 'ISA')} = [Base]; |
|
136
|
|
|
|
|
365
|
|
79
|
136
|
|
|
|
|
448
|
define_const(globref(MY, $shortName), $fullName); |
80
|
136
|
|
|
|
|
345
|
push @EXPORT_OK, $shortName; |
81
|
136
|
|
|
|
|
223
|
push @{$EXPORT_TAGS{type}}, $shortName; |
|
136
|
|
|
|
|
291
|
|
82
|
136
|
100
|
|
|
|
357
|
if ($consts) { |
83
|
85
|
|
|
|
|
255
|
foreach my $key (keys %$consts) { |
84
|
85
|
|
|
|
|
155
|
my $val = $consts->{$key}; |
85
|
85
|
|
|
|
|
139
|
my $glob = *{globref($fullName, $key)}; |
|
85
|
|
|
|
|
220
|
|
86
|
85
|
50
|
|
|
|
246
|
if (ref $val eq 'CODE') { |
87
|
0
|
|
|
|
|
0
|
*glob = $val |
88
|
|
|
|
|
|
|
} else { |
89
|
85
|
|
|
|
|
211
|
define_const($glob, $val); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
136
|
100
|
|
|
|
429
|
if (@slots) { |
94
|
34
|
|
|
|
|
67
|
my $i = our @fields; |
95
|
34
|
|
|
|
|
71
|
foreach my $name (@slots) { |
96
|
51
|
|
|
|
|
147
|
add_slot_to($fullName, $name, $i); |
97
|
51
|
|
|
|
|
2501
|
} continue { $i++ } |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# widget だけ lvalue sub にするのも、一つの手ではないか? |
103
|
|
|
|
|
|
|
{ |
104
|
|
|
|
|
|
|
package YATT::Lite::VarTypes::t_delegate; |
105
|
|
|
|
|
|
|
sub weakened_set_widget { |
106
|
3
|
|
|
3
|
|
7
|
my $self = shift; |
107
|
3
|
|
|
|
|
9
|
$self->[VSLOT_WIDGET] = shift; |
108
|
|
|
|
|
|
|
Scalar::Util::weaken($self->[VSLOT_WIDGET]) |
109
|
3
|
50
|
|
|
|
16
|
if $self->[VSLOT_WIDGET]->{cf_folder}; |
110
|
3
|
|
|
|
|
8
|
$self; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |