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

Few improvements on user callback generation #706

Merged
merged 6 commits into from Jan 28, 2019

Conversation

Projects
None yet
3 participants
@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jan 26, 2019

Fixes #704.

This currently fixes two things:

  • Remove the invalid indirection (Box::<Option<X>>.as_ptr() -> &Box<Option<X>> is not longer a thing)
  • Added the missing Option (yep, everything is an Option by default) (it's now correctly handled everywhere)
  • No more GString parameters: they're replaced with &str now
  • Fix invalid Send/Sync bounds (by default, I was giving both of them :p)
  • Fix invalid nullable "status" from destroy callbacks.

I intend to fix the other issues on this PR as well so please don't merge! :)

@EPashkin EPashkin changed the title Few improvements on user callback generation WIP: Few improvements on user callback generation Jan 26, 2019

@@ -356,7 +356,7 @@ impl Builder {
if is_destroy || trampoline.scope.is_async() {
format!("Box_::from_raw({} as *mut _)", func)
} else if trampoline.scope.is_call() {
format!("{} as *const _ as usize as *mut {}",
format!("{} as *const _ as usize as *mut Option<{}>",

This comment has been minimized.

@sdroege

sdroege Jan 26, 2019

Member

Why do we store scope call in an Option<_>? See here how the generated code should look like

Option<_> should only be needed if the closure is optional or for FnOnce

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jan 26, 2019

Author Member

Simpler that way. Everything is an Option. :)

This comment has been minimized.

@sdroege

sdroege Jan 26, 2019

Member

On one side, yes. On the other side you need to unwrap the Option<_>, which adds code (quite a bit due to potentially panicking) and also involves runtime costs :)

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jan 26, 2019

Author Member

And of course you're right. I'll need to add another field to know if the callback is nullable. I'll do it next.

@GuillaumeGomez GuillaumeGomez force-pushed the GuillaumeGomez:user-callbacks branch 2 times, most recently from 9b790b0 to a8a1b8c Jan 26, 2019

@GuillaumeGomez GuillaumeGomez changed the title WIP: Few improvements on user callback generation Few improvements on user callback generation Jan 27, 2019

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Jan 27, 2019

I think this is ready! If you want to look at the result, take a look at gtk-rs/gtk#760

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jan 27, 2019

I think this is ready! If you want to look at the result, take a look at gtk-rs/gtk#760

Great :) I'll review tomorrow or maybe later

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Jan 27, 2019

I fixed the nullable bug spotted on gtk PR (which has been updated too).

@@ -389,7 +397,7 @@ fn analyze_function(
Some(obj) => {
match env.library.type_(type_tid) {
library::Type::Class(_) => obj.concurrency,
_ => library::Concurrency::SendSync,
_ => library::Concurrency::None,

This comment has been minimized.

@EPashkin

EPashkin Jan 27, 2019

Member

Maybe interface and record need be here too,
please add comment for checking later (at first glance I don't find any)

This comment has been minimized.

@GuillaumeGomez

GuillaumeGomez Jan 27, 2019

Author Member

Good point! I add the comment.

This comment has been minimized.

@sdroege

sdroege Jan 28, 2019

Member

Both are needed here, yes.

This comment has been minimized.

@sdroege

sdroege Jan 28, 2019

Member

I mean, add them and not just a FIXME comment :P

@GuillaumeGomez GuillaumeGomez force-pushed the GuillaumeGomez:user-callbacks branch from 5802a4d to 6e51a29 Jan 27, 2019

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jan 28, 2019

👍 (after adding record/interface!)

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Jan 28, 2019

Updated.

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jan 28, 2019

All good for me

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Jan 28, 2019

Then lets merge, @GuillaumeGomez Thanks

@EPashkin EPashkin merged commit c28c3c1 into gtk-rs:master Jan 28, 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

@GuillaumeGomez GuillaumeGomez deleted the GuillaumeGomez:user-callbacks branch Jan 28, 2019

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Jan 28, 2019

I'll send the regens this evening.

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.