-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathname_gen.go
executable file
·56 lines (47 loc) · 1.59 KB
/
name_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package tables
import (
"encoding/binary"
"fmt"
)
// Code generated by binarygen from name_src.go. DO NOT EDIT
func ParseName(src []byte) (Name, int, error) {
var item Name
n := 0
if L := len(src); L < 6 {
return item, 0, fmt.Errorf("reading Name: "+"EOF: expected length: 6, got %d", L)
}
_ = src[5] // early bound checking
item.version = binary.BigEndian.Uint16(src[0:])
item.count = binary.BigEndian.Uint16(src[2:])
offsetStringData := int(binary.BigEndian.Uint16(src[4:]))
n += 6
{
if offsetStringData != 0 { // ignore null offset
if L := len(src); L < offsetStringData {
return item, 0, fmt.Errorf("reading Name: "+"EOF: expected length: %d, got %d", offsetStringData, L)
}
item.stringData = src[offsetStringData:]
}
}
{
arrayLength := int(item.count)
if L := len(src); L < 6+arrayLength*12 {
return item, 0, fmt.Errorf("reading Name: "+"EOF: expected length: %d, got %d", 6+arrayLength*12, L)
}
item.nameRecords = make([]nameRecord, arrayLength) // allocation guarded by the previous check
for i := range item.nameRecords {
item.nameRecords[i].mustParse(src[6+i*12:])
}
n += arrayLength * 12
}
return item, n, nil
}
func (item *nameRecord) mustParse(src []byte) {
_ = src[11] // early bound checking
item.platformID = PlatformID(binary.BigEndian.Uint16(src[0:]))
item.encodingID = EncodingID(binary.BigEndian.Uint16(src[2:]))
item.languageID = LanguageID(binary.BigEndian.Uint16(src[4:]))
item.nameID = NameID(binary.BigEndian.Uint16(src[6:]))
item.length = binary.BigEndian.Uint16(src[8:])
item.stringOffset = binary.BigEndian.Uint16(src[10:])
}