| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| // |
| // Code generated by go generate; DO NOT EDIT. |
| |
| package inspect |
| |
| import ( |
| "fmt" |
| "math" |
| "unsafe" |
| ) |
| |
| // The BlockOrder type represents the order of an allocation returned by the buddy allocator. |
| type BlockOrder uint64 |
| |
| const ( |
| // Order0 is a constant representing allocations of order 0. |
| Order0 = BlockOrder(iota) |
| |
| // Order1 is a constant representing allocations of order 1. |
| Order1 |
| |
| // Order2 is a constant representing allocations of order 2. |
| Order2 |
| |
| // Order3 is a constant representing allocations of order 3. |
| Order3 |
| |
| // Order4 is a constant representing allocations of order 4. |
| Order4 |
| |
| // Order5 is a constant representing allocations of order 5. |
| Order5 |
| |
| // Order6 is a constant representing allocations of order 6. |
| Order6 |
| |
| // Order7 is a constant representing allocations of order 7. |
| Order7 |
| ) |
| |
| // nOrders contains the number of allocation orders. |
| const nOrders = uint(8) |
| |
| var orderSize = []BlockOrder{16, 32, 64, 128, 256, 512, 1024, 2048} |
| |
| // Size returns the usable size of an allocation for the given order. |
| func (o BlockOrder) Size() uint64 { |
| return uint64(orderSize[o]) |
| } |
| |
| func (o BlockOrder) String() string { |
| switch o { |
| case Order0: |
| return "0 [16 bytes]" |
| |
| case Order1: |
| return "1 [32 bytes]" |
| |
| case Order2: |
| return "2 [64 bytes]" |
| |
| case Order3: |
| return "3 [128 bytes]" |
| |
| case Order4: |
| return "4 [256 bytes]" |
| |
| case Order5: |
| return "5 [512 bytes]" |
| |
| case Order6: |
| return "6 [1024 bytes]" |
| |
| case Order7: |
| return "7 [2048 bytes]" |
| } |
| |
| return "INVALID" |
| } |
| |
| // The BlockType type represents the type of a block returned by the buddy allocator. |
| type BlockType uint64 |
| |
| const ( |
| // FreeBlockType is the type value for blocks of type FreeBlock. |
| FreeBlockType = BlockType(iota) |
| |
| // ReservedBlockType is the type value for blocks of type ReservedBlock. |
| ReservedBlockType |
| |
| // HeaderBlockType is the type value for blocks of type HeaderBlock. |
| HeaderBlockType |
| |
| // NodeValueBlockType is the type value for blocks of type NodeValueBlock. |
| NodeValueBlockType |
| |
| // IntValueBlockType is the type value for blocks of type IntValueBlock. |
| IntValueBlockType |
| |
| // UintValueBlockType is the type value for blocks of type UintValueBlock. |
| UintValueBlockType |
| |
| // DoubleValueBlockType is the type value for blocks of type DoubleValueBlock. |
| DoubleValueBlockType |
| |
| // PropertyBlockType is the type value for blocks of type PropertyBlock. |
| PropertyBlockType |
| |
| // ExtentBlockType is the type value for blocks of type ExtentBlock. |
| ExtentBlockType |
| |
| // NameBlockType is the type value for blocks of type NameBlock. |
| NameBlockType |
| |
| // TombstoneBlockType is the type value for blocks of type TombstoneBlock. |
| TombstoneBlockType |
| |
| // ArrayBlockType is the type value for blocks of type ArrayBlock. |
| ArrayBlockType |
| |
| // LinkBlockType is the type value for blocks of type LinkBlock. |
| LinkBlockType |
| ) |
| |
| func (t BlockType) String() string { |
| switch t { |
| case FreeBlockType: |
| return "FreeBlockType" |
| |
| case ReservedBlockType: |
| return "ReservedBlockType" |
| |
| case HeaderBlockType: |
| return "HeaderBlockType" |
| |
| case NodeValueBlockType: |
| return "NodeValueBlockType" |
| |
| case IntValueBlockType: |
| return "IntValueBlockType" |
| |
| case UintValueBlockType: |
| return "UintValueBlockType" |
| |
| case DoubleValueBlockType: |
| return "DoubleValueBlockType" |
| |
| case PropertyBlockType: |
| return "PropertyBlockType" |
| |
| case ExtentBlockType: |
| return "ExtentBlockType" |
| |
| case NameBlockType: |
| return "NameBlockType" |
| |
| case TombstoneBlockType: |
| return "TombstoneBlockType" |
| |
| case ArrayBlockType: |
| return "ArrayBlockType" |
| |
| case LinkBlockType: |
| return "LinkBlockType" |
| } |
| |
| return "INVALID" |
| } |
| |
| // Block is an opaque type representing any region returned by the buddy allocator. |
| type Block struct { |
| header uint64 |
| payload uint64 |
| } |
| |
| // AsBlock converts the Block to a Block. |
| func (b *Block) AsBlock() *Block { |
| return (*Block)(unsafe.Pointer(b)) |
| } |
| |
| // AsFreeBlock converts the Block to a FreeBlock. |
| func (b *Block) AsFreeBlock() *FreeBlock { |
| return (*FreeBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsReservedBlock converts the Block to a ReservedBlock. |
| func (b *Block) AsReservedBlock() *ReservedBlock { |
| return (*ReservedBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsHeaderBlock converts the Block to a HeaderBlock. |
| func (b *Block) AsHeaderBlock() *HeaderBlock { |
| return (*HeaderBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsNodeValueBlock converts the Block to a NodeValueBlock. |
| func (b *Block) AsNodeValueBlock() *NodeValueBlock { |
| return (*NodeValueBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsIntValueBlock converts the Block to a IntValueBlock. |
| func (b *Block) AsIntValueBlock() *IntValueBlock { |
| return (*IntValueBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsUintValueBlock converts the Block to a UintValueBlock. |
| func (b *Block) AsUintValueBlock() *UintValueBlock { |
| return (*UintValueBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsDoubleValueBlock converts the Block to a DoubleValueBlock. |
| func (b *Block) AsDoubleValueBlock() *DoubleValueBlock { |
| return (*DoubleValueBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsPropertyBlock converts the Block to a PropertyBlock. |
| func (b *Block) AsPropertyBlock() *PropertyBlock { |
| return (*PropertyBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsExtentBlock converts the Block to a ExtentBlock. |
| func (b *Block) AsExtentBlock() *ExtentBlock { |
| return (*ExtentBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsNameBlock converts the Block to a NameBlock. |
| func (b *Block) AsNameBlock() *NameBlock { |
| return (*NameBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsTombstoneBlock converts the Block to a TombstoneBlock. |
| func (b *Block) AsTombstoneBlock() *TombstoneBlock { |
| return (*TombstoneBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsArrayBlock converts the Block to a ArrayBlock. |
| func (b *Block) AsArrayBlock() *ArrayBlock { |
| return (*ArrayBlock)(unsafe.Pointer(b)) |
| } |
| |
| // AsLinkBlock converts the Block to a LinkBlock. |
| func (b *Block) AsLinkBlock() *LinkBlock { |
| return (*LinkBlock)(unsafe.Pointer(b)) |
| } |
| |
| func (b *Block) zeroPayload(size uint64, off uintptr) { |
| p := uintptr(unsafe.Pointer(&b.payload)) + off |
| for i := uint64(0); i < size; i++ { |
| *(*byte)(unsafe.Pointer(p + uintptr(i))) = 0 |
| } |
| } |
| |
| func (b *Block) Free(order BlockOrder, nextFree BlockIndex) { |
| b.header = (uint64(order) & 0xf) | ((uint64(nextFree) & 0xfffffff) << 8) |
| } |
| |
| func (b Block) String() string { |
| return fmt.Sprintf("Header: %x, Payload: %x, Type: %s, Order: %s\n", b.header, b.payload, b.GetType(), b.GetOrder()) |
| } |
| |
| // SetHeader sets the header fields for Block. |
| func (b *Block) SetHeader(Order BlockOrder, Type BlockType) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240)) |
| } |
| |
| // GetOrder returns the Order field in the Block. |
| func (b *Block) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the Block. |
| func (b *Block) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the Block. |
| func (b *Block) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the Block. |
| func (b *Block) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // The FreeBlock type represents a block of type FreeBlock. |
| type FreeBlock Block |
| |
| // SetHeader sets the header fields for FreeBlock. |
| func (b *FreeBlock) SetHeader(Order BlockOrder, Type BlockType, NextFree BlockIndex) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(NextFree) << 8) & 68719476480)) |
| } |
| |
| // GetOrder returns the Order field in the FreeBlock. |
| func (b *FreeBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the FreeBlock. |
| func (b *FreeBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the FreeBlock. |
| func (b *FreeBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the FreeBlock. |
| func (b *FreeBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetNextFree returns the NextFree field in the FreeBlock. |
| func (b *FreeBlock) GetNextFree() BlockIndex { |
| return BlockIndex((b.header & 68719476480) >> 8) |
| } |
| |
| // SetNextFree sets the NextFree field in the FreeBlock. |
| func (b *FreeBlock) SetNextFree(v BlockIndex) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // The ReservedBlock type represents a block of type ReservedBlock. |
| type ReservedBlock Block |
| |
| // SetHeader sets the header fields for ReservedBlock. |
| func (b *ReservedBlock) SetHeader(Order BlockOrder, Type BlockType) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240)) |
| } |
| |
| // GetOrder returns the Order field in the ReservedBlock. |
| func (b *ReservedBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the ReservedBlock. |
| func (b *ReservedBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the ReservedBlock. |
| func (b *ReservedBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the ReservedBlock. |
| func (b *ReservedBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // The HeaderBlock type represents a block of type HeaderBlock. |
| type HeaderBlock Block |
| |
| // SetHeader sets the header fields for HeaderBlock. |
| func (b *HeaderBlock) SetHeader(Order BlockOrder, Type BlockType, Version uint, Magic uint) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(Version) << 8) & 4294967040) | ((uint64(Magic) << 32) & 18446744069414584320)) |
| } |
| |
| // GetOrder returns the Order field in the HeaderBlock. |
| func (b *HeaderBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the HeaderBlock. |
| func (b *HeaderBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the HeaderBlock. |
| func (b *HeaderBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the HeaderBlock. |
| func (b *HeaderBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetVersion returns the Version field in the HeaderBlock. |
| func (b *HeaderBlock) GetVersion() uint { |
| return uint((b.header & 4294967040) >> 8) |
| } |
| |
| // SetVersion sets the Version field in the HeaderBlock. |
| func (b *HeaderBlock) SetVersion(v uint) { |
| mask := uint64(4294967040) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // GetMagic returns the Magic field in the HeaderBlock. |
| func (b *HeaderBlock) GetMagic() uint { |
| return uint((b.header & 18446744069414584320) >> 32) |
| } |
| |
| // SetMagic sets the Magic field in the HeaderBlock. |
| func (b *HeaderBlock) SetMagic(v uint) { |
| mask := uint64(18446744069414584320) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 32) & mask) |
| } |
| |
| // The NodeValueBlock type represents a block of type NodeValueBlock. |
| type NodeValueBlock Block |
| |
| // SetHeader sets the header fields for NodeValueBlock. |
| func (b *NodeValueBlock) SetHeader(Order BlockOrder, Type BlockType, ParentIndex BlockIndex, NameIndex BlockIndex) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(ParentIndex) << 8) & 68719476480) | ((uint64(NameIndex) << 36) & 18446744004990074880)) |
| } |
| |
| // GetOrder returns the Order field in the NodeValueBlock. |
| func (b *NodeValueBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the NodeValueBlock. |
| func (b *NodeValueBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the NodeValueBlock. |
| func (b *NodeValueBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the NodeValueBlock. |
| func (b *NodeValueBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetParentIndex returns the ParentIndex field in the NodeValueBlock. |
| func (b *NodeValueBlock) GetParentIndex() BlockIndex { |
| return BlockIndex((b.header & 68719476480) >> 8) |
| } |
| |
| // SetParentIndex sets the ParentIndex field in the NodeValueBlock. |
| func (b *NodeValueBlock) SetParentIndex(v BlockIndex) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // GetNameIndex returns the NameIndex field in the NodeValueBlock. |
| func (b *NodeValueBlock) GetNameIndex() BlockIndex { |
| return BlockIndex((b.header & 18446744004990074880) >> 36) |
| } |
| |
| // SetNameIndex sets the NameIndex field in the NodeValueBlock. |
| func (b *NodeValueBlock) SetNameIndex(v BlockIndex) { |
| mask := uint64(18446744004990074880) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 36) & mask) |
| } |
| |
| func (b *NodeValueBlock) SetPayload(data []byte) { |
| p := uintptr(unsafe.Pointer(b)) + 8 |
| for i, v := range data { |
| *(*byte)(unsafe.Pointer(p + uintptr(i))) = v |
| } |
| } |
| |
| // The IntValueBlock type represents a block of type IntValueBlock. |
| type IntValueBlock Block |
| |
| // SetHeader sets the header fields for IntValueBlock. |
| func (b *IntValueBlock) SetHeader(Order BlockOrder, Type BlockType, ParentIndex BlockIndex, NameIndex BlockIndex) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(ParentIndex) << 8) & 68719476480) | ((uint64(NameIndex) << 36) & 18446744004990074880)) |
| } |
| |
| // GetOrder returns the Order field in the IntValueBlock. |
| func (b *IntValueBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the IntValueBlock. |
| func (b *IntValueBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the IntValueBlock. |
| func (b *IntValueBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the IntValueBlock. |
| func (b *IntValueBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetParentIndex returns the ParentIndex field in the IntValueBlock. |
| func (b *IntValueBlock) GetParentIndex() BlockIndex { |
| return BlockIndex((b.header & 68719476480) >> 8) |
| } |
| |
| // SetParentIndex sets the ParentIndex field in the IntValueBlock. |
| func (b *IntValueBlock) SetParentIndex(v BlockIndex) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // GetNameIndex returns the NameIndex field in the IntValueBlock. |
| func (b *IntValueBlock) GetNameIndex() BlockIndex { |
| return BlockIndex((b.header & 18446744004990074880) >> 36) |
| } |
| |
| // SetNameIndex sets the NameIndex field in the IntValueBlock. |
| func (b *IntValueBlock) SetNameIndex(v BlockIndex) { |
| mask := uint64(18446744004990074880) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 36) & mask) |
| } |
| |
| // GetValue returns the Value field in the IntValueBlock. |
| func (b *IntValueBlock) GetValue() int64 { |
| return int64((b.payload & 18446744073709551615) >> 0) |
| } |
| |
| // SetValue sets the Value field in the IntValueBlock. |
| func (b *IntValueBlock) SetValue(v int64) { |
| mask := uint64(18446744073709551615) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 0) & mask) |
| } |
| |
| // The UintValueBlock type represents a block of type UintValueBlock. |
| type UintValueBlock Block |
| |
| // SetHeader sets the header fields for UintValueBlock. |
| func (b *UintValueBlock) SetHeader(Order BlockOrder, Type BlockType, ParentIndex uint, NameIndex uint) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(ParentIndex) << 8) & 68719476480) | ((uint64(NameIndex) << 36) & 18446744004990074880)) |
| } |
| |
| // GetOrder returns the Order field in the UintValueBlock. |
| func (b *UintValueBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the UintValueBlock. |
| func (b *UintValueBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the UintValueBlock. |
| func (b *UintValueBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the UintValueBlock. |
| func (b *UintValueBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetParentIndex returns the ParentIndex field in the UintValueBlock. |
| func (b *UintValueBlock) GetParentIndex() uint { |
| return uint((b.header & 68719476480) >> 8) |
| } |
| |
| // SetParentIndex sets the ParentIndex field in the UintValueBlock. |
| func (b *UintValueBlock) SetParentIndex(v uint) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // GetNameIndex returns the NameIndex field in the UintValueBlock. |
| func (b *UintValueBlock) GetNameIndex() uint { |
| return uint((b.header & 18446744004990074880) >> 36) |
| } |
| |
| // SetNameIndex sets the NameIndex field in the UintValueBlock. |
| func (b *UintValueBlock) SetNameIndex(v uint) { |
| mask := uint64(18446744004990074880) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 36) & mask) |
| } |
| |
| // GetValue returns the Value field in the UintValueBlock. |
| func (b *UintValueBlock) GetValue() uint64 { |
| return uint64((b.payload & 18446744073709551615) >> 0) |
| } |
| |
| // SetValue sets the Value field in the UintValueBlock. |
| func (b *UintValueBlock) SetValue(v uint64) { |
| mask := uint64(18446744073709551615) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 0) & mask) |
| } |
| |
| // The DoubleValueBlock type represents a block of type DoubleValueBlock. |
| type DoubleValueBlock Block |
| |
| // SetHeader sets the header fields for DoubleValueBlock. |
| func (b *DoubleValueBlock) SetHeader(Order BlockOrder, Type BlockType, ParentIndex BlockIndex, NameIndex BlockIndex) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(ParentIndex) << 8) & 68719476480) | ((uint64(NameIndex) << 36) & 18446744004990074880)) |
| } |
| |
| // GetOrder returns the Order field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetParentIndex returns the ParentIndex field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) GetParentIndex() BlockIndex { |
| return BlockIndex((b.header & 68719476480) >> 8) |
| } |
| |
| // SetParentIndex sets the ParentIndex field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) SetParentIndex(v BlockIndex) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // GetNameIndex returns the NameIndex field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) GetNameIndex() BlockIndex { |
| return BlockIndex((b.header & 18446744004990074880) >> 36) |
| } |
| |
| // SetNameIndex sets the NameIndex field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) SetNameIndex(v BlockIndex) { |
| mask := uint64(18446744004990074880) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 36) & mask) |
| } |
| |
| // GetValue returns the Value field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) GetValue() float64 { |
| return math.Float64frombits(((b.payload & 18446744073709551615) >> 0)) |
| } |
| |
| // SetValue sets the Value field in the DoubleValueBlock. |
| func (b *DoubleValueBlock) SetValue(f float64) { |
| v := math.Float64bits(f) |
| mask := uint64(18446744073709551615) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 0) & mask) |
| } |
| |
| // The PropertyBlock type represents a block of type PropertyBlock. |
| type PropertyBlock Block |
| |
| // SetHeader sets the header fields for PropertyBlock. |
| func (b *PropertyBlock) SetHeader(Order BlockOrder, Type BlockType, ParentIndex BlockIndex, NameIndex BlockIndex) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(ParentIndex) << 8) & 68719476480) | ((uint64(NameIndex) << 36) & 18446744004990074880)) |
| } |
| |
| // GetOrder returns the Order field in the PropertyBlock. |
| func (b *PropertyBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the PropertyBlock. |
| func (b *PropertyBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the PropertyBlock. |
| func (b *PropertyBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the PropertyBlock. |
| func (b *PropertyBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetParentIndex returns the ParentIndex field in the PropertyBlock. |
| func (b *PropertyBlock) GetParentIndex() BlockIndex { |
| return BlockIndex((b.header & 68719476480) >> 8) |
| } |
| |
| // SetParentIndex sets the ParentIndex field in the PropertyBlock. |
| func (b *PropertyBlock) SetParentIndex(v BlockIndex) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // GetNameIndex returns the NameIndex field in the PropertyBlock. |
| func (b *PropertyBlock) GetNameIndex() BlockIndex { |
| return BlockIndex((b.header & 18446744004990074880) >> 36) |
| } |
| |
| // SetNameIndex sets the NameIndex field in the PropertyBlock. |
| func (b *PropertyBlock) SetNameIndex(v BlockIndex) { |
| mask := uint64(18446744004990074880) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 36) & mask) |
| } |
| |
| // GetLength returns the Length field in the PropertyBlock. |
| func (b *PropertyBlock) GetLength() uint { |
| return uint((b.payload & 4294967295) >> 0) |
| } |
| |
| // SetLength sets the Length field in the PropertyBlock. |
| func (b *PropertyBlock) SetLength(v uint) { |
| mask := uint64(4294967295) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetExtentIndex returns the ExtentIndex field in the PropertyBlock. |
| func (b *PropertyBlock) GetExtentIndex() uint { |
| return uint((b.payload & 1152921500311879680) >> 32) |
| } |
| |
| // SetExtentIndex sets the ExtentIndex field in the PropertyBlock. |
| func (b *PropertyBlock) SetExtentIndex(v uint) { |
| mask := uint64(1152921500311879680) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 32) & mask) |
| } |
| |
| // GetFlags returns the Flags field in the PropertyBlock. |
| func (b *PropertyBlock) GetFlags() uint { |
| return uint((b.payload & 17293822569102704640) >> 60) |
| } |
| |
| // SetFlags sets the Flags field in the PropertyBlock. |
| func (b *PropertyBlock) SetFlags(v uint) { |
| mask := uint64(17293822569102704640) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 60) & mask) |
| } |
| |
| // The ExtentBlock type represents a block of type ExtentBlock. |
| type ExtentBlock Block |
| |
| // SetHeader sets the header fields for ExtentBlock. |
| func (b *ExtentBlock) SetHeader(Order BlockOrder, Type BlockType, NextExtent BlockIndex) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(NextExtent) << 8) & 68719476480)) |
| } |
| |
| // GetOrder returns the Order field in the ExtentBlock. |
| func (b *ExtentBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the ExtentBlock. |
| func (b *ExtentBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the ExtentBlock. |
| func (b *ExtentBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the ExtentBlock. |
| func (b *ExtentBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetNextExtent returns the NextExtent field in the ExtentBlock. |
| func (b *ExtentBlock) GetNextExtent() BlockIndex { |
| return BlockIndex((b.header & 68719476480) >> 8) |
| } |
| |
| // SetNextExtent sets the NextExtent field in the ExtentBlock. |
| func (b *ExtentBlock) SetNextExtent(v BlockIndex) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // The NameBlock type represents a block of type NameBlock. |
| type NameBlock Block |
| |
| // SetHeader sets the header fields for NameBlock. |
| func (b *NameBlock) SetHeader(Order BlockOrder, Type BlockType, Length uint) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(Length) << 8) & 1048320)) |
| } |
| |
| // GetOrder returns the Order field in the NameBlock. |
| func (b *NameBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the NameBlock. |
| func (b *NameBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the NameBlock. |
| func (b *NameBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the NameBlock. |
| func (b *NameBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetLength returns the Length field in the NameBlock. |
| func (b *NameBlock) GetLength() uint { |
| return uint((b.header & 1048320) >> 8) |
| } |
| |
| // SetLength sets the Length field in the NameBlock. |
| func (b *NameBlock) SetLength(v uint) { |
| mask := uint64(1048320) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| func (b *NameBlock) SetPayload(data []byte) { |
| p := uintptr(unsafe.Pointer(b)) + 8 |
| for i, v := range data { |
| *(*byte)(unsafe.Pointer(p + uintptr(i))) = v |
| } |
| } |
| |
| // The TombstoneBlock type represents a block of type TombstoneBlock. |
| type TombstoneBlock Block |
| |
| // SetHeader sets the header fields for TombstoneBlock. |
| func (b *TombstoneBlock) SetHeader(Order BlockOrder, Type BlockType) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240)) |
| } |
| |
| // GetOrder returns the Order field in the TombstoneBlock. |
| func (b *TombstoneBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the TombstoneBlock. |
| func (b *TombstoneBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the TombstoneBlock. |
| func (b *TombstoneBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the TombstoneBlock. |
| func (b *TombstoneBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetRefCount returns the RefCount field in the TombstoneBlock. |
| func (b *TombstoneBlock) GetRefCount() uint64 { |
| return uint64((b.payload & 18446744073709551615) >> 0) |
| } |
| |
| // SetRefCount sets the RefCount field in the TombstoneBlock. |
| func (b *TombstoneBlock) SetRefCount(v uint64) { |
| mask := uint64(18446744073709551615) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 0) & mask) |
| } |
| |
| // The ArrayBlock type represents a block of type ArrayBlock. |
| type ArrayBlock Block |
| |
| // SetHeader sets the header fields for ArrayBlock. |
| func (b *ArrayBlock) SetHeader(Order BlockOrder, Type BlockType, ParentIndex BlockIndex, NameIndex BlockIndex) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240) | ((uint64(ParentIndex) << 8) & 68719476480) | ((uint64(NameIndex) << 36) & 18446744004990074880)) |
| } |
| |
| // GetOrder returns the Order field in the ArrayBlock. |
| func (b *ArrayBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the ArrayBlock. |
| func (b *ArrayBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the ArrayBlock. |
| func (b *ArrayBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the ArrayBlock. |
| func (b *ArrayBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetParentIndex returns the ParentIndex field in the ArrayBlock. |
| func (b *ArrayBlock) GetParentIndex() BlockIndex { |
| return BlockIndex((b.header & 68719476480) >> 8) |
| } |
| |
| // SetParentIndex sets the ParentIndex field in the ArrayBlock. |
| func (b *ArrayBlock) SetParentIndex(v BlockIndex) { |
| mask := uint64(68719476480) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 8) & mask) |
| } |
| |
| // GetNameIndex returns the NameIndex field in the ArrayBlock. |
| func (b *ArrayBlock) GetNameIndex() BlockIndex { |
| return BlockIndex((b.header & 18446744004990074880) >> 36) |
| } |
| |
| // SetNameIndex sets the NameIndex field in the ArrayBlock. |
| func (b *ArrayBlock) SetNameIndex(v BlockIndex) { |
| mask := uint64(18446744004990074880) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 36) & mask) |
| } |
| |
| // GetEntryType returns the EntryType field in the ArrayBlock. |
| func (b *ArrayBlock) GetEntryType() uint { |
| return uint((b.payload & 15) >> 0) |
| } |
| |
| // SetEntryType sets the EntryType field in the ArrayBlock. |
| func (b *ArrayBlock) SetEntryType(v uint) { |
| mask := uint64(15) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetFlags returns the Flags field in the ArrayBlock. |
| func (b *ArrayBlock) GetFlags() uint { |
| return uint((b.payload & 240) >> 4) |
| } |
| |
| // SetFlags sets the Flags field in the ArrayBlock. |
| func (b *ArrayBlock) SetFlags(v uint) { |
| mask := uint64(240) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetCount returns the Count field in the ArrayBlock. |
| func (b *ArrayBlock) GetCount() uint { |
| return uint((b.payload & 65280) >> 8) |
| } |
| |
| // SetCount sets the Count field in the ArrayBlock. |
| func (b *ArrayBlock) SetCount(v uint) { |
| mask := uint64(65280) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 8) & mask) |
| } |
| |
| func (b *ArrayBlock) SetPayload(data []byte) { |
| p := uintptr(unsafe.Pointer(b)) + 16 |
| for i, v := range data { |
| *(*byte)(unsafe.Pointer(p + uintptr(i))) = v |
| } |
| } |
| |
| // The LinkBlock type represents a block of type LinkBlock. |
| type LinkBlock Block |
| |
| // SetHeader sets the header fields for LinkBlock. |
| func (b *LinkBlock) SetHeader(Order BlockOrder, Type BlockType) { |
| b.header = uint64(((uint64(Order) << 0) & 15) | ((uint64(Type) << 4) & 240)) |
| } |
| |
| // GetOrder returns the Order field in the LinkBlock. |
| func (b *LinkBlock) GetOrder() BlockOrder { |
| return BlockOrder((b.header & 15) >> 0) |
| } |
| |
| // SetOrder sets the Order field in the LinkBlock. |
| func (b *LinkBlock) SetOrder(v BlockOrder) { |
| mask := uint64(15) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetType returns the Type field in the LinkBlock. |
| func (b *LinkBlock) GetType() BlockType { |
| return BlockType((b.header & 240) >> 4) |
| } |
| |
| // SetType sets the Type field in the LinkBlock. |
| func (b *LinkBlock) SetType(v BlockType) { |
| mask := uint64(240) |
| b.header &= ^mask |
| b.header |= ((uint64(v) << 4) & mask) |
| } |
| |
| // GetContextIndex returns the ContextIndex field in the LinkBlock. |
| func (b *LinkBlock) GetContextIndex() uint { |
| return uint((b.payload & 1048575) >> 0) |
| } |
| |
| // SetContextIndex sets the ContextIndex field in the LinkBlock. |
| func (b *LinkBlock) SetContextIndex(v uint) { |
| mask := uint64(1048575) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 0) & mask) |
| } |
| |
| // GetFlags returns the Flags field in the LinkBlock. |
| func (b *LinkBlock) GetFlags() uint { |
| return uint((b.payload & 17293822569102704640) >> 60) |
| } |
| |
| // SetFlags sets the Flags field in the LinkBlock. |
| func (b *LinkBlock) SetFlags(v uint) { |
| mask := uint64(17293822569102704640) |
| b.payload &= ^mask |
| b.payload |= ((uint64(v) << 60) & mask) |
| } |