line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Evo::Ee; |
2
|
1
|
|
|
1
|
|
461
|
use Evo -Class, 'Carp croak; List::Util first'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
requires 'ee_events'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# [name, cb] |
7
|
|
|
|
|
|
|
has ee_data => sub { {q => [], cur => undef} }; |
8
|
|
|
|
|
|
|
|
9
|
12
|
50
|
|
12
|
1
|
28
|
sub ee_check ($self, $name) { |
|
12
|
50
|
|
|
|
27
|
|
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
15
|
|
10
|
12
|
100
|
|
17
|
|
50
|
croak qq{Not recognized event "$name"} unless first { $_ eq $name } $self->ee_events; |
|
17
|
|
|
|
|
697
|
|
11
|
9
|
|
|
|
|
45
|
$self; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
6
|
50
|
|
6
|
1
|
37
|
sub on ($self, $name, $fn) { |
|
6
|
50
|
|
|
|
14
|
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
8
|
|
15
|
6
|
|
|
|
|
13
|
push $self->ee_check($name)->ee_data->{q}->@*, [$name, $fn]; |
16
|
5
|
|
|
|
|
23
|
$self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
4
|
50
|
|
4
|
1
|
22
|
sub ee_add ($self, $name, $fn) { |
|
4
|
50
|
|
|
|
11
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
6
|
|
20
|
4
|
|
|
|
|
9
|
push $self->ee_check($name)->ee_data->{q}->@*, my $id = [$name, $fn]; |
21
|
3
|
|
|
|
|
9
|
$id; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
1
|
1
|
6
|
sub ee_remove ($self, $id) { |
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
25
|
1
|
|
|
|
|
3
|
my $data = $self->ee_data->{q}; |
26
|
1
|
50
|
|
0
|
|
81
|
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
|
17
|
sub ee_remove_current($self) { |
|
2
|
50
|
|
|
|
5
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
4
|
|
32
|
2
|
|
|
|
|
2
|
my ($q, $cur) = @{$self->ee_data}{qw(q cur)}; |
|
2
|
|
|
|
|
7
|
|
33
|
2
|
100
|
|
1
|
|
83
|
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
|
13
|
sub emit ($self, $name, @args) { |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
3
|
|
40
|
3
|
|
|
|
|
7
|
my $data = $self->ee_data; |
41
|
2
|
|
|
|
|
5
|
do { local $data->{cur} = $_; $_->[1]->($self, @args) } |
|
2
|
|
|
|
|
5
|
|
42
|
3
|
|
|
|
|
7
|
for grep { $_->[0] eq $name } $self->ee_data->{q}->@*; |
|
2
|
|
|
|
|
8
|
|
43
|
3
|
|
|
|
|
12
|
$self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
2
|
50
|
|
2
|
1
|
1061
|
sub ee_listeners ($self, $name) { |
|
2
|
50
|
|
|
|
7
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
4
|
|
47
|
2
|
|
|
|
|
7
|
grep { $_->[0] eq $name } $self->ee_data->{q}->@*; |
|
6
|
|
|
|
|
17
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |