mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
qapi: De-duplicate parameter list generation
Generated qapi-event.[ch] lose line breaks. No change otherwise. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1442401589-24189-18-git-send-email-armbru@redhat.com>
This commit is contained in:
parent
7fad30f06e
commit
03b4367a55
|
@ -17,19 +17,12 @@
|
||||||
|
|
||||||
|
|
||||||
def gen_command_decl(name, arg_type, ret_type):
|
def gen_command_decl(name, arg_type, ret_type):
|
||||||
argstr = ''
|
|
||||||
if arg_type:
|
|
||||||
for memb in arg_type.members:
|
|
||||||
if memb.optional:
|
|
||||||
argstr += 'bool has_%s, ' % c_name(memb.name)
|
|
||||||
argstr += '%s %s, ' % (memb.type.c_type(is_param=True),
|
|
||||||
c_name(memb.name))
|
|
||||||
return mcgen('''
|
return mcgen('''
|
||||||
%(c_type)s qmp_%(c_name)s(%(args)sError **errp);
|
%(c_type)s qmp_%(c_name)s(%(params)s);
|
||||||
''',
|
''',
|
||||||
c_type=(ret_type and ret_type.c_type()) or 'void',
|
c_type=(ret_type and ret_type.c_type()) or 'void',
|
||||||
c_name=c_name(name),
|
c_name=c_name(name),
|
||||||
args=argstr)
|
params=gen_params(arg_type, 'Error **errp'))
|
||||||
|
|
||||||
|
|
||||||
def gen_err_check(err):
|
def gen_err_check(err):
|
||||||
|
|
|
@ -15,21 +15,9 @@
|
||||||
|
|
||||||
|
|
||||||
def gen_event_send_proto(name, arg_type):
|
def gen_event_send_proto(name, arg_type):
|
||||||
api_name = "void qapi_event_send_%s(" % c_name(name).lower()
|
return 'void qapi_event_send_%(c_name)s(%(param)s)' % {
|
||||||
l = len(api_name)
|
'c_name': c_name(name.lower()),
|
||||||
|
'param': gen_params(arg_type, 'Error **errp')}
|
||||||
if arg_type:
|
|
||||||
for m in arg_type.members:
|
|
||||||
if m.optional:
|
|
||||||
api_name += "bool has_%s,\n" % c_name(m.name)
|
|
||||||
api_name += "".ljust(l)
|
|
||||||
|
|
||||||
api_name += "%s %s,\n" % (m.type.c_type(is_param=True),
|
|
||||||
c_name(m.name))
|
|
||||||
api_name += "".ljust(l)
|
|
||||||
|
|
||||||
api_name += "Error **errp)"
|
|
||||||
return api_name
|
|
||||||
|
|
||||||
|
|
||||||
def gen_event_send_decl(name, arg_type):
|
def gen_event_send_decl(name, arg_type):
|
||||||
|
|
|
@ -1469,6 +1469,22 @@ def gen_enum(name, values, prefix=None):
|
||||||
c_name=c_name(name))
|
c_name=c_name(name))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def gen_params(arg_type, extra):
|
||||||
|
if not arg_type:
|
||||||
|
return extra
|
||||||
|
assert not arg_type.variants
|
||||||
|
ret = ''
|
||||||
|
sep = ''
|
||||||
|
for memb in arg_type.members:
|
||||||
|
ret += sep
|
||||||
|
sep = ', '
|
||||||
|
if memb.optional:
|
||||||
|
ret += 'bool has_%s, ' % c_name(memb.name)
|
||||||
|
ret += '%s %s' % (memb.type.c_type(is_param=True), c_name(memb.name))
|
||||||
|
if extra:
|
||||||
|
ret += sep + extra
|
||||||
|
return ret
|
||||||
|
|
||||||
#
|
#
|
||||||
# Common command line parsing
|
# Common command line parsing
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue