Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate GtkAtom and GIConv as disguised types #79

Merged
merged 2 commits into from Feb 16, 2018

Conversation

Projects
None yet
4 participants
@EPashkin
Copy link
Member

EPashkin commented Feb 13, 2018

@EPashkin EPashkin changed the title Generate GtkAtom and GIConv as disguised types WIP: Generate GtkAtom and GIConv as disguised types Feb 13, 2018

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Feb 13, 2018

👍

#[repr(C)]
pub struct _GdkAtom(c_void);

impl ::std::fmt::Debug for _GdkAtom {

This comment has been minimized.

@sdroege

sdroege Feb 13, 2018

Member

This is a bit ugly. If you have a GdkAtom (which is a raw pointer), you need to dereference it to use the Debug impl. But GdkAtom can have values that are invalid to dereference (like 0, 1, 2) IIRC.

This comment has been minimized.

@tmiasko

tmiasko Feb 13, 2018

Contributor

It shouldn't be really possible to dereference it, because its type is
incomplete. The c_void wrapped in struct doesn't really expresses this now, but
this should be possible to do with extern types once they are in stable Rust.

This comment has been minimized.

@EPashkin

EPashkin Feb 13, 2018

Author Member

IMHO This is minor problem for Atom,

let atom = gdk::SELECTION_CLIPBOARD;
println!("{:?}", atom.to_glib_none().0); //GdkAtom
println!("{:?}", atom.name());

print

0x45
"CLIPBOARD"

This comment has been minimized.

@sdroege

sdroege Feb 13, 2018

Member

It shouldn't be really possible to dereference it, because its type is
incomplete.

The _GdkAtom type is "incomplete", but GdkAtom is a pointer and that can be dereferenced and must be dereferenced to access the Debug impl.

@EPashkin

This comment has been minimized.

Copy link
Member Author

EPashkin commented Feb 15, 2018

Added commit with changes from gtk-rs/gir#546.
Removed unusable Debug implementation and internal aliases.

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Feb 15, 2018

👍

@EPashkin EPashkin force-pushed the EPashkin:generate_disguised branch from e0b502e to 3fb325c Feb 16, 2018

@EPashkin EPashkin changed the title WIP: Generate GtkAtom and GIConv as disguised types Generate GtkAtom and GIConv as disguised types Feb 16, 2018

@EPashkin

This comment has been minimized.

Copy link
Member Author

EPashkin commented Feb 16, 2018

This is final version.
CI passed too.

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Feb 16, 2018

👍

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Feb 16, 2018

Then I merge. Thanks!

@GuillaumeGomez GuillaumeGomez merged commit 53beb6a into gtk-rs:master Feb 16, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@EPashkin EPashkin deleted the EPashkin:generate_disguised branch Feb 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.