line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
22
|
|
|
22
|
|
439
|
use 5.008; |
|
22
|
|
|
|
|
80
|
|
2
|
22
|
|
|
22
|
|
130
|
use strict; |
|
22
|
|
|
|
|
46
|
|
|
22
|
|
|
|
|
515
|
|
3
|
22
|
|
|
22
|
|
125
|
use warnings; |
|
22
|
|
|
|
|
44
|
|
|
22
|
|
|
|
|
1393
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
7
|
|
|
|
|
|
|
our $VERSION = '0.045'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Sub::HandlesVia::Mite; |
10
|
22
|
|
|
22
|
|
10015
|
extends 'Sub::HandlesVia::Toolkit'; |
|
22
|
|
|
|
|
70
|
|
|
22
|
|
|
|
|
137
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $me = shift; |
13
|
|
|
|
|
|
|
my ($target) = @_; |
14
|
89
|
|
|
89
|
0
|
265
|
|
15
|
89
|
|
|
|
|
289
|
require Moose::Util; |
16
|
|
|
|
|
|
|
my $meta = Moose::Util::find_meta($target); |
17
|
89
|
|
|
|
|
455
|
$me->meta_hack( $meta ); |
18
|
89
|
|
|
|
|
429
|
} |
19
|
89
|
|
|
|
|
1317
|
|
20
|
|
|
|
|
|
|
my ( $me, $meta ) = ( shift, @_ ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require Moose::Util::MetaRole; |
23
|
92
|
|
|
92
|
0
|
354
|
|
24
|
|
|
|
|
|
|
if ( $meta->isa('Moose::Meta::Role') ) { |
25
|
92
|
|
|
|
|
438
|
|
26
|
|
|
|
|
|
|
return Moose::Util::MetaRole::apply_metaroles( |
27
|
92
|
100
|
|
|
|
747
|
for => $meta, |
28
|
|
|
|
|
|
|
role_metaroles => { role => [ $me->package_trait, $me->role_trait ] }, |
29
|
3
|
|
|
|
|
10
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return Moose::Util::MetaRole::apply_metaroles( |
34
|
|
|
|
|
|
|
for => $meta, |
35
|
|
|
|
|
|
|
class_metaroles => { class => [ $me->package_trait ] }, |
36
|
89
|
|
|
|
|
461
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__PACKAGE__ . "::PackageTrait"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__PACKAGE__ . "::RoleTrait"; |
44
|
93
|
|
|
93
|
0
|
706
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my ($me, $target, $attrname) = (shift, @_); |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
4
|
0
|
65
|
if (ref $attrname) { |
49
|
|
|
|
|
|
|
@$attrname==1 or die; |
50
|
|
|
|
|
|
|
($attrname) = @$attrname; |
51
|
|
|
|
|
|
|
} |
52
|
104
|
|
|
104
|
0
|
504
|
|
53
|
|
|
|
|
|
|
my $meta; |
54
|
104
|
50
|
|
|
|
486
|
if (ref $target) { |
55
|
104
|
50
|
|
|
|
490
|
$meta = $target; |
56
|
104
|
|
|
|
|
329
|
$target = $meta->name; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
104
|
|
|
|
|
262
|
require Moose::Util; |
60
|
104
|
50
|
|
|
|
397
|
$meta = Moose::Util::find_meta($target); |
61
|
0
|
|
|
|
|
0
|
} |
62
|
0
|
|
|
|
|
0
|
|
63
|
|
|
|
|
|
|
my $attr = $meta->get_attribute($attrname); |
64
|
|
|
|
|
|
|
my $spec = +{%$attr}; |
65
|
104
|
|
|
|
|
765
|
|
66
|
104
|
|
|
|
|
518
|
my $captures = {}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $slot = sub { |
69
|
104
|
|
|
|
|
2241
|
my $gen = shift; |
70
|
104
|
|
|
|
|
1990
|
$meta->get_meta_instance->inline_slot_access($gen->generate_self, $attrname); |
71
|
|
|
|
|
|
|
}; |
72
|
104
|
|
|
|
|
391
|
|
73
|
|
|
|
|
|
|
my ($get, $set, $get_is_lvalue, $set_checks_isa); |
74
|
|
|
|
|
|
|
if (!$spec->{lazy} and !$spec->{traits} and !$spec->{auto_deref}) { |
75
|
1542
|
|
|
1542
|
|
2628
|
$get = $slot; |
76
|
1542
|
|
|
|
|
5299
|
++$get_is_lvalue; |
77
|
104
|
|
|
|
|
676
|
} |
78
|
|
|
|
|
|
|
elsif ($attr->has_read_method) { |
79
|
104
|
|
|
|
|
333
|
my $read_method = $attr->get_read_method; |
80
|
104
|
100
|
33
|
|
|
1224
|
$get = sub { my $self = shift->generate_self; "scalar($self\->$read_method)" }; |
|
|
100
|
|
|
|
|
|
81
|
80
|
|
|
|
|
217
|
} |
82
|
80
|
|
|
|
|
196
|
else { |
83
|
|
|
|
|
|
|
my $read_method = $attr->get_read_method_ref; |
84
|
|
|
|
|
|
|
eval { $read_method = $read_method->{body} }; # Moose docs lie! |
85
|
18
|
|
|
|
|
484
|
$captures->{'$shv_read_method'} = \$read_method; |
86
|
18
|
|
|
294
|
|
321
|
$get = sub { my $self = shift->generate_self; "scalar($self\->\$shv_read_method)" }; |
|
294
|
|
|
|
|
793
|
|
|
294
|
|
|
|
|
2068
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
6
|
|
|
|
|
77
|
if ($attr->has_write_method) { |
90
|
6
|
|
|
|
|
625
|
my $write_method = $attr->get_write_method; |
|
6
|
|
|
|
|
34
|
|
91
|
6
|
|
|
|
|
19
|
$set = sub { |
92
|
6
|
|
|
12
|
|
27
|
my ($gen, $val) = @_; |
|
12
|
|
|
|
|
36
|
|
|
12
|
|
|
|
|
75
|
|
93
|
|
|
|
|
|
|
my $self = $gen->generate_self; |
94
|
|
|
|
|
|
|
"$self\->$write_method\($val)" |
95
|
104
|
100
|
|
|
|
696
|
}; |
96
|
76
|
|
|
|
|
1260
|
++$set_checks_isa; |
97
|
|
|
|
|
|
|
} |
98
|
777
|
|
|
777
|
|
2980
|
else { |
99
|
777
|
|
|
|
|
2114
|
$captures->{'$shv_write_method'} = \( |
100
|
777
|
|
|
|
|
4406
|
$attr->can('set_value') |
101
|
76
|
|
|
|
|
1175
|
? sub { $attr->set_value(@_) } |
102
|
76
|
|
|
|
|
208
|
: sub { my ($instance, $value) = @_; $instance->meta->get_attribute($attrname)->set_value($instance, $value) } |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
$set = sub { |
105
|
|
|
|
|
|
|
my ($gen, $val) = @_; |
106
|
|
|
|
|
|
|
my $self = $gen->generate_self; |
107
|
30
|
|
|
30
|
|
249660
|
$self.'->$shv_write_method('.$val.')'; |
108
|
0
|
|
|
0
|
|
0
|
}; |
|
0
|
|
|
|
|
0
|
|
109
|
28
|
50
|
|
|
|
480
|
++$set_checks_isa; |
110
|
|
|
|
|
|
|
} |
111
|
13
|
|
|
13
|
|
78
|
|
112
|
13
|
|
|
|
|
45
|
my $default; |
113
|
13
|
|
|
|
|
79
|
if (exists $spec->{default}) { |
114
|
28
|
|
|
|
|
130
|
$default = [ default => $spec->{default} ]; |
115
|
28
|
|
|
|
|
58
|
} |
116
|
|
|
|
|
|
|
elsif (exists $spec->{builder}) { |
117
|
|
|
|
|
|
|
$default = [ builder => $spec->{builder} ]; |
118
|
104
|
|
|
|
|
276
|
} |
119
|
104
|
100
|
|
|
|
421
|
|
|
|
100
|
|
|
|
|
|
120
|
81
|
|
|
|
|
327
|
if (ref $default->[1] eq 'CODE') { |
121
|
|
|
|
|
|
|
$captures->{'$shv_default_for_reset'} = \$default->[1]; |
122
|
|
|
|
|
|
|
} |
123
|
9
|
|
|
|
|
32
|
|
124
|
|
|
|
|
|
|
require Sub::HandlesVia::CodeGenerator; |
125
|
|
|
|
|
|
|
return 'Sub::HandlesVia::CodeGenerator'->new( |
126
|
104
|
100
|
|
|
|
465
|
toolkit => $me, |
127
|
37
|
|
|
|
|
133
|
target => $target, |
128
|
|
|
|
|
|
|
attribute => $attrname, |
129
|
|
|
|
|
|
|
attribute_spec => $spec, |
130
|
104
|
|
|
|
|
13295
|
env => $captures, |
131
|
|
|
|
|
|
|
isa => Types::TypeTiny::to_TypeTiny($attr->type_constraint), |
132
|
|
|
|
|
|
|
coerce => !!$spec->{coerce}, |
133
|
|
|
|
|
|
|
generator_for_slot => $slot, |
134
|
|
|
|
|
|
|
generator_for_get => $get, |
135
|
|
|
|
|
|
|
generator_for_set => $set, |
136
|
|
|
|
|
|
|
get_is_lvalue => $get_is_lvalue, |
137
|
|
|
|
|
|
|
set_checks_isa => $set_checks_isa, |
138
|
|
|
|
|
|
|
set_strictly => !!1, |
139
|
|
|
|
|
|
|
method_installer => sub { $meta->add_method(@_) }, |
140
|
|
|
|
|
|
|
generator_for_default => sub { |
141
|
|
|
|
|
|
|
my ( $gen, $handler ) = @_ or die; |
142
|
|
|
|
|
|
|
if ( !$default and $handler ) { |
143
|
|
|
|
|
|
|
return $handler->default_for_reset->(); |
144
|
|
|
|
|
|
|
} |
145
|
1295
|
|
|
1295
|
|
5137
|
elsif ( $default->[0] eq 'builder' ) { |
146
|
|
|
|
|
|
|
return sprintf( |
147
|
15
|
50
|
|
15
|
|
60
|
'(%s)->%s', |
148
|
15
|
50
|
33
|
|
|
197
|
$gen->generate_self, |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
149
|
0
|
|
|
|
|
0
|
$default->[1], |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} |
152
|
4
|
|
|
|
|
21
|
elsif ( $default->[0] eq 'default' and ref $default->[1] eq 'CODE' ) { |
153
|
|
|
|
|
|
|
return sprintf( |
154
|
|
|
|
|
|
|
'(%s)->$shv_default_for_reset', |
155
|
|
|
|
|
|
|
$gen->generate_self, |
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
elsif ( $default->[0] eq 'default' and !defined $default->[1] ) { |
159
|
0
|
|
|
|
|
0
|
return 'undef'; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
elsif ( $default->[0] eq 'default' and !ref $default->[1] ) { |
162
|
|
|
|
|
|
|
require B; |
163
|
|
|
|
|
|
|
return B::perlstring( $default->[1] ); |
164
|
|
|
|
|
|
|
} |
165
|
0
|
|
|
|
|
0
|
return; |
166
|
|
|
|
|
|
|
}, |
167
|
|
|
|
|
|
|
); |
168
|
11
|
|
|
|
|
66
|
} |
169
|
11
|
|
|
|
|
77
|
|
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
0
|
our $AUTHORITY = 'cpan:TOBYINK'; |
172
|
|
|
|
|
|
|
our $VERSION = '0.045'; |
173
|
104
|
|
|
|
|
4606
|
|
174
|
|
|
|
|
|
|
use Moose::Role; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
'Sub::HandlesVia::Toolkit::Moose', |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
around add_attribute => sub { |
180
|
|
|
|
|
|
|
my ($next, $self, @args) = (shift, shift, @_); |
181
|
22
|
|
|
22
|
|
35273
|
my ($spec, $attrobj, $attrname); |
|
22
|
|
|
|
|
92430
|
|
|
22
|
|
|
|
|
123
|
|
182
|
|
|
|
|
|
|
if (@args == 1) { |
183
|
|
|
|
|
|
|
$spec = $attrobj = $_[0]; |
184
|
213
|
|
|
213
|
|
1353
|
$attrname = $attrobj->name; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
elsif (@args == 2) { |
187
|
|
|
|
|
|
|
($attrname, $spec) = @args; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
else { |
190
|
|
|
|
|
|
|
my %spec; |
191
|
|
|
|
|
|
|
($attrname, %spec) = @args; |
192
|
|
|
|
|
|
|
$spec = \%spec; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
( my $real_attrname = $attrname ) =~ s/^[+]//; |
195
|
|
|
|
|
|
|
$spec->{definition_context}{shv} = $self->_shv_toolkit->clean_spec($self->name, $real_attrname, $spec) |
196
|
|
|
|
|
|
|
unless $spec->{definition_context}{shv}; |
197
|
|
|
|
|
|
|
my $attr = $self->$next($attrobj ? $attrobj : ($attrname, %$spec)); |
198
|
|
|
|
|
|
|
if ($spec->{definition_context}{shv} and $self->isa('Moose::Meta::Class')) { |
199
|
|
|
|
|
|
|
$self->_shv_toolkit->install_delegations(+{ |
200
|
|
|
|
|
|
|
%{ $spec->{definition_context}{shv} }, |
201
|
|
|
|
|
|
|
target => $self->name, |
202
|
|
|
|
|
|
|
}); |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
return $attr; |
205
|
|
|
|
|
|
|
}; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
209
|
|
|
|
|
|
|
our $VERSION = '0.045'; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
use Moose::Role; |
212
|
|
|
|
|
|
|
requires '_shv_toolkit'; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
around apply => sub { |
215
|
|
|
|
|
|
|
my ($next, $self, $other, %args) = (shift, shift, @_); |
216
|
|
|
|
|
|
|
$other = $self->_shv_toolkit->meta_hack( $other ); |
217
|
|
|
|
|
|
|
$self->$next( $other, %args ); |
218
|
|
|
|
|
|
|
}; |
219
|
|
|
|
|
|
|
|
220
|
22
|
|
|
22
|
|
139689
|
around composition_class_roles => sub { |
|
22
|
|
|
|
|
60
|
|
|
22
|
|
|
|
|
106
|
|
221
|
|
|
|
|
|
|
my ( $next, $self ) = ( shift, shift ); |
222
|
|
|
|
|
|
|
my @return = $self->$next( @_ ); |
223
|
|
|
|
|
|
|
return ( |
224
|
|
|
|
|
|
|
@return, |
225
|
|
|
|
|
|
|
$self->_shv_toolkit->package_trait, |
226
|
|
|
|
|
|
|
$self->_shv_toolkit->role_trait, |
227
|
|
|
|
|
|
|
); |
228
|
|
|
|
|
|
|
}; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
1; |