@@ -31,26 +31,25 @@ macro_rules! string_arg_output_receive {
31
31
}
32
32
33
33
macro_rules! callback_arg {
34
- ( $tr_name: ident( $( $tr_arg_name: ident: $tr_arg_type: ty) ,* ) -> $tr_ret: ty => $tr_userdata_name: ident in $callbacks_name : ident => $ callback_name: ident( $( $fw_arg_name: ident: $fw_arg_type: ty) ,* ) -> $fw_ret: ty) => {
34
+ ( $tr_name: ident( $( $tr_arg_name: ident: $tr_arg_type: ty) ,* ) -> $tr_ret: ty => $tr_userdata_name: ident in $callback_name: ident( $( $fw_arg_name: ident: $fw_arg_type: ty) ,* ) -> $fw_ret: ty) => {
35
35
unsafe extern "C" fn trampoline( $( $tr_arg_name: $tr_arg_type) ,* ) -> $tr_ret {
36
- let mut callback: Box <Box <dyn FnMut ( $( $fw_arg_type) ,* ) -> $fw_ret + Send + Sync >> = Box :: from_raw( $tr_userdata_name. cast( ) ) ;
37
- let out = callback( $( $fw_arg_name) ,* ) ;
38
- Box :: into_raw( callback) ;
36
+ let callback: * mut Box <dyn FnMut ( $( $fw_arg_type) ,* ) -> $fw_ret> = $tr_userdata_name. cast( ) ;
37
+ let out = ( * callback) ( $( $fw_arg_name) ,* ) ;
39
38
out
40
39
}
41
40
42
41
let $tr_name = if $callback_name. is_some( ) {
43
- Some ( trampoline as unsafe extern "C" fn ( $( $tr_arg_name : $ tr_arg_type) ,* ) -> $tr_ret)
42
+ Some ( trampoline as unsafe extern "C" fn ( $( $tr_arg_type) ,* ) -> $tr_ret)
44
43
} else {
45
44
None
46
45
} ;
47
46
}
48
47
}
49
48
50
49
macro_rules! userdata_arg {
51
- ( $userdata_name: ident in $callbacks_name : ident => $callback_name: ident) => {
52
- let $userdata_name = if let Some ( callback) = $callback_name {
53
- Box :: into_raw( Box :: new( callback) ) . cast:: < :: std :: ffi :: c_void> ( )
50
+ ( $userdata_name: ident: $userdata_type : ty => $callback_name: ident) => {
51
+ let $userdata_name: $userdata_type = if let Some ( callback) = $callback_name {
52
+ Box :: into_raw( Box :: new( callback) ) . cast( )
54
53
} else {
55
54
:: std:: ptr:: null_mut( ) // fixme, remove previous callback
56
55
} ;
0 commit comments