diff options
author | Eric Blake <eblake@redhat.com> | 2015-10-26 16:35:03 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2015-11-02 08:30:28 +0100 |
commit | 32bc6879beea0b0cac6196cb15a71d206401e96d (patch) | |
tree | 797e056bb817327f14abd49769c8604717b82ba6 | |
parent | 5e59baf90a72cd25d38a3134edc029f4f022da74 (diff) | |
download | hqemu-32bc6879beea0b0cac6196cb15a71d206401e96d.zip hqemu-32bc6879beea0b0cac6196cb15a71d206401e96d.tar.gz |
qapi: Simplify gen_struct_field()
Rather than having all callers pass a name, type, and optional
flag, have them instead pass a QAPISchemaObjectTypeMember which
already has all that information.
No change to generated code.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1445898903-12082-25-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r-- | scripts/qapi-types.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 7e35bb6..b37900f 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -36,18 +36,18 @@ struct %(c_name)s { c_name=c_name(name), c_type=element_type.c_type()) -def gen_struct_field(name, typ, optional): +def gen_struct_field(member): ret = '' - if optional: + if member.optional: ret += mcgen(''' bool has_%(c_name)s; ''', - c_name=c_name(name)) + c_name=c_name(member.name)) ret += mcgen(''' %(c_type)s %(c_name)s; ''', - c_type=typ.c_type(), c_name=c_name(name)) + c_type=member.type.c_type(), c_name=c_name(member.name)) return ret @@ -60,13 +60,13 @@ def gen_struct_fields(local_members, base=None): ''', c_name=base.c_name()) for memb in base.members: - ret += gen_struct_field(memb.name, memb.type, memb.optional) + ret += gen_struct_field(memb) ret += mcgen(''' /* Own members: */ ''') for memb in local_members: - ret += gen_struct_field(memb.name, memb.type, memb.optional) + ret += gen_struct_field(memb) return ret @@ -149,9 +149,7 @@ struct %(c_name)s { if base: ret += gen_struct_fields([], base) else: - ret += gen_struct_field(variants.tag_member.name, - variants.tag_member.type, - False) + ret += gen_struct_field(variants.tag_member) # 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 |