From: Richard Pospesel Subject: [PATCH 04/18] widl: refactor to have bitfield type's field use decl_spec_t rather than type_t Message-Id: <20190606013415.23642-4-richard@torproject.org> Date: Wed, 5 Jun 2019 18:34:01 -0700 In-Reply-To: <20190606013415.23642-1-richard@torproject.org> References: <20190606013415.23642-1-richard@torproject.org> Signed-off-by: Richard Pospesel --- tools/widl/header.c | 2 +- tools/widl/typetree.c | 2 +- tools/widl/typetree.h | 9 +++++++-- tools/widl/widltypes.h | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/widl/header.c b/tools/widl/header.c index 8c07564751..1c0a0ee040 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -423,7 +423,7 @@ void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly) fprintf(h, "void"); break; case TYPE_BITFIELD: - write_type_left(h, type_bitfield_get_field(t), name_type, declonly); + write_type_left(h, type_bitfield_get_field_type(t), name_type, declonly); break; case TYPE_ALIAS: case TYPE_FUNCTION: diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 0a8ae0f3b2..9c8747ea67 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -408,7 +408,7 @@ type_t *type_new_bitfield(type_t *field, const expr_t *bits) /* FIXME: validate bits->cval <= memsize(field) * 8 */ t = make_type(TYPE_BITFIELD); - t->details.bitfield.field = field; + t->details.bitfield.field.type = field; t->details.bitfield.bits = bits; return t; } diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 22232fc0a7..6b745d2667 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -313,11 +313,16 @@ static inline unsigned char type_pointer_get_default_fc(const type_t *type) return type->details.pointer.def_fc; } -static inline type_t *type_bitfield_get_field(const type_t *type) +static inline const decl_spec_t *type_bitfield_get_field(const type_t *type) { type = type_get_real_type(type); assert(type_get_type(type) == TYPE_BITFIELD); - return type->details.bitfield.field; + return &type->details.bitfield.field; +} + +static inline type_t *type_bitfield_get_field_type(const type_t *type) +{ + return type_bitfield_get_field(type)->type; } static inline const expr_t *type_bitfield_get_bits(const type_t *type) diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index bd727f70b6..59d5a284b2 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -390,7 +390,7 @@ struct pointer_details struct bitfield_details { - struct _type_t *field; + struct _decl_spec_t field; const expr_t *bits; }; -- 2.17.1