line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1097
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
2
|
1
|
|
|
1
|
|
23
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package DR::Msgpuck::Str; |
6
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
103
|
|
7
|
|
|
|
|
|
|
use overload |
8
|
0
|
0
|
|
0
|
|
0
|
bool => sub { ${ $_[0] } ? 1 : 0 }, |
|
0
|
|
|
|
|
0
|
|
9
|
0
|
|
|
0
|
|
0
|
int => sub { int ${ $_[0] } }, |
|
0
|
|
|
|
|
0
|
|
10
|
0
|
|
|
0
|
|
0
|
'""' => sub { ${ $_[0] } }, |
|
0
|
|
|
|
|
0
|
|
11
|
1
|
|
|
1
|
|
3
|
; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub TO_MSGPACK { |
14
|
10
|
|
|
10
|
0
|
10
|
my ($self) = @_; |
15
|
10
|
|
|
|
|
32
|
my $len = length $$self; |
16
|
10
|
100
|
|
|
|
39
|
return pack 'Ca*', 0xA0| $len, $$self if $len < 0x20; |
17
|
6
|
100
|
|
|
|
20
|
return pack 'CCa*', 0xD9, $len, $$self if $len < 0x1_00; |
18
|
4
|
100
|
|
|
|
49
|
return pack 'Cs>a*', 0xDA, $len, $$self if $len < 0x1_0000; |
19
|
2
|
50
|
|
|
|
2241
|
return pack 'Cl>a*', 0xDB, $len, $$self if $len <= 0xFFFF_FFFF; |
20
|
0
|
|
|
|
|
0
|
croak "Too long line ($len bytes) can't be packed as msgpack"; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
10
|
|
|
10
|
0
|
31543
|
my ($class, $v) = @_; |
25
|
10
|
50
|
|
|
|
24
|
croak 'usage DR::Msgpuck::Str->new($str)' unless defined $v; |
26
|
10
|
|
|
|
|
587
|
$v = "$v"; |
27
|
10
|
100
|
|
|
|
22
|
utf8::encode $v if utf8::is_utf8 $v; |
28
|
10
|
|
33
|
|
|
55
|
bless \$v => ref($class) || $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |