SwiftScripting icon indicating copy to clipboard operation
SwiftScripting copied to clipboard

Incorrect Generation of Enum Cases

Open bdkjones opened this issue 7 years ago • 1 comments

Using the latest version to make Swift files for the Finder's sdef, this is part of the output:

screen shot 2018-10-03 at 14 21 35

In C, enum items do not need unique values. In Swift, they do. It's my understanding that the correct way to handle this situation would be to generate:

@objc public enum FinderEcvw : AEKeyword {
    case iconView = 0x69636e76 /* 'icnv' */
    case listView = 0x6c737677 /* 'lsvw' */
    case columnView = 0x636c7677 /* 'clvw' */
    case groupView = 0x666c7677 /* 'flvw' */
    static var flowView: FinderEcvw { return groupView }
}

bdkjones avatar Oct 03 '18 21:10 bdkjones

I've "handled" these collisions in the past by making a hand-edit to comment out the duplicate case. Your suggested approach is interesting. I'll consider beefing up the conversion logic if/when I spend time on updating the conversion script.

Thank you.

tingraldi avatar Oct 04 '18 02:10 tingraldi