Support rename rule for union body members.

Closes #751.
This commit is contained in:
kavoor
2022-04-13 01:34:53 -07:00
committed by Emilio Cobos Álvarez
parent 770f352375
commit 5b418d968c
12 changed files with 216 additions and 11 deletions
+23 -1
View File
@@ -204,6 +204,27 @@ typedef struct Q {
};
} Q;
typedef enum R_Tag {
IRFoo,
IRBar,
IRBaz,
} R_Tag;
typedef struct IRBar_Body {
uint8_t x;
int16_t y;
} IRBar_Body;
typedef struct R {
R_Tag tag;
union {
struct {
int16_t IRFoo;
};
IRBar_Body IRBar;
};
} R;
void root(struct Opaque *opaque,
A a,
B b,
@@ -221,7 +242,8 @@ void root(struct Opaque *opaque,
enum N n,
O o,
struct P p,
struct Q q);
struct Q q,
struct R r);
#if 0
''' '
+23 -1
View File
@@ -270,6 +270,27 @@ typedef struct Q {
};
} Q;
typedef enum R_Tag {
IRFoo,
IRBar,
IRBaz,
} R_Tag;
typedef struct IRBar_Body {
uint8_t x;
int16_t y;
} IRBar_Body;
typedef struct R {
R_Tag tag;
union {
struct {
int16_t IRFoo;
};
IRBar_Body IRBar;
};
} R;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@@ -291,7 +312,8 @@ void root(struct Opaque *opaque,
enum N n,
O o,
struct P p,
struct Q q);
struct Q q,
struct R r);
#ifdef __cplusplus
} // extern "C"
+23 -1
View File
@@ -204,6 +204,27 @@ typedef struct {
};
} Q;
typedef enum {
IRFoo,
IRBar,
IRBaz,
} R_Tag;
typedef struct {
uint8_t x;
int16_t y;
} IRBar_Body;
typedef struct {
R_Tag tag;
union {
struct {
int16_t IRFoo;
};
IRBar_Body IRBar;
};
} R;
void root(Opaque *opaque,
A a,
B b,
@@ -221,7 +242,8 @@ void root(Opaque *opaque,
N n,
O o,
P p,
Q q);
Q q,
R r);
#if 0
''' '
+23 -1
View File
@@ -270,6 +270,27 @@ typedef struct {
};
} Q;
typedef enum {
IRFoo,
IRBar,
IRBaz,
} R_Tag;
typedef struct {
uint8_t x;
int16_t y;
} IRBar_Body;
typedef struct {
R_Tag tag;
union {
struct {
int16_t IRFoo;
};
IRBar_Body IRBar;
};
} R;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@@ -291,7 +312,8 @@ void root(Opaque *opaque,
N n,
O o,
P p,
Q q);
Q q,
R r);
#ifdef __cplusplus
} // extern "C"
+25 -1
View File
@@ -208,6 +208,29 @@ struct Q {
};
};
struct R {
enum class Tag {
IRFoo,
IRBar,
IRBaz,
};
struct IRFoo_Body {
int16_t _0;
};
struct IRBar_Body {
uint8_t x;
int16_t y;
};
Tag tag;
union {
IRFoo_Body IRFoo;
IRBar_Body IRBar;
};
};
extern "C" {
void root(Opaque *opaque,
@@ -227,7 +250,8 @@ void root(Opaque *opaque,
N n,
O o,
P p,
Q q);
Q q,
R r);
} // extern "C"
+16 -1
View File
@@ -165,6 +165,20 @@ cdef extern from *:
uint32_t *ok;
uint32_t err;
ctypedef enum R_Tag:
IRFoo,
IRBar,
IRBaz,
ctypedef struct IRBar_Body:
uint8_t x;
int16_t y;
ctypedef struct R:
R_Tag tag;
int16_t IRFoo;
IRBar_Body IRBar;
void root(Opaque *opaque,
A a,
B b,
@@ -182,7 +196,8 @@ cdef extern from *:
N n,
O o,
P p,
Q q);
Q q,
R r);
#if 0
''' '
+23 -1
View File
@@ -204,6 +204,27 @@ struct Q {
};
};
enum R_Tag {
IRFoo,
IRBar,
IRBaz,
};
struct IRBar_Body {
uint8_t x;
int16_t y;
};
struct R {
enum R_Tag tag;
union {
struct {
int16_t IRFoo;
};
struct IRBar_Body IRBar;
};
};
void root(struct Opaque *opaque,
A a,
B b,
@@ -221,7 +242,8 @@ void root(struct Opaque *opaque,
enum N n,
O o,
struct P p,
struct Q q);
struct Q q,
struct R r);
#if 0
''' '
+23 -1
View File
@@ -270,6 +270,27 @@ struct Q {
};
};
enum R_Tag {
IRFoo,
IRBar,
IRBaz,
};
struct IRBar_Body {
uint8_t x;
int16_t y;
};
struct R {
enum R_Tag tag;
union {
struct {
int16_t IRFoo;
};
struct IRBar_Body IRBar;
};
};
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@@ -291,7 +312,8 @@ void root(struct Opaque *opaque,
enum N n,
O o,
struct P p,
struct Q q);
struct Q q,
struct R r);
#ifdef __cplusplus
} // extern "C"
+16 -1
View File
@@ -165,6 +165,20 @@ cdef extern from *:
uint32_t *ok;
uint32_t err;
cdef enum R_Tag:
IRFoo,
IRBar,
IRBaz,
cdef struct IRBar_Body:
uint8_t x;
int16_t y;
cdef struct R:
R_Tag tag;
int16_t IRFoo;
IRBar_Body IRBar;
void root(Opaque *opaque,
A a,
B b,
@@ -182,7 +196,8 @@ cdef extern from *:
N n,
O o,
P p,
Q q);
Q q,
R r);
#if 0
''' '
+9
View File
@@ -133,6 +133,14 @@ enum Q {
Err(u32),
}
/// cbindgen:rename-variant-name-fields=None
#[repr(C)]
enum R {
IRFoo(i16),
IRBar { x: u8, y: i16 },
IRBaz,
}
#[no_mangle]
pub extern "C" fn root(
opaque: *mut Opaque,
@@ -153,5 +161,6 @@ pub extern "C" fn root(
o: O,
p: P,
q: Q,
r: R,
) {
}