| 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
| |||||||||||
| 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
| |||||||||||
| 54 | 80 | return $key => undef; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | # c char (a signed byte) | ||||||||||
| 58 | 1136 | ▶ | if ( $type == 0x1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 2 | return $key => ['c', 'Int8']; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | # bool (true/false) | ||||||||||
| 63 | 1134 | ▶ | if ( $type == 0x2 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | return $key => ['C', 'UInt8 (true/false)']; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | # yes/no | ||||||||||
| 68 | 1134 | ▶ | if ( $type == 0x3 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 16 | return $key => ['C', 'UInt8 (yes/no)']; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | # on/off | ||||||||||
| 73 | 1118 | ▶ | if ( $type == 0x4 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 8 | return $key => ['C', 'UInt8 (on/off)']; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | # c unsigned char | ||||||||||
| 78 | 1110 | ▶ | if ( $type == 0x5 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 0 | return $key => ['C', 'UInt8']; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | # c short | ||||||||||
| 83 | 1110 | ▶ | if ( $type == 0x6 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 44 | return $key => ['s<', 'Int16']; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | # c unsigned short | ||||||||||
| 88 | 1066 | ▶ | if ( $type == 0x7 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | 0 | return $key => ['v', 'UInt16']; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | # c long | ||||||||||
| 93 | 1066 | ▶ | if ( $type == 0x8 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 0 | return $key => ['l<', 'Int32']; | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | # c unsigned long | ||||||||||
| 98 | 1066 | ▶ | if ( $type == 0x9 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 18 | return $key => ['V', 'UInt32']; | |||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | # c float | ||||||||||
| 103 | 1048 | ▶ | if ( $type == 0xA ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 222 | return $key => ['f<', 'Float32']; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | # c double | ||||||||||
| 108 | 826 | ▶ | if ( $type == 0xB ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | 804 | return $key => ['d<', 'Float64']; | |||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | # asciiz string | ||||||||||
| 113 | 22 | ▶ | if ( $type == 0xC ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||