gtk-rs / gtk-rs-core

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

Derive TransparentPtrType trait for Boxed #1431

Closed pbor closed 3 months ago

sdroege commented 3 months ago

I don't think this is correct, at least not for the shared case. from_raw() and into_raw() are not just returning &Arc<T> as *const T or so but do some offsetting.

Can you add tests for both cases somewhere (using a pointer slice or something else that requires the traits) to ensure this is actually working correctly? Also if these traits are implemented you can implement FromValue for references like glib::wrapper! does.

pbor commented 3 months ago

Thanks for catching that SharedBoxed was a bad idea... indeed I did it by cut&paste without thinking :(

Can you add tests for both cases somewhere (using a pointer slice or something else that requires the traits) to ensure this is actually working correctly?

I added a small test for the boxed case, but please check if you think it is enough to exercise this.

you can implement FromValue for references like glib::wrapper! does

As far as I can see that is already there: https://github.com/gtk-rs/gtk-rs-core/blob/master/glib-macros/src/boxed_derive.rs#L56