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

Add Char wrapper; implement KeyFile::set_list_separator() with it #248

Merged
merged 3 commits into from
Dec 7, 2017

Conversation

federicomenaquintero
Copy link
Contributor

I'm in the process of adding "impl ToGlib" for all the fundamental types, so that gnome-class will have an easier time passing them around: then it can just call .to_glib() on every method argument with a fundamental type.

Along the way I ran into the distinction between Rust's char and Glib's C c_char. Here we introduce a Char wrapper, which can be created fallibly from a Rust char. When it succeeds, the result can be passed to C functions that take a c_char.

Finally, we implement KeyFile::set_list_separator in terms of this.

We will use this to actually bind KeyFile::set_list_separator(), and
as a general tool to pass values to C functions which expect a C 'char'.
/// }
/// ```
///
/// This would be inconvenient because users would have to do the conversion from a Rust `char` to an `i8` by hand. It would be the same case for `libc::c_char`, which is just a type alias
Copy link
Member

Choose a reason for hiding this comment

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

They could pass b'a' for example

Gir.toml Outdated
@@ -252,6 +252,10 @@ status = "generate"
# file parameter needs to be a PathBuf
ignore = true
[[object.function]]
name = "set_list_separator"
# separator parameter neds to be a glib::Char
Copy link
Member

Choose a reason for hiding this comment

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

need

@EPashkin
Copy link
Member

Better do regen with same gir version if possible.
IMHO Char need ToGlib/FromGlib for gir can generate functions (and this too).
I don't found comments about Fundamental: UChar in gtk-rs, but this type maybe also needed.

@EPashkin
Copy link
Member

@federicomenaquintero I'm very sorry for long delay.
You agree to add UChar type with same functionality?
I almost "fixed" generator, so manual implementation for KeyFile::set_list_separator will not needed.

@EPashkin
Copy link
Member

EPashkin commented Dec 7, 2017

@GuillaumeGomez, seems @federicomenaquintero don't have time, maybe we just merge PR as is and then I make PR that add UChar and KeyFile::set_list_separator generation?

@GuillaumeGomez
Copy link
Member

Sure, let's do it like that then. Thanks everyone!

@GuillaumeGomez GuillaumeGomez merged commit ed90523 into gtk-rs:master Dec 7, 2017
@EPashkin EPashkin mentioned this pull request Dec 7, 2017
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.

4 participants