Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Migrate subclassing infrastructure to glib-rs #392

Merged
merged 26 commits into from
Nov 20, 2018
Merged

Migrate subclassing infrastructure to glib-rs #392

merged 26 commits into from
Nov 20, 2018

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Nov 19, 2018

For an example see the unit test in src/subclass/object.rs at the bottom: https://github.com/sdroege/glib-rs/blob/3eee4c7da6e6947efa4c1970d7d36e17cbfca577/src/subclass/object.rs#L288-L379 . Another example can be found here gtk-rs/examples#205 (https://github.com/gtk-rs/examples/blob/4cf46ec7a6409b92ed726eaec74d4d983c84e386/src/bin/listbox_model.rs#L251-L401)

This is a complete rewrite of gobject-subclass to be more flexible, lightweight, simple and to be usable with gnome-class too.

I have a WIP port of gst-plugin-rs for this (need to migrate all the code to the bindings first) and it all works well.

I also have a minimal change to gir (gtk-rs/gir#669) to add the Rust class type to the glib_wrapper! macro, which should be merged first. And then gtk-rs/gir#604 can be updated to actually generate quite a bit of the boilerplate code.


This is now part of the proper bindings instead of an external crate because otherwise the API can't be made as nice as it is now due to not being able to implement traits for types defined in other crates, and generally more traits for marking all the relationships are needed.

And fill it in by default with () in the macro to prevent existing code
from failing to compile.
And keep the existing ones on ObjectExt as wrappers around ObjectClass
The object is destroyed already at that time
It is potentially unsafe as the object is not fully initialized yet and
especially does not have its private struct created yet (we just do
exactly that here!).

It's better to use Object::constructed() for any initialization.
Copy link
Member

@EPashkin EPashkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work

src/lib.rs Show resolved Hide resolved
src/subclass/mod.rs Outdated Show resolved Hide resolved
src/subclass/mod.rs Outdated Show resolved Hide resolved
src/subclass/guard.rs Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member

Global comments while I'm reviewing: can you add punctuation on your (doc) comments please? A lot of them are missing a dot at the end.

@GuillaumeGomez
Copy link
Member

Could you also add a section into the README about this please?

src/object.rs Outdated Show resolved Hide resolved
src/subclass/mod.rs Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit dab55a4 into gtk-rs:master Nov 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants