@@ -33,7 +33,7 @@ fn test_function() {
33
33
doc_comment: None ,
34
34
return_type: MappedType {
35
35
rs_type: RsType {
36
- name: Some ( "i32 " ) ,
36
+ name: Some ( "::core::ffi::c_int " ) ,
37
37
lifetime_args: [ ] ,
38
38
type_args: [ ] ,
39
39
decl_id: None ,
@@ -49,7 +49,7 @@ fn test_function() {
49
49
FuncParam {
50
50
type_: MappedType {
51
51
rs_type: RsType {
52
- name: Some ( "i32 " ) ,
52
+ name: Some ( "::core::ffi::c_int " ) ,
53
53
lifetime_args: [ ] ,
54
54
type_args: [ ] ,
55
55
decl_id: None ,
@@ -66,7 +66,7 @@ fn test_function() {
66
66
FuncParam {
67
67
type_: MappedType {
68
68
rs_type: RsType {
69
- name: Some ( "i32 " ) ,
69
+ name: Some ( "::core::ffi::c_int " ) ,
70
70
lifetime_args: [ ] ,
71
71
type_args: [ ] ,
72
72
decl_id: None ,
@@ -399,7 +399,7 @@ fn test_bitfields() {
399
399
Field {
400
400
identifier: Some ( "b1" ) , ...
401
401
type_: Ok ( MappedType {
402
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
402
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
403
403
cc_type: CcType { name: Some ( "int" ) , ... } ,
404
404
} ) , ...
405
405
offset: 0 ,
@@ -409,7 +409,7 @@ fn test_bitfields() {
409
409
Field {
410
410
identifier: Some ( "b2" ) , ...
411
411
type_: Ok ( MappedType {
412
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
412
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
413
413
cc_type: CcType { name: Some ( "int" ) , ... } ,
414
414
} ) , ...
415
415
offset: 1 ,
@@ -419,7 +419,7 @@ fn test_bitfields() {
419
419
Field {
420
420
identifier: Some ( "b3" ) , ...
421
421
type_: Ok ( MappedType {
422
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
422
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
423
423
cc_type: CcType { name: Some ( "int" ) , ... } ,
424
424
} ) , ...
425
425
offset: 3 ,
@@ -429,7 +429,7 @@ fn test_bitfields() {
429
429
Field {
430
430
identifier: Some ( "b4" ) , ...
431
431
type_: Ok ( MappedType {
432
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
432
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
433
433
cc_type: CcType { name: Some ( "int" ) , ... } ,
434
434
} ) , ...
435
435
offset: 16 ,
@@ -909,37 +909,36 @@ fn test_type_conversion() -> Result<()> {
909
909
910
910
assert_eq ! ( type_mapping[ "bool" ] , "bool" ) ;
911
911
912
- // TODO(b/276790180, b/276931370): use c_char instead.
912
+ // TODO(b/276790180, b/276931370): use `::core::ffi:: c_char` instead.
913
913
if multiplatform_testing:: test_platform ( ) == multiplatform_testing:: Platform :: X86Linux {
914
914
assert_eq ! ( type_mapping[ "char" ] , "i8" ) ;
915
915
} else {
916
916
assert_eq ! ( type_mapping[ "char" ] , "u8" ) ;
917
917
}
918
+ assert_eq ! ( type_mapping[ "unsigned char" ] , "::core::ffi::c_uchar" ) ;
919
+ assert_eq ! ( type_mapping[ "signed char" ] , "::core::ffi::c_schar" ) ;
918
920
919
- assert_eq ! ( type_mapping[ "unsigned char" ] , "u8" ) ;
920
- assert_eq ! ( type_mapping[ "signed char" ] , "i8" ) ;
921
921
assert_eq ! ( type_mapping[ "char16_t" ] , "u16" ) ;
922
+
922
923
// We cannot map C++ char32_t or wchar_t to Rust char,
923
924
// because Rust requires that chars are valid UTF scalar values.
924
925
assert_eq ! ( type_mapping[ "char32_t" ] , "u32" ) ;
925
- assert_eq ! ( type_mapping[ "wchar_t" ] , "i32" ) ;
926
926
927
- assert_eq ! ( type_mapping[ "short" ] , "i16" ) ;
928
- assert_eq ! ( type_mapping[ "int" ] , "i32" ) ;
929
- assert_eq ! ( type_mapping[ "long" ] , "i64" ) ;
930
- assert_eq ! ( type_mapping[ "long long" ] , "i64" ) ;
927
+ // TODO(b/283268558): Per https://en.cppreference.com/w/cpp/language/types#Character_types
928
+ // maybe `wchar_t` should translate to`i16` on Windows?
929
+ assert_eq ! ( type_mapping[ "wchar_t" ] , "i32" ) ;
931
930
932
- assert_eq ! ( type_mapping[ "unsigned short" ] , "u16 " ) ;
933
- assert_eq ! ( type_mapping[ "unsigned int" ] , "u32 " ) ;
934
- assert_eq ! ( type_mapping[ "unsigned long" ] , "u64 " ) ;
935
- assert_eq ! ( type_mapping[ "unsigned long long" ] , "u64 " ) ;
931
+ assert_eq ! ( type_mapping[ "short" ] , "::core::ffi::c_short " ) ;
932
+ assert_eq ! ( type_mapping[ "int" ] , "::core::ffi::c_int " ) ;
933
+ assert_eq ! ( type_mapping[ "long" ] , "::core::ffi::c_long " ) ;
934
+ assert_eq ! ( type_mapping[ "long long" ] , "::core::ffi::c_longlong " ) ;
936
935
937
- assert_eq ! ( type_mapping[ "short" ] , "i16 " ) ;
938
- assert_eq ! ( type_mapping[ "int" ] , "i32 " ) ;
939
- assert_eq ! ( type_mapping[ "long" ] , "i64 " ) ;
940
- assert_eq ! ( type_mapping[ "long long" ] , "i64 " ) ;
936
+ assert_eq ! ( type_mapping[ "unsigned short" ] , "::core::ffi::c_ushort " ) ;
937
+ assert_eq ! ( type_mapping[ "unsigned int" ] , "::core::ffi::c_uint " ) ;
938
+ assert_eq ! ( type_mapping[ "unsigned long" ] , "::core::ffi::c_ulong " ) ;
939
+ assert_eq ! ( type_mapping[ "unsigned long long" ] , "::core::ffi::c_ulonglong " ) ;
941
940
942
- /* TOOD(b/275876867): Reenable assertions below after fix the `#include` problem.
941
+ /* TOOD(b/275876867): Reenable assertions below after fixing the `#include` problem.
943
942
assert_eq!(type_mapping["int8_t"], "i8");
944
943
assert_eq!(type_mapping["int16_t"], "i16");
945
944
assert_eq!(type_mapping["int32_t"], "i32");
@@ -989,7 +988,7 @@ fn test_typedef() -> Result<()> {
989
988
let int = quote ! {
990
989
MappedType {
991
990
rs_type: RsType {
992
- name: Some ( "i32 " ) ,
991
+ name: Some ( "::core::ffi::c_int " ) ,
993
992
lifetime_args: [ ] ,
994
993
type_args: [ ] ,
995
994
decl_id: None ,
@@ -1117,7 +1116,7 @@ fn test_typedef_of_full_template_specialization() -> Result<()> {
1117
1116
identifier: Some ( "value" ) , ...
1118
1117
doc_comment: Some ( "Doc comment of `value` field." ) , ...
1119
1118
type_: Ok ( MappedType {
1120
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
1119
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
1121
1120
cc_type: CcType { name: Some ( "int" ) , ... } ,
1122
1121
} ) ,
1123
1122
access: Public ,
@@ -1226,7 +1225,7 @@ fn test_typedef_for_explicit_template_specialization() -> Result<()> {
1226
1225
identifier: Some ( "value" ) , ...
1227
1226
doc_comment: Some ( "Doc comment of the `value` field specialization for T=int." ) , ...
1228
1227
type_: Ok ( MappedType {
1229
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
1228
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
1230
1229
cc_type: CcType { name: Some ( "int" ) , ... } ,
1231
1230
} ) ,
1232
1231
access: Public ,
@@ -1503,14 +1502,14 @@ fn test_subst_template_type_parm_pack_type() -> Result<()> {
1503
1502
params: [
1504
1503
FuncParam {
1505
1504
type_: MappedType {
1506
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
1505
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
1507
1506
cc_type: CcType { name: Some ( "int" ) , ... } ,
1508
1507
} ,
1509
1508
identifier: "__my_args_0" ,
1510
1509
} ,
1511
1510
FuncParam {
1512
1511
type_: MappedType {
1513
- rs_type: RsType { name: Some ( "i32 " ) , ... } ,
1512
+ rs_type: RsType { name: Some ( "::core::ffi::c_int " ) , ... } ,
1514
1513
cc_type: CcType { name: Some ( "int" ) , ... } ,
1515
1514
} ,
1516
1515
identifier: "__my_args_1" ,
@@ -1759,7 +1758,7 @@ fn test_template_with_decltype_and_with_auto() -> Result<()> {
1759
1758
Func {
1760
1759
name: "TemplatedAdd" , ...
1761
1760
return_type: MappedType {
1762
- rs_type: RsType { name: Some ( "i64 " ) , ... } ,
1761
+ rs_type: RsType { name: Some ( "::core::ffi::c_longlong " ) , ... } ,
1763
1762
cc_type: CcType { name: Some ( "long long" ) , ... } ,
1764
1763
} , ...
1765
1764
}
@@ -1798,7 +1797,7 @@ fn test_subst_template_type_parm_type_vs_const_when_non_const_template_param() -
1798
1797
return_type: MappedType {
1799
1798
rs_type: RsType {
1800
1799
name: Some ( "&" ) , ...
1801
- type_args: [ RsType { name: Some ( "i32 " ) , ... } ] , ...
1800
+ type_args: [ RsType { name: Some ( "::core::ffi::c_int " ) , ... } ] , ...
1802
1801
} ,
1803
1802
cc_type: CcType {
1804
1803
name: Some ( "&" ) ,
@@ -1820,7 +1819,7 @@ fn test_subst_template_type_parm_type_vs_const_when_non_const_template_param() -
1820
1819
return_type: MappedType {
1821
1820
rs_type: RsType {
1822
1821
name: Some ( "&mut" ) , ...
1823
- type_args: [ RsType { name: Some ( "i32 " ) , ... } ] , ...
1822
+ type_args: [ RsType { name: Some ( "::core::ffi::c_int " ) , ... } ] , ...
1824
1823
} ,
1825
1824
cc_type: CcType {
1826
1825
name: Some ( "&" ) ,
@@ -1867,7 +1866,7 @@ fn test_subst_template_type_parm_type_vs_const_when_const_template_param() -> Re
1867
1866
return_type: MappedType {
1868
1867
rs_type: RsType {
1869
1868
name: Some ( "&" ) , ...
1870
- type_args: [ RsType { name: Some ( "i32 " ) , ... } ] , ...
1869
+ type_args: [ RsType { name: Some ( "::core::ffi::c_int " ) , ... } ] , ...
1871
1870
} ,
1872
1871
cc_type: CcType {
1873
1872
name: Some ( "&" ) ,
@@ -1889,7 +1888,7 @@ fn test_subst_template_type_parm_type_vs_const_when_const_template_param() -> Re
1889
1888
return_type: MappedType {
1890
1889
rs_type: RsType {
1891
1890
name: Some ( "&" ) , ...
1892
- type_args: [ RsType { name: Some ( "i32 " ) , ... } ] , ...
1891
+ type_args: [ RsType { name: Some ( "::core::ffi::c_int " ) , ... } ] , ...
1893
1892
} ,
1894
1893
cc_type: CcType {
1895
1894
name: Some ( "&" ) ,
@@ -2528,7 +2527,7 @@ fn test_struct() {
2528
2527
Field {
2529
2528
identifier: Some ( "first_field" ) , ...
2530
2529
type_: Ok ( MappedType {
2531
- rs_type : RsType { name : Some ( "i32 ") , ...} ,
2530
+ rs_type : RsType { name : Some ( "::core::ffi::c_int ") , ...} ,
2532
2531
cc_type : CcType { name : Some ( "int" ) , ...} ,
2533
2532
} ) , ...
2534
2533
offset: 0 , ...
@@ -2538,7 +2537,7 @@ fn test_struct() {
2538
2537
Field {
2539
2538
identifier: Some ( "second_field" ) , ...
2540
2539
type_: Ok ( MappedType {
2541
- rs_type : RsType { name : Some ( "i32 ") , ...} ,
2540
+ rs_type : RsType { name : Some ( "::core::ffi::c_int ") , ...} ,
2542
2541
cc_type : CcType { name : Some ( "int" ) , ...} ,
2543
2542
} ) , ...
2544
2543
offset: 32 , ...
@@ -2631,7 +2630,7 @@ fn test_union() {
2631
2630
Field {
2632
2631
identifier: Some ( "first_field" ) , ...
2633
2632
type_: Ok ( MappedType {
2634
- rs_type : RsType { name : Some ( "i32 ") , ...} ,
2633
+ rs_type : RsType { name : Some ( "::core::ffi::c_int ") , ...} ,
2635
2634
cc_type : CcType { name : Some ( "int" ) , ...} ,
2636
2635
} ) , ...
2637
2636
offset: 0 , ...
@@ -2641,7 +2640,7 @@ fn test_union() {
2641
2640
Field {
2642
2641
identifier: Some ( "second_field" ) , ...
2643
2642
type_: Ok ( MappedType {
2644
- rs_type : RsType { name : Some ( "i32 ") , ...} ,
2643
+ rs_type : RsType { name : Some ( "::core::ffi::c_int ") , ...} ,
2645
2644
cc_type : CcType { name : Some ( "int" ) , ...} ,
2646
2645
} ) , ...
2647
2646
offset: 0 , ...
0 commit comments