mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 19:15:34 +00:00
qapi: Drop unused and useless parameters and variables
gen_sync_call()'s parameter indent is useless: gen_sync_call() uses it only as optional argument for push_indent() and pop_indent(), their default is four, and gen_sync_call()'s only caller passes four. Drop the parameter. gen_visitor_input_containers_decl()'s parameter obj is always "QOBJECT(args)". Use that, and drop the parameter. Drop unused parameters of gen_marshal_output(), gen_marshal_input_decl(), generate_visit_struct_body(), generate_visit_list(), generate_visit_enum(), generate_declaration(), generate_enum_declaration(), generate_decl_enum(). Drop unused variables in generate_event_enum_lookup(), generate_enum_lookup(), generate_visit_struct_fields(), check_event(). Backports commit 5aa05d3f72e556752167f7005d6a3dea0f4432c5 from qemu
This commit is contained in:
parent
cf9d457200
commit
b190e4887e
|
@ -199,7 +199,6 @@ const char *%(event_enum_name)s_lookup[] = {
|
|||
''',
|
||||
event_enum_name = event_enum_name)
|
||||
|
||||
i = 0
|
||||
for string in event_enum_strings:
|
||||
ret += mcgen('''
|
||||
"%(string)s",
|
||||
|
|
|
@ -108,7 +108,6 @@ def generate_enum_lookup(name, values):
|
|||
const char * const %(name)s_lookup[] = {
|
||||
''',
|
||||
name=c_name(name))
|
||||
i = 0
|
||||
for value in values:
|
||||
ret += mcgen('''
|
||||
"%(value)s",
|
||||
|
|
|
@ -40,7 +40,6 @@ static void visit_type_implicit_%(c_type)s(Visitor *m, %(c_type)s **obj, Error *
|
|||
c_type=type_name(type))
|
||||
|
||||
def generate_visit_struct_fields(name, members, base = None):
|
||||
substructs = []
|
||||
ret = ''
|
||||
|
||||
if base:
|
||||
|
@ -103,7 +102,7 @@ out:
|
|||
return ret
|
||||
|
||||
|
||||
def generate_visit_struct_body(name, members):
|
||||
def generate_visit_struct_body(name):
|
||||
ret = mcgen('''
|
||||
Error *err = NULL;
|
||||
|
||||
|
@ -136,14 +135,14 @@ void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **e
|
|||
''',
|
||||
name=c_name(name))
|
||||
|
||||
ret += generate_visit_struct_body(name, members)
|
||||
ret += generate_visit_struct_body(name)
|
||||
|
||||
ret += mcgen('''
|
||||
}
|
||||
''')
|
||||
return ret
|
||||
|
||||
def generate_visit_list(name, members):
|
||||
def generate_visit_list(name):
|
||||
return mcgen('''
|
||||
|
||||
void visit_type_%(name)sList(Visitor *m, %(name)sList **obj, const char *name, Error **errp)
|
||||
|
@ -172,7 +171,7 @@ out:
|
|||
''',
|
||||
name=type_name(name))
|
||||
|
||||
def generate_visit_enum(name, members):
|
||||
def generate_visit_enum(name):
|
||||
return mcgen('''
|
||||
|
||||
void visit_type_%(name)s(Visitor *m, %(name)s *obj, const char *name, Error **errp)
|
||||
|
@ -253,7 +252,7 @@ def generate_visit_union(expr):
|
|||
else:
|
||||
# There will always be a discriminator in the C switch code, by default
|
||||
# it is an enum type generated silently
|
||||
ret = generate_visit_enum(name + 'Kind', members.keys())
|
||||
ret = generate_visit_enum(name + 'Kind')
|
||||
disc_type = c_name(name) + 'Kind'
|
||||
|
||||
if base:
|
||||
|
@ -341,7 +340,7 @@ out:
|
|||
|
||||
return ret
|
||||
|
||||
def generate_declaration(name, members, builtin_type=False):
|
||||
def generate_declaration(name, builtin_type=False):
|
||||
ret = ""
|
||||
if not builtin_type:
|
||||
name = c_name(name)
|
||||
|
@ -359,7 +358,7 @@ void visit_type_%(name)sList(Visitor *m, %(name)sList **obj, const char *name, E
|
|||
|
||||
return ret
|
||||
|
||||
def generate_enum_declaration(name, members):
|
||||
def generate_enum_declaration(name):
|
||||
ret = mcgen('''
|
||||
void visit_type_%(name)sList(Visitor *m, %(name)sList **obj, const char *name, Error **errp);
|
||||
''',
|
||||
|
@ -367,7 +366,7 @@ void visit_type_%(name)sList(Visitor *m, %(name)sList **obj, const char *name, E
|
|||
|
||||
return ret
|
||||
|
||||
def generate_decl_enum(name, members):
|
||||
def generate_decl_enum(name):
|
||||
return mcgen('''
|
||||
|
||||
void visit_type_%(name)s(Visitor *m, %(name)s *obj, const char *name, Error **errp);
|
||||
|
@ -435,7 +434,7 @@ exprs = parse_schema(input_file)
|
|||
# for built-in types in our header files and simply guard them
|
||||
fdecl.write(guardstart("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
||||
for typename in builtin_types.keys():
|
||||
fdecl.write(generate_declaration(typename, None, builtin_type=True))
|
||||
fdecl.write(generate_declaration(typename, builtin_type=True))
|
||||
fdecl.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
||||
|
||||
# ...this doesn't work for cases where we link in multiple objects that
|
||||
|
@ -443,44 +442,42 @@ fdecl.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
|||
# over these cases
|
||||
if do_builtins:
|
||||
for typename in builtin_types.keys():
|
||||
fdef.write(generate_visit_list(typename, None))
|
||||
fdef.write(generate_visit_list(typename))
|
||||
|
||||
for expr in exprs:
|
||||
if expr.has_key('struct'):
|
||||
ret = generate_visit_struct(expr)
|
||||
ret += generate_visit_list(expr['struct'], expr['data'])
|
||||
ret += generate_visit_list(expr['struct'])
|
||||
fdef.write(ret)
|
||||
|
||||
ret = generate_declaration(expr['struct'], expr['data'])
|
||||
ret = generate_declaration(expr['struct'])
|
||||
fdecl.write(ret)
|
||||
elif expr.has_key('union'):
|
||||
ret = generate_visit_union(expr)
|
||||
ret += generate_visit_list(expr['union'], expr['data'])
|
||||
ret += generate_visit_list(expr['union'])
|
||||
fdef.write(ret)
|
||||
|
||||
enum_define = discriminator_find_enum_define(expr)
|
||||
ret = ""
|
||||
if not enum_define:
|
||||
ret = generate_decl_enum('%sKind' % expr['union'],
|
||||
expr['data'].keys())
|
||||
ret += generate_declaration(expr['union'], expr['data'])
|
||||
ret = generate_decl_enum('%sKind' % expr['union'])
|
||||
ret += generate_declaration(expr['union'])
|
||||
fdecl.write(ret)
|
||||
elif expr.has_key('alternate'):
|
||||
ret = generate_visit_alternate(expr['alternate'], expr['data'])
|
||||
ret += generate_visit_list(expr['alternate'], expr['data'])
|
||||
ret += generate_visit_list(expr['alternate'])
|
||||
fdef.write(ret)
|
||||
|
||||
ret = generate_decl_enum('%sKind' % expr['alternate'],
|
||||
expr['data'].keys())
|
||||
ret += generate_declaration(expr['alternate'], expr['data'])
|
||||
ret = generate_decl_enum('%sKind' % expr['alternate'])
|
||||
ret += generate_declaration(expr['alternate'])
|
||||
fdecl.write(ret)
|
||||
elif expr.has_key('enum'):
|
||||
ret = generate_visit_list(expr['enum'], expr['data'])
|
||||
ret += generate_visit_enum(expr['enum'], expr['data'])
|
||||
ret = generate_visit_list(expr['enum'])
|
||||
ret += generate_visit_enum(expr['enum'])
|
||||
fdef.write(ret)
|
||||
|
||||
ret = generate_decl_enum(expr['enum'], expr['data'])
|
||||
ret += generate_enum_declaration(expr['enum'], expr['data'])
|
||||
ret = generate_decl_enum(expr['enum'])
|
||||
ret += generate_enum_declaration(expr['enum'])
|
||||
fdecl.write(ret)
|
||||
|
||||
close_output(fdef, fdecl)
|
||||
|
|
|
@ -507,7 +507,6 @@ def check_command(expr, expr_info):
|
|||
def check_event(expr, expr_info):
|
||||
global events
|
||||
name = expr['event']
|
||||
params = expr.get('data')
|
||||
|
||||
if name.upper() == 'MAX':
|
||||
raise QAPIExprError(expr_info, "Event name 'MAX' cannot be created")
|
||||
|
|
Loading…
Reference in a new issue