enum Kind {} func dumpMemory(_ p: UnsafeRawPointer, _ size: Int) { let addr = unsafeBitCast(p, to: Int64.self) let p = p.bindMemory(to: UInt8.self, capacity: size) for i in 0..<size { if i % 8 == 0 { if i != 0 { print() } print(String(format: "[0x%016lx](\(i/8))", addr + Int64(i)), terminator: "") } print(String(format: " %02x", p[i]), terminator: "") } print() } var type: Any.Type = Kind.self let base: UnsafeMutablePointer = unsafeBitCast(type, to: UnsafeMutablePointer<Int64>.self) let metadataPointer = base.advanced(by: -1) let p = UnsafeMutableRawPointer(metadataPointer) dumpMemory(p, 16)
struct: 01 enum: 02 protocol: 0c なのでそれっぽい値は出ているのですが、検証として正しいのか…