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

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Jul 11, 2018

See individual commits.

@sdroege
Copy link
Member Author

sdroege commented Jul 11, 2018

The object ones are preventing the obj.clone().downcast::<Foo>() calls I have in various places

where T: StaticType + UnsafeFrom<ObjectRef> + Wrapper,
Self: IsA<T> {
unsafe {
mem::transmute(self)
Copy link
Member Author

Choose a reason for hiding this comment

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

The object casts are safe because all the types have the same memory representation apart from their name and the phantom data type, and IsA is an unsafe trait so must only be implemented if it's actually a proper GObject wrapper type

gobject_ffi::g_type_check_value_holds(mut_override(self.to_glib_none().0),
T::static_type().to_glib()));
if ok {
Some(mem::transmute(self))
Copy link
Member Author

Choose a reason for hiding this comment

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

The value transmutes are safe because the only difference between Value and TypedValue is the zero-sized phantom data.

Copy link
Member

Choose a reason for hiding this comment

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

This comment not better be in code? ;)

@EPashkin
Copy link
Member

@sdroege Looks good

@GuillaumeGomez
Copy link
Member

I clearly don't know enough this part of GLib and the code looks good to me so I'll trust you and @EPashkin's opinion on this one. Thanks!

@GuillaumeGomez GuillaumeGomez merged commit c5b00ed into gtk-rs:master Jul 11, 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