-
-
Notifications
You must be signed in to change notification settings - Fork 31
Conversation
|
||
impl Subprocess { | ||
//#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
//pub fn new<'a, P: Into<Option<&'a Error>>>(flags: SubprocessFlags, error: P, argv0: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Subprocess { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a crate that we could use to give VarArgs
: https://crates.io/crates/va_list-rs (apparently, you can just give a va_list
as a VarArgs
argument so why not enjoying this?). Should we give it a try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it worth to try but not in this PR (or if PR not merged until next release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we discussed that a while ago on IRC and I believe there are some safety concerns there. Have to look again, I can't remember :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't intend to put it in this PR but since I had the chance to talk about it... 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the newv
variant is equivalent and more Rust-y :)
src/auto/inet_address_mask.rs
Outdated
pub trait InetAddressMaskExt { | ||
fn equal(&self, mask2: &InetAddressMask) -> bool; | ||
|
||
fn get_address(&self) -> Option<InetAddress>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this really return None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it cannot.
src/auto/subprocess.rs
Outdated
//} | ||
|
||
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
pub fn newv(argv: &[&std::path::Path], flags: SubprocessFlags) -> Result<Subprocess, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argv
should be an OsString
AFAIU
src/auto/subprocess_launcher.rs
Outdated
//fn spawn(&self, error: &mut Error, argv0: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<Subprocess>; | ||
|
||
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
fn spawnv(&self, argv: &[&std::path::Path]) -> Result<Subprocess, Error>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OsString
as above
src/auto/subprocess_launcher.rs
Outdated
fn set_stdout_file_path<P: AsRef<std::path::Path>>(&self, path: P); | ||
|
||
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
fn setenv<P: AsRef<std::path::Path>, Q: AsRef<std::path::Path>>(&self, variable: P, value: Q, overwrite: bool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OsString
as above (or rather they should all be &OsStr
, there's a gir parameter for this)
src/auto/subprocess_launcher.rs
Outdated
fn spawnv(&self, argv: &[&std::path::Path]) -> Result<Subprocess, Error>; | ||
|
||
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
fn take_fd(&self, source_fd: i32, target_fd: i32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be wrappers around RawFd
on UNIX and Handle
on Windows. All the fd related functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fd functions are also unsafe, as you can safely create a random fd (it's just a type alias for an integer) and then having GLib use that will cause problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean they must be marked as unsafe
src/auto/subprocess_launcher.rs
Outdated
fn take_stdout_fd(&self, fd: i32); | ||
|
||
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
fn unsetenv<P: AsRef<std::path::Path>>(&self, variable: P); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OsString
Looks generally good except for those comments above. Thanks for working on this :) This will become a good release for GIO! |
I hope it'll! I need to understand what's happening on the appveyor failure as well. Some duplicate implementations apparently... |
Duplicate trait happened on travis too. |
I'll test and we'll see. In worst case, I'll just copy/paste the whole file and ignore its generation... |
The We need a way to opt-out of the automatic |
You can ignore the |
Updated. |
c303880
to
7c59612
Compare
7c59612
to
3ac3424
Compare
src/subprocess_launcher.rs
Outdated
use ffi; | ||
use glib; | ||
use glib::object::IsA; | ||
use GtkRawFd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this one, and it will also make the API unsafe as you can pass random integers in there now. There's a reason why I said to use the proper traits for this :)
src/subprocess_launcher.rs
Outdated
|
||
pub trait SubprocessLauncherExtManual { | ||
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
fn take_fd(&self, source_fd: GtkRawFd, target_fd: GtkRawFd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should all take a https://doc.rust-lang.org/nightly/std/os/unix/io/trait.IntoRawFd.html on UNIX and https://doc.rust-lang.org/nightly/std/os/windows/io/trait.IntoRawHandle.html on Windows to be safe (the safety aspect is then moved to the implementors of that trait and people can safely pass various types in there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was wrong, my link only for sockets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically same thing though, yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I had unsafe in mind, but I don't get why I didn't think about AsRawFd
and AsRawHandle
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Into, not As :) this takes ownership. And it does not have to be unsafe then because the trait impls already take care of that being safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True!
Okay, the safe version is now here! |
32b8e6e
to
32928bb
Compare
After multiple windows fixes, does it seem good? |
Travis don't think so 😭 |
By way, seems manual function in |
Another bug in |
878b06c
to
312e5fa
Compare
Futures bug now in beta too :( |
These are missing imports in the Same for the beta problems. |
Gir.toml
Outdated
name = "communicate_utf8_async" | ||
ignore = true | ||
[[object.function]] | ||
name = "communicate_utf8_async_future" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to ignore that one here. It is generated as a result of the non-futures function and does not exist as such in C
src/subprocess.rs
Outdated
use send_cell::SendCell; | ||
|
||
let stdin_buf = stdin_buf.into(); | ||
let stdin_buf = stdin_buf.map(ToOwned::to_owned); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It already is a String
, there's nothing to convert here. But you could make it take a &str
and do the copy internally here like you do already
src/subprocess.rs
Outdated
let stdin_buf = stdin_buf.to_glib_none(); | ||
let cancellable = cancellable.into(); | ||
let cancellable = cancellable.to_glib_none(); | ||
let user_data: Box<Box<(R, *mut i8)>> = Box::new(Box::new((callback, stdin_buf.0))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stdin_buf
has to be the result of to_glib_full()
as you want to keep it alive until the trampoline ran and then free it there.
0215a3d
to
600674f
Compare
Updated! |
src/subprocess_launcher.rs
Outdated
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
use SubprocessLauncher; | ||
#[cfg(any(feature = "v2_40", feature = "dox"))] | ||
use ffi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This better have same cfg as functions, see warning in appveyor
src/subprocess_launcher.rs
Outdated
#[cfg(any(all(feature = "v2_40", not(windows)), all(feature = "dox", not(windows))))] | ||
use std::os::unix::io::IntoRawFd; | ||
#[cfg(all(feature = "dox", windows))] | ||
pub trait IntoRawFd {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO better use unix
and not(unix)
instead
Looks good, thanks |
Go for it then :) |
I want to update following @EPashkin's comments first. Then I merge. :) Thanks a lot to both of you for your reviews! |
src/subprocess_launcher.rs
Outdated
/// Replacement for "real" [`IntoRawFd`] trait for non-unix targets. | ||
/// | ||
/// [`IntoRawFd`]: https://doc.rust-lang.org/std/os/unix/io/trait.IntoRawFd.html | ||
pub trait IntoRawFd {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your check don't allow doc comments here, you need add it to lgpl-docs, but not sure that it restored in right place.
Also IMHO better not mixing windows
and unix
and use only unix
(in all this file)
for |
Great! Complained about that here, let's see what they reply https://users.rust-lang.org/t/futures-0-2-has-been-moved-to-futures-preview/18329/2?u=slomo |
Maybe only needs moving to the futures-preview crates instead, I'll check later |
src/subprocess_launcher.rs
Outdated
@@ -1,36 +1,36 @@ | |||
#[cfg(any(feature = "v2_40", feature = "dox"))] | |||
use SubprocessLauncher; | |||
#[cfg(any(all(feature = "v2_40", not(windows)), feature = "dox"))] | |||
#[cfg(any(all(feature = "v2_40", not(unix)), feature = "dox"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong change, as windows ~= not(unix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups indeed!
6df4ce2
to
2d7017a
Compare
I fixed conditions. |
Currently preparing gio-futures PR, then this can be merged IMHO |
@GuillaumeGomez Docs on windows failed
|
.. and doc comments will be not accepted anyway it need be added to lgpl-docs |
This is really annoying. :-/ I'll open a PR to remove it from here. |
Add new types
cc @sdroege @EPashkin