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

WIP: Don't generate any but the main IsA<_> bound for extension traits #672

Merged
merged 1 commit into from Nov 30, 2018

Conversation

Projects
None yet
3 participants
@sdroege
Copy link
Member

sdroege commented Nov 29, 2018

Closes #670

@sdroege sdroege force-pushed the sdroege:fewer-bounds branch from e24d2bc to 435de99 Nov 29, 2018

@sdroege

This comment has been minimized.

Copy link
Member Author

sdroege commented Nov 29, 2018

And now without the other commit. @EPashkin what do you think about this generally?

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Nov 29, 2018

Result seems "hacky" (especially emit calls), but seems works good.
I don't see problem in gir code.

For reference there main changes:

-impl<O: IsA<AboutDialog> + IsA<glib::object::Object>> AboutDialogExt for O {
+impl<O: 'static + IsA<AboutDialog>> AboutDialogExt for O {
...
fn connect_activate_link<F: Fn(&Self, &str) -> Inhibit + 'static>(&self, f: F) -> SignalHandlerId {
         unsafe {
             let f: Box_<Box_<Fn(&Self, &str) -> Inhibit + 'static>> = Box_::new(Box_::new(f));
-            connect(self.to_glib_none().0, "activate-link",
+            connect(self.to_glib_none().0 as *mut _, "activate-link",
                 transmute(activate_link_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
         }
     }
...
-impl<O: IsA<ActionBar> + IsA<Container>> ActionBarExt for O {
+impl<O: 'static + IsA<ActionBar>> ActionBarExt for O {
...
     fn get_child_pack_type<T: IsA<Widget>>(&self, item: &T) -> PackType {
         unsafe {
             let mut value = Value::from_type(<PackType as StaticType>::static_type());
-            ffi::gtk_container_child_get_property(self.to_glib_none().0, item.to_glib_none().0, "pack-type".to_glib_none().0, value.to_glib_none_mut().0);
+            ffi::gtk_container_child_get_property(self.to_glib_none().0 as *mut ffi::GtkContainer, item.to_glib_none().0, "bpack-type\0".as_ptr() as *const _, value.to_glib_none_mut().0);
             value.get().unwrap()
         }
     }
...
     fn emit_escape(&self) {
-        let _ = self.emit("escape", &[]).unwrap();
+        let _ = unsafe { glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_ffi::GObject).emit("escape", &[]).unwrap() };
     }
@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Nov 29, 2018

So overall it really removes extra restriction. thanks

@sdroege

This comment has been minimized.

Copy link
Member Author

sdroege commented Nov 29, 2018

The emit one will be nicer once I'm done with my next changes related to making IsA object-safe :)

@sdroege

This comment has been minimized.

Copy link
Member Author

sdroege commented Nov 30, 2018

Ok then I clean this up later or some time this weekend and we can get it in for now to keep PRs small?

@EPashkin EPashkin merged commit bdc4404 into gtk-rs:master Nov 30, 2018

2 checks passed

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

This comment has been minimized.

Copy link
Member Author

sdroege commented Nov 30, 2018

@EPashkin erm, I first meant to clean up the commit before it's merged :) Ok, will do so later in a second PR then!

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Nov 30, 2018

Yes, I was too hurry, sorry

@sdroege

This comment has been minimized.

Copy link
Member Author

sdroege commented Nov 30, 2018

Not going to get to that today anymore, but I won't forget :) No problem, the code is doing the right thing it's just not the most beautiful code

@philn

This comment has been minimized.

Copy link
Contributor

philn commented Dec 1, 2018

The generated code broke gstreamer-rs:

                                                                                                                                                                                                                  
error[E0282]: type annotations needed                                                                                                                                                                              
  --> gstreamer/src/auto/pad_template.rs:64:48                                                                                                                                                                     
   |                                                                                                                                                                                                               
64 |             gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, "bdirection\0".as_ptr() as *const _, value.to_glib_none_mut().0);                                          
   |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `P`                                                                                   
   |                                                                                                                                                                                                               
   = note: type must be known at this point                                                                                                                                                                        
                                                                                                                                                                                                                   
error[E0282]: type annotations needed                                                                                                                                                                              
  --> gstreamer/src/auto/pad_template.rs:73:48                                                                                                                                                                     
   |                                                                                                                                                                                                               
73 |             gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, "bgtype\0".as_ptr() as *const _, value.to_glib_none_mut().0);                                              
   |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `P`                                                                                   
   |                                                                                                                                                                                                               
   = note: type must be known at this point                  

And so on.

@sdroege

This comment has been minimized.

Copy link
Member Author

sdroege commented Dec 1, 2018

Thanks, will check tomorrow. I know why this happens.

Should also completely disappear once I got my IsA refactoring done in the next days, so maybe waiting for that

@sdroege

This comment has been minimized.

Copy link
Member Author

sdroege commented Dec 3, 2018

Basically we'll need to distinguish between being inside a trait impl or not. In trait impls we currently need the cast (and later something else), outside trait impls we need nothing and can directly call without a cast (and later something different for the calls that are for a parent type)

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Dec 7, 2018

@sdroege For next PR: There wrong string ""b{}\0" in src/codegen/property_body.rs, as result it tried work with child properties like "bexpand", "bfill" etc.

@EPashkin EPashkin referenced this pull request Dec 8, 2018

Merged

Various minor fixes #673

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.