line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::RPC::Simple; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
184320
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
112
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use Scalar::Util qw(blessed refaddr); |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
427
|
|
7
|
3
|
|
|
3
|
|
17
|
use Carp qw(croak); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1681
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $ClientClass = "JSON::RPC::Simple::Client"; |
12
|
|
|
|
|
|
|
sub connect { |
13
|
2
|
|
|
2
|
1
|
884
|
my $pkg = shift; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
17
|
require JSON::RPC::Simple::Client; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
21
|
my $self = $ClientClass->new(@_); |
18
|
2
|
|
|
|
|
11
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub dispatch_to { |
22
|
1
|
|
|
1
|
0
|
11
|
my $pkg = shift; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
7
|
require JSON::RPC::Simple::Dispatcher; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
10
|
my $self = JSON::RPC::Simple::Dispatcher->new(); |
27
|
1
|
|
|
|
|
6
|
return $self->dispatch_to(@_); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
my %method_attributes; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub fetch_method_arguments { |
34
|
5
|
|
|
5
|
0
|
9
|
my ($pkg, $code) = @_; |
35
|
|
|
|
|
|
|
|
36
|
5
|
50
|
|
|
|
31
|
return unless exists $method_attributes{refaddr $code}; |
37
|
5
|
|
|
|
|
26
|
return $method_attributes{refaddr $code}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $method_attr_re = qr{ |
41
|
|
|
|
|
|
|
^ |
42
|
|
|
|
|
|
|
JSONRpcMethod |
43
|
|
|
|
|
|
|
(?:\(\)|\( |
44
|
|
|
|
|
|
|
\s* |
45
|
|
|
|
|
|
|
(\w+ (\s*,\s* \w+)*)? |
46
|
|
|
|
|
|
|
\s* |
47
|
|
|
|
|
|
|
\))? |
48
|
|
|
|
|
|
|
}sx; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub MODIFY_CODE_ATTRIBUTES { |
51
|
4
|
|
|
4
|
|
2481
|
my ($class, $code, @attributes) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Check if this contains a JSONRpcMethod attribute |
54
|
4
|
|
|
|
|
7
|
my @bad; |
55
|
4
|
|
|
|
|
5
|
for my $attribute (@attributes) { |
56
|
4
|
50
|
|
|
|
33
|
if ($attribute =~ $method_attr_re) { |
57
|
4
|
|
100
|
|
|
33
|
my @attrs = split /\s*,\s*/, ($1 || ""); |
58
|
4
|
|
|
|
|
23
|
$method_attributes{refaddr $code} = \@attrs; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
0
|
|
|
|
|
0
|
push @bad, $attribute; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
4
|
|
|
|
|
16
|
return @bad; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
__END__ |