From bdcbb07b60d7207fad211ca19af064224a762b54 Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Tue, 27 Apr 2021 11:40:55 -0700 Subject: [PATCH 1/5] Add test for plain c_char. --- tests/ffi/lib.rs | 1 + tests/ffi/tests.cc | 2 ++ tests/ffi/tests.h | 1 + tests/test.rs | 1 + 4 files changed, 5 insertions(+) diff --git a/tests/ffi/lib.rs b/tests/ffi/lib.rs index 25b4ccdc8..f9b5f7767 100644 --- a/tests/ffi/lib.rs +++ b/tests/ffi/lib.rs @@ -124,6 +124,7 @@ pub mod ffi { fn c_return_nested_ns_enum(n: u16) -> ABEnum; fn c_return_const_ptr(n: usize) -> *const C; fn c_return_mut_ptr(n: usize) -> *mut C; + fn c_return_char() -> c_char; fn c_take_primitive(n: usize); fn c_take_shared(shared: Shared); diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc index ff215ca00..fdc795895 100644 --- a/tests/ffi/tests.cc +++ b/tests/ffi/tests.cc @@ -211,6 +211,8 @@ const C *c_return_const_ptr(size_t c) { return new C(c); } C *c_return_mut_ptr(size_t c) { return new C(c); } +char c_return_char() { return 'a'; } + Borrow::Borrow(const std::string &s) : s(s) {} void Borrow::const_member() const {} diff --git a/tests/ffi/tests.h b/tests/ffi/tests.h index b624d3933..6a45a5b61 100644 --- a/tests/ffi/tests.h +++ b/tests/ffi/tests.h @@ -120,6 +120,7 @@ ::A::B::ABEnum c_return_nested_ns_enum(uint16_t n); std::unique_ptr c_return_borrow(const std::string &s); const C *c_return_const_ptr(size_t n); C *c_return_mut_ptr(size_t n); +char c_return_char(); void c_take_primitive(size_t n); void c_take_shared(Shared shared); diff --git a/tests/test.rs b/tests/test.rs index 1f0b16603..cd6cb4e68 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -91,6 +91,7 @@ fn test_c_return() { enm @ ffi::ABEnum::ABAVal => assert_eq!(0, enm.repr), _ => assert!(false), } + assert_eq!(ffi::c_return_char(), 'a' as i8); } #[test] From b0e98a5f78c9d418d0211e24b90e429a0594876d Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Tue, 27 Apr 2021 11:36:27 -0700 Subject: [PATCH 2/5] Support standard C numeric types. This adds direct support for the C integer and float types defined in std::os::raw. Unlike existing cxx-supported integers, these may not be a consistent length on all platforms - but sometimes this is useful to enable direct interoperability with existing APIs. --- gen/src/write.rs | 17 ++++++++++++++++- syntax/atom.rs | 36 ++++++++++++++++++++++++++++++++++++ syntax/check.rs | 16 ++++++++++++---- syntax/pod.rs | 3 ++- syntax/tokens.rs | 15 ++++++++++++++- tests/ffi/lib.rs | 13 +++++++++++++ tests/ffi/tests.cc | 21 +++++++++++++++++++++ tests/ffi/tests.h | 13 +++++++++++++ tests/test.rs | 18 ++++++++++++++++++ 9 files changed, 145 insertions(+), 7 deletions(-) diff --git a/gen/src/write.rs b/gen/src/write.rs index c6d59d8b9..c2b0f2534 100644 --- a/gen/src/write.rs +++ b/gen/src/write.rs @@ -211,7 +211,10 @@ fn pick_includes_and_builtins(out: &mut OutFile, apis: &[Api]) { Some(Isize) => out.builtin.rust_isize = true, Some(CxxString) => out.include.string = true, Some(RustString) => out.builtin.rust_string = true, - Some(Bool) | Some(Char) | Some(F32) | Some(F64) | None => {} + Some(Bool) | Some(Char) | Some(F32) | Some(F64) | Some(CInt) | Some(CDouble) + | Some(CFloat) | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) + | Some(CUChar) | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) + | None => {} }, Type::RustBox(_) => out.builtin.rust_box = true, Type::RustVec(_) => out.builtin.rust_vec = true, @@ -1305,6 +1308,18 @@ fn write_atom(out: &mut OutFile, atom: Atom) { F64 => write!(out, "double"), CxxString => write!(out, "::std::string"), RustString => write!(out, "::rust::String"), + CInt => write!(out, "int"), + CDouble => write!(out, "double"), + CFloat => write!(out, "float"), + CLong => write!(out, "long"), + CLongLong => write!(out, "long long"), + CSChar => write!(out, "signed char"), + CShort => write!(out, "short"), + CUChar => write!(out, "unsigned char"), + CUInt => write!(out, "unsigned int"), + CULong => write!(out, "unsigned long"), + CULongLong => write!(out, "unsigned long long"), + CUShort => write!(out, "unsigned short"), } } diff --git a/syntax/atom.rs b/syntax/atom.rs index d4ad78f17..79191efa4 100644 --- a/syntax/atom.rs +++ b/syntax/atom.rs @@ -20,6 +20,18 @@ pub enum Atom { F64, CxxString, RustString, + CInt, + CDouble, + CFloat, + CLong, + CLongLong, + CSChar, + CShort, + CUChar, + CUInt, + CULong, + CULongLong, + CUShort, } impl Atom { @@ -46,6 +58,18 @@ impl Atom { "f64" => Some(F64), "CxxString" => Some(CxxString), "String" => Some(RustString), + "c_int" => Some(CInt), + "c_double" => Some(CDouble), + "c_float" => Some(CFloat), + "c_long" => Some(CLong), + "c_longlong" => Some(CLongLong), + "c_schar" => Some(CSChar), + "c_short" => Some(CShort), + "c_uchar" => Some(CUChar), + "c_uint" => Some(CUInt), + "c_ulong" => Some(CULong), + "c_ulonglong" => Some(CULongLong), + "c_ushort" => Some(CUShort), _ => None, } } @@ -77,6 +101,18 @@ impl AsRef for Atom { F64 => "f64", CxxString => "CxxString", RustString => "String", + CInt => "c_int", + CDouble => "c_double", + CFloat => "c_float", + CLong => "c_long", + CLongLong => "c_longlong", + CSChar => "c_schar", + CShort => "c_short", + CUChar => "c_uchar", + CUInt => "c_uint", + CULong => "c_ulong", + CULongLong => "c_ulonglong", + CUShort => "c_ushort", } } } diff --git a/syntax/check.rs b/syntax/check.rs index 38be4b640..04bfce060 100644 --- a/syntax/check.rs +++ b/syntax/check.rs @@ -125,7 +125,9 @@ fn check_type_rust_vec(cx: &mut Check, ty: &Ty1) { match Atom::from(&ident.rust) { None | Some(Char) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) - | Some(F64) | Some(RustString) => return, + | Some(F64) | Some(RustString) | Some(CInt) | Some(CDouble) | Some(CFloat) + | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) + | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, Some(Bool) => { /* todo */ } Some(CxxString) => {} } @@ -165,7 +167,9 @@ fn check_type_shared_ptr(cx: &mut Check, ptr: &Ty1) { match Atom::from(&ident.rust) { None | Some(Bool) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) - | Some(F64) | Some(CxxString) => return, + | Some(F64) | Some(CxxString) | Some(CInt) | Some(CDouble) | Some(CFloat) + | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) + | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, Some(Char) | Some(RustString) => {} } } else if let Type::CxxVector(_) = &ptr.inner { @@ -186,7 +190,9 @@ fn check_type_weak_ptr(cx: &mut Check, ptr: &Ty1) { match Atom::from(&ident.rust) { None | Some(Bool) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) - | Some(F64) | Some(CxxString) => return, + | Some(F64) | Some(CxxString) | Some(CInt) | Some(CDouble) | Some(CFloat) + | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) + | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, Some(Char) | Some(RustString) => {} } } else if let Type::CxxVector(_) = &ptr.inner { @@ -210,7 +216,9 @@ fn check_type_cxx_vector(cx: &mut Check, ptr: &Ty1) { match Atom::from(&ident.rust) { None | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) | Some(F64) - | Some(CxxString) => return, + | Some(CxxString) | Some(CInt) | Some(CDouble) | Some(CFloat) | Some(CLong) + | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) | Some(CUInt) + | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, Some(Char) => { /* todo */ } Some(Bool) | Some(RustString) => {} } diff --git a/syntax/pod.rs b/syntax/pod.rs index 0bf152eea..7778e9250 100644 --- a/syntax/pod.rs +++ b/syntax/pod.rs @@ -9,7 +9,8 @@ impl<'a> Types<'a> { if let Some(atom) = Atom::from(ident) { match atom { Bool | Char | U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 - | Isize | F32 | F64 => true, + | Isize | F32 | F64 | CInt | CDouble | CFloat | CLong | CLongLong + | CSChar | CShort | CUChar | CUInt | CULong | CULongLong | CUShort => true, CxxString | RustString => false, } } else if let Some(strct) = self.structs.get(ident) { diff --git a/syntax/tokens.rs b/syntax/tokens.rs index 33f20fa3c..700c1ccd1 100644 --- a/syntax/tokens.rs +++ b/syntax/tokens.rs @@ -11,7 +11,20 @@ impl ToTokens for Type { fn to_tokens(&self, tokens: &mut TokenStream) { match self { Type::Ident(ident) => { - if ident.rust == Char { + if ident.rust == Char + || ident.rust == CInt + || ident.rust == CDouble + || ident.rust == CFloat + || ident.rust == CLong + || ident.rust == CLongLong + || ident.rust == CSChar + || ident.rust == CShort + || ident.rust == CUChar + || ident.rust == CUInt + || ident.rust == CULong + || ident.rust == CULongLong + || ident.rust == CUShort + { let span = ident.rust.span(); tokens.extend(quote_spanned!(span=> ::std::os::raw::)); } else if ident.rust == CxxString { diff --git a/tests/ffi/lib.rs b/tests/ffi/lib.rs index f9b5f7767..6d6b88a54 100644 --- a/tests/ffi/lib.rs +++ b/tests/ffi/lib.rs @@ -125,6 +125,19 @@ pub mod ffi { fn c_return_const_ptr(n: usize) -> *const C; fn c_return_mut_ptr(n: usize) -> *mut C; fn c_return_char() -> c_char; + fn c_return_cint() -> c_int; + fn c_return_cdouble() -> c_double; + fn c_return_cfloat() -> c_float; + fn c_return_clong() -> c_long; + fn c_return_clonglong() -> c_longlong; + fn c_return_cschar() -> c_schar; + fn c_return_cshort() -> c_short; + fn c_return_cuchar() -> c_uchar; + fn c_return_cuint() -> c_uint; + fn c_return_culong() -> c_ulong; + fn c_return_culonglong() -> c_ulonglong; + fn c_return_cushort() -> c_ushort; + fn c_return_unique_ptr_vector_ulonglong() -> UniquePtr>; fn c_take_primitive(n: usize); fn c_take_shared(shared: Shared); diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc index fdc795895..22302b053 100644 --- a/tests/ffi/tests.cc +++ b/tests/ffi/tests.cc @@ -213,6 +213,27 @@ C *c_return_mut_ptr(size_t c) { return new C(c); } char c_return_char() { return 'a'; } +int c_return_cint() { return 7; } + +double c_return_cdouble() { return 8.0; } +float c_return_cfloat() { return 9.0; } +long c_return_clong() { return 10; } +long long c_return_clonglong() { return 11; } +signed char c_return_cschar() { return 12; } +short c_return_cshort() { return 13; } +unsigned char c_return_cuchar() { return 14; } +unsigned int c_return_cuint() { return 15; } +unsigned long c_return_culong() { return 16; } +unsigned long long c_return_culonglong() { return 17; } +unsigned short c_return_cushort() { return 18; } + +std::unique_ptr> c_return_unique_ptr_vector_ulonglong() { + auto vec = std::unique_ptr>(new std::vector()); + vec->push_back(19); + vec->push_back(20); + return vec; +} + Borrow::Borrow(const std::string &s) : s(s) {} void Borrow::const_member() const {} diff --git a/tests/ffi/tests.h b/tests/ffi/tests.h index 6a45a5b61..5b38d27ba 100644 --- a/tests/ffi/tests.h +++ b/tests/ffi/tests.h @@ -121,6 +121,19 @@ std::unique_ptr c_return_borrow(const std::string &s); const C *c_return_const_ptr(size_t n); C *c_return_mut_ptr(size_t n); char c_return_char(); +int c_return_cint(); +double c_return_cdouble(); +float c_return_cfloat(); +long c_return_clong(); +long long c_return_clonglong(); +signed char c_return_cschar(); +short c_return_cshort(); +unsigned char c_return_cuchar(); +unsigned int c_return_cuint(); +unsigned long c_return_culong(); +unsigned long long c_return_culonglong(); +unsigned short c_return_cushort(); +std::unique_ptr> c_return_unique_ptr_vector_ulonglong(); void c_take_primitive(size_t n); void c_take_shared(Shared shared); diff --git a/tests/test.rs b/tests/test.rs index cd6cb4e68..5eda4e886 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -92,6 +92,24 @@ fn test_c_return() { _ => assert!(false), } assert_eq!(ffi::c_return_char(), 'a' as i8); + assert_eq!(ffi::c_return_cint(), 7 as std::os::raw::c_int); + assert_eq!(ffi::c_return_cdouble(), 8 as std::os::raw::c_double); + assert_eq!(ffi::c_return_cfloat(), 9 as std::os::raw::c_float); + assert_eq!(ffi::c_return_clong(), 10 as std::os::raw::c_long); + assert_eq!(ffi::c_return_clonglong(), 11 as std::os::raw::c_longlong); + assert_eq!(ffi::c_return_cschar(), 12 as std::os::raw::c_schar); + assert_eq!(ffi::c_return_cshort(), 13 as std::os::raw::c_short); + assert_eq!(ffi::c_return_cuchar(), 14 as std::os::raw::c_uchar); + assert_eq!(ffi::c_return_cuint(), 15 as std::os::raw::c_uint); + assert_eq!(ffi::c_return_culong(), 16 as std::os::raw::c_ulong); + assert_eq!(ffi::c_return_culonglong(), 17 as std::os::raw::c_ulonglong); + assert_eq!(ffi::c_return_cushort(), 18 as std::os::raw::c_ushort); + assert_eq!( + 39 as std::os::raw::c_ulong, + ffi::c_return_unique_ptr_vector_ulonglong() + .into_iter() + .sum(), + ); } #[test] From 5fa67f4846c20d61b3aeb27a09b389b55eb214ce Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Tue, 11 May 2021 20:35:06 -0700 Subject: [PATCH 3/5] Bug fix. --- tests/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.rs b/tests/test.rs index 5eda4e886..16139681d 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -105,7 +105,7 @@ fn test_c_return() { assert_eq!(ffi::c_return_culonglong(), 17 as std::os::raw::c_ulonglong); assert_eq!(ffi::c_return_cushort(), 18 as std::os::raw::c_ushort); assert_eq!( - 39 as std::os::raw::c_ulong, + 39 as std::os::raw::c_ulonglong, ffi::c_return_unique_ptr_vector_ulonglong() .into_iter() .sum(), From f47cba9c186c8a21cbd28d5c65e8dbd42ec41817 Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Tue, 11 May 2021 20:56:15 -0700 Subject: [PATCH 4/5] Handle clippy complaints. --- tests/test.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index 16139681d..2040198b0 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -92,6 +92,14 @@ fn test_c_return() { _ => assert!(false), } assert_eq!(ffi::c_return_char(), 'a' as i8); +} + +#[test] +#[allow(clippy::unnecessary_cast)] // because we want explicitly + // to check that these types match the various std::os::raw + // types, even when those types are actually just + // aliases for i32, etc. +fn test_c_return_raw_types() { assert_eq!(ffi::c_return_cint(), 7 as std::os::raw::c_int); assert_eq!(ffi::c_return_cdouble(), 8 as std::os::raw::c_double); assert_eq!(ffi::c_return_cfloat(), 9 as std::os::raw::c_float); From d855aa79ecc63272de88b530533cde3467e35745 Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Wed, 12 May 2021 11:10:27 -0700 Subject: [PATCH 5/5] Remove floats/doubles. Floats are always 32-bit and doubles always 64-bit, so there's no need to duplicate the existing f32 and f64 support. --- gen/src/write.rs | 9 +++------ syntax/atom.rs | 6 ------ syntax/check.rs | 24 ++++++++++++------------ syntax/pod.rs | 4 ++-- syntax/tokens.rs | 2 -- tests/ffi/lib.rs | 2 -- tests/ffi/tests.cc | 2 -- tests/ffi/tests.h | 2 -- tests/test.rs | 2 -- 9 files changed, 17 insertions(+), 36 deletions(-) diff --git a/gen/src/write.rs b/gen/src/write.rs index c2b0f2534..bd6443fc6 100644 --- a/gen/src/write.rs +++ b/gen/src/write.rs @@ -211,10 +211,9 @@ fn pick_includes_and_builtins(out: &mut OutFile, apis: &[Api]) { Some(Isize) => out.builtin.rust_isize = true, Some(CxxString) => out.include.string = true, Some(RustString) => out.builtin.rust_string = true, - Some(Bool) | Some(Char) | Some(F32) | Some(F64) | Some(CInt) | Some(CDouble) - | Some(CFloat) | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) - | Some(CUChar) | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) - | None => {} + Some(Bool) | Some(Char) | Some(F32) | Some(F64) | Some(CInt) | Some(CLong) + | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) | Some(CUInt) + | Some(CULong) | Some(CULongLong) | Some(CUShort) | None => {} }, Type::RustBox(_) => out.builtin.rust_box = true, Type::RustVec(_) => out.builtin.rust_vec = true, @@ -1309,8 +1308,6 @@ fn write_atom(out: &mut OutFile, atom: Atom) { CxxString => write!(out, "::std::string"), RustString => write!(out, "::rust::String"), CInt => write!(out, "int"), - CDouble => write!(out, "double"), - CFloat => write!(out, "float"), CLong => write!(out, "long"), CLongLong => write!(out, "long long"), CSChar => write!(out, "signed char"), diff --git a/syntax/atom.rs b/syntax/atom.rs index 79191efa4..44cd293e9 100644 --- a/syntax/atom.rs +++ b/syntax/atom.rs @@ -21,8 +21,6 @@ pub enum Atom { CxxString, RustString, CInt, - CDouble, - CFloat, CLong, CLongLong, CSChar, @@ -59,8 +57,6 @@ impl Atom { "CxxString" => Some(CxxString), "String" => Some(RustString), "c_int" => Some(CInt), - "c_double" => Some(CDouble), - "c_float" => Some(CFloat), "c_long" => Some(CLong), "c_longlong" => Some(CLongLong), "c_schar" => Some(CSChar), @@ -102,8 +98,6 @@ impl AsRef for Atom { CxxString => "CxxString", RustString => "String", CInt => "c_int", - CDouble => "c_double", - CFloat => "c_float", CLong => "c_long", CLongLong => "c_longlong", CSChar => "c_schar", diff --git a/syntax/check.rs b/syntax/check.rs index 04bfce060..1ab9332c9 100644 --- a/syntax/check.rs +++ b/syntax/check.rs @@ -125,9 +125,9 @@ fn check_type_rust_vec(cx: &mut Check, ty: &Ty1) { match Atom::from(&ident.rust) { None | Some(Char) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) - | Some(F64) | Some(RustString) | Some(CInt) | Some(CDouble) | Some(CFloat) - | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) - | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, + | Some(F64) | Some(RustString) | Some(CInt) | Some(CLong) | Some(CLongLong) + | Some(CSChar) | Some(CShort) | Some(CUChar) | Some(CUInt) | Some(CULong) + | Some(CULongLong) | Some(CUShort) => return, Some(Bool) => { /* todo */ } Some(CxxString) => {} } @@ -167,9 +167,9 @@ fn check_type_shared_ptr(cx: &mut Check, ptr: &Ty1) { match Atom::from(&ident.rust) { None | Some(Bool) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) - | Some(F64) | Some(CxxString) | Some(CInt) | Some(CDouble) | Some(CFloat) - | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) - | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, + | Some(F64) | Some(CxxString) | Some(CInt) | Some(CLong) | Some(CLongLong) + | Some(CSChar) | Some(CShort) | Some(CUChar) | Some(CUInt) | Some(CULong) + | Some(CULongLong) | Some(CUShort) => return, Some(Char) | Some(RustString) => {} } } else if let Type::CxxVector(_) = &ptr.inner { @@ -190,9 +190,9 @@ fn check_type_weak_ptr(cx: &mut Check, ptr: &Ty1) { match Atom::from(&ident.rust) { None | Some(Bool) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) - | Some(F64) | Some(CxxString) | Some(CInt) | Some(CDouble) | Some(CFloat) - | Some(CLong) | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) - | Some(CUInt) | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, + | Some(F64) | Some(CxxString) | Some(CInt) | Some(CLong) | Some(CLongLong) + | Some(CSChar) | Some(CShort) | Some(CUChar) | Some(CUInt) | Some(CULong) + | Some(CULongLong) | Some(CUShort) => return, Some(Char) | Some(RustString) => {} } } else if let Type::CxxVector(_) = &ptr.inner { @@ -216,9 +216,9 @@ fn check_type_cxx_vector(cx: &mut Check, ptr: &Ty1) { match Atom::from(&ident.rust) { None | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) | Some(F64) - | Some(CxxString) | Some(CInt) | Some(CDouble) | Some(CFloat) | Some(CLong) - | Some(CLongLong) | Some(CSChar) | Some(CShort) | Some(CUChar) | Some(CUInt) - | Some(CULong) | Some(CULongLong) | Some(CUShort) => return, + | Some(CxxString) | Some(CInt) | Some(CLong) | Some(CLongLong) | Some(CSChar) + | Some(CShort) | Some(CUChar) | Some(CUInt) | Some(CULong) | Some(CULongLong) + | Some(CUShort) => return, Some(Char) => { /* todo */ } Some(Bool) | Some(RustString) => {} } diff --git a/syntax/pod.rs b/syntax/pod.rs index 7778e9250..423842777 100644 --- a/syntax/pod.rs +++ b/syntax/pod.rs @@ -9,8 +9,8 @@ impl<'a> Types<'a> { if let Some(atom) = Atom::from(ident) { match atom { Bool | Char | U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 - | Isize | F32 | F64 | CInt | CDouble | CFloat | CLong | CLongLong - | CSChar | CShort | CUChar | CUInt | CULong | CULongLong | CUShort => true, + | Isize | F32 | F64 | CInt | CLong | CLongLong | CSChar | CShort + | CUChar | CUInt | CULong | CULongLong | CUShort => true, CxxString | RustString => false, } } else if let Some(strct) = self.structs.get(ident) { diff --git a/syntax/tokens.rs b/syntax/tokens.rs index 700c1ccd1..45b197688 100644 --- a/syntax/tokens.rs +++ b/syntax/tokens.rs @@ -13,8 +13,6 @@ impl ToTokens for Type { Type::Ident(ident) => { if ident.rust == Char || ident.rust == CInt - || ident.rust == CDouble - || ident.rust == CFloat || ident.rust == CLong || ident.rust == CLongLong || ident.rust == CSChar diff --git a/tests/ffi/lib.rs b/tests/ffi/lib.rs index 6d6b88a54..eda2fecdb 100644 --- a/tests/ffi/lib.rs +++ b/tests/ffi/lib.rs @@ -126,8 +126,6 @@ pub mod ffi { fn c_return_mut_ptr(n: usize) -> *mut C; fn c_return_char() -> c_char; fn c_return_cint() -> c_int; - fn c_return_cdouble() -> c_double; - fn c_return_cfloat() -> c_float; fn c_return_clong() -> c_long; fn c_return_clonglong() -> c_longlong; fn c_return_cschar() -> c_schar; diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc index 22302b053..58e71680b 100644 --- a/tests/ffi/tests.cc +++ b/tests/ffi/tests.cc @@ -215,8 +215,6 @@ char c_return_char() { return 'a'; } int c_return_cint() { return 7; } -double c_return_cdouble() { return 8.0; } -float c_return_cfloat() { return 9.0; } long c_return_clong() { return 10; } long long c_return_clonglong() { return 11; } signed char c_return_cschar() { return 12; } diff --git a/tests/ffi/tests.h b/tests/ffi/tests.h index 5b38d27ba..120677a00 100644 --- a/tests/ffi/tests.h +++ b/tests/ffi/tests.h @@ -122,8 +122,6 @@ const C *c_return_const_ptr(size_t n); C *c_return_mut_ptr(size_t n); char c_return_char(); int c_return_cint(); -double c_return_cdouble(); -float c_return_cfloat(); long c_return_clong(); long long c_return_clonglong(); signed char c_return_cschar(); diff --git a/tests/test.rs b/tests/test.rs index 2040198b0..a7d0a38a8 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -101,8 +101,6 @@ fn test_c_return() { // aliases for i32, etc. fn test_c_return_raw_types() { assert_eq!(ffi::c_return_cint(), 7 as std::os::raw::c_int); - assert_eq!(ffi::c_return_cdouble(), 8 as std::os::raw::c_double); - assert_eq!(ffi::c_return_cfloat(), 9 as std::os::raw::c_float); assert_eq!(ffi::c_return_clong(), 10 as std::os::raw::c_long); assert_eq!(ffi::c_return_clonglong(), 11 as std::os::raw::c_longlong); assert_eq!(ffi::c_return_cschar(), 12 as std::os::raw::c_schar);