haiku-rs icon indicating copy to clipboard operation
haiku-rs copied to clipboard

Move to bindgen?

Open kallisti5 opened this issue 2 years ago • 3 comments

haiku-sys might want to consider migrating to bindgen.

https://docs.rs/bindgen/0.59.1/bindgen/

Essentially the bindings are auto-generated for you based on headers.

A smallish example project putting bindgen to work is here:

  • https://github.com/storj-thirdparty/uplink-rust

I confirmed bindgen does indeed compile under Haiku.

kallisti5 avatar Nov 17 '21 15:11 kallisti5

Actually haiku-sys has been mostly (if not all) absorbed into libc, which is (infamously) manually maintained. Not sure if it makes sense to copy the efforts.

nielx avatar Nov 17 '21 16:11 nielx

@nielx is that also true of the Application Kit part as well? Would it make sense to use bindgen for the other kits in a separate lib (like this one) or am I missing something or thinking about this the wrong way?

sammoore avatar Dec 24 '23 00:12 sammoore

@nielx is that also true of the Application Kit part as well? Would it make sense to use bindgen for the other kits in a separate lib (like this one) or am I missing something or thinking about this the wrong way?

It is my opinion that anything in the higher level kits (UI or otherwise) is fundamentally incompatible with Rust, both because the Haiku API is fully based on the OO model, as well as the fact that the borrow checker's rules are incompatible with ownership rules in the Haiku API.

I don't have any experience with other bindings, but I think there is a reasonably useful GTK binding, where I suppose the C-Style OO is better reproducible in Rust. I think there is also a Qt binding, but last time I checked that bound to the QML layer of the API. This is in line with other attempts of using Rust for UI toolkits, where it seems the binding is for a declarative UI API, and the rendering/drawing is deferred to a lower level OO layer (like a browser DOM)

nielx avatar Dec 24 '23 08:12 nielx