line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::REPL::Client::AnyEvent; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
731
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
332
|
use Devel::REPL::Client::AnyEvent::Connection; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
657
|
use AnyEvent::Socket; |
|
1
|
|
|
|
|
10557
|
|
|
1
|
|
|
|
|
121
|
|
9
|
1
|
|
|
1
|
|
10
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
10
|
1
|
|
|
1
|
|
4
|
use Term::ReadKey; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
66
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use constant { |
13
|
1
|
|
|
|
|
261
|
EOT => "\x04", |
14
|
1
|
|
|
1
|
|
5
|
}; |
|
1
|
|
|
|
|
1
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $RESTORE_READMODE; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
END { |
19
|
|
|
|
|
|
|
ReadMode 0, \*STDIN if $RESTORE_READMODE; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
0
|
|
my ($class, %args) = @_; |
24
|
|
|
|
|
|
|
my $self = bless { |
25
|
|
|
|
|
|
|
port => $args{port}, |
26
|
|
|
|
|
|
|
path => $args{path}, |
27
|
|
|
|
|
|
|
on_connection => $args{on_connection}, |
28
|
0
|
|
|
|
|
|
tcp_guard => undef, |
29
|
|
|
|
|
|
|
}, $class; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub listen { |
35
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $weak_self = $self; |
38
|
0
|
|
|
|
|
|
weaken($weak_self); |
39
|
0
|
|
|
0
|
|
|
my $cb = sub { $weak_self->_new_connection($_[0]) }; |
|
0
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ($self->{port}) { |
|
|
0
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->{tcp_guard} = tcp_server('127.0.0.1', $self->{port}, $cb); |
42
|
|
|
|
|
|
|
} elsif ($self->{path}) { |
43
|
0
|
|
|
|
|
|
$self->{tcp_guard} = tcp_server('unix/', $self->{path}, $cb); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _new_connection { |
48
|
0
|
|
|
0
|
|
|
my ($self, $fh) = @_; |
49
|
0
|
|
|
|
|
|
my $connection = Devel::REPL::Client::AnyEvent::Connection->new(socket => $fh); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$RESTORE_READMODE = 1; |
52
|
0
|
|
|
|
|
|
ReadMode 3, \*STDIN; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->{on_connection}->($connection); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |