aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi/visit.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-08-31 14:37:58 +0200
committerMarkus Armbruster <armbru@redhat.com>2021-09-03 17:06:40 +0200
commit1889e57a7140c4f89c8fd9a217f8c3845eb48b5b (patch)
tree86307aa6c4f5b872aeaaf0ce760566c579c1c43c /scripts/qapi/visit.py
parent3e038d7d7a2616e12a07b08df6a9c9239ff7f228 (diff)
downloadqemu-1889e57a7140c4f89c8fd9a217f8c3845eb48b5b.zip
qemu-1889e57a7140c4f89c8fd9a217f8c3845eb48b5b.tar.gz
qemu-1889e57a7140c4f89c8fd9a217f8c3845eb48b5b.tar.bz2
qapi: Simplify QAPISchemaIfCond's interface for generating C
QAPISchemaIfCond.cgen() is only ever used like gen_if(ifcond.cgen()) and gen_endif(ifcond.cgen()) Simplify to ifcond.gen_if() and ifcond.gen_endif() Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-2-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [Import statements tidied up with isort]
Diffstat (limited to 'scripts/qapi/visit.py')
-rw-r--r--scripts/qapi/visit.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index 56ea516..9d9196a 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -18,8 +18,6 @@ from typing import List, Optional
from .common import (
c_enum_const,
c_name,
- gen_endif,
- gen_if,
indent,
mcgen,
)
@@ -79,7 +77,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
for memb in members:
deprecated = 'deprecated' in [f.name for f in memb.features]
- ret += gen_if(memb.ifcond.cgen())
+ ret += memb.ifcond.gen_if()
if memb.optional:
ret += mcgen('''
if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) {
@@ -112,7 +110,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
ret += mcgen('''
}
''')
- ret += gen_endif(memb.ifcond.cgen())
+ ret += memb.ifcond.gen_endif()
if variants:
tag_member = variants.tag_member
@@ -126,7 +124,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
for var in variants.variants:
case_str = c_enum_const(tag_member.type.name, var.name,
tag_member.type.prefix)
- ret += gen_if(var.ifcond.cgen())
+ ret += var.ifcond.gen_if()
if var.type.name == 'q_empty':
# valid variant and nothing to do
ret += mcgen('''
@@ -142,7 +140,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
case=case_str,
c_type=var.type.c_name(), c_name=c_name(var.name))
- ret += gen_endif(var.ifcond.cgen())
+ ret += var.ifcond.gen_endif()
ret += mcgen('''
default:
abort();
@@ -228,7 +226,7 @@ bool visit_type_%(c_name)s(Visitor *v, const char *name,
c_name=c_name(name))
for var in variants.variants:
- ret += gen_if(var.ifcond.cgen())
+ ret += var.ifcond.gen_if()
ret += mcgen('''
case %(case)s:
''',
@@ -254,7 +252,7 @@ bool visit_type_%(c_name)s(Visitor *v, const char *name,
ret += mcgen('''
break;
''')
- ret += gen_endif(var.ifcond.cgen())
+ ret += var.ifcond.gen_endif()
ret += mcgen('''
case QTYPE_NONE: