| 1 | package Data::Dumper::MessagePack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:GETTY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | $Data::Dumper::MessagePack::VERSION = '0.002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Dump MessagePack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use B (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Term::ANSIColor qw( color ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # Stolen from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # http://cpansearch.perl.org/src/GFUJI/Data-MessagePack-0.48/lib/Data/MessagePack/PP.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our @EXPORT = qw( ddmp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | our @EXPORT_OK = qw( mp_unpack ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=15 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | my $unpack_int64_slow; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my $unpack_uint64_slow; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | if(!eval { pack 'Q', 1 }) { # don't have quad types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # emulates quad types with Math::BigInt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # very slow but works well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $unpack_int64_slow = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | require Math::BigInt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $high = unpack_uint32( $_[0], $_[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $low = unpack_uint32( $_[0], $_[1] + 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if($high < 0xF0000000) { # positive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $high = Math::BigInt->new( $high ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $low = Math::BigInt->new( $low ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return +($high << 32 | $low)->bstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | else { # negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $high = Math::BigInt->new( ~$high ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $low = Math::BigInt->new( ~$low ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return +( -($high << 32 | $low + 1) )->bstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | $unpack_uint64_slow = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | require Math::BigInt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $high = Math::BigInt->new( unpack_uint32( $_[0], $_[1]) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $low = Math::BigInt->new( unpack_uint32( $_[0], $_[1] + 4) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return +($high << 32 | $low)->bstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | *unpack_uint16 = sub { return unpack 'n', substr( $_[0], $_[1], 2 ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | *unpack_uint32 = sub { return unpack 'N', substr( $_[0], $_[1], 4 ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # For ARM OABI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | my $bo_is_me = unpack ( 'd', "\x00\x00\xf0\x3f\x00\x00\x00\x00") == 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | my $unpack_double_oabi; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # for pack and unpack compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | if ( $] < 5.010 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $bo_is_le = ( $Config{byteorder} =~ /^1234/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($bo_is_me) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $unpack_double_oabi = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my @v = unpack( 'V2', substr( $_[0], $_[1], 8 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return unpack( 'd', pack( 'N2', @v[0,1] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | *unpack_int16 = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $v = unpack 'n', substr( $_[0], $_[1], 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | return $v ? $v - 0x10000 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | *unpack_int32 = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=10.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | ▶ | no warnings; # avoid for warning about Hexadecimal number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $v = unpack 'N', substr( $_[0], $_[1], 4 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | return $v ? $v - 0x100000000 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # In reality, since 5.9.2 '>' is introduced. but 'n!' and 'N!'? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if($bo_is_le) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | *unpack_float = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my @v = unpack( 'v2', substr( $_[0], $_[1], 4 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return unpack( 'f', pack( 'n2', @v[1,0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | *unpack_double = $unpack_double_oabi || sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my @v = unpack( 'V2', substr( $_[0], $_[1], 8 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return unpack( 'd', pack( 'N2', @v[1,0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$unpack_double_oabi || sub {
my(@v) = unpack('V2', substr($_[0], $_[1], 8));
return unpack('d', pack('N2', @v[1, 0]));
}
MC/DC0%0/2
$unpack_double_oabi || sub {
my(@v) = unpack('V2', substr($_[0], $_[1], 8));
return unpack('d', pack('N2', @v[1, 0]));
}
$unpack_double_oabi
sub {
my(@v) = unpack('V2', substr($_[0], $_[1], 8));
return unpack('d', pack('N2', @v[1, 0]));
}
Truth table0%0/3
A || B
A= $unpack_double_oabiB= sub {
my(@v) = unpack('V2', substr($_[0], $_[1], 8));
return unpack('d', pack('N2', @v[1, 0]));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | *unpack_int64 = $unpack_int64_slow || sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my @v = unpack( 'V*', substr( $_[0], $_[1], 8 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return unpack( 'q', pack( 'N2', @v[1,0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$unpack_int64_slow || sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('q', pack('N2', @v[1, 0]));
}
MC/DC0%0/2
$unpack_int64_slow || sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('q', pack('N2', @v[1, 0]));
}
$unpack_int64_slow
sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('q', pack('N2', @v[1, 0]));
}
Truth table0%0/3
A || B
A= $unpack_int64_slowB= sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('q', pack('N2', @v[1, 0]));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | *unpack_uint64 = $unpack_uint64_slow || sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my @v = unpack( 'V*', substr( $_[0], $_[1], 8 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return unpack( 'Q', pack( 'N2', @v[1,0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$unpack_uint64_slow || sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('Q', pack('N2', @v[1, 0]));
}
MC/DC0%0/2
$unpack_uint64_slow || sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('Q', pack('N2', @v[1, 0]));
}
$unpack_uint64_slow
sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('Q', pack('N2', @v[1, 0]));
}
Truth table0%0/3
A || B
A= $unpack_uint64_slowB= sub {
my(@v) = unpack('V*', substr($_[0], $_[1], 8));
return unpack('Q', pack('N2', @v[1, 0]));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | else { # big endian | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | *unpack_float = sub { return unpack( 'f', substr( $_[0], $_[1], 4 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | *unpack_double = $unpack_double_oabi || sub { return unpack( 'd', substr( $_[0], $_[1], 8 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$unpack_double_oabi || sub {
return unpack('d', substr($_[0], $_[1], 8));
}
MC/DC0%0/2
$unpack_double_oabi || sub {
return unpack('d', substr($_[0], $_[1], 8));
}
$unpack_double_oabi
sub {
return unpack('d', substr($_[0], $_[1], 8));
}
Truth table0%0/3
A || B
A= $unpack_double_oabiB= sub {
return unpack('d', substr($_[0], $_[1], 8));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | *unpack_int64 = $unpack_int64_slow || sub { unpack 'q', substr( $_[0], $_[1], 8 ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$unpack_int64_slow || sub {
unpack 'q', substr($_[0], $_[1], 8);
}
MC/DC0%0/2
$unpack_int64_slow || sub {
unpack 'q', substr($_[0], $_[1], 8);
}
$unpack_int64_slow
sub {
unpack 'q', substr($_[0], $_[1], 8);
}
Truth table0%0/3
A || B
A= $unpack_int64_slowB= sub {
unpack 'q', substr($_[0], $_[1], 8);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | *unpack_uint64 = $unpack_uint64_slow || sub { unpack 'Q', substr( $_[0], $_[1], 8 ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$unpack_uint64_slow || sub {
unpack 'Q', substr($_[0], $_[1], 8);
}
MC/DC0%0/2
$unpack_uint64_slow || sub {
unpack 'Q', substr($_[0], $_[1], 8);
}
$unpack_uint64_slow
sub {
unpack 'Q', substr($_[0], $_[1], 8);
}
Truth table0%0/3
A || B
A= $unpack_uint64_slowB= sub {
unpack 'Q', substr($_[0], $_[1], 8);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | else { # 5.10.0 or later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | ▶ | if ($bo_is_me) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $unpack_double_oabi = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $first_word = substr($_[0], $_[1], 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $second_word = substr($_[0], $_[1] + 4, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $d_bin = $second_word . $first_word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return unpack( 'd>', $d_bin ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | *unpack_float = sub { return unpack( 'f>', substr( $_[0], $_[1], 4 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | *unpack_double = $unpack_double_oabi || sub { return unpack( 'd>', substr( $_[0], $_[1], 8 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$unpack_double_oabi || sub {
return unpack('d>', substr($_[0], $_[1], 8));
}
MC/DC0%0/2
$unpack_double_oabi || sub {
return unpack('d>', substr($_[0], $_[1], 8));
}
$unpack_double_oabi
sub {
return unpack('d>', substr($_[0], $_[1], 8));
}
Truth table33%1/3
A || B
A= $unpack_double_oabiB= sub {
return unpack('d>', substr($_[0], $_[1], 8));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | *unpack_int16 = sub { return unpack( 'n!', substr( $_[0], $_[1], 2 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | *unpack_int32 = sub { return unpack( 'N!', substr( $_[0], $_[1], 4 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | *unpack_int64 = $unpack_int64_slow || sub { return unpack( 'q>', substr( $_[0], $_[1], 8 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$unpack_int64_slow || sub {
return unpack('q>', substr($_[0], $_[1], 8));
}
MC/DC0%0/2
$unpack_int64_slow || sub {
return unpack('q>', substr($_[0], $_[1], 8));
}
$unpack_int64_slow
sub {
return unpack('q>', substr($_[0], $_[1], 8));
}
Truth table33%1/3
A || B
A= $unpack_int64_slowB= sub {
return unpack('q>', substr($_[0], $_[1], 8));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | *unpack_uint64 = $unpack_uint64_slow || sub { return unpack( 'Q>', substr( $_[0], $_[1], 8 ) ); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$unpack_uint64_slow || sub {
return unpack('Q>', substr($_[0], $_[1], 8));
}
MC/DC0%0/2
$unpack_uint64_slow || sub {
return unpack('Q>', substr($_[0], $_[1], 8));
}
$unpack_uint64_slow
sub {
return unpack('Q>', substr($_[0], $_[1], 8));
}
Truth table33%1/3
A || B
A= $unpack_uint64_slowB= sub {
return unpack('Q>', substr($_[0], $_[1], 8));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # fixin package symbols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | sub _unexpected { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unexpected: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | Carp::confess("Unexpected " . sprintf(shift, @_) . " found"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # UNPACK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | our $_utf8 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | my $p; # position variables for speed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub _insufficient { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_insufficient: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | Carp::confess("Insufficient bytes (pos=$p, type=@_)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | sub mp_unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mp_unpack: called CC=2 SCAR=12.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | $p = 0; # init | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | my $data = _unpack( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if($p < length($_[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | Carp::croak("Data::Dumper::MessagePack->mp_unpack: extra bytes"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | my $T_RAW = 0x01; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | my $T_ARRAY = 0x02; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | my $T_MAP = 0x04; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | my $T_DIRECT = 0x08; # direct mapping (e.g. 0xc0 <-> nil) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | my @detailed = ( (0x00) x 256 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | my @typemap = ( (0x00) x 256 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | $detailed[$_] = 'fixarray' for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0x90 .. 0x9f | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | $detailed[0xdc] = 'array16'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | $detailed[0xdd] = 'array32'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | $detailed[$_] = 'fixmap' for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0x80 .. 0x8f | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | $detailed[0xde] = 'map16'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | $detailed[0xdf] = 'map32'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | $detailed[$_] = 'fixstr' for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0xa0 .. 0xbf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | $detailed[0xda] = 'str16'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | $detailed[0xdb] = 'str32'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | $typemap[$_] |= $T_ARRAY for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0x90 .. 0x9f, # fix array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0xdc, # array16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0xdd, # array32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | $typemap[$_] |= $T_MAP for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0x80 .. 0x8f, # fix map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0xde, # map16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0xdf, # map32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | $typemap[$_] |= $T_RAW for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0xa0 .. 0xbf, # fix raw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0xda, # raw16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0xdb, # raw32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | $detailed[0xc3] = 'true'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | $detailed[0xc2] = 'false'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | $detailed[0xc0] = 'nil'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | $detailed[$_] = 'positive fixint' for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0x00 .. 0x7f | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | $detailed[$_] = 'negative fixint' for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0xe0 .. 0xff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | my @byte2value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | foreach my $pair( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | [0xc3, true], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | [0xc2, false], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | [0xc0, undef], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 256 | (map { [ $_, $_ ] } 0x00 .. 0x7f), # positive fixnum | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 64 | (map { [ $_, $_ - 0x100 ] } 0xe0 .. 0xff), # negative fixnum | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 326 | $typemap[ $pair->[0] ] |= $T_DIRECT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 326 | $byte2value[ $pair->[0] ] = $pair->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | sub _fetch_size { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_size: called CC=5 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | my($value_ref, $byte, $x16, $x32, $x_fixbits) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | if ( $byte == $x16 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $p += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $p <= length(${$value_ref}) or _insufficient('x/16'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return CORE::unpack 'n', substr( ${$value_ref}, $p - 2, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | elsif ( $byte == $x32 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $p += 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $p <= length(${$value_ref}) or _insufficient('x/32'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return CORE::unpack 'N', substr( ${$value_ref}, $p - 4, 4 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | else { # fix raw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | return $byte & ~$x_fixbits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | sub _unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unpack: called CC=30 SCAR=59.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | my ( $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | $p < length($value) or _insufficient('header byte'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # get a header byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | my $byte = ord( substr $value, $p, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | $p++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # +/- fixnum, nil, true, false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | ▶ | return [ $detailed[$byte], $byte2value[$byte] ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | if $typemap[$byte] & $T_DIRECT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | ▶ | if ( $typemap[$byte] & $T_RAW ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $size = _fetch_size(\$value, $byte, 0xda, 0xdb, 0xa0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $s = substr( $value, $p, $size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | length($s) == $size or _insufficient('raw'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $p += $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | utf8::decode($s) if $_utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return [ $detailed[$byte], $s ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | elsif ( $typemap[$byte] & $T_ARRAY ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $size = _fetch_size(\$value, $byte, 0xdc, 0xdd, 0x90); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my @array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | push @array, _unpack( $value ) while --$size >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return [ $detailed[$byte], \@array ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | elsif ( $typemap[$byte] & $T_MAP ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | my $size = _fetch_size(\$value, $byte, 0xde, 0xdf, 0x80); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | my @map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | while(--$size >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | no warnings; # for undef key case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | my $key = _unpack( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $val = _unpack( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | push @map, $key, $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | return [ $detailed[$byte], \@map ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | elsif ( $byte == 0xcc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $p++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $p <= length($value) or _insufficient('uint8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $number = CORE::unpack( 'C', substr( $value, $p - 1, 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | return [ uint8 => $number ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | elsif ( $byte == 0xcd ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $p += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $p <= length($value) or _insufficient('uint16'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return [ uint16 => unpack_uint16( $value, $p - 2 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | elsif ( $byte == 0xce ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $p += 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $p <= length($value) or _insufficient('uint32'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return [ uint32 => unpack_uint32( $value, $p - 4 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | elsif ( $byte == 0xcf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $p += 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | $p <= length($value) or _insufficient('uint64'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | return [ uint64 => unpack_uint64( $value, $p - 8 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | elsif ( $byte == 0xd3 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $p += 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | $p <= length($value) or _insufficient('int64'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return [ int64 => unpack_int64( $value, $p - 8 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | elsif ( $byte == 0xd2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $p += 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $p <= length($value) or _insufficient('int32'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return [ int32 => unpack_int32( $value, $p - 4 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | elsif ( $byte == 0xd1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $p += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | $p <= length($value) or _insufficient('int16'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | return [ int16 => unpack_int16( $value, $p - 2 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | elsif ( $byte == 0xd0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $p++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | $p <= length($value) or _insufficient('int8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $number = CORE::unpack('c', substr( $value, $p - 1, 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return [ int8 => $number ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | elsif ( $byte == 0xcb ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $p += 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | $p <= length($value) or _insufficient('double'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return [ float64 => unpack_double( $value, $p - 8 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | elsif ( $byte == 0xca ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $p += 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | $p <= length($value) or _insufficient('float'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return [ float32 => unpack_float( $value, $p - 4 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | _unexpected("byte 0x%02x", $byte); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | our %array_types = map { $_, 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | fixarray array16 array32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 2 | our %map_types = map { $_, 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | fixmap map16 map32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | our %type_color; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2 | $type_color{$_} = "blue" for (keys %map_types, keys %array_types); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 2 | $type_color{$_} = "yellow" for qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | fixstr str16 str32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | $type_color{$_} = "red" for qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | uint8 uint16 uint32 uint64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | int8 int16 int32 int64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | float32 float64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ),"positive fixint","negative fixint"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | $type_color{$_} = "magenta" for qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | true false nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 2 | our $type_name_color = "green"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub _ddmp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ddmp: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my ( $depth, $data, $no_prespace ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $type = $data->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $value = $data->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | unless ($no_prespace) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | print " " x ($depth * 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | print color($type_name_color); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | print $type." "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | print color($type_color{$type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if ($array_types{$type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | print "(".(scalar @{$value}).") [\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | for (@{$value}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | _ddmp($depth + 1, $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | print color($type_color{$type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | print " " x ($depth * 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | print "]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } elsif ($map_types{$type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | print "(".((scalar @{$value}) / 2).") {\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my @values = @{$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | while (@values) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $key = shift @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $value = shift @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | _ddmp($depth + 1, $key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | print color($type_color{$type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | print " " x (($depth + 1) * 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | print "=> "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | _ddmp($depth + 1, $value, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | print color($type_color{$type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | print " " x ($depth * 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | print "}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } elsif ($type eq 'nil') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | print "nil"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } elsif ($type eq 'true') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | print "true"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } elsif ($type eq 'false') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | print "false"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | print $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | print "\n".color('reset'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | sub ddmp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ddmp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my ( $bytes ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $data = mp_unpack($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | _ddmp(0, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||