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