line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rope::Type; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4198
|
use Types::Standard; |
|
1
|
|
|
|
|
99829
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my (%PRO); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
|
|
|
|
|
|
%PRO = ( |
9
|
|
|
|
|
|
|
keyword => sub { |
10
|
9
|
|
|
|
|
17
|
my ($caller, $method, $cb) = @_; |
11
|
1
|
|
|
1
|
|
633
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
75
|
|
12
|
9
|
|
|
|
|
10
|
*{"${caller}::${method}"} = $cb; |
|
9
|
|
|
|
|
1848
|
|
13
|
|
|
|
|
|
|
}, |
14
|
1
|
|
|
1
|
|
218
|
type_map => { |
15
|
|
|
|
|
|
|
int => 'Int', |
16
|
|
|
|
|
|
|
bool => 'Bool', |
17
|
|
|
|
|
|
|
str => 'Str', |
18
|
|
|
|
|
|
|
hash => 'HashRef', |
19
|
|
|
|
|
|
|
array => 'ArrayRef', |
20
|
|
|
|
|
|
|
scalar => 'ScalarRef', |
21
|
|
|
|
|
|
|
code => 'CodeRef', |
22
|
|
|
|
|
|
|
file => 'FileHandle', |
23
|
|
|
|
|
|
|
obj => 'Object' |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub import { |
29
|
1
|
|
|
1
|
|
15
|
my ($caller, $pkg, @types) = (scalar caller, @_); |
30
|
|
|
|
|
|
|
|
31
|
1
|
50
|
|
|
|
5
|
@types = keys %{$PRO{type_map}} unless scalar @types; |
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
3
|
for (@types) { |
34
|
9
|
|
|
|
|
16
|
my $type = &{"Types::Standard::$PRO{type_map}{$_}"}; |
|
9
|
|
|
|
|
31
|
|
35
|
|
|
|
|
|
|
$PRO{keyword}($caller, $_, sub { |
36
|
8
|
|
|
8
|
|
116
|
my (@params) = @_; |
37
|
8
|
|
|
|
|
13
|
my $count = scalar @params; |
38
|
8
|
100
|
|
|
|
25
|
return $type unless $count; |
39
|
6
|
100
|
|
|
|
13
|
if ($count <= 2) { |
40
|
5
|
100
|
|
|
|
18
|
$caller->property($params[0], |
41
|
|
|
|
|
|
|
type => $type, |
42
|
|
|
|
|
|
|
enumerable => 1, |
43
|
|
|
|
|
|
|
writeable => 1, |
44
|
|
|
|
|
|
|
(defined $params[1] ? (value => $params[1]) : ()), |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} else { |
47
|
1
|
|
|
|
|
5
|
my $name = shift @params; |
48
|
1
|
|
|
|
|
3
|
$caller->property($name, @params, type => $type); |
49
|
|
|
|
|
|
|
} |
50
|
6
|
|
|
|
|
13
|
return; |
51
|
9
|
|
|
|
|
61
|
}); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |