-
Notifications
You must be signed in to change notification settings - Fork 7
add support for typeQDRectangle #2
Copy link
Copy link
Closed
Description
Similar to the proposed solution to issue #1:
public func unpackAsQDRectangle(_ descriptor: Descriptor) throws -> [Int] {
struct QDRectangle { // derived from MacTypes.h
var top: Int16
var left: Int16
var bottom: Int16
var right: Int16
}
guard descriptor.data.count == MemoryLayout<Int16>.size * 4 else { throw AppleEventError.corruptData }
let theRect: QDRectangle = descriptor.data.withUnsafeBytes { buffer in
buffer.bindMemory(to: QDRectangle.self)[0]
}
let top = Int(Int16(bigEndian: theRect.top))
let left = Int(Int16(bigEndian: theRect.left))
let bottom = Int(Int16(bigEndian: theRect.bottom))
let right = Int(Int16(bigEndian: theRect.right))
// AppleScript returns {left, top, right, bottom}
return [left, top, right, bottom]
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels