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

Rename SelectionData get_data_with_length method to get_data #762

Merged
merged 1 commit into from Jan 23, 2019

Conversation

Projects
None yet
4 participants
@osa1
Copy link
Contributor

osa1 commented Jan 23, 2019

No description provided.

@osa1

This comment has been minimized.

Copy link
Contributor Author

osa1 commented Jan 23, 2019

Ping @sdroege

Show resolved Hide resolved src/selection_data.rs Outdated
@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Jan 23, 2019

@osa1 Thanks
👍

@osa1 osa1 force-pushed the osa1:update_selectiondata_method branch from ee17cf1 to 57b87de Jan 23, 2019

pub fn get_data(&self) -> Vec<u8> {
unsafe {
let mut length = mem::uninitialized();
let ret = FromGlibContainer::from_glib_none_num(ffi::gtk_selection_data_get_data_with_length(self.to_glib_none().0, &mut length), length as usize);

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jan 23, 2019

Member

Will length be used after its value change from the C call or before? (I'm very curious about this!)

This comment has been minimized.

@osa1

osa1 Jan 23, 2019

Author Contributor

That's a good question. This code is actually auto-generated, I just copied it from the auto/ directory to here and renamed it. Perhaps it's a good idea to make it explicit by adding one more line that length will be used after being initialized.

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jan 23, 2019

Member

What do you think about it @EPashkin @sdroege ?

This comment has been minimized.

@sdroege

sdroege Jan 23, 2019

Member

It will only be written to by the C function. See that it's marked as out via the annotations, not as inout.

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jan 23, 2019

Member

It wasn't my point. The value received by from_glib_none_mut will be the one of length before its modification in the C function or after?

This comment has been minimized.

@sdroege

sdroege Jan 23, 2019

Member

Oh... I see. Evaluation order is defined/guaranteed, yes. Inside-out, left-to-right. In this specific case that means

  1. self.to_glib_none().0
  2. &mut length
  3. gtk_selection_data_get_data_with_length()
  4. length as usize
  5. from_glib_none_num()
  6. ret = ...

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jan 23, 2019

Member

Thanks for the clarification!

This comment has been minimized.

@EPashkin

EPashkin Jan 23, 2019

Member

As I know, first get_data called, then its result pushed to stack, length pushed and next from_glib_none_num called.

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jan 23, 2019

👍

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Jan 23, 2019

Just waiting for CI then I merge. Thanks!

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jan 23, 2019

@GuillaumeGomez all green apart from the examples being generally broken now :)

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Jan 23, 2019

Oh indeed. Merging then!

@GuillaumeGomez GuillaumeGomez merged commit 86467e7 into gtk-rs:master Jan 23, 2019

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
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.