Finnigan/GenericDataDescriptor.pm

filter: Statementstmt 84.1% 53 / 63 Branchbran 83.3% 25 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 100% 6 / 6 totaltotal 85.4% 94 / 110 CC 16 SCAR 23.9
CC
16
Cov
84%
definition
17.0
stringify
2.0
BEGIN
1.0
CRAP 10.9
« Finnigan/Scan.pm ↑ Summary Finnigan/OLE2DirectoryEntry.pm »
1 package Finnigan::GenericDataDescriptor;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings FATAL => qw( all );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = 0.0206;
6  
7 2 ▶use Finnigan;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use base 'Finnigan::Decoder';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use overload ('""' => 'stringify');
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 608 ▶sub decode {
Subroutine decode: called CC=1 SCAR=0.0
Pod documented
13 608 my ($class, $stream) = @_;
14  
15 608 my $fields = [
16 "type" => ['V', 'UInt32'],
17 "length" => ['V', 'UInt32'],
18 "label" => ['varstr', 'PascalStringWin32'],
19 ];
20  
21 608 my $self = Finnigan::Decoder->read($stream, $fields);
22  
23 608 return bless $self, $class;
24 }
25  
26 1223 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
27 1223 shift->{data}->{"type"}->{value};
28 }
29  
30 29 ▶sub length {
Subroutine length: called CC=1 SCAR=0.0
Pod documented
31 29 shift->{data}->{"length"}->{value};
32 }
33  
34 615 ▶sub label {
Subroutine label: called CC=1 SCAR=0.0
Pod documented
35 615 shift->{data}->{"label"}->{value};
36 }
37  
38 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
39 0 my $self = shift;
40 0 my $type = $self->type;
41 0 my $length = $self->length;
42 0 my $label = $self->label;
43 0 return "$label [type $type, length $length]";
44 }
45  
46 1216 ▶sub definition {
Subroutine definition: called CC=16 SCAR=28.3
Pod documented
47 1216 my ($self, $ord) = @_;
48  
49 1216 ▶ my $key = defined $ord ? "$ord|$self->{data}->{label}->{value}" : $self->{data}->{label}->{value};
Branch: 1 branch
BranchTrueFalseTotal
defined $ord ? : 608 608 1216
50 1216 my $type = $self->type;
51  
52 # a gap in the listing or a section title
53 1216 ▶ if ( $type == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 0) 80 1136 1216
54 80 return $key => undef;
55 }
56  
57 # c char (a signed byte)
58 1136 ▶ if ( $type == 0x1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 1) 2 1134 1136
59 2 return $key => ['c', 'Int8'];
60 }
61  
62 # bool (true/false)
63 1134 ▶ if ( $type == 0x2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 2) 0 1134 1134
64 0 return $key => ['C', 'UInt8 (true/false)'];
65 }
66
67 # yes/no
68 1134 ▶ if ( $type == 0x3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 3) 16 1118 1134
69 16 return $key => ['C', 'UInt8 (yes/no)'];
70 }
71  
72 # on/off
73 1118 ▶ if ( $type == 0x4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 4) 8 1110 1118
74 8 return $key => ['C', 'UInt8 (on/off)'];
75 }
76  
77 # c unsigned char
78 1110 ▶ if ( $type == 0x5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 5) 0 1110 1110
79 0 return $key => ['C', 'UInt8'];
80 }
81  
82 # c short
83 1110 ▶ if ( $type == 0x6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 6) 44 1066 1110
84 44 return $key => ['s<', 'Int16'];
85 }
86  
87 # c unsigned short
88 1066 ▶ if ( $type == 0x7 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 7) 0 1066 1066
89 0 return $key => ['v', 'UInt16'];
90 }
91  
92 # c long
93 1066 ▶ if ( $type == 0x8 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 8) 0 1066 1066
94 0 return $key => ['l<', 'Int32'];
95 }
96  
97 # c unsigned long
98 1066 ▶ if ( $type == 0x9 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 9) 18 1048 1066
99 18 return $key => ['V', 'UInt32'];
100 }
101  
102 # c float
103 1048 ▶ if ( $type == 0xA ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 10) 222 826 1048
104 222 return $key => ['f<', 'Float32'];
105 }
106  
107 # c double
108 826 ▶ if ( $type == 0xB ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 11) 804 22 826
109 804 return $key => ['d<', 'Float64'];
110 }
111  
112 # asciiz string
113 22 ▶ if ( $type == 0xC ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 12) 4 18 22
114 4 my $l = $self->length;
115 4 return $key => ['string', "ASCIIZ:$l"];
116 }
117  
118 # wide string, zero-terminated
119 18 ▶ if ( $type == 0xD ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 13) 18 0 18
120 18 my $l = $self->length * 2;
121 18 return $key => ['string', "UTF-16-LE:$l"];
122 }
123  
124 0 die "unkown data type at $self->{addr}, " . $self;
125 }
126  
127 2 1;
128 __END__
« Finnigan/Scan.pm ↑ Summary Finnigan/OLE2DirectoryEntry.pm »