-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
multi_payload_enum.go
46 lines (38 loc) · 1.25 KB
/
multi_payload_enum.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
package swift
import "fmt"
type MultiPayloadEnum struct {
Address uint64
Type string
Contents []uint32
}
func (e MultiPayloadEnum) String() string {
return fmt.Sprintf("// %#x (multi-payload)\nenum %s {}", e.Address, e.Type)
}
// ref: include/swift/RemoteInspection/Records.h
type MultiPayloadEnumDescriptor struct {
TypeName int32
Contents []uint32
}
type MultiPayloadEnumSizeAndFlags uint32
func (f MultiPayloadEnumSizeAndFlags) Size() uint16 {
return uint16(f >> 16)
}
func (f MultiPayloadEnumSizeAndFlags) Flags() uint16 {
return uint16(f & 0xffff)
}
func (f MultiPayloadEnumSizeAndFlags) UsesPayloadSpareBits() bool {
return (f.Flags() & 1) != 0
}
func (f MultiPayloadEnumSizeAndFlags) String() string {
return fmt.Sprintf("size: %d, flags: %d, uses_payload_spare_bits: %t", f.Size(), f.Flags(), f.UsesPayloadSpareBits())
}
type MultiPayloadEnumPayloadSpareBitMaskByteCount uint32
func (f MultiPayloadEnumPayloadSpareBitMaskByteCount) ByteOffset() uint16 {
return uint16(f >> 16)
}
func (f MultiPayloadEnumPayloadSpareBitMaskByteCount) ByteCount() uint16 {
return uint16(f & 0xffff)
}
func (f MultiPayloadEnumPayloadSpareBitMaskByteCount) String() string {
return fmt.Sprintf("byte_offset: %d, byte_count: %d", f.ByteOffset(), f.ByteCount())
}