| 1 | package Protocol::DBus::Pack; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use constant CAN_64 => eval { !!pack 'q' }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | use constant NUMERIC => { | |||||||||||||||||||||||||||
| 9 | y => 'C', # uint8 | ||||||||||||||||||||||||||||
| 10 | b => 'L', # boolean (uint32) | ||||||||||||||||||||||||||||
| 11 | n => 's', # int16 | ||||||||||||||||||||||||||||
| 12 | q => 'S', # uint16 | ||||||||||||||||||||||||||||
| 13 | i => 'l', # int32 | ||||||||||||||||||||||||||||
| 14 | u => 'L', # uint32 | ||||||||||||||||||||||||||||
| 15 | x => 'q', # int64 | ||||||||||||||||||||||||||||
| 16 | t => 'Q', # uint64 | ||||||||||||||||||||||||||||
| 17 | d => 'd', # double float (?) | ||||||||||||||||||||||||||||
| 18 | h => 'L', # unix fd, uint32 | ||||||||||||||||||||||||||||
| 19 | 7 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 7 | use constant STRING => { | |||||||||||||||||||||||||||
| 22 | s => 'L/a x', | ||||||||||||||||||||||||||||
| 23 | o => 'L/a x', | ||||||||||||||||||||||||||||
| 24 | g => 'C/a x', | ||||||||||||||||||||||||||||
| 25 | 7 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | use constant WIDTH => { | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # Accommodate 32-bit Perls: | ||||||||||||||||||||||||||||
| 30 | 70 | ▶ | (map { $_ => ($_ eq 'x' || $_ eq 't') ? 8 : length pack NUMERIC()->{$_} } keys %{ NUMERIC() }), | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_ eq "x" or $_ eq "t"
MC/DC100%2/2
$_ eq "x" or $_ eq "t"
$_ eq "x"
$_ eq "t"
Truth table100%3/3
A or B
A= $_ eq "x"B= $_ eq "t"
| |||||||||||||||||||||||||||||
| 31 | 7 | (map { $_ => length pack STRING()->{$_} } keys %{ STRING() }), | |||||||||||||||||||||||||||
| 32 | 7 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | use constant ALIGNMENT => { | ||||||||||||||||||||||||||||
| 35 | 7 | %{ WIDTH() }, | |||||||||||||||||||||||||||
| 36 | 7 | map { $_ => length pack( substr( STRING()->{$_}, 0, 1 ) ) } keys %{ STRING() }, | |||||||||||||||||||||||||||
| 37 | 7 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Increments the 1st arg in-place to align on a boundary of the 2nd arg. | ||||||||||||||||||||||||||||
| 40 | # ex. align( 7, 8 ) will change the $_[0] to be 8. | ||||||||||||||||||||||||||||
| 41 | sub align { | ||||||||||||||||||||||||||||
| 42 | 1789 | ▶ | if ($_[0] % $_[1]) { | ||||||||||||||||||||||||||
|
Subroutine
align: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 221 | $_[0] += ($_[1] - ($_[0] % $_[1])); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub align_str { | ||||||||||||||||||||||||||||
| 48 | 207 | ▶ | if (my $mod = length($_[0]) % $_[1]) { | ||||||||||||||||||||||||||
|
Subroutine
align_str: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 31 | $_[0] .= "\0" x ($_[1] - $mod); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 7 | 1; | |||||||||||||||||||||||||||