line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::NativeTraits::MethodProvider::Counter; |
2
|
4
|
|
|
24
|
|
2994
|
use Mouse; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
27
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
extends qw(MouseX::NativeTraits::MethodProvider); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub generate_reset { |
7
|
7
|
|
|
27
|
1
|
121
|
my($self) = @_; |
8
|
7
|
|
|
|
|
18
|
my $attr = $self->attr; |
9
|
7
|
|
|
|
|
24
|
my $writer = $self->writer; |
10
|
7
|
|
|
|
|
33
|
my $builder; |
11
|
|
|
|
|
|
|
my $default; |
12
|
|
|
|
|
|
|
|
13
|
7
|
50
|
|
|
|
31
|
if($attr->has_builder){ |
14
|
0
|
|
|
|
|
0
|
$builder = $attr->builder; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
7
|
|
|
|
|
29
|
$default = $attr->default; |
18
|
7
|
50
|
|
|
|
23
|
if(ref $default){ |
19
|
0
|
|
|
|
|
0
|
$builder = $default; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
7
|
50
|
|
|
|
16
|
if(ref $builder){ |
24
|
|
|
|
|
|
|
return sub { |
25
|
0
|
|
|
20
|
|
0
|
my($instance) = @_; |
26
|
0
|
0
|
|
|
|
0
|
if(@_ != 1) { |
27
|
0
|
|
|
|
|
0
|
$self->argument_error('reset', 1, 1, scalar @_); |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
0
|
$writer->($instance, $instance->$builder()); |
30
|
0
|
|
|
|
|
0
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else{ |
33
|
|
|
|
|
|
|
return sub { |
34
|
20
|
|
|
20
|
|
13510
|
my($instance) = @_; |
|
|
|
|
144
|
|
|
|
|
|
|
|
94
|
|
|
|
35
|
20
|
100
|
|
|
|
74
|
if(@_ != 1) { |
36
|
10
|
|
|
|
|
52
|
$self->argument_error('reset', 1, 1, scalar @_); |
37
|
|
|
|
|
|
|
} |
38
|
10
|
|
|
|
|
68
|
$writer->($instance, $default); |
39
|
7
|
|
|
|
|
52
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub generate_set{ |
44
|
10
|
|
|
10
|
1
|
157
|
my($self) = @_; |
45
|
10
|
|
|
|
|
26
|
my $writer = $self->writer; |
46
|
|
|
|
|
|
|
return sub { |
47
|
30
|
100
|
|
30
|
|
12813
|
if(@_ != 2) { |
48
|
10
|
|
|
|
|
57
|
$self->argument_error('set', 2, 2, scalar @_); |
49
|
|
|
|
|
|
|
} |
50
|
20
|
|
|
|
|
138
|
$writer->( $_[0], $_[1] ) |
51
|
10
|
|
|
|
|
50
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub generate_inc { |
55
|
13
|
|
|
43
|
1
|
226
|
my($self) = @_; |
56
|
|
|
|
|
|
|
|
57
|
13
|
|
|
|
|
71
|
my $reader = $self->reader; |
58
|
13
|
|
|
|
|
219
|
my $writer = $self->writer; |
59
|
13
|
|
|
|
|
175
|
my $constraint = $self->attr->type_constraint; |
60
|
13
|
|
|
|
|
41
|
my $name = $self->attr->name; |
61
|
|
|
|
|
|
|
|
62
|
13
|
|
100
|
|
|
156
|
my $optimized_inc = ( $constraint->name eq 'Int' |
63
|
|
|
|
|
|
|
&& !$self->attr->trigger ); |
64
|
|
|
|
|
|
|
return sub { |
65
|
144
|
|
|
174
|
|
58517
|
my($instance, $value) = @_; |
|
|
|
|
94
|
|
|
|
|
|
|
|
42
|
|
|
|
66
|
144
|
100
|
|
|
|
341
|
if(@_ == 1){ |
|
|
100
|
|
|
|
|
|
67
|
114
|
100
|
|
|
|
182
|
if($optimized_inc) { |
68
|
60
|
|
|
|
|
207
|
return ++$instance->{$name}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
54
|
|
|
|
|
71
|
$value = 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif(@_ == 2){ |
75
|
20
|
|
|
|
|
95
|
$constraint->assert_valid($value); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
10
|
|
|
|
|
70
|
$self->argument_error('inc', 1, 2, scalar @_); |
79
|
|
|
|
|
|
|
} |
80
|
74
|
|
|
|
|
588
|
$instance->$writer($instance->$reader() + $value); |
81
|
13
|
|
|
|
|
218
|
}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub generate_dec { |
85
|
13
|
|
|
179
|
1
|
221
|
my($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
13
|
|
|
|
|
48
|
my $reader = $self->reader; |
88
|
13
|
|
|
|
|
106
|
my $writer = $self->writer; |
89
|
13
|
|
|
|
|
110
|
my $constraint = $self->attr->type_constraint; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
return sub { |
92
|
50
|
|
|
216
|
|
27652
|
my($instance, $value) = @_; |
|
|
|
|
42
|
|
|
|
93
|
50
|
100
|
|
|
|
334
|
if(@_ == 1){ |
|
|
100
|
|
|
|
|
|
94
|
20
|
|
|
|
|
27
|
$value = 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
elsif(@_ == 2){ |
97
|
20
|
|
|
|
|
69
|
$constraint->assert_valid($value); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
else { |
100
|
10
|
|
|
|
|
46
|
$self->argument_error('dec', 1, 2, scalar @_); |
101
|
|
|
|
|
|
|
} |
102
|
40
|
|
|
|
|
424
|
$writer->($instance, $reader->($instance) - $value); |
103
|
13
|
|
|
|
|
125
|
}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
4
|
|
|
24
|
|
4574
|
no Mouse; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
25
|
|
107
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |