gtk-rs / gtk-rs-core

Rust bindings for GNOME libraries
https://gtk-rs.org/gtk-rs-core
MIT License
280 stars 112 forks source link

Simplify/automate implementation of IsSubclassable #24

Open ids1024 opened 3 years ago

ids1024 commented 3 years ago

https://github.com/gtk-rs/gtk/tree/master/src/subclass has a lot of similar code, but still leaves various gtk widgets impossible to subclass from Rust (with safe code anyway).

I'm not sure exactly what difficulties are involved, but that should probably be automated as much as possible (in gir, a macro, etc.) so as little work as possible is needed to support sub-classing a new type.

sdroege commented 3 years ago

See https://github.com/gtk-rs/gir/pull/604

The "empty" case without virtual methods is easy to automate, the problems come with the virtual methods. Often those are not very bindings friendly and require custom implementations. Those are the bad cases and you can find quite a few in gio, gtk and GStreamer.

Another problem is that it's not clear from the introspection data which virtual methods are optional and which are mandatory, or what the "default" behaviour (and return value) would be. That's a more fundamental problem with gobject-introspection missing information.

And last, the annotations for virtual methods are generally lacking in all the libraries. Which of course should be fixed, but prevents autogeneration too right now.