line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::VarTypes; sub MY () {__PACKAGE__} |
2
|
11
|
|
|
11
|
|
56
|
use strict; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
317
|
|
3
|
11
|
|
|
11
|
|
56
|
use warnings qw(FATAL all NONFATAL misc); |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
395
|
|
4
|
11
|
|
|
11
|
|
119
|
use Exporter qw(import); |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
611
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub Base () {'YATT::Lite::VarTypes::Base'} |
7
|
11
|
|
|
11
|
|
53
|
use YATT::Lite::Util qw(globref define_const); |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
3978
|
|
8
|
|
|
|
|
|
|
require Scalar::Util; |
9
|
|
|
|
|
|
|
our @EXPORT_OK; |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub add_slot_to { |
13
|
110
|
|
|
110
|
0
|
188
|
my ($pkg, $name, $i) = @_; |
14
|
110
|
|
|
|
|
293
|
*{globref($pkg, $name)} = sub { |
15
|
3168
|
|
|
3168
|
|
4383
|
my $self = shift; |
16
|
3168
|
100
|
|
|
|
5431
|
if (@_) { $self->[$i] = shift; $self; } else { $self->[$i] } |
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
53
|
|
|
3149
|
|
|
|
|
13954
|
|
17
|
110
|
|
|
|
|
372
|
}; |
18
|
110
|
|
|
|
|
260
|
my $constName = 'VSLOT_'.uc($name); |
19
|
110
|
|
|
|
|
283
|
my $sub = define_const(globref($pkg, $constName), $i); |
20
|
110
|
|
|
|
|
284
|
($constName => $sub); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
BEGIN { |
24
|
11
|
|
|
11
|
|
50
|
our @fields = qw(type |
25
|
|
|
|
|
|
|
varname argno |
26
|
|
|
|
|
|
|
lineno quote dflag default); |
27
|
11
|
|
|
|
|
22
|
my $slotNum = 0; |
28
|
11
|
|
|
|
|
30
|
foreach my $name (@fields) { |
29
|
|
|
|
|
|
|
# accessor |
30
|
77
|
|
|
|
|
166
|
my ($constName, $sub) = add_slot_to(Base, $name, $slotNum); |
31
|
|
|
|
|
|
|
# constant |
32
|
77
|
|
|
|
|
162
|
push @EXPORT_OK, $constName; |
33
|
77
|
|
|
|
|
99
|
push @{$EXPORT_TAGS{VSLOT}}, $constName; |
|
77
|
|
|
|
|
157
|
|
34
|
77
|
|
|
|
|
110
|
*{globref(MY, $constName)} = $sub; |
|
77
|
|
|
|
|
274
|
|
35
|
|
|
|
|
|
|
} continue { |
36
|
77
|
|
|
|
|
5577
|
$slotNum++; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
# our @EXPORT = our @EXPORT_OK; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
# new(\@type |
43
|
|
|
|
|
|
|
# , $varname, $argno |
44
|
|
|
|
|
|
|
# , $quote, $dflag, $default, widget) |
45
|
|
|
|
|
|
|
sub YATT::Lite::VarTypes::Base::new { |
46
|
1232
|
|
|
1232
|
|
1897
|
my $pack = shift; |
47
|
1232
|
|
|
|
|
4597
|
bless [@_], $pack; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
sub YATT::Lite::VarTypes::Base::is_required { |
50
|
303
|
|
|
303
|
|
522
|
my $dflag = shift->[VSLOT_DFLAG]; |
51
|
303
|
100
|
100
|
|
|
1897
|
return 1 if defined $dflag and $dflag eq '!'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
3
|
|
15
|
sub YATT::Lite::VarTypes::Base::flag { undef } |
55
|
0
|
|
|
0
|
|
0
|
sub YATT::Lite::VarTypes::Base::callable { 0 } |
56
|
29
|
|
|
29
|
|
120
|
sub YATT::Lite::VarTypes::Base::already_escaped { 0 } |
57
|
|
|
|
|
|
|
sub YATT::Lite::VarTypes::Base::is_type { |
58
|
6
|
|
|
6
|
|
13
|
my $type = shift->[VSLOT_TYPE]; |
59
|
6
|
|
|
|
|
8
|
my $want = shift; |
60
|
6
|
|
|
|
|
31
|
$type->[0] eq $want; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
BEGIN { |
65
|
|
|
|
|
|
|
# export する理由は無い? |
66
|
11
|
|
|
11
|
|
126
|
our @types = (qw(text list scalar) |
67
|
|
|
|
|
|
|
, [attr => {callable => 1}] |
68
|
|
|
|
|
|
|
, [bool => {flag => 1}] |
69
|
|
|
|
|
|
|
, [html => {already_escaped => 1}] |
70
|
|
|
|
|
|
|
, [code => {callable => 1}, qw(widget)] |
71
|
|
|
|
|
|
|
, [delegate => {callable => 1}, qw(widget delegate_vars)]); |
72
|
11
|
|
|
|
|
32
|
foreach my $spec (@types) { |
73
|
88
|
100
|
|
|
|
293
|
my ($type, $consts, @slots) = ref $spec ? @$spec : $spec; |
74
|
88
|
|
|
|
|
183
|
my $shortName = "t_$type"; |
75
|
88
|
|
|
|
|
199
|
my $fullName = join '::', MY, $shortName; |
76
|
88
|
|
|
|
|
163
|
*{globref($fullName, 'ISA')} = [Base]; |
|
88
|
|
|
|
|
241
|
|
77
|
88
|
|
|
|
|
296
|
define_const(globref(MY, $shortName), $fullName); |
78
|
88
|
|
|
|
|
182
|
push @EXPORT_OK, $shortName; |
79
|
88
|
|
|
|
|
108
|
push @{$EXPORT_TAGS{type}}, $shortName; |
|
88
|
|
|
|
|
188
|
|
80
|
88
|
100
|
|
|
|
230
|
if ($consts) { |
81
|
55
|
|
|
|
|
141
|
foreach my $key (keys %$consts) { |
82
|
55
|
|
|
|
|
90
|
my $val = $consts->{$key}; |
83
|
55
|
|
|
|
|
68
|
my $glob = *{globref($fullName, $key)}; |
|
55
|
|
|
|
|
145
|
|
84
|
55
|
50
|
|
|
|
142
|
if (ref $val eq 'CODE') { |
85
|
0
|
|
|
|
|
0
|
*glob = $val |
86
|
|
|
|
|
|
|
} else { |
87
|
55
|
|
|
|
|
138
|
define_const($glob, $val); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
88
|
100
|
|
|
|
274
|
if (@slots) { |
92
|
22
|
|
|
|
|
40
|
my $i = our @fields; |
93
|
22
|
|
|
|
|
52
|
foreach my $name (@slots) { |
94
|
33
|
|
|
|
|
74
|
add_slot_to($fullName, $name, $i); |
95
|
33
|
|
|
|
|
1179
|
} continue { $i++ } |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# widget だけ lvalue sub にするのも、一つの手ではないか? |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
package YATT::Lite::VarTypes::t_delegate; |
103
|
|
|
|
|
|
|
sub weakened_set_widget { |
104
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
105
|
2
|
|
|
|
|
4
|
$self->[VSLOT_WIDGET] = shift; |
106
|
|
|
|
|
|
|
Scalar::Util::weaken($self->[VSLOT_WIDGET]) |
107
|
2
|
50
|
|
|
|
9
|
if $self->[VSLOT_WIDGET]->{cf_folder}; |
108
|
2
|
|
|
|
|
5
|
$self; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |