From f56c857bf5f1cc95252cf9ed0d874f50626e687f Mon Sep 17 00:00:00 2001 From: Evgenii Pashkin Date: Sat, 19 Mar 2016 19:15:56 +0300 Subject: [PATCH 1/2] Cast trampolines before transmuting --- src/signal.rs | 224 +++++++++++++++++++++++++------------------------- 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/src/signal.rs b/src/signal.rs index 51ee6c361b..759a7b4fdd 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -90,7 +90,7 @@ pub fn idle_add(func: F) -> u32 where F: FnMut() -> Continue + 'static { assert_initialized_main_thread!(); unsafe { - glib_ffi::g_idle_add_full(glib_ffi::G_PRIORITY_DEFAULT_IDLE, transmute(trampoline), + glib_ffi::g_idle_add_full(glib_ffi::G_PRIORITY_DEFAULT_IDLE, transmute(trampoline as usize), into_raw(func), Some(destroy_closure)) } } @@ -109,7 +109,7 @@ pub fn timeout_add(interval: u32, func: F) -> u32 where F: FnMut() -> Continue + 'static { assert_initialized_main_thread!(); unsafe { - glib_ffi::g_timeout_add_full(glib_ffi::G_PRIORITY_DEFAULT, interval, transmute(trampoline), + glib_ffi::g_timeout_add_full(glib_ffi::G_PRIORITY_DEFAULT, interval, transmute(trampoline as usize), into_raw(func), Some(destroy_closure)) } } @@ -128,7 +128,7 @@ pub fn timeout_add_seconds(interval: u32, func: F) -> u32 assert_initialized_main_thread!(); unsafe { glib_ffi::g_timeout_add_seconds_full(glib_ffi::G_PRIORITY_DEFAULT, interval, - transmute(trampoline), into_raw(func), Some(destroy_closure)) + transmute(trampoline as usize), into_raw(func), Some(destroy_closure)) } } @@ -214,7 +214,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "accel-closures-changed", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -222,7 +222,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "button-press-event", - transmute(event_button_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_button_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -231,7 +231,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "button-release-event", - transmute(event_button_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_button_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -239,7 +239,7 @@ mod widget { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "can-activate-accel", - transmute(accel_trampoline::), Box::into_raw(f) as *mut _) + transmute(accel_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -247,7 +247,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "composited-changed", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -255,7 +255,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "configure-event", - transmute(event_configure_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_configure_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -263,7 +263,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "damage-event", - transmute(event_expose_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_expose_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -271,7 +271,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "delete-event", - transmute(event_any_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_any_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -279,7 +279,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "destroy", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -287,7 +287,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "destroy-event", - transmute(event_any_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_any_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -295,7 +295,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "direction-changed", - transmute(text_direction_trampoline::), Box::into_raw(f) as *mut _) + transmute(text_direction_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -303,7 +303,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "draw", - transmute(draw_trampoline::), Box::into_raw(f) as *mut _) + transmute(draw_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -312,7 +312,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "enter-notify-event", - transmute(event_crossing_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_crossing_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -320,7 +320,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "event", - transmute(event_any_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_any_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -328,7 +328,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "event-after", - transmute(event_any_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_any_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -336,7 +336,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "focus", - transmute(direction_trampoline::), Box::into_raw(f) as *mut _) + transmute(direction_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -344,7 +344,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "focus-in-event", - transmute(event_focus_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_focus_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -352,7 +352,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "focus-out-event", - transmute(event_focus_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_focus_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -361,7 +361,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "grab-broken-event", - transmute(event_grab_broken_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_grab_broken_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -369,7 +369,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "grab-focus", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -377,7 +377,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "grab-notify", - transmute(grab_trampoline::), Box::into_raw(f) as *mut _) + transmute(grab_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -385,7 +385,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "hide", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -393,7 +393,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "keynav-failed", - transmute(direction_trampoline::), Box::into_raw(f) as *mut _) + transmute(direction_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -401,7 +401,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "key-press-event", - transmute(event_key_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_key_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -409,7 +409,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "key-release-event", - transmute(event_key_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_key_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -418,7 +418,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "leave-notify-event", - transmute(event_crossing_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_crossing_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -426,7 +426,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "map", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -434,7 +434,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "map-event", - transmute(event_any_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_any_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -442,7 +442,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "mnemonic-activate", - transmute(mnemonic_trampoline::), Box::into_raw(f) as *mut _) + transmute(mnemonic_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -450,7 +450,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "move-focus", - transmute(direction_void_trampoline::), Box::into_raw(f) as *mut _) + transmute(direction_void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -459,7 +459,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "motion-notify-event", - transmute(event_motion_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_motion_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -468,7 +468,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "property-notify-event", - transmute(event_property_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_property_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -477,7 +477,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "proximity-in-event", - transmute(event_proximity_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_proximity_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -486,7 +486,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "proximity-out-event", - transmute(event_proximity_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_proximity_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -494,7 +494,7 @@ mod widget { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "popup-menu", - transmute(bool_trampoline::), Box::into_raw(f) as *mut _) + transmute(bool_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -504,7 +504,7 @@ mod widget { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "query-tooltip", - transmute(query_trampoline::), Box::into_raw(f) as *mut _) + transmute(query_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -512,7 +512,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "realize", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -520,7 +520,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "screen-changed", - transmute(screen_trampoline::), Box::into_raw(f) as *mut _) + transmute(screen_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -528,7 +528,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "scroll-event", - transmute(event_scroll_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_scroll_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -536,7 +536,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "show", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -544,7 +544,7 @@ mod widget { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "show-help", - transmute(help_trampoline::), Box::into_raw(f) as *mut _) + transmute(help_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -552,7 +552,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "size-allocate", - transmute(rectangle_trampoline::), Box::into_raw(f) as *mut _) + transmute(rectangle_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -560,7 +560,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "state-flags-changed", - transmute(state_trampoline::), Box::into_raw(f) as *mut _) + transmute(state_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -568,7 +568,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "style-updated", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -576,7 +576,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "touch-event", - transmute(event_any_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_any_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -584,7 +584,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "unmap", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -592,7 +592,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "unmap-event", - transmute(event_any_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_any_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -600,7 +600,7 @@ mod widget { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "unrealize", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -609,7 +609,7 @@ mod widget { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "window-state-event", - transmute(event_window_state_trampoline::), Box::into_raw(f) as *mut _) + transmute(event_window_state_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -843,7 +843,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "activate", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -851,7 +851,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "backspace", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -859,7 +859,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "copy_clipboard", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -867,7 +867,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "cut_clipboard", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -875,7 +875,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "paste_clipboard", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -883,7 +883,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "toggle_overwrite", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -891,7 +891,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "delete_from_cursor", - transmute(delete_trampoline::), Box::into_raw(f) as *mut _) + transmute(delete_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -899,7 +899,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "move_cursor", - transmute(move_cursor_trampoline::), Box::into_raw(f) as *mut _) + transmute(move_cursor_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -907,7 +907,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "insert_at_cursor", - transmute(string_trampoline::), Box::into_raw(f) as *mut _) + transmute(string_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -915,7 +915,7 @@ mod entry { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "preedit_changed", - transmute(string_trampoline::), Box::into_raw(f) as *mut _) + transmute(string_trampoline:: as usize), Box::into_raw(f) as *mut _) } } } @@ -968,7 +968,7 @@ mod button { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "activate", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -976,7 +976,7 @@ mod button { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "clicked", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } } @@ -1009,7 +1009,7 @@ mod combobox { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "changed", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1017,7 +1017,7 @@ mod combobox { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "move-active", - transmute(move_trampoline::), Box::into_raw(f) as *mut _) + transmute(move_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1025,7 +1025,7 @@ mod combobox { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "popdown", - transmute(bool_trampoline::), Box::into_raw(f) as *mut _) + transmute(bool_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1033,7 +1033,7 @@ mod combobox { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "popup", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } } @@ -1076,7 +1076,7 @@ mod tool_button { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "clicked", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } } @@ -1105,7 +1105,7 @@ mod toggle_button { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "toggled", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1133,7 +1133,7 @@ mod cell_renderer_toggle { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "toggled", - transmute(string_path_trampoline), Box::into_raw(f) as *mut _) + transmute(string_path_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1163,7 +1163,7 @@ mod spin_button { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "value-changed", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1171,7 +1171,7 @@ mod spin_button { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "clicked", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1201,7 +1201,7 @@ mod dialog { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "close", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1209,7 +1209,7 @@ mod dialog { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "response", - transmute(int_trampoline::), Box::into_raw(f) as *mut _) + transmute(int_trampoline:: as usize), Box::into_raw(f) as *mut _) } } } @@ -1261,7 +1261,7 @@ mod tree_view { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "columns-changed", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1269,7 +1269,7 @@ mod tree_view { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "cursor-changed", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1278,7 +1278,7 @@ mod tree_view { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "expand-collapse-cursor-row", - transmute(bool3_bool_trampoline), Box::into_raw(f) as *mut _) + transmute(bool3_bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1286,7 +1286,7 @@ mod tree_view { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "row-activated", - transmute(path_column_trampoline), Box::into_raw(f) as *mut _) + transmute(path_column_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1294,7 +1294,7 @@ mod tree_view { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "row-collapsed", - transmute(iter_path_trampoline), Box::into_raw(f) as *mut _) + transmute(iter_path_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1302,7 +1302,7 @@ mod tree_view { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "row-expanded", - transmute(iter_path_trampoline), Box::into_raw(f) as *mut _) + transmute(iter_path_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1310,7 +1310,7 @@ mod tree_view { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "select-all", - transmute(bool_trampoline), Box::into_raw(f) as *mut _) + transmute(bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1318,7 +1318,7 @@ mod tree_view { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "select-cursor-parent", - transmute(bool_trampoline), Box::into_raw(f) as *mut _) + transmute(bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1326,7 +1326,7 @@ mod tree_view { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "select-cursor-row", - transmute(bool_bool_trampoline), Box::into_raw(f) as *mut _) + transmute(bool_bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1334,7 +1334,7 @@ mod tree_view { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "start-interactive-search", - transmute(bool_trampoline), Box::into_raw(f) as *mut _) + transmute(bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1344,7 +1344,7 @@ mod tree_view { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "test-collapse-row", - transmute(iter_path_bool_trampoline), Box::into_raw(f) as *mut _) + transmute(iter_path_bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1354,7 +1354,7 @@ mod tree_view { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "test-expand-row", - transmute(iter_path_bool_trampoline), Box::into_raw(f) as *mut _) + transmute(iter_path_bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1362,7 +1362,7 @@ mod tree_view { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "toggle-cursor-row", - transmute(bool_trampoline), Box::into_raw(f) as *mut _) + transmute(bool_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1370,7 +1370,7 @@ mod tree_view { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "unselect-all", - transmute(bool_trampoline), Box::into_raw(f) as *mut _) + transmute(bool_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1443,7 +1443,7 @@ mod range { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "adjust-bounds", - transmute(adjust_trampoline::), Box::into_raw(f) as *mut _) + transmute(adjust_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1451,7 +1451,7 @@ mod range { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "change-value", - transmute(change_trampoline::), Box::into_raw(f) as *mut _) + transmute(change_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1459,7 +1459,7 @@ mod range { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "move-slider", - transmute(move_trampoline::), Box::into_raw(f) as *mut _) + transmute(move_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1467,7 +1467,7 @@ mod range { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "value-changed", - transmute(void_trampoline::), Box::into_raw(f) as *mut _) + transmute(void_trampoline:: as usize), Box::into_raw(f) as *mut _) } } @@ -1506,7 +1506,7 @@ impl Adjustment { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "value-changed", - transmute(adjustment_trampoline), Box::into_raw(f) as *mut _) + transmute(adjustment_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1521,7 +1521,7 @@ impl TreeSelection { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "changed", - transmute(tree_selection_trampoline), Box::into_raw(f) as *mut _) + transmute(tree_selection_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1537,7 +1537,7 @@ impl TreeViewColumn { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "clicked", - transmute(tree_view_column_trampoline), Box::into_raw(f) as *mut _) + transmute(tree_view_column_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1565,7 +1565,7 @@ mod gl_area { unsafe { let f: Box gdk::GLContext + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0,"create-context", - transmute(gl_context_trampoline), Box::into_raw(f) as *mut _) + transmute(gl_context_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1573,7 +1573,7 @@ mod gl_area { unsafe { let f: Box Inhibit + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0,"render", - transmute(gl_area_trampoline), Box::into_raw(f) as *mut _) + transmute(gl_area_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1627,7 +1627,7 @@ mod calendar { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "day-selected", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1635,7 +1635,7 @@ mod calendar { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "day-selected-double-click", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1643,7 +1643,7 @@ mod calendar { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "month-changed", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1651,7 +1651,7 @@ mod calendar { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "next-month", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1659,7 +1659,7 @@ mod calendar { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "next-year", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1667,7 +1667,7 @@ mod calendar { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "prev-month", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1675,7 +1675,7 @@ mod calendar { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "prev-year", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } } @@ -1712,7 +1712,7 @@ mod status_icon { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "activate", - transmute(void_trampoline), Box::into_raw(f) as *mut _) + transmute(void_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1720,7 +1720,7 @@ mod status_icon { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "button-press-event", - transmute(event_trampoline), Box::into_raw(f) as *mut _) + transmute(event_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1728,7 +1728,7 @@ mod status_icon { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "button-release-event", - transmute(event_trampoline), Box::into_raw(f) as *mut _) + transmute(event_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1736,7 +1736,7 @@ mod status_icon { unsafe { let f: Box> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "popup-menu", - transmute(popup_menu_trampoline), Box::into_raw(f) as *mut _) + transmute(popup_menu_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1744,7 +1744,7 @@ mod status_icon { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "query-tooltip", - transmute(query_tooltip_trampoline), Box::into_raw(f) as *mut _) + transmute(query_tooltip_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1752,7 +1752,7 @@ mod status_icon { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "scroll-event", - transmute(event_trampoline), Box::into_raw(f) as *mut _) + transmute(event_trampoline as usize), Box::into_raw(f) as *mut _) } } @@ -1760,7 +1760,7 @@ mod status_icon { unsafe { let f: Box bool + 'static>> = Box::new(Box::new(f)); connect(self.to_glib_none().0, "size-changed", - transmute(size_changed_trampoline), Box::into_raw(f) as *mut _) + transmute(size_changed_trampoline as usize), Box::into_raw(f) as *mut _) } } } From 63b8c0a72b751c230bd0a57015011f8e835a4dcc Mon Sep 17 00:00:00 2001 From: Evgenii Pashkin Date: Sun, 20 Mar 2016 23:50:20 +0300 Subject: [PATCH 2/2] Don't use transmute on some trampoline --- src/signal.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/signal.rs b/src/signal.rs index 759a7b4fdd..5152ab49c3 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -64,8 +64,9 @@ impl ToGlib for Inhibit { // idle_add and timeout_add fixed to the main thread -extern "C" fn trampoline(func: &RefCell Continue + 'static>>) -> gboolean { +unsafe extern "C" fn trampoline(func: gpointer) -> gboolean { callback_guard!(); + let func: &RefCell Continue + 'static>> = transmute(func); (&mut *func.borrow_mut())().to_glib() } @@ -90,7 +91,7 @@ pub fn idle_add(func: F) -> u32 where F: FnMut() -> Continue + 'static { assert_initialized_main_thread!(); unsafe { - glib_ffi::g_idle_add_full(glib_ffi::G_PRIORITY_DEFAULT_IDLE, transmute(trampoline as usize), + glib_ffi::g_idle_add_full(glib_ffi::G_PRIORITY_DEFAULT_IDLE, Some(trampoline), into_raw(func), Some(destroy_closure)) } } @@ -109,7 +110,7 @@ pub fn timeout_add(interval: u32, func: F) -> u32 where F: FnMut() -> Continue + 'static { assert_initialized_main_thread!(); unsafe { - glib_ffi::g_timeout_add_full(glib_ffi::G_PRIORITY_DEFAULT, interval, transmute(trampoline as usize), + glib_ffi::g_timeout_add_full(glib_ffi::G_PRIORITY_DEFAULT, interval, Some(trampoline), into_raw(func), Some(destroy_closure)) } } @@ -128,7 +129,7 @@ pub fn timeout_add_seconds(interval: u32, func: F) -> u32 assert_initialized_main_thread!(); unsafe { glib_ffi::g_timeout_add_seconds_full(glib_ffi::G_PRIORITY_DEFAULT, interval, - transmute(trampoline as usize), into_raw(func), Some(destroy_closure)) + Some(trampoline), into_raw(func), Some(destroy_closure)) } }