@@ -118,7 +118,7 @@ pub(crate) trait BridgeableType: Debug {
118
118
119
119
/// Generate a C include statement to put in the C header.
120
120
/// For example, for a `u8` we would generate a `#include <stdint.h>` line.
121
- fn to_c_include ( & self ) -> Option < & ' static str > ;
121
+ fn to_c_include ( & self , types : & TypeDeclarations ) -> Option < Vec < & ' static str > > ;
122
122
123
123
/// Get the FFI compatible Rust type.
124
124
///
@@ -531,7 +531,7 @@ impl BridgeableType for BridgedType {
531
531
self . to_c ( types)
532
532
}
533
533
534
- fn to_c_include ( & self ) -> Option < & ' static str > {
534
+ fn to_c_include ( & self , _types : & TypeDeclarations ) -> Option < Vec < & ' static str > > {
535
535
todo ! ( )
536
536
}
537
537
@@ -1645,9 +1645,9 @@ impl BridgedType {
1645
1645
}
1646
1646
}
1647
1647
1648
- pub fn to_c_include ( & self ) -> Option < & ' static str > {
1648
+ pub fn to_c_include ( & self , types : & TypeDeclarations ) -> Option < Vec < & ' static str > > {
1649
1649
match self {
1650
- BridgedType :: Bridgeable ( b) => b. to_c_include ( ) ,
1650
+ BridgedType :: Bridgeable ( b) => b. to_c_include ( types ) ,
1651
1651
BridgedType :: StdLib ( stdlib_type) => match stdlib_type {
1652
1652
StdLibType :: U8
1653
1653
| StdLibType :: I8
@@ -1658,18 +1658,15 @@ impl BridgedType {
1658
1658
| StdLibType :: U64
1659
1659
| StdLibType :: I64
1660
1660
| StdLibType :: Usize
1661
- | StdLibType :: Isize => Some ( "stdint.h" ) ,
1662
- StdLibType :: Bool => Some ( "stdbool.h" ) ,
1661
+ | StdLibType :: Isize => Some ( vec ! [ "stdint.h" ] ) ,
1662
+ StdLibType :: Bool => Some ( vec ! [ "stdbool.h" ] ) ,
1663
1663
StdLibType :: Pointer ( ptr) => match & ptr. pointee {
1664
- Pointee :: BuiltIn ( ty) => ty. to_c_include ( ) ,
1664
+ Pointee :: BuiltIn ( ty) => ty. to_c_include ( types ) ,
1665
1665
Pointee :: Void ( _) => None ,
1666
1666
} ,
1667
- StdLibType :: RefSlice ( slice) => slice. ty . to_c_include ( ) ,
1668
- StdLibType :: Vec ( _vec) => Some ( "stdint.h" ) ,
1669
- StdLibType :: Tuple ( _tuple) => {
1670
- // TODO: Iterate over the fields and see if any of them need imports..
1671
- None
1672
- }
1667
+ StdLibType :: RefSlice ( slice) => slice. ty . to_c_include ( types) ,
1668
+ StdLibType :: Vec ( _vec) => Some ( vec ! [ "stdint.h" ] ) ,
1669
+ StdLibType :: Tuple ( tuple) => tuple. to_c_include ( types) ,
1673
1670
_ => None ,
1674
1671
} ,
1675
1672
BridgedType :: Foreign ( CustomBridgedType :: Shared ( SharedType :: Struct ( _shared_struct) ) ) => {
@@ -1855,9 +1852,14 @@ impl BridgedType {
1855
1852
StdLibType :: U8 => "U8" . to_string ( ) ,
1856
1853
StdLibType :: U16 => "U16" . to_string ( ) ,
1857
1854
StdLibType :: U32 => "U32" . to_string ( ) ,
1855
+ StdLibType :: Usize => "UInt" . to_string ( ) ,
1858
1856
StdLibType :: I8 => "I8" . to_string ( ) ,
1859
1857
StdLibType :: I16 => "I16" . to_string ( ) ,
1860
1858
StdLibType :: I32 => "I32" . to_string ( ) ,
1859
+ StdLibType :: Isize => "Int" . to_string ( ) ,
1860
+ StdLibType :: Bool => "Bool" . to_string ( ) ,
1861
+ StdLibType :: F32 => "F32" . to_string ( ) ,
1862
+ StdLibType :: F64 => "F64" . to_string ( ) ,
1861
1863
_ => todo ! ( ) ,
1862
1864
} ,
1863
1865
BridgedType :: Foreign ( ty) => match ty {
0 commit comments