File tree Expand file tree Collapse file tree 5 files changed +32
-4
lines changed Expand file tree Collapse file tree 5 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ Automated tests of FFI bindings.
14
14
[dependencies ]
15
15
syntex_syntax = " 0.59.1"
16
16
cc = " 1.0.1"
17
- syn = { version = " 0.15" , features = [" full" ] }
18
17
19
18
[workspace ]
20
19
members = [" testcrate" ]
Original file line number Diff line number Diff line change 13
13
14
14
extern crate cc;
15
15
extern crate syntex_syntax as syntax;
16
- extern crate syn;
17
16
18
17
use std:: cell:: RefCell ;
19
18
use std:: collections:: { HashMap , HashSet } ;
@@ -1208,7 +1207,7 @@ impl<'a> Generator<'a> {
1208
1207
let cname = cname. unwrap_or_else ( || name. to_string ( ) ) ;
1209
1208
1210
1209
if rust_ty. contains ( "extern fn" ) {
1211
- let c_ty = c_ty. replace ( "(*)" , & format ! ( "(* __test_static_{}(void))" , name) ) ;
1210
+ let c_ty = c_ty. replacen ( "(*)" , & format ! ( "(* __test_static_{}(void))" , name) , 1 ) ;
1212
1211
t ! ( writeln!( self . c, r#"
1213
1212
{ty} {{
1214
1213
return {cname};
@@ -1318,7 +1317,13 @@ impl<'a> Generator<'a> {
1318
1317
if args. len ( ) == 0 {
1319
1318
args. push ( "void" . to_string ( ) ) ;
1320
1319
}
1321
- format ! ( "{}(*)({})" , ret, args. join( ", " ) )
1320
+
1321
+ let s = if ret. contains ( "(*)" ) {
1322
+ ret. replace ( "(*)" , & format ! ( "(*(*)({}))" , args. join( ", " ) ) )
1323
+ } else {
1324
+ format ! ( "{}(*)({})" , ret, args. join( ", " ) )
1325
+ } ;
1326
+ s
1322
1327
}
1323
1328
}
1324
1329
ast:: TyKind :: Array ( ref t, ref e) => {
Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ uint8_t foo(uint8_t a, uint8_t b) { return a + b; }
21
21
void bar (uint8_t a ) { return ; }
22
22
void baz (void ) { return ; }
23
23
24
+ uint32_t (* nested (uint8_t arg ))(uint16_t ) {
25
+ return NULL ;
26
+ }
27
+
28
+ uint32_t (* nested2 (uint8_t (* arg0 )(uint8_t ), uint16_t (* arg1 )(uint16_t )))(uint16_t ) {
29
+ return NULL ;
30
+ }
24
31
25
32
uint8_t (* T1_static_mut_fn_ptr )(uint8_t , uint8_t ) = foo ;
26
33
uint8_t (* const T1_static_const_fn_ptr_unsafe )(uint8_t , uint8_t ) = foo ;
@@ -29,3 +36,6 @@ void (*const T1_static_const_fn_ptr_unsafe3)(void) = baz;
29
36
30
37
const uint8_t T1_static_right = 7 ;
31
38
uint8_t (* T1_static_right2 )(uint8_t , uint8_t ) = foo ;
39
+
40
+ uint32_t (* (* T1_fn_ptr_s )(uint8_t ))(uint16_t ) = nested ;
41
+ uint32_t (* (* T1_fn_ptr_s2 )(uint8_t (* arg0 )(uint8_t ), uint16_t (* arg1 )(uint16_t )))(uint16_t ) = nested2 ;
Original file line number Diff line number Diff line change @@ -56,3 +56,13 @@ void (*const T1_static_const_fn_ptr_unsafe3)(void);
56
56
57
57
const uint8_t T1_static_right ;
58
58
uint8_t (* T1_static_right2 )(uint8_t , uint8_t );
59
+
60
+ // T1_fn_ptr_nested: function pointer to a function, taking a uint8_t, and
61
+ // returning a function pointer to a function taking a uint16_t and returning a
62
+ // uint32_t
63
+ uint32_t (* (* T1_fn_ptr_s )(uint8_t ))(uint16_t );
64
+
65
+ // T1_fn_ptr_nested: function pointer to a function, taking a function pointer
66
+ // uint8_t -> uint8_t, and returning a function pointer to a function taking a
67
+ // uint16_t and returning a uint32_t
68
+ uint32_t (* (* T1_fn_ptr_s2 )(uint8_t (* )(uint8_t ), uint16_t (* )(uint16_t )))(uint16_t );
Original file line number Diff line number Diff line change @@ -84,4 +84,8 @@ extern "C" {
84
84
pub static T1_static_wrong : u8 ;
85
85
#[ link_name = "T1_static_right2" ]
86
86
pub static mut T1_static_wrong2 : extern "C" fn ( u8 , u8 ) -> u8 ;
87
+
88
+ pub static T1_fn_ptr_s : unsafe extern "C" fn ( u8 ) -> extern fn ( u16 ) ->u32 ;
89
+ pub static T1_fn_ptr_s2 : unsafe extern "C" fn ( extern fn ( u8 ) ->u8 ,
90
+ extern fn ( u16 ) ->u16 ) -> extern fn ( u16 ) ->u32 ;
87
91
}
You can’t perform that action at this time.
0 commit comments