diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi-types.py | 8 | ||||
-rw-r--r-- | scripts/qapi-visit.py | 22 | ||||
-rw-r--r-- | scripts/qapi.py | 10 |
3 files changed, 5 insertions, 35 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 79416b23ae..92ae619fa4 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -121,16 +121,10 @@ def gen_variants(variants): c_name=c_name(variants.tag_member.name)) for var in variants.variants: - # Ugly special case for simple union TODO get rid of it - simple_union_type = var.simple_union_type() - if simple_union_type: - typ = simple_union_type.c_type() - else: - typ = var.type.c_unboxed_type() ret += mcgen(''' %(c_type)s %(c_name)s; ''', - c_type=typ, + c_type=var.type.c_unboxed_type(), c_name=c_name(var.name)) ret += mcgen(''' diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 5220badf28..c147990efe 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -77,29 +77,15 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp) c_name=c_name(variants.tag_member.name)) for var in variants.variants: - # TODO ugly special case for simple union - simple_union_type = var.simple_union_type() ret += mcgen(''' case %(case)s: + visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, &err); + break; ''', case=c_enum_const(variants.tag_member.type.name, var.name, - variants.tag_member.type.prefix)) - if simple_union_type: - ret += mcgen(''' - visit_type_%(c_type)s(v, "data", &obj->u.%(c_name)s, &err); -''', - c_type=simple_union_type.c_name(), - c_name=c_name(var.name)) - else: - ret += mcgen(''' - visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, &err); -''', - c_type=var.type.c_name(), - c_name=c_name(var.name)) - ret += mcgen(''' - break; -''') + variants.tag_member.type.prefix), + c_type=var.type.c_name(), c_name=c_name(var.name)) ret += mcgen(''' default: diff --git a/scripts/qapi.py b/scripts/qapi.py index 08d63bffc8..d91af94759 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1115,16 +1115,6 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): def __init__(self, name, typ): QAPISchemaObjectTypeMember.__init__(self, name, typ, False) - # This function exists to support ugly simple union special cases - # TODO get rid of them, and drop the function - def simple_union_type(self): - if (self.type.is_implicit() and - isinstance(self.type, QAPISchemaObjectType)): - assert len(self.type.members) == 1 - assert not self.type.variants - return self.type.members[0].type - return None - class QAPISchemaAlternateType(QAPISchemaType): def __init__(self, name, info, variants): |