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

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

merged 3 commits into from Dec 7, 2017


None yet
4 participants

federicomenaquintero commented Nov 12, 2017

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.

Add a new Char wrapper, for chars that can be represented as i8
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

This comment has been minimized.


sdroege Nov 12, 2017


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
name = "set_list_separator"
# separator parameter neds to be a glib::Char

This comment has been minimized.


This comment has been minimized.


EPashkin commented Nov 12, 2017

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.


This comment has been minimized.


EPashkin commented Nov 26, 2017

@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.


This comment has been minimized.


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?


This comment has been minimized.


GuillaumeGomez commented Dec 7, 2017

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

@GuillaumeGomez GuillaumeGomez merged commit ed90523 into gtk-rs:master Dec 7, 2017

2 checks passed

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

@EPashkin EPashkin referenced this pull request Dec 7, 2017


Char wrapper 2 #274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment