line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Evo::Ee; |
2
|
1
|
|
|
1
|
|
618
|
use Evo -Class, 'Carp croak; List::Util first'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
requires 'ee_events'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# [name, cb] |
7
|
|
|
|
|
|
|
has ee_data => sub { {q => [], cur => undef} }; |
8
|
|
|
|
|
|
|
|
9
|
12
|
50
|
|
12
|
1
|
29
|
sub ee_check ($self, $name) { |
|
12
|
50
|
|
|
|
24
|
|
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
15
|
|
|
12
|
|
|
|
|
14
|
|
10
|
12
|
100
|
|
17
|
|
53
|
croak qq{Not recognized event "$name"} unless first { $_ eq $name } $self->ee_events; |
|
17
|
|
|
|
|
368
|
|
11
|
9
|
|
|
|
|
40
|
$self; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
6
|
50
|
|
6
|
1
|
31
|
sub on ($self, $name, $fn) { |
|
6
|
50
|
|
|
|
15
|
|
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
8
|
|
15
|
6
|
|
|
|
|
11
|
push $self->ee_check($name)->ee_data->{q}->@*, [$name, $fn]; |
16
|
5
|
|
|
|
|
20
|
$self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
4
|
50
|
|
4
|
1
|
22
|
sub ee_add ($self, $name, $fn) { |
|
4
|
50
|
|
|
|
9
|
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
6
|
|
20
|
4
|
|
|
|
|
8
|
push $self->ee_check($name)->ee_data->{q}->@*, my $id = [$name, $fn]; |
21
|
3
|
|
|
|
|
6
|
$id; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
1
|
1
|
7
|
sub ee_remove ($self, $id) { |
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
25
|
1
|
|
|
|
|
4
|
my $data = $self->ee_data->{q}; |
26
|
1
|
50
|
|
0
|
|
80
|
defined(my $index = first { $data->[$_] == $id } 0 .. $#$data) or croak "$id isn't a listener"; |
|
0
|
|
|
|
|
0
|
|
27
|
0
|
|
|
|
|
0
|
splice $data->@*, $index, 1; |
28
|
0
|
|
|
|
|
0
|
$self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
2
|
50
|
|
2
|
1
|
19
|
sub ee_remove_current($self) { |
|
2
|
50
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
3
|
|
32
|
2
|
|
|
|
|
4
|
my ($q, $cur) = @{$self->ee_data}{qw(q cur)}; |
|
2
|
|
|
|
|
8
|
|
33
|
2
|
100
|
|
1
|
|
101
|
defined(my $index = first { $q->[$_] == $cur } 0 .. $#$q) or croak "Not in the event"; |
|
1
|
|
|
|
|
4
|
|
34
|
1
|
|
|
|
|
4
|
splice $q->@*, $index, 1; |
35
|
1
|
|
|
|
|
5
|
$self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
3
|
50
|
|
3
|
1
|
14
|
sub emit ($self, $name, @args) { |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
7
|
|
40
|
3
|
|
|
|
|
8
|
my $data = $self->ee_data; |
41
|
2
|
|
|
|
|
7
|
do { local $data->{cur} = $_; $_->[1]->($self, @args) } |
|
2
|
|
|
|
|
8
|
|
42
|
3
|
|
|
|
|
10
|
for grep { $_->[0] eq $name } $self->ee_data->{q}->@*; |
|
2
|
|
|
|
|
10
|
|
43
|
3
|
|
|
|
|
17
|
$self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
2
|
50
|
|
2
|
1
|
982
|
sub ee_listeners ($self, $name) { |
|
2
|
50
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
47
|
2
|
|
|
|
|
11
|
grep { $_->[0] eq $name } $self->ee_data->{q}->@*; |
|
6
|
|
|
|
|
19
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |