diff options
Diffstat (limited to 'scripts/qapi-types.py')
-rw-r--r-- | scripts/qapi-types.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 4dabe91c92..eac90d2fe9 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -116,14 +116,6 @@ static inline %(base)s *qapi_%(c_name)s_base(const %(c_name)s *obj) def gen_variants(variants): - # HACK: Determine if this is an alternate (at least one variant - # is not an object); unions have all branches as objects. - unboxed = False - for v in variants.variants: - if not isinstance(v.type, QAPISchemaObjectType): - unboxed = True - break - # FIXME: What purpose does data serve, besides preventing a union that # has a branch named 'data'? We use it in qapi-visit.py to decide # whether to bypass the switch statement if visiting the discriminator @@ -140,11 +132,12 @@ def gen_variants(variants): for var in variants.variants: # Ugly special case for simple union TODO get rid of it - typ = var.simple_union_type() or var.type + simple_union_type = var.simple_union_type() + typ = simple_union_type or var.type ret += mcgen(''' %(c_type)s %(c_name)s; ''', - c_type=typ.c_type(is_unboxed=unboxed), + c_type=typ.c_type(is_unboxed=not simple_union_type), c_name=c_name(var.name)) ret += mcgen(''' |