Commit bd494d46 authored by Ingvar Stepanyan's avatar Ingvar Stepanyan Committed by Ryan Hunt

Simplify enum variant handling

parent 3355f2b1
This diff is collapsed.
......@@ -22,7 +22,7 @@ pub struct Struct {
pub name: String,
pub generic_params: GenericParams,
pub fields: Vec<(String, Type, Documentation)>,
pub is_variant: bool,
pub is_tagged: bool,
pub tuple_struct: bool,
pub cfg: Option<Cfg>,
pub annotations: AnnotationSet,
......@@ -64,7 +64,7 @@ impl Struct {
name: name,
generic_params: GenericParams::new(generics),
fields: fields,
is_variant: false,
is_tagged: false,
tuple_struct: tuple_struct,
cfg: Cfg::append(mod_cfg, Cfg::load(attrs)),
annotations: AnnotationSet::load(attrs)?,
......@@ -145,7 +145,7 @@ impl Item for Struct {
}
} else if self.tuple_struct {
// If there is a tag field, skip it
if self.is_variant {
if self.is_tagged {
names.next();
}
......@@ -183,7 +183,7 @@ impl Item for Struct {
.iter()
.map(|x| (x.0.clone(), x.1.specialize(&mappings), x.2.clone()))
.collect(),
is_variant: self.is_variant,
is_tagged: self.is_tagged,
tuple_struct: self.tuple_struct,
cfg: self.cfg.clone(),
annotations: self.annotations.clone(),
......
......@@ -3,8 +3,8 @@
#include <stdbool.h>
enum Status {
Ok = 0,
Err = 1,
Ok,
Err,
};
typedef uint32_t Status;
......
......@@ -2,8 +2,8 @@
#include <cstdlib>
enum class Status : uint32_t {
Ok = 0,
Err = 1,
Ok,
Err,
};
struct Dep {
......
......@@ -4,7 +4,7 @@
enum C {
X = 2,
Y = 3,
Y,
};
typedef uint32_t C;
......
......@@ -3,7 +3,7 @@
enum class C : uint32_t {
X = 2,
Y = 3,
Y,
};
struct A {
......
......@@ -4,18 +4,18 @@
#if (defined(PLATFORM_WIN) || defined(M_32))
enum BarType {
A = 0,
B = 1,
C = 2,
A,
B,
C,
};
typedef uint32_t BarType;
#endif
#if (defined(PLATFORM_UNIX) && defined(X11))
enum FooType {
A = 0,
B = 1,
C = 2,
A,
B,
C,
};
typedef uint32_t FooType;
#endif
......
......@@ -3,17 +3,17 @@
#if (defined(PLATFORM_WIN) || defined(M_32))
enum class BarType : uint32_t {
A = 0,
B = 1,
C = 2,
A,
B,
C,
};
#endif
#if (defined(PLATFORM_UNIX) && defined(X11))
enum class FooType : uint32_t {
A = 0,
B = 1,
C = 2,
A,
B,
C,
};
#endif
......
......@@ -5,7 +5,7 @@
enum A {
a1 = 0,
a2 = 2,
a3 = 3,
a3,
a4 = 5,
};
typedef uint32_t A;
......@@ -13,7 +13,7 @@ typedef uint32_t A;
enum B {
b1 = 0,
b2 = 2,
b3 = 3,
b3,
b4 = 5,
};
typedef uint16_t B;
......@@ -21,7 +21,7 @@ typedef uint16_t B;
enum C {
c1 = 0,
c2 = 2,
c3 = 3,
c3,
c4 = 5,
};
typedef uint8_t C;
......@@ -29,7 +29,7 @@ typedef uint8_t C;
enum D {
d1 = 0,
d2 = 2,
d3 = 3,
d3,
d4 = 5,
};
typedef uintptr_t D;
......@@ -37,15 +37,15 @@ typedef uintptr_t D;
enum E {
e1 = 0,
e2 = 2,
e3 = 3,
e3,
e4 = 5,
};
typedef intptr_t E;
enum F_Tag {
Foo = 0,
Bar = 1,
Baz = 2,
Foo,
Bar,
Baz,
};
typedef uint8_t F_Tag;
......@@ -67,9 +67,9 @@ typedef union {
} F;
typedef enum {
G_Foo = 0,
G_Bar = 1,
G_Baz = 2,
G_Foo,
G_Bar,
G_Baz,
} G_Tag;
typedef struct {
......
......@@ -4,43 +4,43 @@
enum class A : uint32_t {
a1 = 0,
a2 = 2,
a3 = 3,
a3,
a4 = 5,
};
enum class B : uint16_t {
b1 = 0,
b2 = 2,
b3 = 3,
b3,
b4 = 5,
};
enum class C : uint8_t {
c1 = 0,
c2 = 2,
c3 = 3,
c3,
c4 = 5,
};
enum class D : uintptr_t {
d1 = 0,
d2 = 2,
d3 = 3,
d3,
d4 = 5,
};
enum class E : intptr_t {
e1 = 0,
e2 = 2,
e3 = 3,
e3,
e4 = 5,
};
union F {
enum class Tag : uint8_t {
Foo = 0,
Bar = 1,
Baz = 2,
Foo,
Bar,
Baz,
};
struct Foo_Body {
......@@ -61,9 +61,9 @@ union F {
struct G {
enum class Tag {
G_Foo = 0,
G_Bar = 1,
G_Baz = 2,
G_Foo,
G_Bar,
G_Baz,
};
struct G_Foo_Body {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment