diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2021-09-04 19:21:19 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2021-09-04 19:21:19 +0100 |
| commit | 31ebff513fad11f315377f6b07447169be8d9f86 (patch) | |
| tree | d95b132eee4136110e5f8edb3ae90c7065c8829b /scripts/qapi/types.py | |
| parent | 9c03aa87e52567f6c9a7bf456e5dd94dc84088de (diff) | |
| parent | 34f7b25e575a93182b7c0a3558caac34e26227cf (diff) | |
| download | focaccia-qemu-31ebff513fad11f315377f6b07447169be8d9f86.tar.gz focaccia-qemu-31ebff513fad11f315377f6b07447169be8d9f86.zip | |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-09-03' into staging
QAPI patches patches for 2021-09-03 # gpg: Signature made Fri 03 Sep 2021 16:20:49 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-09-03: qapi: Tweak error messages for unknown / conflicting 'if' keys qapi: Tweak error messages for missing / conflicting meta-type tests/qapi-schema: Hide OrderedDict in test output qapi: Use re.fullmatch() where appropriate qapi: Use "not COND" instead of "!COND" for generated documentation qapi: Avoid redundant parens in code generated for conditionals qapi: Factor common recursion out of cgen_ifcond(), docgen_ifcond() qapi: Fix C code generation for 'if' tests/qapi-schema: Demonstrate broken C code for 'if' tests/qapi-schema: Correct two 'if' conditionals qapi: Simplify how QAPISchemaIfCond represents "no condition" qapi: Simplify QAPISchemaIfCond's interface for generating C qapi: Set boolean value correctly in examples Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/types.py')
| -rw-r--r-- | scripts/qapi/types.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index db9ff95bd1..831294fe42 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -15,13 +15,7 @@ This work is licensed under the terms of the GNU GPL, version 2. from typing import List, Optional -from .common import ( - c_enum_const, - c_name, - gen_endif, - gen_if, - mcgen, -) +from .common import c_enum_const, c_name, mcgen from .gen import QAPISchemaModularCVisitor, ifcontext from .schema import ( QAPISchema, @@ -51,13 +45,13 @@ const QEnumLookup %(c_name)s_lookup = { ''', c_name=c_name(name)) for memb in members: - ret += gen_if(memb.ifcond.cgen()) + ret += memb.ifcond.gen_if() index = c_enum_const(name, memb.name, prefix) ret += mcgen(''' [%(index)s] = "%(name)s", ''', index=index, name=memb.name) - ret += gen_endif(memb.ifcond.cgen()) + ret += memb.ifcond.gen_endif() ret += mcgen(''' }, @@ -81,12 +75,12 @@ typedef enum %(c_name)s { c_name=c_name(name)) for memb in enum_members: - ret += gen_if(memb.ifcond.cgen()) + ret += memb.ifcond.gen_if() ret += mcgen(''' %(c_enum)s, ''', c_enum=c_enum_const(name, memb.name, prefix)) - ret += gen_endif(memb.ifcond.cgen()) + ret += memb.ifcond.gen_endif() ret += mcgen(''' } %(c_name)s; @@ -126,7 +120,7 @@ struct %(c_name)s { def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str: ret = '' for memb in members: - ret += gen_if(memb.ifcond.cgen()) + ret += memb.ifcond.gen_if() if memb.optional: ret += mcgen(''' bool has_%(c_name)s; @@ -136,7 +130,7 @@ def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str: %(c_type)s %(c_name)s; ''', c_type=memb.type.c_type(), c_name=c_name(memb.name)) - ret += gen_endif(memb.ifcond.cgen()) + ret += memb.ifcond.gen_endif() return ret @@ -159,7 +153,7 @@ def gen_object(name: str, ifcond: QAPISchemaIfCond, ret += mcgen(''' ''') - ret += gen_if(ifcond.cgen()) + ret += ifcond.gen_if() ret += mcgen(''' struct %(c_name)s { ''', @@ -193,7 +187,7 @@ struct %(c_name)s { ret += mcgen(''' }; ''') - ret += gen_endif(ifcond.cgen()) + ret += ifcond.gen_endif() return ret @@ -220,13 +214,13 @@ def gen_variants(variants: QAPISchemaVariants) -> str: for var in variants.variants: if var.type.name == 'q_empty': continue - ret += gen_if(var.ifcond.cgen()) + ret += var.ifcond.gen_if() ret += mcgen(''' %(c_type)s %(c_name)s; ''', c_type=var.type.c_unboxed_type(), c_name=c_name(var.name)) - ret += gen_endif(var.ifcond.cgen()) + ret += var.ifcond.gen_endif() ret += mcgen(''' } u; |