In general, I find that importing C arrays is problematic. I don't have any nice solution to offer, though.
For now, you might be able to get away with withUnsafePointer(&event.data) { ... }. Félix > Le 22 déc. 2015 à 17:29:10, T.J. Usiyan via swift-evolution > <swift-evolution@swift.org> a écrit : > > MIDIMetaEvent and MIDIEventUserData are both examples of framework provided > types which rely on flexible member arrays. Their last member is (officially) > an array of UInt8 with 1 element. In practice, developers are meant to > allocate enough space for an array of the necessary length along with the > rest of the struct. > > These members come into swift as single element tuples. I propose either > automatic import of these as Array or UnsafeReference. > > Example of the current situation: > /*! > @struct MIDIMetaEvent > @discussion The parameters to specify a MIDI meta event > */ > public struct MIDIMetaEvent { > > public var metaEventType: UInt8 > public var unused1: UInt8 > public var unused2: UInt8 > public var unused3: UInt8 > public var dataLength: UInt32 > public var data: (UInt8) > public init() > public init(metaEventType: UInt8, unused1: UInt8, unused2: UInt8, > unused3: UInt8, dataLength: UInt32, data: (UInt8)) > } > > /*! > @struct MusicEventUserData > @discussion Provides a general struct for specifying a user defined > event. > @field length > the size in bytes of the data > @field data > size bytes of user defined event data > */ > public struct MusicEventUserData { > > public var length: UInt32 > public var data: (UInt8) > public init() > public init(length: UInt32, data: (UInt8)) > } > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution