gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
232 stars 105 forks source link

Question: How to rename Object #1488

Closed pentamassiv closed 1 year ago

pentamassiv commented 1 year ago

I am currently generating bindings for GOA. It worked fine for the -sys crate, but I have an issue with the wrapper. Goa has a Goa.Object. When the code is generated, I have a naming conflict with the ObjectExt trait. There is one for the Goa.Object and one from glib. You can see the repo with the generated file here.

I thought the easiest would be to rename Object to GoaObject or something like that but I don't know how to rename it. I looked at the options in the Gir book and tried with

[[object]]
name = "Goa.Object"
status = "generate"
doc_trait_name = "Goa.GOAObject"

but I get a [ERROR libgir::config::error] "object Goa.Object": Unknown key: ["rename"] when running gir. Also, if renaming is the way to go, are there any conventions on how to rename it?

bilelmoussaoui commented 1 year ago

We don't support renaming objects, but you could rename you trait, similar to https://github.com/gtk-rs/gtk4-rs/blob/master/gtk4/Gir.toml#L1617

pentamassiv commented 1 year ago

Awesome, that worked. Thank you

bilelmoussaoui commented 1 year ago

Have you seen https://gitlab.gnome.org/World/Rust/libgoa-rs btw?

pentamassiv commented 1 year ago

Yes, it is the reason why I want to generate the bindings. I want to open a PR to update them. They are very outdated