| 1 | 2 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package DR::Msgpuck::Str; | ||||||||||||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | use overload | ||||||||||||||||||||
| 8 | 0 | ▶ | bool => sub { ${ $_[0] } ? 1 : 0 }, | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.3
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||
| 9 | 0 | ▶ | int => sub { int ${ $_[0] } }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 10 | 0 | ▶ | '""' => sub { ${ $_[0] } }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 11 | 2 | ; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 10 | ▶ | sub TO_MSGPACK { | ||||||||||||||||||
|
Subroutine
TO_MSGPACK: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||
| 14 | 10 | my ($self) = @_; | |||||||||||||||||||
| 15 | 10 | my $len = length $$self; | |||||||||||||||||||
| 16 | 10 | ▶ | return pack 'Ca*', 0xA0| $len, $$self if $len < 0x20; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 17 | 6 | ▶ | return pack 'CCa*', 0xD9, $len, $$self if $len < 0x1_00; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | 4 | ▶ | return pack 'Cs>a*', 0xDA, $len, $$self if $len < 0x1_0000; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | 2 | ▶ | return pack 'Cl>a*', 0xDB, $len, $$self if $len <= 0xFFFF_FFFF; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | 0 | croak "Too long line ($len bytes) can't be packed as msgpack"; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 10 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||
| 24 | 10 | my ($class, $v) = @_; | |||||||||||||||||||
| 25 | 10 | ▶ | croak 'usage DR::Msgpuck::Str->new($str)' unless defined $v; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 10 | $v = "$v"; | |||||||||||||||||||
| 27 | 10 | ▶ | utf8::encode $v if utf8::is_utf8 $v; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 10 | ▶ | bless \$v => ref($class) || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 2 | 1; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | __END__ | ||||||||||||||||||||