@@ -14,6 +14,8 @@ pub type PinnedFuture = Pin<Box<dyn Future<Output = Result<(), Error>> + 'static
14
14
#[ repr( C ) ]
15
15
pub struct BaseButtonClass {
16
16
pub parent_class : gtk:: ffi:: GtkButtonClass ,
17
+ // If these functions are meant to be called from C, you need to make these functions
18
+ // `extern "C"` & use FFI-safe types (usually raw pointers).
17
19
pub sync_method : Option < unsafe fn ( & BaseButtonInstance , extra_text : Option < String > ) > ,
18
20
pub async_method : Option < unsafe fn ( & BaseButtonInstance ) -> PinnedFuture > ,
19
21
}
@@ -22,38 +24,27 @@ unsafe impl ClassStruct for BaseButtonClass {
22
24
type Type = BaseButton ;
23
25
}
24
26
25
- impl std:: ops:: Deref for BaseButtonClass {
26
- type Target = glib:: Class < glib:: Object > ;
27
-
28
- fn deref ( & self ) -> & Self :: Target {
29
- unsafe { & * ( self as * const _ as * const Self :: Target ) }
30
- }
31
- }
32
-
33
- impl std:: ops:: DerefMut for BaseButtonClass {
34
- fn deref_mut ( & mut self ) -> & mut glib:: Class < glib:: Object > {
35
- unsafe { & mut * ( self as * mut _ as * mut glib:: Class < glib:: Object > ) }
36
- }
37
- }
38
-
39
27
#[ derive( Debug , Default ) ]
40
28
pub struct BaseButton ;
41
29
42
30
// Virtual method default implementation trampolines
43
- unsafe fn sync_method_default_trampoline ( this : & BaseButtonInstance , extra_text : Option < String > ) {
31
+ fn sync_method_default_trampoline ( this : & BaseButtonInstance , extra_text : Option < String > ) {
44
32
BaseButton :: from_instance ( this) . sync_method ( this, extra_text)
45
33
}
46
34
47
- unsafe fn async_method_default_trampoline ( this : & BaseButtonInstance ) -> PinnedFuture {
35
+ fn async_method_default_trampoline ( this : & BaseButtonInstance ) -> PinnedFuture {
48
36
BaseButton :: from_instance ( this) . async_method ( this)
49
37
}
50
38
51
- pub unsafe fn base_button_sync_method ( this : & BaseButtonInstance , extra_text : Option < String > ) {
39
+ pub ( super ) unsafe fn base_button_sync_method (
40
+ this : & BaseButtonInstance ,
41
+ extra_text : Option < String > ,
42
+ ) {
52
43
let klass = & * ( this. class ( ) as * const _ as * const BaseButtonClass ) ;
53
44
( klass. sync_method . unwrap ( ) ) ( this, extra_text)
54
45
}
55
46
56
- pub unsafe fn base_button_async_method ( this : & BaseButtonInstance ) -> PinnedFuture {
47
+ pub ( super ) unsafe fn base_button_async_method ( this : & BaseButtonInstance ) -> PinnedFuture {
57
48
let klass = & * ( this. class ( ) as * const _ as * const BaseButtonClass ) ;
58
49
klass. async_method . unwrap ( ) ( this)
59
50
}
0 commit comments