Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

In glib_object_wrapper!, use generic Class type instead defining a struct #10

Merged
merged 2 commits into from
Nov 5, 2020

Conversation

ids1024
Copy link
Contributor

@ids1024 ids1024 commented Oct 30, 2020

Update of gtk-rs/glib#720 with corresponding changes to other crates.

This makes the $rust_class_name argument in glib_wrapper! optional. If specified, it defines a type alias for the class. At least optionally allowing it is required to avoid breaking lots of gir generated code, but perhaps it can be removed after a change to gir.

This removes the ObjectType::RustClassType associated type, since it can't be enforced/assumed by the type system that that is an instance of this generic struct.

The IsClassFor trait is also removed, superseded by this generic type.

This also changes the IsSubclassable trait to be implemented on the object struct rather than the class struct, since there otherwise would be foreign trait on foreign type errors.

@sdroege
Copy link
Member

sdroege commented Nov 4, 2020

Can you rebase on top of latest master? Then we get CI back :)

Copy link
Member

@sdroege sdroege left a comment

Choose a reason for hiding this comment

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

Looks good to me otherwise. Thanks a lot!

…ruct

This makes the `$rust_class_name` argument in `glib_wrapper!` optional.
If specified, it defines a `type` alias for the class. At least
optionally allowing it is required to avoid breaking lots of gir
generated code, but perhaps it can be removed after a change to gir.

This removes the `ObjectType::RustClassType` associated type, since it
can't be enforced/assumed by the type system that that is an instance of
this generic struct.

The `IsClassFor` trait is also removed, superseded by this generic
type.

This also changes the `IsSubclassable` trait to be implemented on the
object struct rather than the class struct, since there otherwise would
be foreign trait on foreign type errors.
@sdroege
Copy link
Member

sdroege commented Nov 4, 2020

I'll merge this later today or tomorrow once I've updated gstreamer-rs accordingly. Don't want it to fail once this is merged :)

@GuillaumeGomez
Copy link
Member

Thanks!


match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, ::std::os::raw::c_void, $rust_class_name, @get_type $get_type_expr, @extends [], @implements []);
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, ::std::os::raw::c_void, @get_type $get_type_expr, @extends [], @implements []);
Copy link
Member

Choose a reason for hiding this comment

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

@ids1024 Can you also do the gir change that makes it use the new variants without the explicit class name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't look complicated to update gir, but I'm seeing issues running generator.py with gir master similar to those mentioned in #11

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, something's broken currently. Can you create an issue for gir otherwise?

@sdroege
Copy link
Member

sdroege commented Nov 5, 2020

I'll merge this later today or tomorrow once I've updated gstreamer-rs accordingly. Don't want it to fail once this is merged :)

That's waiting here now https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/621

This makes it easier/safer to implement `IsSubclassable`.
@sdroege sdroege merged commit c070941 into gtk-rs:master Nov 5, 2020
gstreamer-github pushed a commit to sdroege/gstreamer-rs that referenced this pull request Nov 5, 2020
ids1024 added a commit to ids1024/gir that referenced this pull request Nov 5, 2020
ids1024 added a commit to ids1024/gir that referenced this pull request Nov 5, 2020
sdroege pushed a commit to ids1024/gir that referenced this pull request Nov 6, 2020
@ids1024 ids1024 deleted the generic-class branch January 13, 2021 22:57
elmarco pushed a commit to elmarco/gtk-rs that referenced this pull request Feb 10, 2021
elmarco pushed a commit to elmarco/gtk-rs that referenced this pull request Feb 10, 2021
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