[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 20/54] qapi-introspect: modify to_qlit() to t
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v2 20/54] qapi-introspect: modify to_qlit() to take an optional suffix |
Date: |
Tue, 05 Sep 2017 11:42:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> The following patch is going to break list entries with #if/#endif, so
> they should have the trailing ',' as suffix.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> scripts/qapi-introspect.py | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
> index 4c437d60ec..dfb6d2ded4 100644
> --- a/scripts/qapi-introspect.py
> +++ b/scripts/qapi-introspect.py
> @@ -16,7 +16,7 @@ def to_c_string(s):
> return '"' + s.replace('\\', r'\\').replace('"', r'\"') + '"'
>
>
> -def to_qlit(obj, level=0, first_indent=True):
> +def to_qlit(obj, level=0, first_indent=True, suffix=''):
>
> def indent(level):
> return level * 4 * ' '
> @@ -29,11 +29,11 @@ def to_qlit(obj, level=0, first_indent=True):
> elif isinstance(obj, str):
> ret += 'QLIT_QSTR(' + to_c_string(obj) + ')'
> elif isinstance(obj, list):
> - elts = [to_qlit(elt, level + 1)
> + elts = [to_qlit(elt, level + 1, suffix=',')
> for elt in obj]
> elts.append(indent(level + 1) + "{}")
> ret += 'QLIT_QLIST(((QLitObject[]) {\n'
> - ret += ',\n'.join(elts) + '\n'
> + ret += '\n'.join(elts) + '\n'
> ret += indent(level) + '}))'
> elif isinstance(obj, dict):
> elts = []
> @@ -46,7 +46,7 @@ def to_qlit(obj, level=0, first_indent=True):
> ret += indent(level) + '}))'
> else:
> assert False # not implemented
> - return ret
> + return ret + suffix
>
>
> class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
Hmm. I wonder the appended simpler patch would do.
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 4c437d60ec..73edb55cd5 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -33,7 +33,7 @@ def to_qlit(obj, level=0, first_indent=True):
for elt in obj]
elts.append(indent(level + 1) + "{}")
ret += 'QLIT_QLIST(((QLitObject[]) {\n'
- ret += ',\n'.join(elts) + '\n'
+ ret += '\n'.join(elts) + '\n'
ret += indent(level) + '}))'
elif isinstance(obj, dict):
elts = []
@@ -46,6 +46,8 @@ def to_qlit(obj, level=0, first_indent=True):
ret += indent(level) + '}))'
else:
assert False # not implemented
+ if level > 0:
+ ret += ','
return ret
- Re: [Qemu-devel] [PATCH v2 20/54] qapi-introspect: modify to_qlit() to take an optional suffix,
Markus Armbruster <=