aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-05-07 09:53:46 +0200
committerLuiz Capitulino <lcapitulino@redhat.com>2014-05-15 14:00:45 -0400
commite2cd0f4fb42b1fae65ad22e8efde9804446e6254 (patch)
treef8ea58b96ee1114f9dd0c45d67d567faec516df3 /scripts
parentcbc95538eda98929d2c5c8ff0d9db9043fcf1ae6 (diff)
downloadqemu-e2cd0f4fb42b1fae65ad22e8efde9804446e6254.zip
qemu-e2cd0f4fb42b1fae65ad22e8efde9804446e6254.tar.gz
qemu-e2cd0f4fb42b1fae65ad22e8efde9804446e6254.tar.bz2
qapi: Replace start_optional()/end_optional() by optional()
Semantics of end_optional() differ subtly from the other end_FOO() callbacks: when start_FOO() succeeds, the matching end_FOO() gets called regardless of what happens in between. end_optional() gets called only when everything in between succeeds as well. Entirely undocumented, like all of the visitor API. The only user of Visitor Callback end_optional() never did anything, and was removed in commit 9f9ab46. I'm about to clean up error handling in the generated visitor code, and end_optional() is in my way. No users mean no test cases, and making non-trivial cleanup transformations without test cases doesn't strike me as a good idea. Drop end_optional(), and rename start_optional() to optional(). We can always go back to a pair of callbacks when we have an actual need. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-commands.py5
-rw-r--r--scripts/qapi-visit.py3
2 files changed, 3 insertions, 5 deletions
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 1399826..341dba2 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -131,7 +131,7 @@ v = qmp_input_get_visitor(mi);
for argname, argtype, optional, structured in parse_args(args):
if optional:
ret += mcgen('''
-visit_start_optional(v, &has_%(c_name)s, "%(name)s", %(errp)s);
+visit_optional(v, &has_%(c_name)s, "%(name)s", %(errp)s);
if (has_%(c_name)s) {
''',
c_name=c_var(argname), name=argname, errp=errparg)
@@ -145,8 +145,7 @@ if (has_%(c_name)s) {
pop_indent()
ret += mcgen('''
}
-visit_end_optional(v, %(errp)s);
-''', errp=errparg)
+''')
if dealloc:
ret += mcgen('''
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index c6579be..9f22eee 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -61,7 +61,7 @@ if (!err) {
for argname, argentry, optional, structured in parse_args(members):
if optional:
ret += mcgen('''
-visit_start_optional(m, &(*obj)->%(c_prefix)shas_%(c_name)s, "%(name)s", &err);
+visit_optional(m, &(*obj)->%(c_prefix)shas_%(c_name)s, "%(name)s", &err);
if ((*obj)->%(prefix)shas_%(c_name)s) {
''',
c_prefix=c_var(field_prefix), prefix=field_prefix,
@@ -82,7 +82,6 @@ visit_type_%(type)s(m, &(*obj)->%(c_prefix)s%(c_name)s, "%(name)s", &err);
pop_indent()
ret += mcgen('''
}
-visit_end_optional(m, &err);
''')
pop_indent()