From aa04308986cf18d47c5257ee96282d2c8f924562 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Tue, 4 Apr 2017 08:40:06 +0100 Subject: [PATCH] Tidy up handling of char --- src/ir/context.rs | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/src/ir/context.rs b/src/ir/context.rs index 66e7e28482..fe079ef0b8 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -1090,38 +1090,10 @@ impl<'ctx> BindgenContext<'ctx> { CXType_Bool => TypeKind::Int(IntKind::Bool), CXType_Int => TypeKind::Int(IntKind::Int), CXType_UInt => TypeKind::Int(IntKind::UInt), - CXType_SChar | CXType_Char_S | - CXType_UChar | CXType_Char_U => { - let spelling = ty.spelling(); - - debug_assert!(spelling.contains("char"), - "This is the canonical type, so no aliases or \ - typedefs!"); - - let signed = match ty.kind() { - CXType_SChar | CXType_Char_S => true, - _ => false, - }; - - // Clang only gives us the signedness of the target platform. - // - // Match the spelling for common cases we can handle - // cross-platform. - match &*spelling { - "char" | "const char" => { - TypeKind::Int(IntKind::Char { - is_signed: signed, - }) - }, - _ => { - if signed { - TypeKind::Int(IntKind::SChar) - } else { - TypeKind::Int(IntKind::UChar) - } - }, - } - } + CXType_Char_S => TypeKind::Int(IntKind::Char { is_signed: true }), + CXType_Char_U => TypeKind::Int(IntKind::Char { is_signed: false }), + CXType_SChar => TypeKind::Int(IntKind::SChar), + CXType_UChar => TypeKind::Int(IntKind::UChar), CXType_Short => TypeKind::Int(IntKind::Short), CXType_UShort => TypeKind::Int(IntKind::UShort), CXType_WChar | CXType_Char16 => TypeKind::Int(IntKind::U16),