line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Patro::N4; |
2
|
7
|
|
|
10
|
|
45
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
228
|
|
3
|
7
|
|
|
7
|
|
57
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
302
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Patro::N4. Proxy class for ARRAY type references |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# we must keep this namespace very clean |
8
|
7
|
|
|
7
|
|
39
|
use Carp (); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
471
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use overload |
11
|
112
|
|
|
112
|
|
15341
|
'@{}' => sub { ${$_[0]}->{array} }, |
|
112
|
|
|
|
|
571
|
|
12
|
7
|
|
|
|
|
115
|
'nomethod' => \&Patro::LeumJelly::overload_handler, |
13
|
7
|
|
|
7
|
|
39
|
; |
|
7
|
|
|
|
|
21
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# override UNIVERSAL methods |
16
|
|
|
|
|
|
|
foreach my $umethod (keys %UNIVERSAL::) { |
17
|
7
|
|
|
7
|
|
406
|
no strict 'refs'; |
|
7
|
|
|
|
|
45
|
|
|
7
|
|
|
|
|
5363
|
|
18
|
|
|
|
|
|
|
*{$umethod} = sub { |
19
|
3
|
|
|
3
|
|
5
|
my $proxy = shift; |
20
|
3
|
100
|
|
|
|
8
|
if (!CORE::ref($proxy)) { |
21
|
|
|
|
|
|
|
package UNIVERSAL; |
22
|
1
|
|
|
|
|
14
|
return &$umethod($proxy,@_); |
23
|
|
|
|
|
|
|
} |
24
|
2
|
50
|
|
|
|
6
|
my $context = defined(wantarray) ? 1 + wantarray : 0; |
25
|
|
|
|
|
|
|
return Patro::LeumJelly::proxy_request( $$proxy, |
26
|
2
|
|
|
|
|
30
|
{ id => $$proxy->{id}, topic => 'METHOD', command => $umethod, |
27
|
|
|
|
|
|
|
has_args => @_ > 0, args => [ @_ ], context => $context }, @_ ); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub AUTOLOAD { |
32
|
6
|
|
|
6
|
|
23
|
my $method = $Patro::N4::AUTOLOAD; |
33
|
6
|
|
|
|
|
32
|
$method =~ s/.*:://; |
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
|
|
21
|
my $self = shift; |
36
|
6
|
|
|
|
|
13
|
my $has_args = @_ > 0; |
37
|
6
|
|
|
|
|
11
|
my $args = [ @_ ]; |
38
|
|
|
|
|
|
|
|
39
|
6
|
50
|
|
|
|
15
|
my $context = defined(wantarray) ? 1 + wantarray : 0; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return Patro::LeumJelly::proxy_request( $$self, |
42
|
|
|
|
|
|
|
{ id => $$self->{id}, |
43
|
6
|
|
|
|
|
35
|
topic => 'METHOD', |
44
|
|
|
|
|
|
|
command => $method, |
45
|
|
|
|
|
|
|
has_args => $has_args, |
46
|
|
|
|
|
|
|
args => $args, |
47
|
|
|
|
|
|
|
context => $context, |
48
|
|
|
|
|
|
|
_autoload => 1 }, @_ ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub DESTROY { |
52
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
53
|
0
|
0
|
|
|
|
0
|
if ($$self->{_DESTROY}++) { |
54
|
0
|
|
|
|
|
0
|
return; |
55
|
|
|
|
|
|
|
} |
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
|
|
|
|
|
|
|
my $response = Patro::LeumJelly::proxy_request( |
65
|
|
|
|
|
|
|
$$self, |
66
|
|
|
|
|
|
|
{ id => $$self->{id}, |
67
|
0
|
|
|
|
|
0
|
topic => 'META', |
68
|
|
|
|
|
|
|
#command => 'disconnect' } ); |
69
|
|
|
|
|
|
|
command => 'destroy' } ); |
70
|
0
|
0
|
|
|
|
0
|
if ($response->{disconnect_ok}) { |
71
|
0
|
|
|
|
|
0
|
close $socket; |
72
|
0
|
|
|
|
|
0
|
delete $$self->{socket}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
############################################################ |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# tie class for array proxy object. Operations on the proxy object |
80
|
|
|
|
|
|
|
# are forwarded to the remote server |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub Patro::Tie::ARRAY::TIEARRAY { |
83
|
27
|
|
|
27
|
|
88
|
my ($pkg,$proxy) = @_; |
84
|
27
|
|
|
|
|
124
|
return bless { obj => $proxy, id => $proxy->{id} }, $pkg; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub Patro::Tie::ARRAY::__ { |
88
|
240
|
|
|
240
|
|
399
|
my $tied = shift; |
89
|
240
|
|
|
|
|
322
|
my $name = shift; |
90
|
240
|
|
|
|
|
296
|
my $context = shift; |
91
|
240
|
50
|
|
|
|
453
|
if (!defined($context)) { |
92
|
0
|
0
|
|
|
|
0
|
$context = defined(wantarray) ? 1 + wantarray : 0; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
return Patro::LeumJelly::proxy_request( $tied->{obj}, |
95
|
|
|
|
|
|
|
{ topic => 'ARRAY', |
96
|
|
|
|
|
|
|
command => $name, |
97
|
|
|
|
|
|
|
context => $context, |
98
|
|
|
|
|
|
|
has_args => @_ > 0, |
99
|
|
|
|
|
|
|
args => [ @_ ], |
100
|
240
|
|
|
|
|
1350
|
id => $tied->{id} }, @_ ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
174
|
|
|
174
|
|
695
|
sub Patro::Tie::ARRAY::FETCH { return shift->__('FETCH',1,@_) } |
104
|
6
|
|
|
6
|
|
22
|
sub Patro::Tie::ARRAY::STORE { return shift->__('STORE',0,@_) } |
105
|
32
|
|
|
32
|
|
70
|
sub Patro::Tie::ARRAY::FETCHSIZE { return shift->__('FETCHSIZE',1) } |
106
|
0
|
|
|
0
|
|
0
|
sub Patro::Tie::ARRAY::STORESIZE { return shift->__('STORESIZE',1,@_) } |
107
|
0
|
|
|
0
|
|
0
|
sub Patro::Tie::ARRAY::DELETE { return shift->__('DELETE',1,@_) } |
108
|
0
|
|
|
0
|
|
0
|
sub Patro::Tie::ARRAY::CLEAR { return shift->__('CLEAR',0) } |
109
|
0
|
|
|
0
|
|
0
|
sub Patro::Tie::ARRAY::EXISTS { return shift->__('EXISTS',1,@_) } |
110
|
4
|
|
|
4
|
|
13
|
sub Patro::Tie::ARRAY::PUSH { return shift->__('PUSH',1,@_) } |
111
|
3
|
|
|
3
|
|
9
|
sub Patro::Tie::ARRAY::POP { return shift->__('POP',1) } |
112
|
3
|
|
|
3
|
|
10
|
sub Patro::Tie::ARRAY::SHIFT { return shift->__('SHIFT',1) } |
113
|
2
|
|
|
2
|
|
12
|
sub Patro::Tie::ARRAY::UNSHIFT { return shift->__('UNSHIFT',1,@_) } |
114
|
|
|
|
|
|
|
sub Patro::Tie::ARRAY::SPLICE { |
115
|
16
|
|
|
16
|
|
25
|
my $tied = shift; |
116
|
16
|
100
|
|
|
|
30
|
my $off = @_ ? shift : 0; |
117
|
16
|
100
|
|
|
|
23
|
my $len = @_ ? shift : 'undef'; |
118
|
16
|
100
|
|
|
|
44
|
return $tied->__('SPLICE',wantarray ? 2:1,$off,$len,@_); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
############################################################ |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |