mokus0 / hoc

Haskell to Objective-C bridge (work in progress: 64-bit support for Mac OS 10.7)
8 stars 2 forks source link

Use BridgeSupport files to generate bindings #3

Open mokus0 opened 12 years ago

mokus0 commented 12 years ago

The interface generator no longer reads Apple's header files (probably not GNU's either), so I propose that the interface generator be overhauled or re-written to use BridgeSupport files. If these are not available on GNUstep, it would probably be worthwhile to write a generator for them rather than maintain a specialized HOC interface generator.

If I recall correctly (I looked at implementing this once a while back), there is not enough information in the BridgeSupport files to generate the exact layout built by the current interface generator, so this will probably entail changes that affect end-user code. Given the advantage of never having to write another hacky header parser, though, I think it is probably worth it.

Another option which @ekmett suggested is to run the headers through the C preprocessor and parse the results. The reason that's not already being done is, I believe, because the parser is interpreting a lot of meta-information from CPP macros that get erased by the preprocessor - but as Ed points out, we can provide our own redefinitions of those that would leave them in a form we can parse. The result would probably not be valid C, so we'd still have to write a custom parser, but it would probably be more resilient to formatting changes than the current approach.

mokus0 commented 12 years ago

@IreneKnapp has offered the use of her BridgeSupport parser for this task. So I don't forget, that code is in a darcs repo at http://ireneknapp.com/software/darcs/direct-cocoa/

mokus0 commented 12 years ago

For the record... confirmed that interface generator chokes on GNUstep headers too.

jprider63 commented 3 years ago

Hi @mokus0. I was wondering how far you got with the switch to BridgeSupport. I see you have a BridgeSupport parser here. I'll probably start updating what's currently in this repository unless you suggest otherwise.