-
-
Notifications
You must be signed in to change notification settings - Fork 90
WIP: macro for *Impl, *ImplExt, IsSubclassable boilerplate #235
Conversation
7735acb
to
d56f9aa
Compare
@@ -64,6 +64,7 @@ glib = { path = "../glib" } | |||
gdk = { path = "../gdk" } | |||
gdk-pixbuf = { path = "../gdk-pixbuf" } | |||
pango = { path = "../pango" } | |||
paste = "1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a hidden re-export of paste
to glib and use that in the macro. It's not very nice if using a macro requires users to add other dependencies :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this was just a quick hack for testing before trying to re-export it correctly
The only part that I found that wouldn't work for all cases is the Otherwise this should help to reduce quite a bit of boring boilerplate. |
It would be nice to have something similar for IsImplementable |
Perhaps the macro could have a variant that adds it, and one that doesn't, since it seems a standard implementation would handle most cases. The other issue is that it potentially just makes the subclassing code potentially even more arcane, since to properly understand it one would have to understand the implementation of the macro as well as the other code where it's used. But I think it's probably better overall (still theoretically as a "temporary" solution before gir generation can be sorted out). |
Yeah that could become configurable in some way :)
Not worse than |
d56f9aa
to
15d7235
Compare
It does define two traits with But currently I think even the people who understand how subclassing works in gtk-rs are afraid to implement it for new types due to the Lovecraftian level of boilerplate, so it probably can't be worse... 😆 |
Or, I guess if someone is trying to implement So no worse. |
Not really, check the gtk4-rs repository. It's just that nobody who understands how it works cares enough about gtk3 to add more things there, and in GStreamer I've already added it for all the things that make sense to be subclassed so... :)
Definitely better, IMHO! |
6112ba9
to
ebe878e
Compare
Just a prototype, but this seems like it could be helpful, in the absence of full gir-based generation. Not sure if this method will work for all implementations.
ebe878e
to
fc64c05
Compare
If you're looking for a complicated case for that one: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/blob/01b16fe6c0a55cb40cfb87113fe2d165c91078e0/gstreamer/src/subclass/uri_handler.rs#L18-41 . Note also that not all the functions are not @ids1024 My plan is to move to associated constants for a few of the class methods we have as part of #31 . Similar to how that does it already for properties, same will be done for signals and I think for GTK it would make sense to make part of the template machinery like that (and in GStreamer pad templates, element factory metadata, etc.). Can you see a way how that could be covered here? Or maybe it's fine to not cover it as the number of classes/interfaces where such a thing is needed is going to be relatively small. |
Needs to be re-opened on gtk-rs-core. |
Just a prototype, but this seems like it could be helpful, in the absence of full gir-based generation. Not sure if this method will work for all implementations.