line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::DBus::Pack; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
82
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use constant CAN_64 => eval { !!pack 'q' }; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
161
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
|
|
144
|
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
|
2
|
|
|
2
|
|
12
|
}; |
|
2
|
|
|
|
|
4
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
272
|
use constant STRING => { |
22
|
|
|
|
|
|
|
s => 'L/a x', |
23
|
|
|
|
|
|
|
o => 'L/a x', |
24
|
|
|
|
|
|
|
g => 'C/a x', |
25
|
2
|
|
|
2
|
|
14
|
}; |
|
2
|
|
|
|
|
4
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use constant WIDTH => { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Accommodate 32-bit Perls: |
30
|
20
|
100
|
100
|
|
|
97
|
(map { $_ => ($_ eq 'x' || $_ eq 't') ? 8 : length pack NUMERIC()->{$_} } keys %{ NUMERIC() }), |
|
2
|
|
|
|
|
17
|
|
31
|
2
|
|
|
|
|
3
|
(map { $_ => length pack STRING()->{$_} } keys %{ STRING() }), |
|
6
|
|
|
|
|
248
|
|
|
2
|
|
|
|
|
6
|
|
32
|
2
|
|
|
2
|
|
13
|
}; |
|
2
|
|
|
|
|
4
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use constant ALIGNMENT => { |
35
|
2
|
|
|
|
|
10
|
%{ WIDTH() }, |
36
|
2
|
|
|
|
|
4
|
map { $_ => length pack( substr( STRING()->{$_}, 0, 1 ) ) } keys %{ STRING() }, |
|
6
|
|
|
|
|
368
|
|
|
2
|
|
|
|
|
5
|
|
37
|
2
|
|
|
2
|
|
14
|
}; |
|
2
|
|
|
|
|
4
|
|
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
|
1618
|
100
|
|
1618
|
0
|
3266
|
if ($_[0] % $_[1]) { |
43
|
193
|
|
|
|
|
341
|
$_[0] += ($_[1] - ($_[0] % $_[1])); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub align_str { |
48
|
125
|
100
|
|
125
|
0
|
313
|
if (my $mod = length($_[0]) % $_[1]) { |
49
|
18
|
|
|
|
|
49
|
$_[0] .= "\0" x ($_[1] - $mod); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |