core-foundation-rs icon indicating copy to clipboard operation
core-foundation-rs copied to clipboard

Automatic binding generation?

Open bors-servo opened this issue 7 years ago • 6 comments

Issue by frewsxcv Saturday Nov 26, 2016 at 21:20 GMT Originally opened as https://github.com/servo/cocoa-rs/issues/147


PyObjc (and possibly RubyCocoa?) use .fwinfo files to generate language bindings around Cocoa and similar objective C libraries:

https://bitbucket.org/ronaldoussoren/pyobjc/raw/6b74fc7e1ba0995038dc5c1f162d1fad860ff175/pyobjc-framework-Cocoa/metadata/raw.AppKit/x86_64-10.10.fwinfo

From what I can tell, PyObjC uses a tool called objective.metadata to generate these files:

https://bitbucket.org/ronaldoussoren/objective.metadata/src/bd0f1b994403?at=default

Has anyone thought about doing automatic binding generation for cocoa-rs? Anyone know of easy strategies?

bors-servo avatar Feb 01 '18 22:02 bors-servo

Comment by chances Friday Jan 20, 2017 at 08:52 GMT


Is rust-bindgen a good option?

bors-servo avatar Feb 01 '18 22:02 bors-servo

Comment by frewsxcv Friday Jan 20, 2017 at 14:38 GMT


It's possible, but I'm familiar with bindgen enough to know for sure.

bors-servo avatar Feb 01 '18 22:02 bors-servo

Comment by emilio Friday Jan 20, 2017 at 14:45 GMT


You could try with https://github.com/servo/rust-bindgen. I recently made a PR to freetype to do the same (avoiding manual bindings), so probably you could get inspired by the script in there:

https://github.com/servo/rust-freetype/pull/48

I can't do this myself since I don't have an OSX machine.

bors-servo avatar Feb 01 '18 22:02 bors-servo

Comment by nox Monday Feb 27, 2017 at 10:45 GMT


Are fwinfo files an Apple thing?

bors-servo avatar Feb 01 '18 22:02 bors-servo

bindgen won't work on modern mac headers because it doesn't support objective c generics: https://github.com/rust-lang-nursery/rust-bindgen/issues/1259

jrmuizel avatar Feb 18 '18 22:02 jrmuizel

FWIW, it looks like Ruby creates the bindings at runtime through introspection and bridgesupport files. https://github.com/rubycocoa/rubycocoa/blob/master/lib/osx/objc/oc_import.rb

jrmuizel avatar Feb 19 '18 16:02 jrmuizel