line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::RPC::Legacy::Procedure; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$JSON::RPC::Legacy::Procedure::VERSION = '0.90'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
10
|
2
|
|
|
2
|
|
8
|
use attributes; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
12
|
|
11
|
2
|
|
|
2
|
|
83
|
use Carp (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
990
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $Procedure = {}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
0
|
1
|
|
sub check { $Procedure->{$_[0]} ? attributes::get($_[1]) : {}; } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub FETCH_CODE_ATTRIBUTES { |
20
|
0
|
|
|
0
|
|
|
my ($pkg, $code) = @_; |
21
|
0
|
|
0
|
|
|
|
my $procedure = $Procedure->{$pkg}{$code} || { return_type => undef, argument_type => undef }; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return { |
24
|
|
|
|
|
|
|
return_type => $procedure->{return_type}, |
25
|
|
|
|
|
|
|
argument_type => $procedure->{argument_type}, |
26
|
0
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub MODIFY_CODE_ATTRIBUTES { |
31
|
0
|
|
|
0
|
|
|
my ($pkg, $code, $attr) = @_; |
32
|
0
|
|
|
|
|
|
my ($ret_type, $args); |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if ($attr =~ /^([A-Z][a-z]+)(?:\(\s*([^)]*)\s*\))?$/) { |
35
|
0
|
0
|
|
|
|
|
$ret_type = $1 if (defined $1); |
36
|
0
|
0
|
|
|
|
|
$args = $2 if (defined $2); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
unless ($ret_type =~ /^Private|Public|Arr|Obj|Bit|Bool|Num|Str|Nil|None/) { |
40
|
0
|
|
|
|
|
|
Carp::croak("Invalid type '$attr'. Specify 'Parivate' or 'Public' or One of JSONRPC Return Types."); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
0
|
|
|
|
if ($ret_type ne 'Private' and defined $args) { |
44
|
0
|
|
|
|
|
|
$Procedure->{$pkg}{$code}{argument_type} = _parse_argument_type($args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$Procedure->{$pkg}{$code}{return_type} = $ret_type; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _parse_argument_type { |
55
|
0
|
|
|
0
|
|
|
my $text = shift; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $declaration; |
58
|
|
|
|
|
|
|
my $pos; |
59
|
0
|
|
|
|
|
|
my $name; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$text =~ /^([,: a-zA-Z0-9]*)?$/; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
unless ( defined($declaration = $1) ) { |
64
|
0
|
|
|
|
|
|
Carp::croak("Invalid argument type."); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my @args = split/\s*,\s*/, $declaration; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $i = 0; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$pos = []; |
72
|
0
|
|
|
|
|
|
$name = {}; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
for my $arg (@args) { |
75
|
0
|
0
|
|
|
|
|
if ($arg =~ /([_0-9a-zA-Z]+)(?::([a-z]+))?/) { |
76
|
0
|
|
|
|
|
|
push @$pos, $1; |
77
|
0
|
|
|
|
|
|
$name->{$1} = $2; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return { |
82
|
0
|
|
|
|
|
|
position => $pos, |
83
|
|
|
|
|
|
|
names => $name, |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
__END__ |