diff options
author | Marc-André Lureau | 2018-12-13 13:37:11 +0100 |
---|---|---|
committer | Markus Armbruster | 2018-12-13 19:20:11 +0100 |
commit | 6cc32b0e14b3f91e15a9511d90b222abc1df391d (patch) | |
tree | 3b8cbbcd19be7c206ae11dd861328ce58dfd6034 /scripts | |
parent | qapi: add a dictionary form with 'name' key for enum members (diff) | |
download | qemu-6cc32b0e14b3f91e15a9511d90b222abc1df391d.tar.gz qemu-6cc32b0e14b3f91e15a9511d90b222abc1df391d.tar.xz qemu-6cc32b0e14b3f91e15a9511d90b222abc1df391d.zip |
qapi: add 'if' to enum members
QAPISchemaMember gains .ifcond for enum members: inherited classes,
such as QAPISchemaObjectTypeMember, will thus have an ifcond member
after this (those different types will also use the .ifcond to store
the condition and generate conditional code in the following patches).
The generated code remains unconditional for now. Later patches
generate the conditionals.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20181213123724.4866-10-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi/common.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index b1cf33af21..a609ffcfee 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -871,7 +871,8 @@ def check_enum(expr, info): for member in members: source = "dictionary member of enum '%s'" % name - check_known_keys(info, source, member, ['name'], []) + check_known_keys(info, source, member, ['name'], ['if']) + check_if(member, info) check_name(info, "Member of enum '%s'" % name, member['name'], enum_member=True) @@ -1345,9 +1346,10 @@ class QAPISchemaObjectType(QAPISchemaType): class QAPISchemaMember(object): role = 'member' - def __init__(self, name): + def __init__(self, name, ifcond=None): assert isinstance(name, str) self.name = name + self.ifcond = listify_cond(ifcond) self.owner = None def set_owner(self, name): @@ -1656,7 +1658,7 @@ class QAPISchema(object): qtype_values, 'QTYPE')) def _make_enum_members(self, values): - return [QAPISchemaMember(v['name']) for v in values] + return [QAPISchemaMember(v['name'], v.get('if')) for v in values] def _make_implicit_enum_type(self, name, info, ifcond, values): # See also QAPISchemaObjectTypeMember._pretty_owner() |