Skip to content

Commit

Permalink
Fix names
Browse files Browse the repository at this point in the history
  • Loading branch information
noahsmartin committed Oct 1, 2024
1 parent 034e3d5 commit 7a71573
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/SnapshotPreviewsCore/ConformanceLookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ import MachO
private func getTypeName(descriptor: UnsafePointer<TargetModuleContextDescriptor>) -> String? {
let flags = descriptor.pointee.flags
var parentName: String? = nil
if descriptor.pointee.parent != 0 {
let parent = UnsafeRawPointer(descriptor).advanced(by: MemoryLayout<TargetModuleContextDescriptor>.offset(of: \.parent)!).advanced(by: Int(descriptor.pointee.parent))
if abs(descriptor.pointee.parent) % 2 == 1 {
return nil
}
parentName = getTypeName(descriptor: parent.assumingMemoryBound(to: TargetModuleContextDescriptor.self))
}
switch flags.kind {
case .Module, .Enum, .Struct, .Class:
let name = UnsafeRawPointer(descriptor)
.advanced(by: MemoryLayout<TargetModuleContextDescriptor>.offset(of: \.name)!)
.advanced(by: Int(descriptor.pointee.name))
.assumingMemoryBound(to: CChar.self)
let typeName = String(cString: name)
if descriptor.pointee.parent != 0 {
let parent = UnsafeRawPointer(descriptor).advanced(by: MemoryLayout<TargetModuleContextDescriptor>.offset(of: \.parent)!).advanced(by: Int(descriptor.pointee.parent))
if abs(descriptor.pointee.parent) % 2 == 1 {
return nil
}
parentName = getTypeName(descriptor: parent.assumingMemoryBound(to: TargetModuleContextDescriptor.self))
}
if let parentName = parentName {
return "\(parentName).\(typeName)"
}
return typeName
default:
return nil
return parentName
}
}

Expand Down

0 comments on commit 7a71573

Please sign in to comment.