diff options
-rw-r--r-- | src/gen.rs | 18 | ||||
-rw-r--r-- | src/types.rs | 18 |
2 files changed, 19 insertions, 17 deletions
@@ -700,22 +700,6 @@ fn const_to_rs(ctx: &mut GenCtx, name: String, val: i64, val_ty: ast::Ty) -> P<a }) } -fn enum_kind_is_signed(kind: IKind) -> bool { - match kind { - IBool => false, - ISChar => true, - IUChar => false, - IShort => true, - IUShort => false, - IInt => true, - IUInt => false, - ILong => true, - IULong => false, - ILongLong => true, - IULongLong => false, - } -} - fn enum_size_to_rust_type_name(signed: bool, size: usize) -> &'static str { match (signed, size) { (true, 1) => "i8", @@ -774,7 +758,7 @@ fn cenum_to_rs(ctx: &mut GenCtx, -> Vec<P<ast::Item>> { let enum_name = ctx.ext_cx.ident_of(&name); let enum_ty = ctx.ext_cx.ty_ident(ctx.span, enum_name); - let enum_is_signed = enum_kind_is_signed(kind); + let enum_is_signed = kind.is_signed(); let mut variants = vec![]; let mut found_values = HashMap::new(); diff --git a/src/types.rs b/src/types.rs index 14526fd0..a8726b53 100644 --- a/src/types.rs +++ b/src/types.rs @@ -174,6 +174,24 @@ pub enum IKind { IULongLong } +impl IKind { + pub fn is_signed(self) -> bool { + match self { + IBool => false, + ISChar => true, + IUChar => false, + IShort => true, + IUShort => false, + IInt => true, + IUInt => false, + ILong => true, + IULong => false, + ILongLong => true, + IULongLong => false, + } + } +} + #[derive(Copy, Clone, PartialEq)] pub enum FKind { FFloat, |