line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Patro::N2; |
2
|
3
|
|
|
3
|
|
27
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
128
|
|
3
|
3
|
|
|
3
|
|
22
|
use warnings; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
158
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Patro::N2. Proxy class for SCALAR type references |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# we must keep this namespace very clean |
8
|
3
|
|
|
3
|
|
17
|
use Carp (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
299
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use overload |
11
|
15
|
|
|
15
|
|
113
|
'${}' => sub { $_[0]->{scalar} }, |
12
|
3
|
|
|
|
|
76
|
'nomethod' => \&Patro::LeumJelly::overload_handler, |
13
|
|
|
|
|
|
|
'@{}' => \&Patro::LeumJelly::array_deref_handler, |
14
|
3
|
|
|
3
|
|
22
|
; |
|
3
|
|
|
|
|
4
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# override UNIVERSAL methods |
17
|
|
|
|
|
|
|
foreach my $umethod (keys %UNIVERSAL::) { |
18
|
3
|
|
|
3
|
|
176
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1736
|
|
19
|
|
|
|
|
|
|
*{$umethod} = sub { |
20
|
4
|
|
|
4
|
|
725
|
my $proxy = shift; |
21
|
4
|
100
|
|
|
|
13
|
if (!CORE::ref($proxy)) { |
22
|
|
|
|
|
|
|
package UNIVERSAL; |
23
|
1
|
|
|
|
|
9
|
return &$umethod($proxy,@_); |
24
|
|
|
|
|
|
|
} |
25
|
3
|
50
|
|
|
|
11
|
my $context = defined(wantarray) ? 1 + wantarray : 0; |
26
|
|
|
|
|
|
|
return Patro::LeumJelly::proxy_request( $proxy, |
27
|
3
|
|
|
|
|
42
|
{ id => $proxy->{id}, topic => 'METHOD', command => $umethod, |
28
|
|
|
|
|
|
|
has_args => @_ > 0, args => [ @_ ], context => $context }, @_ ); |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub AUTOLOAD { |
33
|
2
|
|
|
2
|
|
5
|
my $method = $Patro::N2::AUTOLOAD; |
34
|
2
|
|
|
|
|
12
|
$method =~ s/.*:://; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
3
|
my $self = shift; |
37
|
2
|
|
|
|
|
4
|
my $has_args = @_ > 0; |
38
|
2
|
|
|
|
|
4
|
my $args = [ @_ ]; |
39
|
|
|
|
|
|
|
|
40
|
2
|
50
|
|
|
|
7
|
my $context = defined(wantarray) ? 1 + wantarray : 0; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
return Patro::LeumJelly::proxy_request( $self, |
43
|
|
|
|
|
|
|
{ id => $self->{id}, |
44
|
2
|
|
|
|
|
17
|
topic => 'METHOD', |
45
|
|
|
|
|
|
|
command => $method, |
46
|
|
|
|
|
|
|
has_args => $has_args, |
47
|
|
|
|
|
|
|
args => $args, |
48
|
|
|
|
|
|
|
context => $context, |
49
|
|
|
|
|
|
|
_autoload => 1 }, @_ ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub DESTROY { |
53
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
54
|
0
|
0
|
|
|
|
0
|
return if $self->{_DESTROY}++; |
55
|
0
|
|
|
|
|
0
|
my $socket = $self->{socket}; |
56
|
0
|
0
|
|
|
|
0
|
if ($socket) { |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# XXX - shouldn't disconnect on every object destruction, |
59
|
|
|
|
|
|
|
# only when all of the wrapped objects associated with a |
60
|
|
|
|
|
|
|
# client have been destroyed, or during global |
61
|
|
|
|
|
|
|
# destruction |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Patro::LeumJelly::proxy_request( $self, |
64
|
|
|
|
|
|
|
{ id => $self->{id}, |
65
|
0
|
|
|
|
|
0
|
topic => 'META', |
66
|
|
|
|
|
|
|
command => 'disconnect' } ); |
67
|
0
|
|
|
|
|
0
|
close $socket; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# tie class for proxy object. Operations on the proxy object |
72
|
|
|
|
|
|
|
# are forwarded to the remote server |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub Patro::Tie::SCALAR::TIESCALAR { |
75
|
3
|
|
|
3
|
|
10
|
my ($pkg,$proxy) = @_; |
76
|
3
|
|
|
|
|
22
|
return bless { obj => $proxy, id => $proxy->{id} }, $pkg; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub Patro::Tie::SCALAR::__ { |
80
|
18
|
|
|
18
|
|
31
|
my $tied = shift; |
81
|
18
|
|
|
|
|
35
|
my $name = shift; |
82
|
18
|
|
|
|
|
30
|
my $context = shift; |
83
|
18
|
50
|
|
|
|
48
|
if (!defined($context)) { |
84
|
0
|
0
|
|
|
|
0
|
$context = defined(wantarray) ? 1 + wantarray : 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
return Patro::LeumJelly::proxy_request( $tied->{obj}, |
87
|
|
|
|
|
|
|
{ topic => 'SCALAR', |
88
|
|
|
|
|
|
|
command => $name, |
89
|
|
|
|
|
|
|
context => $context, |
90
|
|
|
|
|
|
|
has_args => @_ > 0, |
91
|
|
|
|
|
|
|
args => [ @_ ], |
92
|
18
|
|
|
|
|
175
|
id => $tied->{id} }, @_ ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
12
|
|
|
12
|
|
207
|
sub Patro::Tie::SCALAR::FETCH { return shift->__('FETCH',1) } |
96
|
6
|
|
|
6
|
|
22
|
sub Patro::Tie::SCALAR::STORE { return shift->__('STORE',0,@_) } |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |