diff mbox series

[v4,06/14] test-qapi: Print struct members' default values

Message ID 20190624173935.25747-7-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: Try to create well-typed json:{} filenames | expand

Commit Message

Max Reitz June 24, 2019, 5:39 p.m. UTC
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qapi-schema/test-qapi.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index b0f770b9bd..320e027d28 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -44,8 +44,12 @@  class QAPISchemaTestVisitor(QAPISchemaVisitor):
         if base:
             print('    base %s' % base.name)
         for m in members:
-            print('    member %s: %s optional=%s'
-                  % (m.name, m.type.name, m.optional))
+            if m.default is not None:
+                default = ' default={}'.format(m.default)
+            else:
+                default = ''
+            print('    member %s: %s optional=%s%s'
+                  % (m.name, m.type.name, m.optional, default))
             self._print_if(m.ifcond, 8)
         self._print_variants(variants)
         self._print_if(ifcond)