Skip to content

Commit

Permalink
Cleanup wchar_t layout computation to happen later. (#1596)
Browse files Browse the repository at this point in the history
This is a breaking cheange since WChar is exposed, but should be no behavior
change otherwise.
  • Loading branch information
emilio authored Jul 24, 2019
1 parent 9fe3e90 commit a3d8cf7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3060,8 +3060,9 @@ impl TryToRustTy for Type {
IntKind::ULong => Ok(raw_type(ctx, "c_ulong")),
IntKind::LongLong => Ok(raw_type(ctx, "c_longlong")),
IntKind::ULongLong => Ok(raw_type(ctx, "c_ulonglong")),
IntKind::WChar { size } => {
let ty = Layout::known_type_for_size(ctx, size)
IntKind::WChar => {
let layout = self.layout(ctx).expect("Couldn't compute wchar_t's layout?");
let ty = Layout::known_type_for_size(ctx, layout.size)
.expect("Non-representable wchar_t?");
let ident = ctx.rust_ident_raw(ty);
Ok(quote! { #ident })
Expand Down
6 changes: 1 addition & 5 deletions src/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2011,11 +2011,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
CXType_UChar => TypeKind::Int(IntKind::UChar),
CXType_Short => TypeKind::Int(IntKind::Short),
CXType_UShort => TypeKind::Int(IntKind::UShort),
CXType_WChar => {
TypeKind::Int(IntKind::WChar {
size: ty.fallible_size(self).expect("Couldn't compute size of wchar_t?"),
})
},
CXType_WChar => TypeKind::Int(IntKind::WChar),
CXType_Char16 => TypeKind::Int(IntKind::U16),
CXType_Char32 => TypeKind::Int(IntKind::U32),
CXType_Long => TypeKind::Int(IntKind::Long),
Expand Down
7 changes: 2 additions & 5 deletions src/ir/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ pub enum IntKind {
UChar,

/// An `wchar_t`.
WChar {
/// The size of the wchar_t in bytes, which will be 2 or 4.
size: usize,
},
WChar,

/// A platform-dependent `char` type, with the signedness support.
Char {
Expand Down Expand Up @@ -97,7 +94,7 @@ impl IntKind {
// to know whether it is or not right now (unlike char, there's no
// WChar_S / WChar_U).
Bool | UChar | UShort | UInt | ULong | ULongLong | U8 | U16 |
WChar { .. } | U32 | U64 | U128 => false,
WChar | U32 | U64 | U128 => false,

SChar | Short | Int | Long | LongLong | I8 | I16 | I32 | I64 |
I128 => true,
Expand Down

0 comments on commit a3d8cf7

Please sign in to comment.