From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 17/26] qapi: De-duplicate parameter list generation
Date: Mon, 21 Sep 2015 10:03:51 +0200 [thread overview]
Message-ID: <1442822640-29912-18-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1442822640-29912-1-git-send-email-armbru@redhat.com>
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>
---
scripts/qapi-commands.py | 11 ++---------
scripts/qapi-event.py | 18 +++---------------
scripts/qapi.py | 16 ++++++++++++++++
3 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index c68659a..833768e 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -17,19 +17,12 @@ import re
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('''
-%(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_name=c_name(name),
- args=argstr)
+ params=gen_params(arg_type, 'Error **errp'))
def gen_err_check(err):
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 5873a05..d15fad9 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -15,21 +15,9 @@ from qapi import *
def gen_event_send_proto(name, arg_type):
- api_name = "void qapi_event_send_%s(" % c_name(name).lower()
- l = len(api_name)
-
- 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
+ return 'void qapi_event_send_%(c_name)s(%(param)s)' % {
+ 'c_name': c_name(name.lower()),
+ 'param': gen_params(arg_type, 'Error **errp')}
def gen_event_send_decl(name, arg_type):
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 7ac72f6..6b6f1ae 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1469,6 +1469,22 @@ extern const char *const %(c_name)s_lookup[];
c_name=c_name(name))
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
#
--
2.4.3
next prev parent reply other threads:[~2015-09-21 8:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 8:03 [Qemu-devel] [PULL 00/26] qapi: QMP introspection Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 01/26] qapi: Rename class QAPISchema to QAPISchemaParser Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 02/26] qapi: New QAPISchema intermediate reperesentation Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 03/26] qapi: QAPISchema code generation helper methods Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 04/26] qapi: New QAPISchemaVisitor Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 05/26] tests/qapi-schema: Convert test harness to QAPISchemaVisitor Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 06/26] qapi-types: Convert to QAPISchemaVisitor, fixing flat unions Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 07/26] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 08/26] qapi-commands: Convert to QAPISchemaVisitor Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 09/26] qapi: De-duplicate enum code generation Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 10/26] qapi-event: Eliminate global variable event_enum_value Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 11/26] qapi-event: Convert to QAPISchemaVisitor, fixing data with base Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 12/26] qapi: Replace dirty is_c_ptr() by method c_null() Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 13/26] qapi: Clean up after recent conversions to QAPISchemaVisitor Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 14/26] qapi-visit: Rearrange code a bit Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 15/26] qapi-commands: Rearrange code Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 16/26] qapi: Rename qmp_marshal_input_FOO() to qmp_marshal_FOO() Markus Armbruster
2015-09-21 8:03 ` Markus Armbruster [this message]
2015-09-21 8:03 ` [Qemu-devel] [PULL 18/26] qapi-commands: De-duplicate output marshaling functions Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 19/26] qapi: Improve built-in type documentation Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 20/26] qapi: Make output visitor return qnull() instead of NULL Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 21/26] qapi: Introduce a first class 'any' type Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 22/26] qom: Don't use 'gen': false for qom-get, qom-set, object-add Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 23/26] qapi-schema: Fix up misleading specification of netdev_add Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 24/26] qapi: Pseudo-type '**' is now unused, drop it Markus Armbruster
2015-09-21 8:03 ` [Qemu-devel] [PULL 25/26] qapi: New QMP command query-qmp-schema for QMP introspection Markus Armbruster
2015-09-21 8:04 ` [Qemu-devel] [PULL 26/26] qapi-introspect: Hide type names Markus Armbruster
2015-09-21 23:36 ` [Qemu-devel] [PULL 00/26] qapi: QMP introspection Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442822640-29912-18-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).