progrium/darwinkit

generate enum & type alias definitions

Closed this issue · 1 comments

mgood commented

Objective-C uses enums & type aliases quite often. The manually written macdriver code often only includes a subset that was needed at the time, but it would help to more easily import these into the generated code to ensure we have all the necessary values.

For enums we generally should have a Value listed that we could include directly in the Go code like:

const NSWindowStyleMaskBorderless = 0

However there are some things like the NSWindowLevel type alias where the docs don't include the actual values, and just the declaration const NSWindowLevel NSDockWindowLevel;. So an approach that would handle both is to use CGo, including the necessary headers and then:

const NSDockWindowLevel = C.NSDockWindowLevel

We should also generate the corresponding Go type names like:

type NSWindowStyleMask NSUInteger

Most enums and many type aliases are generated now as this goes into main:
#176