qapi: Drop dead visitor code related to nested structs

Now that we no longer have nested structs to visit, the use of
prefix strings is no longer required.  Remove the code that is
no longer reachable.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Eric Blake 2015-05-04 09:05:34 -06:00 committed by Markus Armbruster
parent 6b5abc7df7
commit a82b982e2b
1 changed files with 12 additions and 37 deletions

View File

@ -43,50 +43,43 @@ def generate_visit_implicit_struct(type):
''', ''',
c_type=type_name(type)) c_type=type_name(type))
def generate_visit_struct_fields(name, field_prefix, fn_prefix, members, base = None): def generate_visit_struct_fields(name, members, base = None):
substructs = [] substructs = []
ret = '' ret = ''
if not fn_prefix:
full_name = name
else:
full_name = "%s_%s" % (name, fn_prefix)
if base: if base:
ret += generate_visit_implicit_struct(base) ret += generate_visit_implicit_struct(base)
ret += mcgen(''' ret += mcgen('''
static void visit_type_%(full_name)s_fields(Visitor *m, %(name)s **obj, Error **errp) static void visit_type_%(name)s_fields(Visitor *m, %(name)s **obj, Error **errp)
{ {
Error *err = NULL; Error *err = NULL;
''', ''',
name=name, full_name=full_name) name=name)
push_indent() push_indent()
if base: if base:
ret += mcgen(''' ret += mcgen('''
visit_type_implicit_%(type)s(m, &(*obj)->%(c_prefix)s%(c_name)s, &err); visit_type_implicit_%(type)s(m, &(*obj)->%(c_name)s, &err);
if (err) { if (err) {
goto out; goto out;
} }
''', ''',
c_prefix=c_var(field_prefix),
type=type_name(base), c_name=c_var('base')) type=type_name(base), c_name=c_var('base'))
for argname, argentry, optional in parse_args(members): for argname, argentry, optional in parse_args(members):
if optional: if optional:
ret += mcgen(''' ret += mcgen('''
visit_optional(m, &(*obj)->%(c_prefix)shas_%(c_name)s, "%(name)s", &err); visit_optional(m, &(*obj)->has_%(c_name)s, "%(name)s", &err);
if (!err && (*obj)->%(prefix)shas_%(c_name)s) { if (!err && (*obj)->has_%(c_name)s) {
''', ''',
c_prefix=c_var(field_prefix), prefix=field_prefix,
c_name=c_var(argname), name=argname) c_name=c_var(argname), name=argname)
push_indent() push_indent()
ret += mcgen(''' ret += mcgen('''
visit_type_%(type)s(m, &(*obj)->%(c_prefix)s%(c_name)s, "%(name)s", &err); visit_type_%(type)s(m, &(*obj)->%(c_name)s, "%(name)s", &err);
''', ''',
c_prefix=c_var(field_prefix), prefix=field_prefix,
type=type_name(argentry), c_name=c_var(argname), type=type_name(argentry), c_name=c_var(argname),
name=argname) name=argname)
@ -114,29 +107,11 @@ def generate_visit_struct_fields(name, field_prefix, fn_prefix, members, base =
return ret return ret
def generate_visit_struct_body(field_prefix, name, members): def generate_visit_struct_body(name, members):
ret = mcgen(''' ret = mcgen('''
Error *err = NULL; Error *err = NULL;
''')
if not field_prefix:
full_name = name
else:
full_name = "%s_%s" % (field_prefix, name)
if len(field_prefix):
ret += mcgen('''
visit_start_struct(m, NULL, "", "%(name)s", 0, &err);
''',
name=name)
else:
ret += mcgen('''
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err); visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
''',
name=name)
ret += mcgen('''
if (!err) { if (!err) {
if (*obj) { if (*obj) {
visit_type_%(name)s_fields(m, obj, errp); visit_type_%(name)s_fields(m, obj, errp);
@ -145,7 +120,7 @@ def generate_visit_struct_body(field_prefix, name, members):
} }
error_propagate(errp, err); error_propagate(errp, err);
''', ''',
name=full_name) name=name)
return ret return ret
@ -155,7 +130,7 @@ def generate_visit_struct(expr):
members = expr['data'] members = expr['data']
base = expr.get('base') base = expr.get('base')
ret = generate_visit_struct_fields(name, "", "", members, base) ret = generate_visit_struct_fields(name, members, base)
ret += mcgen(''' ret += mcgen('''
@ -164,7 +139,7 @@ def generate_visit_struct(expr):
''', ''',
name=name) name=name)
ret += generate_visit_struct_body("", name, members) ret += generate_visit_struct_body(name, members)
ret += mcgen(''' ret += mcgen('''
} }
@ -288,7 +263,7 @@ def generate_visit_union(expr):
assert discriminator assert discriminator
base_fields = find_struct(base)['data'].copy() base_fields = find_struct(base)['data'].copy()
del base_fields[discriminator] del base_fields[discriminator]
ret += generate_visit_struct_fields(name, "", "", base_fields) ret += generate_visit_struct_fields(name, base_fields)
if discriminator: if discriminator:
for key in members: for key in members: