[swift-evolution] Proposal Sketch: Bring flexible array members in as Array|UnsafeReference
T.J. Usiyan
griotspeak at gmail.com
Tue Dec 22 16:29:10 CST 2015
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))
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151222/4c1e803c/attachment-0001.html>
More information about the swift-evolution
mailing list