qapi doc generation (whole version, squashed)
v6 cover qapi doc generation (whole version, squashed)
Add a qapi2texi script to generate the documentation from the qapi schemas.
The SQUASHED patch in this series is a squashed version of the documentation move from qmp-commands.txt to the schemas. The whole version (not sent on the ML to avoid spamming) is in the following git
branch: https://github.com/elmarco/qemu/commits/qapi-doc
PDF preview:
https://fedorapeople.org/~elmarco/qemu-qmp-ref.pdf
v6:
- rebased on top of armbru/qapi-next branch
- add a few patches to improve Exception subclasses and usage in qapi.py as suggested during review
- parser and generator fixes and improvements after v5 review:
- various union improvements, hopefully with a better syntax
- improve error messages
- improve docs/qapi-code-gen.txt documentation section
- do not allow interleaved body documentation between sections
- more tests for new cases
- make expression documentation mandatory, fix the tests
- replace bad usage of @var{} with @t{} in texi, fix texi2pod to handle it
- renaming, reordering etc..
- add docs/qapi-syntax.texi to describe the API syntax used in the texi documentation
- fix interleaved body and section documentation
- improve documentation sections name
- many build-sys improvements after review
- fix and improve commit messages, update R-b tags
v5:
- many parser and generator fixes and improvements after v4 review:
- simplified current section handling by using a Section object
- adding a line is more stateful: either freeform or symbol comment
- always check_docs() when parsing with QAPISchema
- simplified some code and comments
- do not break current section on empty line, but break after a non indented paragraph in an argument section. This seems to reflects the way documentation is written:
##
# @foo:
# @arg: fluctuat nec mergitur
# - continues here
#
# Since: 1853
#
# Body
#
##
Other sections (Note/Examples etc) are not indented (it seems), but could use a similar rule. I prefer to keep this only for args, for styling reasons (bikeshedding?).
- better handling of flat-union in generator
- list all enum values (even when not documented)
- added qapi-doc parsing tests and more error checking
- pep8/pylint fixes
- some more schema doc fixes
- do not move logo to docs/
v4:
- more device_add schema fixes
- do not merge docs/qmp-intro.txt in qemu-qmp-ref.texi
- remove needless @ifinfo, add GPL copying text
- added qemu logo to pdf
- added some r-b tags
v3:
- many improvements to the doc parser:
- throws an error in various malformated conditions
- allows multiple meta-sections, except for "Since:" and "Return:"
- build a list of docs, instead of attaching docs to expressions
- accept() breaks on new doc block, and get_doc() returns a QAPIDoc
- fix more documentation to fit the new parser
- use a master texi file that includes the generated file, instead of templated texi file
- texi fixes after Markus review
- only build and install html and man pages by default
- fix .gitignore
v2:
- change licence to be lgpl2+
- fix some comments & commit message
- add more code comments
- improve the doc parsing to treat only "Since" as a special case not requiring ":" (common notation in the doc)
- include some early schema doc fixes (to fix generated doc)
- include the squashed version of the doc move
- include the man page and installation build changes
Marc-André Lureau (17):
qapi: improve device_add schema
qapi: improve TransactionAction doc qga/schema: improve guest-set-vcpus Returns: section
qapi: add some sections in docs
docs: add master qapi texi files
qapi: rework qapi Exception
qapi: use a QAPIParseError in parser
qapi: add qapi2texi script
texi2pod: learn quotation, deftp and deftypefn
json: reorder documentation body
(SQUASHED) move doc to schema
docs: add qemu logo to pdf
build-sys: use --no-split for info
build-sys: remove dvi doc generation
build-sys: use a generic TEXI2MAN rule
build-sys: add txt documentation rules
build-sys: add qapi doc generation targets
Makefile | 94 +- tests/Makefile.include | 19 + scripts/qapi.py | 558 ++- scripts/qapi2texi.py | 339 ++ scripts/texi2pod.pl | 54 +- .gitignore | 11 +- configure | 2 +- docs/qapi-code-gen.txt | 138 +- docs/qapi-syntax.texi | 175 + docs/qemu-ga-ref.texi | 89 + docs/qemu-qmp-ref.texi | 89 + docs/qemu_logo.pdf | Bin 0 -> 9117 bytes docs/qmp-commands.txt | 3824 -------------------- docs/qmp-events.txt | 731 ---- docs/qmp-intro.txt | 3 +- qapi-schema.json | 1399 ++++++- qapi/block-core.json | 699 +++- qapi/block.json | 66 +- qapi/common.json | 38 +- qapi/crypto.json | 5 +- qapi/event.json | 246 ++ qapi/introspect.json | 28 +- qapi/rocker.json | 61 +- qapi/trace.json | 33 +- qga/qapi-schema.json | 35 +- rules.mak | 12 + tests/qapi-schema/alternate-any.err | 2 +- tests/qapi-schema/alternate-any.json | 4 + tests/qapi-schema/alternate-array.err | 2 +- tests/qapi-schema/alternate-array.json | 7 + tests/qapi-schema/alternate-base.err | 2 +- tests/qapi-schema/alternate-base.json | 7 + tests/qapi-schema/alternate-clash.err | 2 +- tests/qapi-schema/alternate-clash.json | 4 + tests/qapi-schema/alternate-conflict-dict.err | 2 +- tests/qapi-schema/alternate-conflict-dict.json | 10 + tests/qapi-schema/alternate-conflict-string.err | 2 +- tests/qapi-schema/alternate-conflict-string.json | 7 + tests/qapi-schema/alternate-empty.err | 2 +- tests/qapi-schema/alternate-empty.json | 4 + tests/qapi-schema/alternate-nested.err | 2 +- tests/qapi-schema/alternate-nested.json | 7 + tests/qapi-schema/alternate-unknown.err | 2 +- tests/qapi-schema/alternate-unknown.json | 4 + tests/qapi-schema/args-alternate.err | 2 +- tests/qapi-schema/args-alternate.json | 8 + tests/qapi-schema/args-any.err | 2 +- tests/qapi-schema/args-any.json | 4 + tests/qapi-schema/args-array-empty.err | 2 +- tests/qapi-schema/args-array-empty.json | 4 + tests/qapi-schema/args-array-unknown.err | 2 +- tests/qapi-schema/args-array-unknown.json | 4 + tests/qapi-schema/args-bad-boxed.err | 2 +- tests/qapi-schema/args-bad-boxed.json | 4 + tests/qapi-schema/args-boxed-anon.err | 2 +- tests/qapi-schema/args-boxed-anon.json | 4 + tests/qapi-schema/args-boxed-empty.err | 2 +- tests/qapi-schema/args-boxed-empty.json | 8 + tests/qapi-schema/args-boxed-string.err | 2 +- tests/qapi-schema/args-boxed-string.json | 4 + tests/qapi-schema/args-int.err | 2 +- tests/qapi-schema/args-int.json | 4 + tests/qapi-schema/args-invalid.err | 2 +- tests/qapi-schema/args-invalid.json | 3 + tests/qapi-schema/args-member-array-bad.err | 2 +- tests/qapi-schema/args-member-array-bad.json | 4 + tests/qapi-schema/args-member-case.err | 2 +- tests/qapi-schema/args-member-case.json | 4 + tests/qapi-schema/args-member-unknown.err | 2 +- tests/qapi-schema/args-member-unknown.json | 4 + tests/qapi-schema/args-name-clash.err | 2 +- tests/qapi-schema/args-name-clash.json | 4 + tests/qapi-schema/args-union.err | 2 +- tests/qapi-schema/args-union.json | 7 + tests/qapi-schema/args-unknown.err | 2 +- tests/qapi-schema/args-unknown.json | 4 + tests/qapi-schema/bad-base.err | 2 +- tests/qapi-schema/bad-base.json | 7 + tests/qapi-schema/bad-data.err | 2 +- tests/qapi-schema/bad-data.json | 4 + tests/qapi-schema/bad-ident.err | 2 +- tests/qapi-schema/bad-ident.json | 4 + tests/qapi-schema/bad-type-bool.err | 2 +- tests/qapi-schema/bad-type-bool.json | 4 + tests/qapi-schema/bad-type-dict.err | 2 +- tests/qapi-schema/bad-type-dict.json | 4 + tests/qapi-schema/base-cycle-direct.err | 2 +- tests/qapi-schema/base-cycle-direct.json | 4 + tests/qapi-schema/base-cycle-indirect.err | 2 +- tests/qapi-schema/base-cycle-indirect.json | 7 + tests/qapi-schema/command-int.err | 2 +- tests/qapi-schema/command-int.json | 4 + tests/qapi-schema/comments.json | 4 + tests/qapi-schema/comments.out | 3 + tests/qapi-schema/doc-bad-args.err | 1 + tests/qapi-schema/doc-bad-args.exit | 1 + tests/qapi-schema/doc-bad-args.json | 8 + tests/qapi-schema/doc-bad-args.out | 0 tests/qapi-schema/doc-bad-section.err | 1 + tests/qapi-schema/doc-bad-section.exit | 1 + tests/qapi-schema/doc-bad-section.json | 19 + tests/qapi-schema/doc-bad-section.out | 0 tests/qapi-schema/doc-bad-symbol.err | 1 + tests/qapi-schema/doc-bad-symbol.exit | 1 + tests/qapi-schema/doc-bad-symbol.json | 6 + tests/qapi-schema/doc-bad-symbol.out | 0 tests/qapi-schema/doc-duplicated-arg.err | 1 + tests/qapi-schema/doc-duplicated-arg.exit | 1 + tests/qapi-schema/doc-duplicated-arg.json | 7 + tests/qapi-schema/doc-duplicated-arg.out | 0 tests/qapi-schema/doc-duplicated-return.err | 1 + tests/qapi-schema/doc-duplicated-return.exit | 1 + tests/qapi-schema/doc-duplicated-return.json | 8 + tests/qapi-schema/doc-duplicated-return.out | 0 tests/qapi-schema/doc-duplicated-since.err | 1 + tests/qapi-schema/doc-duplicated-since.exit | 1 + tests/qapi-schema/doc-duplicated-since.json | 8 + tests/qapi-schema/doc-duplicated-since.out | 0 tests/qapi-schema/doc-empty-arg.err | 1 + tests/qapi-schema/doc-empty-arg.exit | 1 + tests/qapi-schema/doc-empty-arg.json | 6 + tests/qapi-schema/doc-empty-arg.out | 0 tests/qapi-schema/doc-empty-section.err | 1 + tests/qapi-schema/doc-empty-section.exit | 1 + tests/qapi-schema/doc-empty-section.json | 8 + tests/qapi-schema/doc-empty-section.out | 0 tests/qapi-schema/doc-empty-symbol.err | 1 + tests/qapi-schema/doc-empty-symbol.exit | 1 + tests/qapi-schema/doc-empty-symbol.json | 5 + tests/qapi-schema/doc-empty-symbol.out | 0 tests/qapi-schema/doc-invalid-end.err | 1 + tests/qapi-schema/doc-invalid-end.exit | 1 + tests/qapi-schema/doc-invalid-end.json | 5 + tests/qapi-schema/doc-invalid-end.out | 0 tests/qapi-schema/doc-invalid-end2.err | 1 + tests/qapi-schema/doc-invalid-end2.exit | 1 + tests/qapi-schema/doc-invalid-end2.json | 5 + tests/qapi-schema/doc-invalid-end2.out | 0 tests/qapi-schema/doc-invalid-return.err | 1 + tests/qapi-schema/doc-invalid-return.exit | 1 + tests/qapi-schema/doc-invalid-return.json | 7 + tests/qapi-schema/doc-invalid-return.out | 0 tests/qapi-schema/doc-invalid-section.err | 1 + tests/qapi-schema/doc-invalid-section.exit | 1 + tests/qapi-schema/doc-invalid-section.json | 6 + tests/qapi-schema/doc-invalid-section.out | 0 tests/qapi-schema/doc-invalid-start.err | 1 + tests/qapi-schema/doc-invalid-start.exit | 1 + tests/qapi-schema/doc-invalid-start.json | 5 + tests/qapi-schema/doc-invalid-start.out | 0 tests/qapi-schema/doc-missing-colon.err | 1 + tests/qapi-schema/doc-missing-colon.exit | 1 + tests/qapi-schema/doc-missing-colon.json | 5 + tests/qapi-schema/doc-missing-colon.out | 0 tests/qapi-schema/doc-missing-expr.err | 1 + tests/qapi-schema/doc-missing-expr.exit | 1 + tests/qapi-schema/doc-missing-expr.json | 5 + tests/qapi-schema/doc-missing-expr.out | 0 tests/qapi-schema/doc-missing-space.err | 1 + tests/qapi-schema/doc-missing-space.exit | 1 + tests/qapi-schema/doc-missing-space.json | 6 + tests/qapi-schema/doc-missing-space.out | 0 tests/qapi-schema/double-type.err | 2 +- tests/qapi-schema/double-type.json | 4 + tests/qapi-schema/enum-bad-name.err | 2 +- tests/qapi-schema/enum-bad-name.json | 4 + tests/qapi-schema/enum-bad-prefix.err | 2 +- tests/qapi-schema/enum-bad-prefix.json | 4 + tests/qapi-schema/enum-clash-member.err | 2 +- tests/qapi-schema/enum-clash-member.json | 4 + tests/qapi-schema/enum-dict-member.err | 2 +- tests/qapi-schema/enum-dict-member.json | 4 + tests/qapi-schema/enum-member-case.err | 2 +- tests/qapi-schema/enum-member-case.json | 7 + tests/qapi-schema/enum-missing-data.err | 2 +- tests/qapi-schema/enum-missing-data.json | 4 + tests/qapi-schema/enum-wrong-data.err | 2 +- tests/qapi-schema/enum-wrong-data.json | 4 + tests/qapi-schema/event-boxed-empty.err | 2 +- tests/qapi-schema/event-boxed-empty.json | 4 + tests/qapi-schema/event-case.json | 4 + tests/qapi-schema/event-case.out | 3 + tests/qapi-schema/event-nest-struct.err | 2 +- tests/qapi-schema/event-nest-struct.json | 4 + tests/qapi-schema/flat-union-array-branch.err | 2 +- tests/qapi-schema/flat-union-array-branch.json | 12 + tests/qapi-schema/flat-union-bad-base.err | 2 +- tests/qapi-schema/flat-union-bad-base.json | 13 + tests/qapi-schema/flat-union-bad-discriminator.err | 2 +- .../qapi-schema/flat-union-bad-discriminator.json | 16 + tests/qapi-schema/flat-union-base-any.err | 2 +- tests/qapi-schema/flat-union-base-any.json | 13 + tests/qapi-schema/flat-union-base-union.err | 2 +- tests/qapi-schema/flat-union-base-union.json | 16 + tests/qapi-schema/flat-union-clash-member.err | 2 +- tests/qapi-schema/flat-union-clash-member.json | 16 + tests/qapi-schema/flat-union-empty.err | 2 +- tests/qapi-schema/flat-union-empty.json | 10 + tests/qapi-schema/flat-union-incomplete-branch.err | 2 +- .../qapi-schema/flat-union-incomplete-branch.json | 10 + tests/qapi-schema/flat-union-inline.err | 2 +- tests/qapi-schema/flat-union-inline.json | 10 + tests/qapi-schema/flat-union-int-branch.err | 2 +- tests/qapi-schema/flat-union-int-branch.json | 13 + .../qapi-schema/flat-union-invalid-branch-key.err | 2 +- .../qapi-schema/flat-union-invalid-branch-key.json | 15 + .../flat-union-invalid-discriminator.err | 2 +- .../flat-union-invalid-discriminator.json | 15 + tests/qapi-schema/flat-union-no-base.err | 2 +- tests/qapi-schema/flat-union-no-base.json | 13 + .../flat-union-optional-discriminator.err | 2 +- .../flat-union-optional-discriminator.json | 13 + .../flat-union-string-discriminator.err | 2 +- .../flat-union-string-discriminator.json | 15 + tests/qapi-schema/ident-with-escape.json | 4 + tests/qapi-schema/ident-with-escape.out | 3 + tests/qapi-schema/include-cycle.err | 2 +- tests/qapi-schema/include-format-err.err | 2 +- tests/qapi-schema/include-no-file.err | 2 +- tests/qapi-schema/include-non-file.err | 2 +- tests/qapi-schema/include-relpath-sub.json | 3 + tests/qapi-schema/include-relpath.out | 3 + tests/qapi-schema/include-repetition.out | 3 + tests/qapi-schema/include-self-cycle.err | 2 +- tests/qapi-schema/include-simple-sub.json | 3 + tests/qapi-schema/include-simple.out | 3 + tests/qapi-schema/indented-expr.json | 6 + tests/qapi-schema/indented-expr.out | 6 + tests/qapi-schema/missing-type.err | 2 +- tests/qapi-schema/missing-type.json | 4 + tests/qapi-schema/nested-struct-data.err | 2 +- tests/qapi-schema/nested-struct-data.json | 4 + tests/qapi-schema/qapi-schema-test.json | 213 ++ tests/qapi-schema/qapi-schema-test.out | 212 ++ tests/qapi-schema/redefined-builtin.err | 2 +- tests/qapi-schema/redefined-builtin.json | 4 + tests/qapi-schema/redefined-command.err | 2 +- tests/qapi-schema/redefined-command.json | 7 + tests/qapi-schema/redefined-event.err | 2 +- tests/qapi-schema/redefined-event.json | 7 + tests/qapi-schema/redefined-type.err | 2 +- tests/qapi-schema/redefined-type.json | 7 + tests/qapi-schema/reserved-command-q.err | 2 +- tests/qapi-schema/reserved-command-q.json | 7 + tests/qapi-schema/reserved-enum-q.err | 2 +- tests/qapi-schema/reserved-enum-q.json | 4 + tests/qapi-schema/reserved-member-has.err | 2 +- tests/qapi-schema/reserved-member-has.json | 4 + tests/qapi-schema/reserved-member-q.err | 2 +- tests/qapi-schema/reserved-member-q.json | 4 + tests/qapi-schema/reserved-member-u.err | 2 +- tests/qapi-schema/reserved-member-u.json | 4 + tests/qapi-schema/reserved-member-underscore.err | 2 +- tests/qapi-schema/reserved-member-underscore.json | 4 + tests/qapi-schema/reserved-type-kind.err | 2 +- tests/qapi-schema/reserved-type-kind.json | 4 + tests/qapi-schema/reserved-type-list.err | 2 +- tests/qapi-schema/reserved-type-list.json | 4 + tests/qapi-schema/returns-alternate.err | 2 +- tests/qapi-schema/returns-alternate.json | 7 + tests/qapi-schema/returns-array-bad.err | 2 +- tests/qapi-schema/returns-array-bad.json | 4 + tests/qapi-schema/returns-dict.err | 2 +- tests/qapi-schema/returns-dict.json | 4 + tests/qapi-schema/returns-unknown.err | 2 +- tests/qapi-schema/returns-unknown.json | 4 + tests/qapi-schema/returns-whitelist.err | 2 +- tests/qapi-schema/returns-whitelist.json | 16 + tests/qapi-schema/struct-base-clash-deep.err | 2 +- tests/qapi-schema/struct-base-clash-deep.json | 10 + tests/qapi-schema/struct-base-clash.err | 2 +- tests/qapi-schema/struct-base-clash.json | 7 + tests/qapi-schema/struct-data-invalid.err | 2 +- tests/qapi-schema/struct-data-invalid.json | 3 + tests/qapi-schema/struct-member-invalid.err | 2 +- tests/qapi-schema/struct-member-invalid.json | 3 + tests/qapi-schema/test-qapi.py | 12 + tests/qapi-schema/type-bypass-bad-gen.err | 2 +- tests/qapi-schema/type-bypass-bad-gen.json | 4 + tests/qapi-schema/unicode-str.err | 2 +- tests/qapi-schema/unicode-str.json | 4 + tests/qapi-schema/union-base-no-discriminator.err | 2 +- tests/qapi-schema/union-base-no-discriminator.json | 12 + tests/qapi-schema/union-branch-case.err | 2 +- tests/qapi-schema/union-branch-case.json | 4 + tests/qapi-schema/union-clash-branches.err | 2 +- tests/qapi-schema/union-clash-branches.json | 4 + tests/qapi-schema/union-empty.err | 2 +- tests/qapi-schema/union-empty.json | 4 + tests/qapi-schema/union-invalid-base.err | 2 +- tests/qapi-schema/union-invalid-base.json | 10 + tests/qapi-schema/union-optional-branch.err | 2 +- tests/qapi-schema/union-optional-branch.json | 4 + tests/qapi-schema/union-unknown.err | 2 +- tests/qapi-schema/union-unknown.json | 4 + tests/qapi-schema/unknown-escape.err | 2 +- tests/qapi-schema/unknown-escape.json | 4 + tests/qapi-schema/unknown-expr-key.err | 2 +- tests/qapi-schema/unknown-expr-key.json | 4 + 299 files changed, 5094 insertions(+), 5079 deletions(-) create mode 100755 scripts/qapi2texi.py create mode 100644 docs/qapi-syntax.texi create mode 100644 docs/qemu-ga-ref.texi create mode 100644 docs/qemu-qmp-ref.texi create mode 100644 docs/qemu_logo.pdf delete mode 100644 docs/qmp-commands.txt delete mode 100644 docs/qmp-events.txt create mode 100644 tests/qapi-schema/doc-bad-args.err create mode 100644 tests/qapi-schema/doc-bad-args.exit create mode 100644 tests/qapi-schema/doc-bad-args.json create mode 100644 tests/qapi-schema/doc-bad-args.out create mode 100644 tests/qapi-schema/doc-bad-section.err create mode 100644 tests/qapi-schema/doc-bad-section.exit create mode 100644 tests/qapi-schema/doc-bad-section.json create mode 100644 tests/qapi-schema/doc-bad-section.out create mode 100644 tests/qapi-schema/doc-bad-symbol.err create mode 100644 tests/qapi-schema/doc-bad-symbol.exit create mode 100644 tests/qapi-schema/doc-bad-symbol.json create mode 100644 tests/qapi-schema/doc-bad-symbol.out create mode 100644 tests/qapi-schema/doc-duplicated-arg.err create mode 100644 tests/qapi-schema/doc-duplicated-arg.exit create mode 100644 tests/qapi-schema/doc-duplicated-arg.json create mode 100644 tests/qapi-schema/doc-duplicated-arg.out create mode 100644 tests/qapi-schema/doc-duplicated-return.err create mode 100644 tests/qapi-schema/doc-duplicated-return.exit create mode 100644 tests/qapi-schema/doc-duplicated-return.json create mode 100644 tests/qapi-schema/doc-duplicated-return.out create mode 100644 tests/qapi-schema/doc-duplicated-since.err create mode 100644 tests/qapi-schema/doc-duplicated-since.exit create mode 100644 tests/qapi-schema/doc-duplicated-since.json create mode 100644 tests/qapi-schema/doc-duplicated-since.out create mode 100644 tests/qapi-schema/doc-empty-arg.err create mode 100644 tests/qapi-schema/doc-empty-arg.exit create mode 100644 tests/qapi-schema/doc-empty-arg.json create mode 100644 tests/qapi-schema/doc-empty-arg.out create mode 100644 tests/qapi-schema/doc-empty-section.err create mode 100644 tests/qapi-schema/doc-empty-section.exit create mode 100644 tests/qapi-schema/doc-empty-section.json create mode 100644 tests/qapi-schema/doc-empty-section.out create mode 100644 tests/qapi-schema/doc-empty-symbol.err create mode 100644 tests/qapi-schema/doc-empty-symbol.exit create mode 100644 tests/qapi-schema/doc-empty-symbol.json create mode 100644 tests/qapi-schema/doc-empty-symbol.out create mode 100644 tests/qapi-schema/doc-invalid-end.err create mode 100644 tests/qapi-schema/doc-invalid-end.exit create mode 100644 tests/qapi-schema/doc-invalid-end.json create mode 100644 tests/qapi-schema/doc-invalid-end.out create mode 100644 tests/qapi-schema/doc-invalid-end2.err create mode 100644 tests/qapi-schema/doc-invalid-end2.exit create mode 100644 tests/qapi-schema/doc-invalid-end2.json create mode 100644 tests/qapi-schema/doc-invalid-end2.out create mode 100644 tests/qapi-schema/doc-invalid-return.err create mode 100644 tests/qapi-schema/doc-invalid-return.exit create mode 100644 tests/qapi-schema/doc-invalid-return.json create mode 100644 tests/qapi-schema/doc-invalid-return.out create mode 100644 tests/qapi-schema/doc-invalid-section.err create mode 100644 tests/qapi-schema/doc-invalid-section.exit create mode 100644 tests/qapi-schema/doc-invalid-section.json create mode 100644 tests/qapi-schema/doc-invalid-section.out create mode 100644 tests/qapi-schema/doc-invalid-start.err create mode 100644 tests/qapi-schema/doc-invalid-start.exit create mode 100644 tests/qapi-schema/doc-invalid-start.json create mode 100644 tests/qapi-schema/doc-invalid-start.out create mode 100644 tests/qapi-schema/doc-missing-colon.err create mode 100644 tests/qapi-schema/doc-missing-colon.exit create mode 100644 tests/qapi-schema/doc-missing-colon.json create mode 100644 tests/qapi-schema/doc-missing-colon.out create mode 100644 tests/qapi-schema/doc-missing-expr.err create mode 100644 tests/qapi-schema/doc-missing-expr.exit create mode 100644 tests/qapi-schema/doc-missing-expr.json create mode 100644 tests/qapi-schema/doc-missing-expr.out create mode 100644 tests/qapi-schema/doc-missing-space.err create mode 100644 tests/qapi-schema/doc-missing-space.exit create mode 100644 tests/qapi-schema/doc-missing-space.json create mode 100644 tests/qapi-schema/doc-missing-space.out
Signature · 1 line
2.11.0
PATCH v6 1/17 qapi: improve device_add schema
'device_add' is still incomplete for now, but we can fix a few arguments:
- 'bus' is a common argument, regardless of the device
- 'id' is an optional argument
--- qapi-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
qapi-schema.json +2 -2
@@ -2292,7 +2292,7 @@ # # @bus: #optional the device's parent bus (device tree path) # -# @id: the device's ID, must be unique +# @id: #optional the device's ID, must be unique # # Additional arguments depend on the type. #
@@ -2322,7 +2322,7 @@ # Since: 0.13 ## { 'command': 'device_add', - 'data': {'driver': 'str', 'id': 'str'}, + 'data': {'driver': 'str', '*bus': 'str', '*id': 'str'}, 'gen': false } # so we can get the additional arguments ##
Signature · 1 line
2.11.0
PATCH v6 2/17 qapi: improve TransactionAction doc
In reply to Marc-André LureauTransactionAction is a flat union, document 'type' versions exhaustively, and sort the members.
--- qapi-schema.json | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
qapi-schema.json +16 -15
@@ -1795,28 +1795,29 @@ # @TransactionAction: # # A discriminated record of operations that can be performed with -# @transaction. +# @transaction. Action @type can be: # -# Since: 1.1 +# - @abort: since 1.6 +# - @block-dirty-bitmap-add: since 2.5 +# - @block-dirty-bitmap-clear: since 2.5 +# - @blockdev-backup: since 2.3 +# - @blockdev-snapshot: since 2.5 +# - @blockdev-snapshot-internal-sync: since 1.7 +# - @blockdev-snapshot-sync: since 1.1 +# - @drive-backup: since 1.6 # -# drive-backup since 1.6 -# abort since 1.6 -# blockdev-snapshot-internal-sync since 1.7 -# blockdev-backup since 2.3 -# blockdev-snapshot since 2.5 -# block-dirty-bitmap-add since 2.5 -# block-dirty-bitmap-clear since 2.5 +# Since: 1.1 ## { 'union': 'TransactionAction', 'data': { - 'blockdev-snapshot': 'BlockdevSnapshot', - 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', - 'drive-backup': 'DriveBackup', - 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', - 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal', 'block-dirty-bitmap-add': 'BlockDirtyBitmapAdd', - 'block-dirty-bitmap-clear': 'BlockDirtyBitmap' + 'block-dirty-bitmap-clear': 'BlockDirtyBitmap', + 'blockdev-backup': 'BlockdevBackup', + 'blockdev-snapshot': 'BlockdevSnapshot', + 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', + 'drive-backup': 'DriveBackup' } } ##
Signature · 1 line
2.11.0
PATCH v6 3/17 qga/schema: improve guest-set-vcpus Returns: section
In reply to Marc-André LureauItemize the possible return values of guest-set-vcpus.
--- qga/qapi-schema.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
qga/qapi-schema.json +4 -4
@@ -697,21 +697,21 @@ # Returns: The length of the initial sublist that has been successfully # processed. The guest agent maximizes this value. Possible cases: # -# 0: if the @vcpus list was empty on input. Guest state +# - 0: if the @vcpus list was empty on input. Guest state # has not been changed. Otherwise, # -# Error: processing the first node of @vcpus failed for the +# - Error: processing the first node of @vcpus failed for the # reason returned. Guest state has not been changed. # Otherwise, # -# < length(@vcpus): more than zero initial nodes have been processed, +# - < length(@vcpus): more than zero initial nodes have been processed, # but not the entire @vcpus list. Guest state has # changed accordingly. To retrieve the error # (assuming it persists), repeat the call with the # successfully processed initial sublist removed. # Otherwise, # -# length(@vcpus): call successful. +# - length(@vcpus): call successful. # # Since: 1.5 ##
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v6 03/17] qga/schema: improve guest-set-vcpus Returns: section
Quoted 27 lines · Marc-André Lureau
Itemize the possible return values of guest-set-vcpus.
Signed-off-by Marc-André Lureau <[email protected]>--- qga/qapi-schema.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)qga/qapi-schema.json +3
-3@@ -697,21 +697,21 @@ # Returns: The length of the initial sublist that has been successfully # processed. The guest agent maximizes this value. Possible cases: # -# 0: if the @vcpus list was empty on input. Guest state +# - 0: if the @vcpus list was empty on input. Guest state # has not been changed. Otherwise, # -# Error: processing the first node of @vcpus failed for the +# - Error: processing the first node of @vcpus failed for the # reason returned. Guest state has not been changed. # Otherwise, # -# < length(@vcpus): more than zero initial nodes have been processed, +# - < length(@vcpus): more than zero initial nodes have been processed, # but not the entire @vcpus list. Guest state has
qga/qapi-schema.json line 717
Quoted 10 lines
qga/qapi-schema.json +1
-1# changed accordingly. To retrieve the error # (assuming it persists), repeat the call with the # successfully processed initial sublist removed. # Otherwise, # -# length(@vcpus): call successful. +# - length(@vcpus): call successful. # # Since: 1.5 ##
I'm fine with this as is, therefore
But do feel free to drop the blank lines for consistency with itemized lists elsewhere.
PATCH v6 4/17 qapi: add some sections in docs
In reply to Marc-André LureauAdd some more section titles to organize the documentation we're going to generate.
--- qapi-schema.json | 4 ++++ qapi/block-core.json | 6 ++++-- qapi/block.json | 10 ++++++++-- qapi/common.json | 6 ++++-- qapi/crypto.json | 5 ++++- qapi/event.json | 6 ++++++ qapi/rocker.json | 4 ++++ qapi/trace.json | 3 +++ 8 files changed, 37 insertions(+), 7 deletions(-)
qapi-schema.json +4 -0
@@ -20,6 +20,10 @@ # QAPI introspection { 'include': 'qapi/introspect.json' } +## +# = QMP commands +## + ## # @qmp_capabilities: #
qapi/block-core.json +4 -2
@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI block core definitions (vm unrelated) + +## +# == QAPI block core definitions (vm unrelated) +## # QAPI common definitions { 'include': 'common.json' }
qapi/block.json +8 -2
@@ -1,10 +1,16 @@ # -*- Mode: Python -*- -# -# QAPI block definitions (vm related) + +## +# = QAPI block definitions +## # QAPI block core definitions { 'include': 'block-core.json' } +## +# == QAPI block definitions (vm unrelated) +## + ## # @BiosAtaTranslation: #
qapi/common.json +4 -2
@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI common definitions + +## +# = QAPI common definitions +## ## # @QapiErrorClass:
qapi/crypto.json +4 -1
@@ -1,6 +1,9 @@ # -*- Mode: Python -*- # -# QAPI crypto definitions + +## +# = QAPI crypto definitions +## ## # @QCryptoTLSCredsEndpoint:
qapi/event.json +6 -0
@@ -1,3 +1,9 @@ +# -*- Mode: Python -*- + +## +# = Other events +## + ## # @SHUTDOWN: #
qapi/rocker.json +4 -0
@@ -1,3 +1,7 @@ +## +# = Rocker switch device +## + ## # @RockerSwitch: #
qapi/trace.json +3 -0
@@ -5,6 +5,9 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +## +# = Tracing commands +## ## # @TraceEventState:
Signature · 1 line
2.11.0
PATCH v6 5/17 docs: add master qapi texi files
In reply to Marc-André LureauThe qapi2texi script generates a file to be included in a texi file. Add "QEMU QMP Reference Manual" and "QEMU Guest Agent Protocol Reference" master texi files.
--- docs/qapi-syntax.texi | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/qemu-ga-ref.texi | 85 ++++++++++++++++++++++++ docs/qemu-qmp-ref.texi | 85 ++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 docs/qapi-syntax.texi create mode 100644 docs/qemu-ga-ref.texi create mode 100644 docs/qemu-qmp-ref.texi
docs/qapi-syntax.texi new file +175 -0
@@ -0,0 +1,175 @@ +See QEMU @file{docs/qapi-code-gen.txt} for details about the ``Client +JSON Protocol'' wire format. Many @b{Example} illustrate the usage of +the various types. + +This reference document uses a simplified syntax for the different +JSON expressions, of the following general form: + +@deftp {Type} TypeName @ +{@{ 'member': @t{type}, ['optional-member: @t{some-type}], ... @}} + +@table @asis +@item @code{'member'} +Member description +@item @code{'optional-member'} * +Optional member description +@end table +@quotation Since +A tagged section +@end quotation +@quotation Example +@example +<- @{ "return": @{ "member": "foo", ... @} @} +@end example +@end quotation +@end deftp + +The [] in the declaration and the * name prefix in the member +description means the member is optional. + +A type name inside [] refers to a single-dimension array of that type. + +@section Enum documentation + +Enumerations are strings over the Client JSON Protocol. + +Example of an API documentation: + +@deftp Enum Enumeration + +@table @asis +@item @code{'auto'} +Description auto +@item @code{'on'} +Description on +@item @code{'off'} +Description off +@end table +An enumeration of three options: on, off, and auto +@end deftp + +@section Struct documentation + +A struct is an Object in the Client JSON protocol, whose members are +listed in the declaration. It may have a base structure: the members +of the base structure are merged in the same top-level Object over the +client protocol. + +The API documentation uses the following syntax for a struct: + +@deftp {Struct} Type @ +{@{ BaseStruct, 'foo': @t{type}, ... @}} + +@table @asis +@item @code{'foo'} +Member foo description +@end table +The type description. +@end deftp + +@section Union documentation + +Union types are used to let the user choose between several different +variants for an object. There are two flavors: simple (no +discriminator or base), and flat (both discriminator and base). + +In the Client JSON Protocol, a simple union is represented by a +dictionary that contains the @t{'type'} member as a discriminator, and +a @t{'data'} member that is of the specified data type corresponding +to the discriminator value. + +The API documentation uses the following syntax for simple union: + +@deftp {Simple Union} SimpleUnionType @ +{@{ 'type': @t{str}, 'data': [ 'type' = 't1': @t{Type1}, 't2: @t{Type2}, ... ] @}} + +Simple union description +@end deftp + +A flat union definition avoids nesting on the wire, and specifies a +set of common members that occur in all variants of the union. The +top-level members of the union dictionary on the wire will be +combination of members from both the base type and the appropriate +discriminated branch type. The @t{'discriminator'} member is the name +of a non-optional enum-typed member of the base struct. + +The documentation uses the following syntax for a flat union: + +@deftp {Flat Union} FlatUnionType @ +{@{ UnionBase, [ 'discriminator' = 'd1': @t{Type1}, 'd2': @t{Type2} ] @}} + +Flat union description +@end deftp + +@section Alternate documentation + +An alternate type is one that allows a choice between two or more JSON +data types (string, integer, number, or object, but currently not +array) on the wire. + +@deftp {Alternate} AlternateType @ +{[ 't1': @t{Type1}, 't2': @t{Type2}, ... ]} + +@table @asis +@item @code{'t1'} +Either this type +@item @code{'t2'} +Or this type +@end table +AlternateType description +@end deftp + +@section Command documentation + +In the Client JSON Protocol, a command is a dictionary with an +@t{'execute'} member (the name of the command as value), and an +@t{'arguments'} member for the arguments. The API documentation uses +the following syntax for a command: + +@deftypefn Command {ReturnType} query-foo @ +{('arg': @t{type}, ...)} + +@table @asis +@item @code{'arg'} +If true, the command will query... +@end table +Query for all bar... +@quotation Returns +The @code{ReturnType} for... +@end quotation +@quotation Example +@example +-> @{ "execute": "query-foo", "arguments": @{ "arg": ... @} @} +<- @{ + "return": @{ "foo": ... @} + @} +@end example +@end quotation +@end deftypefn + +@section Event documentation + +An event is a JSON object defined by its name, used as the @t{'event'} +member value, and a @t{'data'} member for the event members. + +The API documentation uses the following syntax for an event: + +@deftypefn Event {} EVENT_NAME @ +{('foo': @t{type}, ...)} + +@table @asis +@item @code{'foo'} +An event member +@end table +Event emitted when ... +@quotation Note +This event is rate-limited. +@end quotation +@quotation Example +@example +<- @{ "event": "EVENT_NAME", + "data": @{ "param": .. @}, + "timestamp": @{ "seconds": 1267020223, "microseconds": 435656 @} @} +@end example +@end quotation +@end deftypefn
docs/qemu-ga-ref.texi new file +85 -0
85 lines not on this page · raw message
docs/qemu-qmp-ref.texi new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v6 05/17] docs: add master qapi texi files
Quoted 5 lines · Marc-André Lureau
The qapi2texi script generates a file to be included in a texi file. Add "QEMU QMP Reference Manual" and "QEMU Guest Agent Protocol Reference" master texi files.
Signed-off-by Marc-André Lureau <[email protected]>
This is v5 (which got my R-by) with a "Documentation syntax" section added to both manuals, between "API Reference" and the indexes.
Since "Documentation syntax" explains how to read "API reference", it should either come first, or a suitable forward reference should alert novice readers to it. Could be done on top.
docs/qapi-syntax.texi
Quoted 15 lines
--- docs/qapi-syntax.texi | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/qemu-ga-ref.texi | 85 ++++++++++++++++++++++++ docs/qemu-qmp-ref.texi | 85 ++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 docs/qapi-syntax.texi create mode 100644 docs/qemu-ga-ref.texi create mode 100644 docs/qemu-qmp-ref.texidocs/qapi-syntax.texi new file +0
-0@@ -0,0 +1,175 @@
This file is new in v6. I have quite a few remarks. Some of them only say "problem here", without proposing a solution. That's because I'm going to do fewer, more comprehensive proposals rather than scattering lots of them all over the place.
Still, it's a lot of feedback for something on which we both want to converge as quickly as possible. Before you log off in disgust and drink yourself to oblivion for the remainder of the year: I still hope to end review of this series with a plan for committing the bulk of it quickly. This may involve cutting stuff, and adding FIXMEs.
docs/qapi-syntax.texi line 2
Quoted 2 lines
docs/qapi-syntax.texi new file +2
-0+See QEMU @file{docs/qapi-code-gen.txt} for details about the ``Client +JSON Protocol'' wire format. Many @b{Example} illustrate the usage of
Examples
docs/qapi-syntax.texi line 3
Quoted 1 line
docs/qapi-syntax.texi new file +1
-0+the various types.
Jumping right into the wire format is rather abrupt.
docs/qapi-syntax.texi line 5
Quoted 2 lines
docs/qapi-syntax.texi new file +2
-0+ +This reference document uses a simplified syntax for the different
Simplified from what? I know what you mean (the QAPI schema), but I have much more context than I'm willing to assume readers have.
Quoted 15 lines
docs/qapi-syntax.texi new file +15
-0+JSON expressions, of the following general form: + +@deftp {Type} TypeName @ +{@{ 'member': @t{type}, ['optional-member: @t{some-type}], ... @}} + +@table @asis +@item @code{'member'} +Member description +@item @code{'optional-member'} * +Optional member description +@end table +@quotation Since +A tagged section +@end quotation +@quotation Example
docs/qapi-syntax.texi line 30
Quoted 10 lines
docs/qapi-syntax.texi new file +10
-0+@example +<- @{ "return": @{ "member": "foo", ... @} @} +@end example +@end quotation +@end deftp + +The [] in the declaration and the * name prefix in the member +description means the member is optional. + +A type name inside [] refers to a single-dimension array of that type.
Recommend s/refers to/denotes/, and either scratch "single-dimension", or say "one-dimensional".
The overloading of [] for optional and array is confusing.
This "general form" is incomplete: it has the type description derived from the schema, then the argument sections. Non-argument sections are missing.
Let's go through the specific forms before I propose improvements for this general form.
docs/qapi-syntax.texi line 34
Quoted 4 lines
docs/qapi-syntax.texi new file +4
-0+ +@section Enum documentation + +Enumerations are strings over the Client JSON Protocol.
Suggest "Enumeration values are transmitted as JSON strings in the Client JSON Protocol", or even just "are strings on the wire".
The authoritative resource on the wire protocol is qapi-code-gen.txt, as you note above. Explaining the wire protocol here once more is technically redundant, but I guess readers will appreciate it anyway.
However, it's more than just "documentation syntax". Retitle to "How to read API documentation"?
Starting the section with explaining the wire protocol seems awkward. I'd order as follows: introduction, documentation format, example, wire format.
docs/qapi-syntax.texi line 38
Quoted 4 lines
docs/qapi-syntax.texi new file +4
-0+ +Example of an API documentation: + +@deftp Enum Enumeration
Doesn't match the "general form" introduced in the previous section:
there is no list of members in curly braces. Such a list would be redundant here, however.
docs/qapi-syntax.texi line 49
Quoted 11 lines
docs/qapi-syntax.texi new file +11
-0+ +@table @asis +@item @code{'auto'} +Description auto +@item @code{'on'} +Description on +@item @code{'off'} +Description off +@end table +An enumeration of three options: on, off, and auto +@end deftp
Results in the following plain text:
2.1 Enum documentation
======================
Enumerations are strings over the Client JSON Protocol.
Example of an API documentation:
-- Enum: Enumeration
''auto''
Description auto
''on''
Description on
''off''
Description off
An enumeration of three options: on, off, and auto
Why do we jump into explaining the enumeration values, and only then explain what the whole enumeration is good for? We do, because that's what the doc generator introduced later in this series does.
Evidence: the example is cribbed from the docs generated for OnOffAuto
-- Enum: OnOffAuto
''auto''
QEMU selects the value between on and off
''on''
Enabled
''off''
Disabled
An enumeration of three options: on, off, and auto
Since: 2.2which are generated from this schema definition
##
# @OnOffAuto:
#
# An enumeration of three options: on, off, and auto
#
# @auto: QEMU selects the value between on and off
#
# @on: Enabled
#
# @off: Disabled
#
# Since: 2.2
##
{ 'enum': 'OnOffAuto',
'data': [ 'auto', 'on', 'off' ] }Even though the documentation author put "An enumeration of ..." at the beginning (thoughtfully, I presume), the doc generator moves it to the end. This is *not* an improvement. Hardly surprising; I don't expect a computer's reordering of manually written text to improve things.
I want us to stick to the human author's order. I'll come back to this when I review the doc generator.
Here's my try:
2.1 Enum API documentation
==========================
An enumeration type is a set of named values. Its API documentation lists these values. Looks like this:
-- Enum: Enumeration
An enumeration of three options: on, off, and auto
The enumeration values are:
''auto''
Description of auto
''on''
Description of on
''off''
Description of off
Enumeration values are transmitted as JSON strings on the wire.
The "Enum: Enumeration" part can't quite decide whether to be a sketch of the structure or an example.
Sketch of structure would be:
-- Enum: EnumName
Description of the enum type
The enumeration values are:
''foo''
Description of value foo
... more values ...
This is closer to what you do for other kinds of types.
Example would be the actual OnOffAuto type documentation, possibly trimmed a bit.
If we want example, we could use a less anodyne one:
-- Enum: Duckling
One of Donald Duck's nephews
''Huey''
The duckling wearing red
''Dewey''
The duckling wearing blue
''Louie''
The duckling wearing green
Quoted 9 lines
docs/qapi-syntax.texi new file +9
-0+ +@section Struct documentation + +A struct is an Object in the Client JSON protocol, whose members are +listed in the declaration. It may have a base structure: the members +of the base structure are merged in the same top-level Object over the +client protocol. + +The API documentation uses the following syntax for a struct:
docs/qapi-syntax.texi line 68
Quoted 10 lines
docs/qapi-syntax.texi new file +10
-0+ +@deftp {Struct} Type @ +{@{ BaseStruct, 'foo': @t{type}, ... @}} + +@table @asis +@item @code{'foo'} +Member foo description +@end table +The type description. +@end deftp
Plain text:
2.2 Struct documentation
========================
A struct is an Object in the Client JSON protocol, whose members are listed in the declaration. It may have a base structure: the members of the base structure are merged in the same top-level Object over the client protocol.
The API documentation uses the following syntax for a struct:
-- Struct: Type { BaseStruct, 'foo': type, ... }
''foo''
Member foo description
The type description.
The text in curly braces "BaseStruct, " doesn't match actual doc generator output "BaseStruct + ".
Perhaps we should show an optional member here.
Here's my try:
2.2 Struct API documentation
============================
A struct type is a collection of named members. Its API documentation lists these members. Looks like this:
-- Struct: StructName { BaseStruct + 'foo': FooType, ['bar': BarType], ... }
Description of the struct type
The struct's members are the members of struct type BaseStruct, and:
''foo''
Description of member foo
''bar'' *
Description of member bar
... more members ...
Struct values are transmitted as JSON objects on the wire. The JSON object's members correspond to the struct type members.
Note how I have the members list refer to the additional members without explaining base types. That part is omitted when there's no base type.
Perhaps we want an actual example in addition or instead of the format sketch. I guess not, as plenty of them can be found in the actual API docs.
Note the redundancy between the text in curly braces and the list of
members: basically the only information the former adds is types. Avoid that:
-- Struct: StructName
Description of the struct type
The struct's members are the members of struct type BaseStruct, and:
''foo'' (of type FooType)
Description of member foo
''bar'' (of type BarType, optional)
Description of member bar
... more members ...
I believe this is a good deal easier to read.
I'm not attached to the (of type ...) format. Better ideas for these lines welcome.
Quoted 24 lines
docs/qapi-syntax.texi new file +24
-0+ +@section Union documentation + +Union types are used to let the user choose between several different +variants for an object. There are two flavors: simple (no +discriminator or base), and flat (both discriminator and base). + +In the Client JSON Protocol, a simple union is represented by a +dictionary that contains the @t{'type'} member as a discriminator, and +a @t{'data'} member that is of the specified data type corresponding +to the discriminator value. + +The API documentation uses the following syntax for simple union: + +@deftp {Simple Union} SimpleUnionType @ +{@{ 'type': @t{str}, 'data': [ 'type' = 't1': @t{Type1}, 't2: @t{Type2}, ... ] @}} + +Simple union description +@end deftp + +A flat union definition avoids nesting on the wire, and specifies a +set of common members that occur in all variants of the union. The +top-level members of the union dictionary on the wire will be +combination of members from both the base type and the appropriate
docs/qapi-syntax.texi line 102
Quoted 10 lines
docs/qapi-syntax.texi new file +10
-0+discriminated branch type. The @t{'discriminator'} member is the name +of a non-optional enum-typed member of the base struct. + +The documentation uses the following syntax for a flat union: + +@deftp {Flat Union} FlatUnionType @ +{@{ UnionBase, [ 'discriminator' = 'd1': @t{Type1}, 'd2': @t{Type2} ] @}} + +Flat union description +@end deftp
Plain text:
2.3 Union documentation
=======================
Union types are used to let the user choose between several different variants for an object. There are two flavors: simple (no discriminator or base), and flat (both discriminator and base).
In the Client JSON Protocol, a simple union is represented by a dictionary that contains the 'type' member as a discriminator, and a 'data' member that is of the specified data type corresponding to the discriminator value.
The API documentation uses the following syntax for simple union:
-- Simple Union: SimpleUnionType { 'type': str, 'data': [ 'type' =
't1': Type1, 't2: Type2, ... ] }
Simple union description
A flat union definition avoids nesting on the wire, and specifies a set of common members that occur in all variants of the union. The top-level members of the union dictionary on the wire will be combination of members from both the base type and the appropriate discriminated branch type. The 'discriminator' member is the name of a non-optional enum-typed member of the base struct.
The documentation uses the following syntax for a flat union:
-- Flat Union: FlatUnionType { UnionBase, [ 'discriminator' = 'd1':
Type1, 'd2': Type2 ] }
Flat union description
I'd love to relegate flat vs. simple to implementation detail.
The documentation generated for unions is generally sub-par, just as the pre-series doc comments are.
Here's where I want us to go:
2.3 Union API documentation
===========================
A union type is a collection of named members, where one member is the discriminator, and some members are present only when the discriminator member has a certain value. Its API documentation lists these members. Looks like this:
-- Union: UnionName
Description of the union type
The struct's members are the members of struct type BaseStruct, and:
''type'' (of type Type)
... more common members ...
Additionally when member ''type'' has value "ding", the members of struct type DingType
... Members for more values of ''type'' ...
Union values are transmitted as JSON objects on the wire. The JSON object's members correspond to the union type members.
Again, no need for the text in curly braces.
Base types defined inline are to be quietly spliced into the common members.
If this turns out to be too verbose for simple unions, we can invent an abbreviated format for them.
How close to this can we get in the first step? Baby step in the right direction would be fine. Bigger steps in another direction not so much.
Quoted 8 lines
docs/qapi-syntax.texi new file +8
-0+ +@section Alternate documentation + +An alternate type is one that allows a choice between two or more JSON +data types (string, integer, number, or object, but currently not +array) on the wire. + +@deftp {Alternate} AlternateType @
docs/qapi-syntax.texi line 120
Quoted 10 lines
docs/qapi-syntax.texi new file +10
-0+{[ 't1': @t{Type1}, 't2': @t{Type2}, ... ]} + +@table @asis +@item @code{'t1'} +Either this type +@item @code{'t2'} +Or this type +@end table +AlternateType description +@end deftp
Plain text:
2.4 Alternate documentation
===========================
An alternate type is one that allows a choice between two or more JSON data types (string, integer, number, or object, but currently not array) on the wire.
-- Alternate: AlternateType [ 't1': Type1, 't2': Type2, ... ]
''t1''
Either this type
''t2''
Or this type
AlternateType description
My try:
2.4 Alternate API documentation
===============================
An alternate type is one that allows a choice between two or more sufficiently distinct types. Its API documentation lists the possible types. Looks like this:
-- Alternate: AlternateType
Description of the alternate type
Its possible types are:
''Type1''
Description of this alternative
''Type2''
Description of this alternative
... more alternatives ...
Alternate types are transmitted exactly like the selected alternative type on the wire.
If we care, we can add to the last paragraph: Their JSON types are all distinct.
Quoted 18 lines
docs/qapi-syntax.texi new file +18
-0+ +@section Command documentation + +In the Client JSON Protocol, a command is a dictionary with an +@t{'execute'} member (the name of the command as value), and an +@t{'arguments'} member for the arguments. The API documentation uses +the following syntax for a command: + +@deftypefn Command {ReturnType} query-foo @ +{('arg': @t{type}, ...)} + +@table @asis +@item @code{'arg'} +If true, the command will query... +@end table +Query for all bar... +@quotation Returns +The @code{ReturnType} for...
docs/qapi-syntax.texi line 148
Quoted 10 lines
docs/qapi-syntax.texi new file +10
-0+@end quotation +@quotation Example +@example +-> @{ "execute": "query-foo", "arguments": @{ "arg": ... @} @} +<- @{ + "return": @{ "foo": ... @} + @} +@end example +@end quotation +@end deftypefn
Plain text:
2.5 Command documentation
=========================
In the Client JSON Protocol, a command is a dictionary with an 'execute' member (the name of the command as value), and an 'arguments' member for the arguments. The API documentation uses the following syntax for a command:
-- Command: ReturnType query-foo ('arg': type, ...)
''arg''
If true, the command will query...
Query for all bar...
Returns: The 'ReturnType' for...
Example: -> { "execute": "query-foo", "arguments": { "arg": ... } }
<- {
"return": { "foo": ... }
}
Doesn't match the "general form": there is no list of members in curly braces. We have different formal language instead.
Again, the formal language is redundant except for type information.
Again, the order of things is inferior to the doc comment's order.
The example formatting is a bit unfortunate.
My try:
2.5 Command API documentation
=============================
A command is a message consisting of command name and arguments sent by the client to the server, which makes the server send a message in reply. The reply is either a return value or an error. The return value can be an arbitrary type. The arguments taken together are commonly like a struct type, but union type is also possible. API documentation shows arguments and return value like this:
-- Command: command-name
Description of the command
The arguments are:
''arg''
Description of argument ''arg''
... more arguments ...
Returns type ReturnType: Description of the return value
Example:
-> { "execute": "command-name", "arguments": { "arg": ... } } <- { "return": ... }
See qmp-spec.txt for more detailed information on command message wire format.
Mostly glossed over: how exactly we show commands where 'data' is a type name, such as blockdev-add. Can't say offhand how we treat those in the doc generator now.
Quoted 17 lines
docs/qapi-syntax.texi new file +17
-0+ +@section Event documentation + +An event is a JSON object defined by its name, used as the @t{'event'} +member value, and a @t{'data'} member for the event members. + +The API documentation uses the following syntax for an event: + +@deftypefn Event {} EVENT_NAME @ +{('foo': @t{type}, ...)} + +@table @asis +@item @code{'foo'} +An event member +@end table +Event emitted when ... +@quotation Note
docs/qapi-syntax.texi line 175
Quoted 10 lines
docs/qapi-syntax.texi new file +10
-0+This event is rate-limited. +@end quotation +@quotation Example +@example +<- @{ "event": "EVENT_NAME", + "data": @{ "param": .. @}, + "timestamp": @{ "seconds": 1267020223, "microseconds": 435656 @} @} +@end example +@end quotation +@end deftypefn
Plain text:
2.6 Event documentation
=======================
An event is a JSON object defined by its name, used as the 'event' member value, and a 'data' member for the event members.
The API documentation uses the following syntax for an event:
-- Event: EVENT_NAME ('foo': type, ...)
''foo''
An event member
Event emitted when ...
Note: This event is rate-limited.
Example: <- { "event": "EVENT_NAME",
"data": { "param": .. },
"timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
Again, doesn't match the "general form": there is no list of members in curly braces; we have different formal language instead.
Again, the formal language is redundant except for type information.
Again, the order of things is inferior to the doc comment's order.
Again, the example formatting is a bit unfortunate.
The example's data doesn't match the documented event members.
My try:
2.6 Event API documentation
===========================
An event is an asynchronous message sent by the server to the client, consisting of event name and event data. Event data is like a struct type. API documentation shows it like this:
-- Event: EVENT_NAME
Description of the event
Event data members are:
''foo''
Description of member foo
... more members ...
Example:
<- { "event": "EVENT_NAME",
"data": { "foo": ... },
"timestamp": { ... } }
See qmp-spec.txt for more detailed information on command message wire format.
Now that I mangled^Wreviewed all the sections on specific forms: which parts of the "general form" section do we actually need?
Quoted 182 lines
docs/qemu-ga-ref.texi new file +85
-0@@ -0,0 +1,85 @@ +\input texinfo +@setfilename qemu-ga-ref.info + +@exampleindent 0 +@paragraphindent 0 + +@settitle QEMU Guest Agent Protocol Reference + +@copying +This is the QEMU Guest Agent Protocol reference manual. + +Copyright @copyright{} 2016 The QEMU Project developers + +@quotation +This manual is free documentation: you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 2 of the +License, or (at your option) any later version. + +This manual is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this manual. If not, see http://www.gnu.org/licenses/. +@end quotation +@end copying + +@dircategory QEMU +@direntry +* QEMU-GA-Ref: (qemu-ga-ref). QEMU Guest Agent Protocol Reference +@end direntry + +@titlepage +@title Guest Agent Protocol Reference Manual +@subtitle QEMU version @value{VERSION} +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@contents + +@ifnottex +@node Top +@top QEMU Guest Agent protocol reference +@end ifnottex + +@menu +* API Reference:: +* Documentation syntax:: +* Commands and Events Index:: +* Data Types Index:: +@end menu + +@node API Reference +@chapter API Reference + +@c for texi2pod: +@c man begin DESCRIPTION + +@include qemu-ga-qapi.texi + +@c man end + +@node Documentation syntax +@chapter Documentation syntax + +@c for texi2pod: +@c man begin NOTES + +@include qapi-syntax.texi + +@c man end + +@node Commands and Events Index +@unnumbered Commands and Events Index +@printindex fn + +@node Data Types Index +@unnumbered Data Types Index +@printindex tp + +@byedocs/qemu-qmp-ref.texi new file +85
-0@@ -0,0 +1,85 @@ +\input texinfo +@setfilename qemu-qmp-ref.info + +@exampleindent 0 +@paragraphindent 0 + +@settitle QEMU QMP Reference Manual + +@copying +This is the QEMU QMP reference manual. + +Copyright @copyright{} 2016 The QEMU Project developers + +@quotation +This manual is free documentation: you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 2 of the +License, or (at your option) any later version. + +This manual is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this manual. If not, see http://www.gnu.org/licenses/. +@end quotation +@end copying + +@dircategory QEMU +@direntry +* QEMU-QMP-Ref: (qemu-qmp-ref). QEMU QMP Reference Manual +@end direntry + +@titlepage +@title QMP Reference Manual +@subtitle QEMU version @value{VERSION} +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@contents + +@ifnottex +@node Top +@top QEMU QMP reference +@end ifnottex + +@menu +* API Reference:: +* Documentation syntax:: +* Commands and Events Index:: +* Data Types Index:: +@end menu + +@node API Reference +@chapter API Reference + +@c for texi2pod: +@c man begin DESCRIPTION + +@include qemu-qapi.texi + +@c man end + +@node Documentation syntax +@chapter Documentation syntax + +@c for texi2pod: +@c man begin NOTES + +@include qapi-syntax.texi + +@c man end + +@node Commands and Events Index +@unnumbered Commands and Events Index +@printindex fn + +@node Data Types Index +@unnumbered Data Types Index +@printindex tp + +@bye
PATCH v6 6/17 qapi: rework qapi Exception
In reply to Marc-André LureauUse a base class QAPIError, and QAPIParseError for parser errors and QAPISemError for semantic errors, suggested by Markus Armbruster.
--- scripts/qapi.py | 338 ++++++++++++++++++++++++++------------------------------ 1 file changed, 158 insertions(+), 180 deletions(-)
scripts/qapi.py +158 -180
@@ -91,35 +91,38 @@ def error_path(parent): return res -class QAPISchemaError(Exception): - def __init__(self, schema, msg): +class QAPIError(Exception): + def __init__(self, fname, line, col, incl_info, msg): Exception.__init__(self) - self.fname = schema.fname + self.fname = fname + self.line = line + self.col = col + self.info = incl_info self.msg = msg - self.col = 1 - self.line = schema.line - for ch in schema.src[schema.line_pos:schema.pos]: - if ch == '\t': - self.col = (self.col + 7) % 8 + 1 - else: - self.col += 1 - self.info = schema.incl_info def __str__(self): - return error_path(self.info) + \ - "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg) + loc = "%s:%d" % (self.fname, self.line) + if self.col is not None: + loc += ":%s" % self.col + return error_path(self.info) + "%s: %s" % (loc, self.msg) -class QAPIExprError(Exception): - def __init__(self, expr_info, msg): - Exception.__init__(self) - assert expr_info - self.info = expr_info - self.msg = msg +class QAPIParseError(QAPIError): + def __init__(self, parser, msg): + col = 1 + for ch in parser.src[parser.line_pos:parser.pos]: + if ch == '\t': + col = (col + 7) % 8 + 1 + else: + col += 1 + QAPIError.__init__(self, parser.fname, parser.line, + col, parser.incl_info, msg) - def __str__(self): - return error_path(self.info['parent']) + \ - "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg) + +class QAPISemError(QAPIError): + def __init__(self, info, msg): + QAPIError.__init__(self, info['file'], info['line'], None, + info['parent'], msg) class QAPISchemaParser(object):
@@ -140,25 +143,24 @@ class QAPISchemaParser(object): self.accept() while self.tok is not None: - expr_info = {'file': fname, 'line': self.line, - 'parent': self.incl_info} + info = {'file': fname, 'line': self.line, + 'parent': self.incl_info} expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1: - raise QAPIExprError(expr_info, - "Invalid 'include' directive") + raise QAPISemError(info, "Invalid 'include' directive") include = expr["include"] if not isinstance(include, str): - raise QAPIExprError(expr_info, - "Value of 'include' must be a string") + raise QAPISemError(info, + "Value of 'include' must be a string") incl_abs_fname = os.path.join(os.path.dirname(abs_fname), include) # catch inclusion cycle - inf = expr_info + inf = info while inf: if incl_abs_fname == os.path.abspath(inf['file']): - raise QAPIExprError(expr_info, "Inclusion loop for %s" - % include) + raise QAPISemError(info, "Inclusion loop for %s" + % include) inf = inf['parent'] # skip multiple include of the same file if incl_abs_fname in previously_included:
@@ -166,14 +168,13 @@ class QAPISchemaParser(object): try: fobj = open(incl_abs_fname, 'r') except IOError as e: - raise QAPIExprError(expr_info, - '%s: %s' % (e.strerror, include)) + raise QAPISemError(info, '%s: %s' % (e.strerror, include)) exprs_include = QAPISchemaParser(fobj, previously_included, - expr_info) + info) self.exprs.extend(exprs_include.exprs) else: expr_elem = {'expr': expr, - 'info': expr_info} + 'info': info} self.exprs.append(expr_elem) def accept(self):
@@ -194,8 +195,7 @@ class QAPISchemaParser(object): ch = self.src[self.cursor] self.cursor += 1 if ch == '\n': - raise QAPISchemaError(self, - 'Missing terminating "\'"') + raise QAPIParseError(self, 'Missing terminating "\'"') if esc: if ch == 'b': string += '\b'
@@ -213,25 +213,25 @@ class QAPISchemaParser(object): ch = self.src[self.cursor] self.cursor += 1 if ch not in "0123456789abcdefABCDEF": - raise QAPISchemaError(self, - '\\u escape needs 4 ' - 'hex digits') + raise QAPIParseError(self, + '\\u escape needs 4 ' + 'hex digits') value = (value << 4) + int(ch, 16) # If Python 2 and 3 didn't disagree so much on # how to handle Unicode, then we could allow # Unicode string defaults. But most of QAPI is # ASCII-only, so we aren't losing much for now. if not value or value > 0x7f: - raise QAPISchemaError(self, - 'For now, \\u escape ' - 'only supports non-zero ' - 'values up to \\u007f') + raise QAPIParseError(self, + 'For now, \\u escape ' + 'only supports non-zero ' + 'values up to \\u007f') string += chr(value) elif ch in "\\/'\"": string += ch else: - raise QAPISchemaError(self, - "Unknown escape \\%s" % ch) + raise QAPIParseError(self, + "Unknown escape \\%s" % ch) esc = False elif ch == "\\": esc = True
@@ -259,7 +259,7 @@ class QAPISchemaParser(object): self.line += 1 self.line_pos = self.cursor elif not self.tok.isspace(): - raise QAPISchemaError(self, 'Stray "%s"' % self.tok) + raise QAPIParseError(self, 'Stray "%s"' % self.tok) def get_members(self): expr = OrderedDict()
@@ -267,24 +267,24 @@ class QAPISchemaParser(object): self.accept() return expr if self.tok != "'": - raise QAPISchemaError(self, 'Expected string or "}"') + raise QAPIParseError(self, 'Expected string or "}"') while True: key = self.val self.accept() if self.tok != ':': - raise QAPISchemaError(self, 'Expected ":"') + raise QAPIParseError(self, 'Expected ":"') self.accept() if key in expr: - raise QAPISchemaError(self, 'Duplicate key "%s"' % key) + raise QAPIParseError(self, 'Duplicate key "%s"' % key) expr[key] = self.get_expr(True) if self.tok == '}': self.accept() return expr if self.tok != ',': - raise QAPISchemaError(self, 'Expected "," or "}"') + raise QAPIParseError(self, 'Expected "," or "}"') self.accept() if self.tok != "'": - raise QAPISchemaError(self, 'Expected string') + raise QAPIParseError(self, 'Expected string') def get_values(self): expr = []
@@ -292,20 +292,20 @@ class QAPISchemaParser(object): self.accept() return expr if self.tok not in "{['tfn": - raise QAPISchemaError(self, 'Expected "{", "[", "]", string, ' - 'boolean or "null"') + raise QAPIParseError(self, 'Expected "{", "[", "]", string, ' + 'boolean or "null"') while True: expr.append(self.get_expr(True)) if self.tok == ']': self.accept() return expr if self.tok != ',': - raise QAPISchemaError(self, 'Expected "," or "]"') + raise QAPIParseError(self, 'Expected "," or "]"') self.accept() def get_expr(self, nested): if self.tok != '{' and not nested: - raise QAPISchemaError(self, 'Expected "{"') + raise QAPIParseError(self, 'Expected "{"') if self.tok == '{': self.accept() expr = self.get_members()
@@ -316,7 +316,7 @@ class QAPISchemaParser(object): expr = self.val self.accept() else: - raise QAPISchemaError(self, 'Expected "{", "[" or string') + raise QAPIParseError(self, 'Expected "{", "[" or string') return expr #
@@ -375,20 +375,18 @@ valid_name = re.compile('^(__[a-zA-Z0-9.-]+_)?' '[a-zA-Z][a-zA-Z0-9_-]*$') -def check_name(expr_info, source, name, allow_optional=False, +def check_name(info, source, name, allow_optional=False, enum_member=False): global valid_name membername = name if not isinstance(name, str): - raise QAPIExprError(expr_info, - "%s requires a string name" % source) + raise QAPISemError(info, "%s requires a string name" % source) if name.startswith('*'): membername = name[1:] if not allow_optional: - raise QAPIExprError(expr_info, - "%s does not allow optional name '%s'" - % (source, name)) + raise QAPISemError(info, "%s does not allow optional name '%s'" + % (source, name)) # Enum members can start with a digit, because the generated C # code always prefixes it with the enum name if enum_member and membername[0].isdigit():
@@ -397,8 +395,7 @@ def check_name(expr_info, source, name, allow_optional=False, # and 'q_obj_*' implicit type names. if not valid_name.match(membername) or \ c_name(membername, False).startswith('q_'): - raise QAPIExprError(expr_info, - "%s uses invalid name '%s'" % (source, name)) + raise QAPISemError(info, "%s uses invalid name '%s'" % (source, name)) def add_name(name, info, meta, implicit=False):
@@ -407,13 +404,11 @@ def add_name(name, info, meta, implicit=False): # FIXME should reject names that differ only in '_' vs. '.' # vs. '-', because they're liable to clash in generated C. if name in all_names: - raise QAPIExprError(info, - "%s '%s' is already defined" - % (all_names[name], name)) + raise QAPISemError(info, "%s '%s' is already defined" + % (all_names[name], name)) if not implicit and (name.endswith('Kind') or name.endswith('List')): - raise QAPIExprError(info, - "%s '%s' should not end in '%s'" - % (meta, name, name[-4:])) + raise QAPISemError(info, "%s '%s' should not end in '%s'" + % (meta, name, name[-4:])) all_names[name] = meta
@@ -465,7 +460,7 @@ def is_enum(name): return find_enum(name) is not None -def check_type(expr_info, source, value, allow_array=False, +def check_type(info, source, value, allow_array=False, allow_dict=False, allow_optional=False, allow_metas=[]): global all_names
@@ -476,69 +471,64 @@ def check_type(expr_info, source, value, allow_array=False, # Check if array type for value is okay if isinstance(value, list): if not allow_array: - raise QAPIExprError(expr_info, - "%s cannot be an array" % source) + raise QAPISemError(info, "%s cannot be an array" % source) if len(value) != 1 or not isinstance(value[0], str): - raise QAPIExprError(expr_info, - "%s: array type must contain single type name" - % source) + raise QAPISemError(info, + "%s: array type must contain single type name" % + source) value = value[0] # Check if type name for value is okay if isinstance(value, str): if value not in all_names: - raise QAPIExprError(expr_info, - "%s uses unknown type '%s'" - % (source, value)) + raise QAPISemError(info, "%s uses unknown type '%s'" + % (source, value)) if not all_names[value] in allow_metas: - raise QAPIExprError(expr_info, - "%s cannot use %s type '%s'" - % (source, all_names[value], value)) + raise QAPISemError(info, "%s cannot use %s type '%s'" % + (source, all_names[value], value)) return if not allow_dict: - raise QAPIExprError(expr_info, - "%s should be a type name" % source) + raise QAPISemError(info, "%s should be a type name" % source) if not isinstance(value, OrderedDict): - raise QAPIExprError(expr_info, - "%s should be a dictionary or type name" % source) + raise QAPISemError(info, + "%s should be a dictionary or type name" % source) # value is a dictionary, check that each member is okay for (key, arg) in value.items(): - check_name(expr_info, "Member of %s" % source, key, + check_name(info, "Member of %s" % source, key, allow_optional=allow_optional) if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'): - raise QAPIExprError(expr_info, - "Member of %s uses reserved name '%s'" - % (source, key)) + raise QAPISemError(info, "Member of %s uses reserved name '%s'" + % (source, key)) # Todo: allow dictionaries to represent default values of # an optional argument. - check_type(expr_info, "Member '%s' of %s" % (key, source), arg, + check_type(info, "Member '%s' of %s" % (key, source), arg, allow_array=True, allow_metas=['built-in', 'union', 'alternate', 'struct', 'enum']) -def check_command(expr, expr_info): +def check_command(expr, info): name = expr['command'] boxed = expr.get('boxed', False) args_meta = ['struct'] if boxed: args_meta += ['union', 'alternate'] - check_type(expr_info, "'data' for command '%s'" % name, + check_type(info, "'data' for command '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=args_meta) returns_meta = ['union', 'struct'] if name in returns_whitelist: returns_meta += ['built-in', 'alternate', 'enum'] - check_type(expr_info, "'returns' for command '%s'" % name, + check_type(info, "'returns' for command '%s'" % name, expr.get('returns'), allow_array=True, allow_optional=True, allow_metas=returns_meta) -def check_event(expr, expr_info): +def check_event(expr, info): global events name = expr['event'] boxed = expr.get('boxed', False)
@@ -547,12 +537,12 @@ def check_event(expr, expr_info): if boxed: meta += ['union', 'alternate'] events.append(name) - check_type(expr_info, "'data' for event '%s'" % name, + check_type(info, "'data' for event '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=meta) -def check_union(expr, expr_info): +def check_union(expr, info): name = expr['union'] base = expr.get('base') discriminator = expr.get('discriminator')
@@ -565,123 +555,117 @@ def check_union(expr, expr_info): enum_define = None allow_metas = ['built-in', 'union', 'alternate', 'struct', 'enum'] if base is not None: - raise QAPIExprError(expr_info, - "Simple union '%s' must not have a base" - % name) + raise QAPISemError(info, "Simple union '%s' must not have a base" % + name) # Else, it's a flat union. else: # The object must have a string or dictionary 'base'. - check_type(expr_info, "'base' for union '%s'" % name, + check_type(info, "'base' for union '%s'" % name, base, allow_dict=True, allow_optional=True, allow_metas=['struct']) if not base: - raise QAPIExprError(expr_info, - "Flat union '%s' must have a base" - % name) + raise QAPISemError(info, "Flat union '%s' must have a base" + % name) base_members = find_base_members(base) assert base_members # The value of member 'discriminator' must name a non-optional # member of the base struct. - check_name(expr_info, "Discriminator of flat union '%s'" % name, + check_name(info, "Discriminator of flat union '%s'" % name, discriminator) discriminator_type = base_members.get(discriminator) if not discriminator_type: - raise QAPIExprError(expr_info, - "Discriminator '%s' is not a member of base " - "struct '%s'" - % (discriminator, base)) + raise QAPISemError(info, + "Discriminator '%s' is not a member of base " + "struct '%s'" + % (discriminator, base)) enum_define = find_enum(discriminator_type) allow_metas = ['struct'] # Do not allow string discriminator if not enum_define: - raise QAPIExprError(expr_info, - "Discriminator '%s' must be of enumeration " - "type" % discriminator) + raise QAPISemError(info, + "Discriminator '%s' must be of enumeration " + "type" % discriminator) # Check every branch; don't allow an empty union if len(members) == 0: - raise QAPIExprError(expr_info, - "Union '%s' cannot have empty 'data'" % name) + raise QAPISemError(info, "Union '%s' cannot have empty 'data'" % name) for (key, value) in members.items(): - check_name(expr_info, "Member of union '%s'" % name, key) + check_name(info, "Member of union '%s'" % name, key) # Each value must name a known type - check_type(expr_info, "Member '%s' of union '%s'" % (key, name), + check_type(info, "Member '%s' of union '%s'" % (key, name), value, allow_array=not base, allow_metas=allow_metas) # If the discriminator names an enum type, then all members # of 'data' must also be members of the enum type. if enum_define: if key not in enum_define['enum_values']: - raise QAPIExprError(expr_info, - "Discriminator value '%s' is not found in " - "enum '%s'" % - (key, enum_define["enum_name"])) + raise QAPISemError(info, + "Discriminator value '%s' is not found in " + "enum '%s'" + % (key, enum_define["enum_name"])) # If discriminator is user-defined, ensure all values are covered if enum_define: for value in enum_define['enum_values']: if value not in members.keys(): - raise QAPIExprError(expr_info, - "Union '%s' data missing '%s' branch" - % (name, value)) + raise QAPISemError(info, "Union '%s' data missing '%s' branch" + % (name, value)) -def check_alternate(expr, expr_info): +def check_alternate(expr, info): name = expr['alternate'] members = expr['data'] types_seen = {} # Check every branch; require at least two branches if len(members) < 2: - raise QAPIExprError(expr_info, - "Alternate '%s' should have at least two branches " - "in 'data'" % name) + raise QAPISemError(info, + "Alternate '%s' should have at least two branches " + "in 'data'" % name) for (key, value) in members.items(): - check_name(expr_info, "Member of alternate '%s'" % name, key) + check_name(info, "Member of alternate '%s'" % name, key) # Ensure alternates have no type conflicts. - check_type(expr_info, "Member '%s' of alternate '%s'" % (key, name), + check_type(info, "Member '%s' of alternate '%s'" % (key, name), value, allow_metas=['built-in', 'union', 'struct', 'enum']) qtype = find_alternate_member_qtype(value) if not qtype: - raise QAPIExprError(expr_info, - "Alternate '%s' member '%s' cannot use " - "type '%s'" % (name, key, value)) + raise QAPISemError(info, "Alternate '%s' member '%s' cannot use " + "type '%s'" % (name, key, value)) if qtype in types_seen: - raise QAPIExprError(expr_info, - "Alternate '%s' member '%s' can't " - "be distinguished from member '%s'" - % (name, key, types_seen[qtype])) + raise QAPISemError(info, "Alternate '%s' member '%s' can't " + "be distinguished from member '%s'" + % (name, key, types_seen[qtype])) types_seen[qtype] = key -def check_enum(expr, expr_info): +def check_enum(expr, info): name = expr['enum'] members = expr.get('data') prefix = expr.get('prefix') if not isinstance(members, list): - raise QAPIExprError(expr_info, - "Enum '%s' requires an array for 'data'" % name) + raise QAPISemError(info, + "Enum '%s' requires an array for 'data'" % name) if prefix is not None and not isinstance(prefix, str): - raise QAPIExprError(expr_info, - "Enum '%s' requires a string for 'prefix'" % name) + raise QAPISemError(info, + "Enum '%s' requires a string for 'prefix'" % name) for member in members: - check_name(expr_info, "Member of enum '%s'" % name, member, + check_name(info, "Member of enum '%s'" % name, member, enum_member=True) -def check_struct(expr, expr_info): +def check_struct(expr, info): name = expr['struct'] members = expr['data'] - check_type(expr_info, "'data' for struct '%s'" % name, members, + check_type(info, "'data' for struct '%s'" % name, members, allow_dict=True, allow_optional=True) - check_type(expr_info, "'base' for struct '%s'" % name, expr.get('base'), + check_type(info, "'base' for struct '%s'" % name, expr.get('base'), allow_metas=['struct'])
@@ -690,27 +674,24 @@ def check_keys(expr_elem, meta, required, optional=[]): info = expr_elem['info'] name = expr[meta] if not isinstance(name, str): - raise QAPIExprError(info, - "'%s' key must have a string value" % meta) + raise QAPISemError(info, "'%s' key must have a string value" % meta) required = required + [meta] for (key, value) in expr.items(): if key not in required and key not in optional: - raise QAPIExprError(info, - "Unknown key '%s' in %s '%s'" - % (key, meta, name)) + raise QAPISemError(info, "Unknown key '%s' in %s '%s'" + % (key, meta, name)) if (key == 'gen' or key == 'success-response') and value is not False: - raise QAPIExprError(info, - "'%s' of %s '%s' should only use false value" - % (key, meta, name)) + raise QAPISemError(info, + "'%s' of %s '%s' should only use false value" + % (key, meta, name)) if key == 'boxed' and value is not True: - raise QAPIExprError(info, - "'%s' of %s '%s' should only use true value" - % (key, meta, name)) + raise QAPISemError(info, + "'%s' of %s '%s' should only use true value" + % (key, meta, name)) for key in required: if key not in expr: - raise QAPIExprError(info, - "Key '%s' is missing from %s '%s'" - % (key, meta, name)) + raise QAPISemError(info, "Key '%s' is missing from %s '%s'" + % (key, meta, name)) def check_exprs(exprs):
@@ -743,8 +724,8 @@ def check_exprs(exprs): check_keys(expr_elem, 'event', [], ['data', 'boxed']) add_name(expr['event'], info, 'event') else: - raise QAPIExprError(expr_elem['info'], - "Expression is missing metatype") + raise QAPISemError(expr_elem['info'], + "Expression is missing metatype") # Try again for hidden UnionKind enum for expr_elem in exprs:
@@ -978,8 +959,8 @@ class QAPISchemaObjectType(QAPISchemaType): def check(self, schema): if self.members is False: # check for cycles - raise QAPIExprError(self.info, - "Object %s contains itself" % self.name) + raise QAPISemError(self.info, + "Object %s contains itself" % self.name) if self.members: return self.members = False # mark as being checked
@@ -1051,12 +1032,11 @@ class QAPISchemaMember(object): def check_clash(self, info, seen): cname = c_name(self.name) if cname.lower() != cname and self.owner not in case_whitelist: - raise QAPIExprError(info, - "%s should not use uppercase" % self.describe()) + raise QAPISemError(info, + "%s should not use uppercase" % self.describe()) if cname in seen: - raise QAPIExprError(info, - "%s collides with %s" - % (self.describe(), seen[cname].describe())) + raise QAPISemError(info, "%s collides with %s" % + (self.describe(), seen[cname].describe())) seen[cname] = self def _pretty_owner(self):
@@ -1201,14 +1181,13 @@ class QAPISchemaCommand(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, - "Cannot use 'boxed' with empty type") + raise QAPISemError(self.info, + "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, - "Use of 'boxed' requires 'data'") + raise QAPISemError(self.info, "Use of 'boxed' requires 'data'") if self._ret_type_name: self.ret_type = schema.lookup_type(self._ret_type_name) assert isinstance(self.ret_type, QAPISchemaType)
@@ -1235,14 +1214,13 @@ class QAPISchemaEvent(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, - "Cannot use 'boxed' with empty type") + raise QAPISemError(self.info, + "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, - "Use of 'boxed' requires 'data'") + raise QAPISemError(self.info, "Use of 'boxed' requires 'data'") def visit(self, visitor): visitor.visit_event(self.name, self.info, self.arg_type, self.boxed)
@@ -1258,7 +1236,7 @@ class QAPISchema(object): self._predefining = False self._def_exprs() self.check() - except (QAPISchemaError, QAPIExprError) as err: + except QAPIError as err: print >>sys.stderr, err exit(1)
@@ -1557,8 +1535,8 @@ def c_name(name, protect=True): # namespace pollution: polluted_words = set(['unix', 'errno', 'mips', 'sparc']) name = name.translate(c_name_trans) - if protect and (name in c89_words | c99_words | c11_words | gcc_words - | cpp_words | polluted_words): + if protect and (name in c89_words | c99_words | c11_words | gcc_words | + cpp_words | polluted_words): return "q_" + name return name
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v6 06/17] qapi: rework qapi Exception
Quoted 51 lines · Marc-André Lureau
Use a base class QAPIError, and QAPIParseError for parser errors and QAPISemError for semantic errors, suggested by Markus Armbruster.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi.py | 338 ++++++++++++++++++++++++++------------------------------ 1 file changed, 158 insertions(+), 180 deletions(-)scripts/qapi.py +10
-19@@ -91,35 +91,38 @@ def error_path(parent): return res -class QAPISchemaError(Exception): - def __init__(self, schema, msg): +class QAPIError(Exception): + def __init__(self, fname, line, col, incl_info, msg): Exception.__init__(self) - self.fname = schema.fname + self.fname = fname + self.line = line + self.col = col + self.info = incl_info self.msg = msg - self.col = 1 - self.line = schema.line - for ch in schema.src[schema.line_pos:schema.pos]: - if ch == '\t': - self.col = (self.col + 7) % 8 + 1 - else: - self.col += 1 - self.info = schema.incl_info def __str__(self): - return error_path(self.info) + \ - "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg) + loc = "%s:%d" % (self.fname, self.line) + if self.col is not None: + loc += ":%s" % self.col + return error_path(self.info) + "%s: %s" % (loc, self.msg) -class QAPIExprError(Exception): - def __init__(self, expr_info, msg): - Exception.__init__(self) - assert expr_info - self.info = expr_info - self.msg = msg
scripts/qapi.py def error_path(parent): · line 119
Quoted 10 lines
scripts/qapi.py +10
-0+class QAPIParseError(QAPIError): + def __init__(self, parser, msg): + col = 1 + for ch in parser.src[parser.line_pos:parser.pos]: + if ch == '\t': + col = (col + 7) % 8 + 1 + else: + col += 1 + QAPIError.__init__(self, parser.fname, parser.line, + col, parser.incl_info, msg)
Let's break the line after col, so that line and columns stay together. Could be done on commit.
Quoted 638 lines
scripts/qapi.py +136
-159- def __str__(self): - return error_path(self.info['parent']) + \ - "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg) + +class QAPISemError(QAPIError): + def __init__(self, info, msg): + QAPIError.__init__(self, info['file'], info['line'], None, + info['parent'], msg) class QAPISchemaParser(object):@@ -140,25 +143,24 @@ class QAPISchemaParser(object): self.accept() while self.tok is not None: - expr_info = {'file': fname, 'line': self.line, - 'parent': self.incl_info} + info = {'file': fname, 'line': self.line, + 'parent': self.incl_info} expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1: - raise QAPIExprError(expr_info, - "Invalid 'include' directive") + raise QAPISemError(info, "Invalid 'include' directive") include = expr["include"] if not isinstance(include, str): - raise QAPIExprError(expr_info, - "Value of 'include' must be a string") + raise QAPISemError(info, + "Value of 'include' must be a string") incl_abs_fname = os.path.join(os.path.dirname(abs_fname), include) # catch inclusion cycle - inf = expr_info + inf = info while inf: if incl_abs_fname == os.path.abspath(inf['file']): - raise QAPIExprError(expr_info, "Inclusion loop for %s" - % include) + raise QAPISemError(info, "Inclusion loop for %s" + % include) inf = inf['parent'] # skip multiple include of the same file if incl_abs_fname in previously_included:@@ -166,14 +168,13 @@ class QAPISchemaParser(object): try: fobj = open(incl_abs_fname, 'r') except IOError as e: - raise QAPIExprError(expr_info, - '%s: %s' % (e.strerror, include)) + raise QAPISemError(info, '%s: %s' % (e.strerror, include)) exprs_include = QAPISchemaParser(fobj, previously_included, - expr_info) + info) self.exprs.extend(exprs_include.exprs) else: expr_elem = {'expr': expr, - 'info': expr_info} + 'info': info} self.exprs.append(expr_elem) def accept(self):@@ -194,8 +195,7 @@ class QAPISchemaParser(object): ch = self.src[self.cursor] self.cursor += 1 if ch == '\n': - raise QAPISchemaError(self, - 'Missing terminating "\'"') + raise QAPIParseError(self, 'Missing terminating "\'"') if esc: if ch == 'b': string += '\b'@@ -213,25 +213,25 @@ class QAPISchemaParser(object): ch = self.src[self.cursor] self.cursor += 1 if ch not in "0123456789abcdefABCDEF": - raise QAPISchemaError(self, - '\\u escape needs 4 ' - 'hex digits') + raise QAPIParseError(self, + '\\u escape needs 4 ' + 'hex digits') value = (value << 4) + int(ch, 16) # If Python 2 and 3 didn't disagree so much on # how to handle Unicode, then we could allow # Unicode string defaults. But most of QAPI is # ASCII-only, so we aren't losing much for now. if not value or value > 0x7f: - raise QAPISchemaError(self, - 'For now, \\u escape ' - 'only supports non-zero ' - 'values up to \\u007f') + raise QAPIParseError(self, + 'For now, \\u escape ' + 'only supports non-zero ' + 'values up to \\u007f') string += chr(value) elif ch in "\\/'\"": string += ch else: - raise QAPISchemaError(self, - "Unknown escape \\%s" % ch) + raise QAPIParseError(self, + "Unknown escape \\%s" % ch) esc = False elif ch == "\\": esc = True@@ -259,7 +259,7 @@ class QAPISchemaParser(object): self.line += 1 self.line_pos = self.cursor elif not self.tok.isspace(): - raise QAPISchemaError(self, 'Stray "%s"' % self.tok) + raise QAPIParseError(self, 'Stray "%s"' % self.tok) def get_members(self): expr = OrderedDict()@@ -267,24 +267,24 @@ class QAPISchemaParser(object): self.accept() return expr if self.tok != "'": - raise QAPISchemaError(self, 'Expected string or "}"') + raise QAPIParseError(self, 'Expected string or "}"') while True: key = self.val self.accept() if self.tok != ':': - raise QAPISchemaError(self, 'Expected ":"') + raise QAPIParseError(self, 'Expected ":"') self.accept() if key in expr: - raise QAPISchemaError(self, 'Duplicate key "%s"' % key) + raise QAPIParseError(self, 'Duplicate key "%s"' % key) expr[key] = self.get_expr(True) if self.tok == '}': self.accept() return expr if self.tok != ',': - raise QAPISchemaError(self, 'Expected "," or "}"') + raise QAPIParseError(self, 'Expected "," or "}"') self.accept() if self.tok != "'": - raise QAPISchemaError(self, 'Expected string') + raise QAPIParseError(self, 'Expected string') def get_values(self): expr = []@@ -292,20 +292,20 @@ class QAPISchemaParser(object): self.accept() return expr if self.tok not in "{['tfn": - raise QAPISchemaError(self, 'Expected "{", "[", "]", string, ' - 'boolean or "null"') + raise QAPIParseError(self, 'Expected "{", "[", "]", string, ' + 'boolean or "null"') while True: expr.append(self.get_expr(True)) if self.tok == ']': self.accept() return expr if self.tok != ',': - raise QAPISchemaError(self, 'Expected "," or "]"') + raise QAPIParseError(self, 'Expected "," or "]"') self.accept() def get_expr(self, nested): if self.tok != '{' and not nested: - raise QAPISchemaError(self, 'Expected "{"') + raise QAPIParseError(self, 'Expected "{"') if self.tok == '{': self.accept() expr = self.get_members()@@ -316,7 +316,7 @@ class QAPISchemaParser(object): expr = self.val self.accept() else: - raise QAPISchemaError(self, 'Expected "{", "[" or string') + raise QAPIParseError(self, 'Expected "{", "[" or string') return expr #@@ -375,20 +375,18 @@ valid_name = re.compile('^(__[a-zA-Z0-9.-]+_)?' '[a-zA-Z][a-zA-Z0-9_-]*$') -def check_name(expr_info, source, name, allow_optional=False, +def check_name(info, source, name, allow_optional=False, enum_member=False): global valid_name membername = name if not isinstance(name, str): - raise QAPIExprError(expr_info, - "%s requires a string name" % source) + raise QAPISemError(info, "%s requires a string name" % source) if name.startswith('*'): membername = name[1:] if not allow_optional: - raise QAPIExprError(expr_info, - "%s does not allow optional name '%s'" - % (source, name)) + raise QAPISemError(info, "%s does not allow optional name '%s'" + % (source, name)) # Enum members can start with a digit, because the generated C # code always prefixes it with the enum name if enum_member and membername[0].isdigit():@@ -397,8 +395,7 @@ def check_name(expr_info, source, name, allow_optional=False, # and 'q_obj_*' implicit type names. if not valid_name.match(membername) or \ c_name(membername, False).startswith('q_'): - raise QAPIExprError(expr_info, - "%s uses invalid name '%s'" % (source, name)) + raise QAPISemError(info, "%s uses invalid name '%s'" % (source, name)) def add_name(name, info, meta, implicit=False):@@ -407,13 +404,11 @@ def add_name(name, info, meta, implicit=False): # FIXME should reject names that differ only in '_' vs. '.' # vs. '-', because they're liable to clash in generated C. if name in all_names: - raise QAPIExprError(info, - "%s '%s' is already defined" - % (all_names[name], name)) + raise QAPISemError(info, "%s '%s' is already defined" + % (all_names[name], name)) if not implicit and (name.endswith('Kind') or name.endswith('List')): - raise QAPIExprError(info, - "%s '%s' should not end in '%s'" - % (meta, name, name[-4:])) + raise QAPISemError(info, "%s '%s' should not end in '%s'" + % (meta, name, name[-4:])) all_names[name] = meta@@ -465,7 +460,7 @@ def is_enum(name): return find_enum(name) is not None -def check_type(expr_info, source, value, allow_array=False, +def check_type(info, source, value, allow_array=False, allow_dict=False, allow_optional=False, allow_metas=[]): global all_names@@ -476,69 +471,64 @@ def check_type(expr_info, source, value, allow_array=False, # Check if array type for value is okay if isinstance(value, list): if not allow_array: - raise QAPIExprError(expr_info, - "%s cannot be an array" % source) + raise QAPISemError(info, "%s cannot be an array" % source) if len(value) != 1 or not isinstance(value[0], str): - raise QAPIExprError(expr_info, - "%s: array type must contain single type name" - % source) + raise QAPISemError(info, + "%s: array type must contain single type name" % + source) value = value[0] # Check if type name for value is okay if isinstance(value, str): if value not in all_names: - raise QAPIExprError(expr_info, - "%s uses unknown type '%s'" - % (source, value)) + raise QAPISemError(info, "%s uses unknown type '%s'" + % (source, value)) if not all_names[value] in allow_metas: - raise QAPIExprError(expr_info, - "%s cannot use %s type '%s'" - % (source, all_names[value], value)) + raise QAPISemError(info, "%s cannot use %s type '%s'" % + (source, all_names[value], value)) return if not allow_dict: - raise QAPIExprError(expr_info, - "%s should be a type name" % source) + raise QAPISemError(info, "%s should be a type name" % source) if not isinstance(value, OrderedDict): - raise QAPIExprError(expr_info, - "%s should be a dictionary or type name" % source) + raise QAPISemError(info, + "%s should be a dictionary or type name" % source) # value is a dictionary, check that each member is okay for (key, arg) in value.items(): - check_name(expr_info, "Member of %s" % source, key, + check_name(info, "Member of %s" % source, key, allow_optional=allow_optional) if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'): - raise QAPIExprError(expr_info, - "Member of %s uses reserved name '%s'" - % (source, key)) + raise QAPISemError(info, "Member of %s uses reserved name '%s'" + % (source, key)) # Todo: allow dictionaries to represent default values of # an optional argument. - check_type(expr_info, "Member '%s' of %s" % (key, source), arg, + check_type(info, "Member '%s' of %s" % (key, source), arg, allow_array=True, allow_metas=['built-in', 'union', 'alternate', 'struct', 'enum']) -def check_command(expr, expr_info): +def check_command(expr, info): name = expr['command'] boxed = expr.get('boxed', False) args_meta = ['struct'] if boxed: args_meta += ['union', 'alternate'] - check_type(expr_info, "'data' for command '%s'" % name, + check_type(info, "'data' for command '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=args_meta) returns_meta = ['union', 'struct'] if name in returns_whitelist: returns_meta += ['built-in', 'alternate', 'enum'] - check_type(expr_info, "'returns' for command '%s'" % name, + check_type(info, "'returns' for command '%s'" % name, expr.get('returns'), allow_array=True, allow_optional=True, allow_metas=returns_meta) -def check_event(expr, expr_info): +def check_event(expr, info): global events name = expr['event'] boxed = expr.get('boxed', False)@@ -547,12 +537,12 @@ def check_event(expr, expr_info): if boxed: meta += ['union', 'alternate'] events.append(name) - check_type(expr_info, "'data' for event '%s'" % name, + check_type(info, "'data' for event '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=meta) -def check_union(expr, expr_info): +def check_union(expr, info): name = expr['union'] base = expr.get('base') discriminator = expr.get('discriminator')@@ -565,123 +555,117 @@ def check_union(expr, expr_info): enum_define = None allow_metas = ['built-in', 'union', 'alternate', 'struct', 'enum'] if base is not None: - raise QAPIExprError(expr_info, - "Simple union '%s' must not have a base" - % name) + raise QAPISemError(info, "Simple union '%s' must not have a base" % + name) # Else, it's a flat union. else: # The object must have a string or dictionary 'base'. - check_type(expr_info, "'base' for union '%s'" % name, + check_type(info, "'base' for union '%s'" % name, base, allow_dict=True, allow_optional=True, allow_metas=['struct']) if not base: - raise QAPIExprError(expr_info, - "Flat union '%s' must have a base" - % name) + raise QAPISemError(info, "Flat union '%s' must have a base" + % name) base_members = find_base_members(base) assert base_members # The value of member 'discriminator' must name a non-optional # member of the base struct. - check_name(expr_info, "Discriminator of flat union '%s'" % name, + check_name(info, "Discriminator of flat union '%s'" % name, discriminator) discriminator_type = base_members.get(discriminator) if not discriminator_type: - raise QAPIExprError(expr_info, - "Discriminator '%s' is not a member of base " - "struct '%s'" - % (discriminator, base)) + raise QAPISemError(info, + "Discriminator '%s' is not a member of base " + "struct '%s'" + % (discriminator, base)) enum_define = find_enum(discriminator_type) allow_metas = ['struct'] # Do not allow string discriminator if not enum_define: - raise QAPIExprError(expr_info, - "Discriminator '%s' must be of enumeration " - "type" % discriminator) + raise QAPISemError(info, + "Discriminator '%s' must be of enumeration " + "type" % discriminator) # Check every branch; don't allow an empty union if len(members) == 0: - raise QAPIExprError(expr_info, - "Union '%s' cannot have empty 'data'" % name) + raise QAPISemError(info, "Union '%s' cannot have empty 'data'" % name) for (key, value) in members.items(): - check_name(expr_info, "Member of union '%s'" % name, key) + check_name(info, "Member of union '%s'" % name, key) # Each value must name a known type - check_type(expr_info, "Member '%s' of union '%s'" % (key, name), + check_type(info, "Member '%s' of union '%s'" % (key, name), value, allow_array=not base, allow_metas=allow_metas) # If the discriminator names an enum type, then all members # of 'data' must also be members of the enum type. if enum_define: if key not in enum_define['enum_values']: - raise QAPIExprError(expr_info, - "Discriminator value '%s' is not found in " - "enum '%s'" % - (key, enum_define["enum_name"])) + raise QAPISemError(info, + "Discriminator value '%s' is not found in " + "enum '%s'" + % (key, enum_define["enum_name"])) # If discriminator is user-defined, ensure all values are covered if enum_define: for value in enum_define['enum_values']: if value not in members.keys(): - raise QAPIExprError(expr_info, - "Union '%s' data missing '%s' branch" - % (name, value)) + raise QAPISemError(info, "Union '%s' data missing '%s' branch" + % (name, value)) -def check_alternate(expr, expr_info): +def check_alternate(expr, info): name = expr['alternate'] members = expr['data'] types_seen = {} # Check every branch; require at least two branches if len(members) < 2: - raise QAPIExprError(expr_info, - "Alternate '%s' should have at least two branches " - "in 'data'" % name) + raise QAPISemError(info, + "Alternate '%s' should have at least two branches " + "in 'data'" % name) for (key, value) in members.items(): - check_name(expr_info, "Member of alternate '%s'" % name, key) + check_name(info, "Member of alternate '%s'" % name, key) # Ensure alternates have no type conflicts. - check_type(expr_info, "Member '%s' of alternate '%s'" % (key, name), + check_type(info, "Member '%s' of alternate '%s'" % (key, name), value, allow_metas=['built-in', 'union', 'struct', 'enum']) qtype = find_alternate_member_qtype(value) if not qtype: - raise QAPIExprError(expr_info, - "Alternate '%s' member '%s' cannot use " - "type '%s'" % (name, key, value)) + raise QAPISemError(info, "Alternate '%s' member '%s' cannot use " + "type '%s'" % (name, key, value)) if qtype in types_seen: - raise QAPIExprError(expr_info, - "Alternate '%s' member '%s' can't " - "be distinguished from member '%s'" - % (name, key, types_seen[qtype])) + raise QAPISemError(info, "Alternate '%s' member '%s' can't " + "be distinguished from member '%s'" + % (name, key, types_seen[qtype])) types_seen[qtype] = key -def check_enum(expr, expr_info): +def check_enum(expr, info): name = expr['enum'] members = expr.get('data') prefix = expr.get('prefix') if not isinstance(members, list): - raise QAPIExprError(expr_info, - "Enum '%s' requires an array for 'data'" % name) + raise QAPISemError(info, + "Enum '%s' requires an array for 'data'" % name) if prefix is not None and not isinstance(prefix, str): - raise QAPIExprError(expr_info, - "Enum '%s' requires a string for 'prefix'" % name) + raise QAPISemError(info, + "Enum '%s' requires a string for 'prefix'" % name) for member in members: - check_name(expr_info, "Member of enum '%s'" % name, member, + check_name(info, "Member of enum '%s'" % name, member, enum_member=True) -def check_struct(expr, expr_info): +def check_struct(expr, info): name = expr['struct'] members = expr['data'] - check_type(expr_info, "'data' for struct '%s'" % name, members, + check_type(info, "'data' for struct '%s'" % name, members, allow_dict=True, allow_optional=True) - check_type(expr_info, "'base' for struct '%s'" % name, expr.get('base'), + check_type(info, "'base' for struct '%s'" % name, expr.get('base'), allow_metas=['struct'])@@ -690,27 +674,24 @@ def check_keys(expr_elem, meta, required, optional=[]): info = expr_elem['info'] name = expr[meta] if not isinstance(name, str): - raise QAPIExprError(info, - "'%s' key must have a string value" % meta) + raise QAPISemError(info, "'%s' key must have a string value" % meta) required = required + [meta] for (key, value) in expr.items(): if key not in required and key not in optional: - raise QAPIExprError(info, - "Unknown key '%s' in %s '%s'" - % (key, meta, name)) + raise QAPISemError(info, "Unknown key '%s' in %s '%s'" + % (key, meta, name)) if (key == 'gen' or key == 'success-response') and value is not False: - raise QAPIExprError(info, - "'%s' of %s '%s' should only use false value" - % (key, meta, name)) + raise QAPISemError(info, + "'%s' of %s '%s' should only use false value" + % (key, meta, name)) if key == 'boxed' and value is not True: - raise QAPIExprError(info, - "'%s' of %s '%s' should only use true value" - % (key, meta, name)) + raise QAPISemError(info, + "'%s' of %s '%s' should only use true value" + % (key, meta, name)) for key in required: if key not in expr: - raise QAPIExprError(info, - "Key '%s' is missing from %s '%s'" - % (key, meta, name)) + raise QAPISemError(info, "Key '%s' is missing from %s '%s'" + % (key, meta, name)) def check_exprs(exprs):@@ -743,8 +724,8 @@ def check_exprs(exprs): check_keys(expr_elem, 'event', [], ['data', 'boxed']) add_name(expr['event'], info, 'event') else: - raise QAPIExprError(expr_elem['info'], - "Expression is missing metatype") + raise QAPISemError(expr_elem['info'], + "Expression is missing metatype") # Try again for hidden UnionKind enum for expr_elem in exprs:@@ -978,8 +959,8 @@ class QAPISchemaObjectType(QAPISchemaType): def check(self, schema): if self.members is False: # check for cycles - raise QAPIExprError(self.info, - "Object %s contains itself" % self.name) + raise QAPISemError(self.info, + "Object %s contains itself" % self.name) if self.members: return self.members = False # mark as being checked@@ -1051,12 +1032,11 @@ class QAPISchemaMember(object): def check_clash(self, info, seen): cname = c_name(self.name) if cname.lower() != cname and self.owner not in case_whitelist: - raise QAPIExprError(info, - "%s should not use uppercase" % self.describe()) + raise QAPISemError(info, + "%s should not use uppercase" % self.describe()) if cname in seen: - raise QAPIExprError(info, - "%s collides with %s" - % (self.describe(), seen[cname].describe())) + raise QAPISemError(info, "%s collides with %s" % + (self.describe(), seen[cname].describe())) seen[cname] = self def _pretty_owner(self):@@ -1201,14 +1181,13 @@ class QAPISchemaCommand(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, - "Cannot use 'boxed' with empty type") + raise QAPISemError(self.info, + "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, - "Use of 'boxed' requires 'data'") + raise QAPISemError(self.info, "Use of 'boxed' requires 'data'") if self._ret_type_name: self.ret_type = schema.lookup_type(self._ret_type_name) assert isinstance(self.ret_type, QAPISchemaType)@@ -1235,14 +1214,13 @@ class QAPISchemaEvent(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, - "Cannot use 'boxed' with empty type") + raise QAPISemError(self.info, + "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, - "Use of 'boxed' requires 'data'") + raise QAPISemError(self.info, "Use of 'boxed' requires 'data'") def visit(self, visitor): visitor.visit_event(self.name, self.info, self.arg_type, self.boxed)@@ -1258,7 +1236,7 @@ class QAPISchema(object): self._predefining = False self._def_exprs() self.check() - except (QAPISchemaError, QAPIExprError) as err: + except QAPIError as err: print >>sys.stderr, err exit(1)
scripts/qapi.py def c_name(name, protect=True): · line 1541
Quoted 9 lines
scripts/qapi.py +2
-2@@ -1557,8 +1535,8 @@ def c_name(name, protect=True): # namespace pollution: polluted_words = set(['unix', 'errno', 'mips', 'sparc']) name = name.translate(c_name_trans) - if protect and (name in c89_words | c99_words | c11_words | gcc_words - | cpp_words | polluted_words): + if protect and (name in c89_words | c99_words | c11_words | gcc_words | + cpp_words | polluted_words): return "q_" + name return name
Spurious hunk. Could drop on commit.
The change is mostly mechanical. Would be easier to review if the rename from expr_info to info was a separate patch, but I guess it's not worth splitting off now. I'm not sure the rename is an improvement, but backing it out seems not worth it now, either.
With the two touch-ups:
Re: [Qemu-devel] [PATCH v6 06/17] qapi: rework qapi Exception
Hi
----- Original Message -----
Quoted 59 lines
Quoted 57 lines · Marc-André Lureau
Use a base class QAPIError, and QAPIParseError for parser errors and QAPISemError for semantic errors, suggested by Markus Armbruster.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi.py | 338 ++++++++++++++++++++++++++------------------------------ 1 file changed, 158 insertions(+), 180 deletions(-)scripts/qapi.py +15
-19@@ -91,35 +91,38 @@ def error_path(parent): return res -class QAPISchemaError(Exception): - def __init__(self, schema, msg): +class QAPIError(Exception): + def __init__(self, fname, line, col, incl_info, msg): Exception.__init__(self) - self.fname = schema.fname + self.fname = fname + self.line = line + self.col = col + self.info = incl_info self.msg = msg - self.col = 1 - self.line = schema.line - for ch in schema.src[schema.line_pos:schema.pos]: - if ch == '\t': - self.col = (self.col + 7) % 8 + 1 - else: - self.col += 1 - self.info = schema.incl_info def __str__(self): - return error_path(self.info) + \ - "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg) + loc = "%s:%d" % (self.fname, self.line) + if self.col is not None: + loc += ":%s" % self.col + return error_path(self.info) + "%s: %s" % (loc, self.msg) -class QAPIExprError(Exception): - def __init__(self, expr_info, msg): - Exception.__init__(self) - assert expr_info - self.info = expr_info - self.msg = msg +class QAPIParseError(QAPIError): + def __init__(self, parser, msg): + col = 1 + for ch in parser.src[parser.line_pos:parser.pos]: + if ch == '\t':
Quoted 9 lines
scripts/qapi.py def error_path(parent): · line 119
Quoted 5 lines
scripts/qapi.py +5
-0+ col = (col + 7) % 8 + 1 + else: + col += 1 + QAPIError.__init__(self, parser.fname, parser.line, + col, parser.incl_info, msg)Let's break the line after col, so that line and columns stay together. Could be done on commit.
ok
Quoted 706 lines
Quoted 706 lines
scripts/qapi.py +11
-11- def __str__(self): - return error_path(self.info['parent']) + \ - "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg) + +class QAPISemError(QAPIError): + def __init__(self, info, msg): + QAPIError.__init__(self, info['file'], info['line'], None, + info['parent'], msg) class QAPISchemaParser(object):@@ -140,25 +143,24 @@ class QAPISchemaParser(object): self.accept() while self.tok is not None: - expr_info = {'file': fname, 'line': self.line, - 'parent': self.incl_info} + info = {'file': fname, 'line': self.line, + 'parent': self.incl_info} expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1: - raise QAPIExprError(expr_info, - "Invalid 'include' directive") + raise QAPISemError(info, "Invalid 'include' directive") include = expr["include"] if not isinstance(include, str): - raise QAPIExprError(expr_info, - "Value of 'include' must be a string") + raise QAPISemError(info, + "Value of 'include' must be a string") incl_abs_fname = os.path.join(os.path.dirname(abs_fname), include) # catch inclusion cycle - inf = expr_info + inf = info while inf: if incl_abs_fname == os.path.abspath(inf['file']): - raise QAPIExprError(expr_info, "Inclusion loop for%s"
scripts/qapi.py +5
-5- % include) + raise QAPISemError(info, "Inclusion loop for %s" + % include) inf = inf['parent'] # skip multiple include of the same file if incl_abs_fname in previously_included:@@ -166,14 +168,13 @@ class QAPISchemaParser(object): try: fobj = open(incl_abs_fname, 'r') except IOError as e: - raise QAPIExprError(expr_info, - '%s: %s' % (e.strerror, include)) + raise QAPISemError(info, '%s: %s' % (e.strerror, include)) exprs_include = QAPISchemaParser(fobj, previously_included, - expr_info) + info) self.exprs.extend(exprs_include.exprs) else: expr_elem = {'expr': expr, - 'info': expr_info} + 'info': info} self.exprs.append(expr_elem)def accept(self):
scripts/qapi.py +1
-2@@ -194,8 +195,7 @@ class QAPISchemaParser(object): ch = self.src[self.cursor] self.cursor += 1 if ch == '\n': - raise QAPISchemaError(self, - 'Missing terminating "\'"') + raise QAPIParseError(self, 'Missing terminating "\'"') if esc: if ch == 'b':string += '\b'scripts/qapi.py +0
-2@@ -213,25 +213,25 @@ class QAPISchemaParser(object): ch = self.src[self.cursor] self.cursor += 1 if ch not in "0123456789abcdefABCDEF": - raise QAPISchemaError(self, - '\\u escapeneeds 4 '
scripts/qapi.py +2
-1- 'hex digits') + raise QAPIParseError(self, + '\\u escape needs4 '
scripts/qapi.py +1
-2+ 'hex digits') value = (value << 4) + int(ch, 16) # If Python 2 and 3 didn't disagree so much on # how to handle Unicode, then we could allow # Unicode string defaults. But most of QAPI is # ASCII-only, so we aren't losing much for now. if not value or value > 0x7f: - raise QAPISchemaError(self, - 'For now, \\u escape'
- 'only supports
non-zero '
- 'values up to
\\u007f')scripts/qapi.py +2
-0+ raise QAPIParseError(self, + 'For now, \\u escape'
+ 'only supports
non-zero '
+ 'values up to
\\u007f')string += chr(value) elif ch in "\\/'\"": string += ch else:scripts/qapi.py +0
-2- raise QAPISchemaError(self, - "Unknown escape \\%s" %ch)
scripts/qapi.py +2
-0+ raise QAPIParseError(self, + "Unknown escape \\%s" %ch)
esc = False
elif ch == "\\":
esc = Truescripts/qapi.py +14
-17@@ -259,7 +259,7 @@ class QAPISchemaParser(object): self.line += 1 self.line_pos = self.cursor elif not self.tok.isspace(): - raise QAPISchemaError(self, 'Stray "%s"' % self.tok) + raise QAPIParseError(self, 'Stray "%s"' % self.tok) def get_members(self): expr = OrderedDict()@@ -267,24 +267,24 @@ class QAPISchemaParser(object): self.accept() return expr if self.tok != "'": - raise QAPISchemaError(self, 'Expected string or "}"') + raise QAPIParseError(self, 'Expected string or "}"') while True: key = self.val self.accept() if self.tok != ':': - raise QAPISchemaError(self, 'Expected ":"') + raise QAPIParseError(self, 'Expected ":"') self.accept() if key in expr: - raise QAPISchemaError(self, 'Duplicate key "%s"' % key) + raise QAPIParseError(self, 'Duplicate key "%s"' % key) expr[key] = self.get_expr(True) if self.tok == '}': self.accept() return expr if self.tok != ',': - raise QAPISchemaError(self, 'Expected "," or "}"') + raise QAPIParseError(self, 'Expected "," or "}"') self.accept() if self.tok != "'": - raise QAPISchemaError(self, 'Expected string') + raise QAPIParseError(self, 'Expected string') def get_values(self): expr = []@@ -292,20 +292,20 @@ class QAPISchemaParser(object): self.accept() return expr if self.tok not in "{['tfn": - raise QAPISchemaError(self, 'Expected "{", "[", "]", string, ' - 'boolean or "null"') + raise QAPIParseError(self, 'Expected "{", "[", "]", string, ' + 'boolean or "null"') while True: expr.append(self.get_expr(True)) if self.tok == ']': self.accept() return expr if self.tok != ',': - raise QAPISchemaError(self, 'Expected "," or "]"') + raise QAPIParseError(self, 'Expected "," or "]"') self.accept() def get_expr(self, nested): if self.tok != '{' and not nested: - raise QAPISchemaError(self, 'Expected "{"') + raise QAPIParseError(self, 'Expected "{"') if self.tok == '{': self.accept() expr = self.get_members()@@ -316,7 +316,7 @@ class QAPISchemaParser(object): expr = self.val self.accept() else: - raise QAPISchemaError(self, 'Expected "{", "[" or string') + raise QAPIParseError(self, 'Expected "{", "[" or string') return expr #@@ -375,20 +375,18 @@ valid_name = re.compile('^(__[a-zA-Z0-9.-]+_)?' '[a-zA-Z][a-zA-Z0-9_-]*$') -def check_name(expr_info, source, name, allow_optional=False, +def check_name(info, source, name, allow_optional=False, enum_member=False): global valid_name membername = name if not isinstance(name, str): - raise QAPIExprError(expr_info, - "%s requires a string name" % source) + raise QAPISemError(info, "%s requires a string name" % source) if name.startswith('*'): membername = name[1:] if not allow_optional: - raise QAPIExprError(expr_info, - "%s does not allow optional name '%s'" - % (source, name)) + raise QAPISemError(info, "%s does not allow optional name'%s'"
scripts/qapi.py +2
-2+ % (source, name)) # Enum members can start with a digit, because the generated C # code always prefixes it with the enum name if enum_member and membername[0].isdigit():@@ -397,8 +395,7 @@ def check_name(expr_info, source, name, allow_optional=False, # and 'q_obj_*' implicit type names. if not valid_name.match(membername) or \ c_name(membername, False).startswith('q_'): - raise QAPIExprError(expr_info, - "%s uses invalid name '%s'" % (source, name)) + raise QAPISemError(info, "%s uses invalid name '%s'" % (source, name))def
add_name(name, info, meta, implicit=False):scripts/qapi.py +6
-11@@ -407,13 +404,11 @@ def add_name(name, info, meta, implicit=False): # FIXME should reject names that differ only in '_' vs. '.' # vs. '-', because they're liable to clash in generated C. if name in all_names: - raise QAPIExprError(info, - "%s '%s' is already defined" - % (all_names[name], name)) + raise QAPISemError(info, "%s '%s' is already defined" + % (all_names[name], name)) if not implicit and (name.endswith('Kind') or name.endswith('List')): - raise QAPIExprError(info, - "%s '%s' should not end in '%s'" - % (meta, name, name[-4:])) + raise QAPISemError(info, "%s '%s' should not end in '%s'" + % (meta, name, name[-4:])) all_names[name] = meta@@ -465,7 +460,7 @@ def is_enum(name): return find_enum(name) is not None -def check_type(expr_info, source, value, allow_array=False, +def check_type(info, source, value, allow_array=False, allow_dict=False, allow_optional=False, allow_metas=[]): global all_names@@ -476,69 +471,64 @@ def check_type(expr_info, source, value, allow_array=False, # Check if array type for value is okay if isinstance(value, list): if not allow_array: - raise QAPIExprError(expr_info, - "%s cannot be an array" % source) + raise QAPISemError(info, "%s cannot be an array" % source) if len(value) != 1 or not isinstance(value[0], str): - raise QAPIExprError(expr_info, - "%s: array type must contain single typename"
scripts/qapi.py +2
-1- % source) + raise QAPISemError(info, + "%s: array type must contain single typename" %
scripts/qapi.py +6
-10+ source) value = value[0] # Check if type name for value is okay if isinstance(value, str): if value not in all_names: - raise QAPIExprError(expr_info, - "%s uses unknown type '%s'" - % (source, value)) + raise QAPISemError(info, "%s uses unknown type '%s'" + % (source, value)) if not all_names[value] in allow_metas: - raise QAPIExprError(expr_info, - "%s cannot use %s type '%s'" - % (source, all_names[value], value)) + raise QAPISemError(info, "%s cannot use %s type '%s'" % + (source, all_names[value], value)) return if not allow_dict: - raise QAPIExprError(expr_info, - "%s should be a type name" % source) + raise QAPISemError(info, "%s should be a type name" % source) if not isinstance(value, OrderedDict): - raise QAPIExprError(expr_info, - "%s should be a dictionary or type name" %source)
scripts/qapi.py +2
-0+ raise QAPISemError(info, + "%s should be a dictionary or type name" %source)
# value is a dictionary, check that each member is okay for (key, arg) in value.items():scripts/qapi.py +2
-4- check_name(expr_info, "Member of %s" % source, key, + check_name(info, "Member of %s" % source, key, allow_optional=allow_optional) if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'): - raise QAPIExprError(expr_info, - "Member of %s uses reserved name '%s'" - % (source, key)) + raise QAPISemError(info, "Member of %s uses reserved name'%s'"
scripts/qapi.py +8
-7+ % (source, key)) # Todo: allow dictionaries to represent default values of # an optional argument. - check_type(expr_info, "Member '%s' of %s" % (key, source), arg, + check_type(info, "Member '%s' of %s" % (key, source), arg, allow_array=True, allow_metas=['built-in', 'union', 'alternate', 'struct', 'enum']) -def check_command(expr, expr_info): +def check_command(expr, info): name = expr['command'] boxed = expr.get('boxed', False) args_meta = ['struct'] if boxed: args_meta += ['union', 'alternate'] - check_type(expr_info, "'data' for command '%s'" % name, + check_type(info, "'data' for command '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=args_meta) returns_meta = ['union', 'struct'] if name in returns_whitelist: returns_meta += ['built-in', 'alternate', 'enum'] - check_type(expr_info, "'returns' for command '%s'" % name, + check_type(info, "'returns' for command '%s'" % name, expr.get('returns'), allow_array=True, allow_optional=True, allow_metas=returns_meta) -def check_event(expr, expr_info): +def check_event(expr, info): global events name = expr['event'] boxed = expr.get('boxed', False)@@ -547,12 +537,12 @@ def check_event(expr, expr_info): if boxed: meta += ['union', 'alternate'] events.append(name) - check_type(expr_info, "'data' for event '%s'" % name, + check_type(info, "'data' for event '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=meta) -def check_union(expr, expr_info): +def check_union(expr, info): name = expr['union'] base = expr.get('base')discriminator =
expr.get('discriminator')scripts/qapi.py +1
-3@@ -565,123 +555,117 @@ def check_union(expr, expr_info): enum_define = None allow_metas = ['built-in', 'union', 'alternate', 'struct', 'enum'] if base is not None: - raise QAPIExprError(expr_info, - "Simple union '%s' must not have a base" - % name) + raise QAPISemError(info, "Simple union '%s' must not have abase" %
scripts/qapi.py +5
-7+ name) # Else, it's a flat union. else: # The object must have a string or dictionary 'base'. - check_type(expr_info, "'base' for union '%s'" % name, + check_type(info, "'base' for union '%s'" % name, base, allow_dict=True, allow_optional=True, allow_metas=['struct']) if not base: - raise QAPIExprError(expr_info, - "Flat union '%s' must have a base" - % name) + raise QAPISemError(info, "Flat union '%s' must have a base" + % name) base_members = find_base_members(base) assert base_members # The value of member 'discriminator' must name a non-optional # member of the base struct. - check_name(expr_info, "Discriminator of flat union '%s'" % name, + check_name(info, "Discriminator of flat union '%s'" % name, discriminator) discriminator_type = base_members.get(discriminator) if not discriminator_type: - raise QAPIExprError(expr_info, - "Discriminator '%s' is not a member ofbase "
scripts/qapi.py +2
-2- "struct '%s'" - % (discriminator, base)) + raise QAPISemError(info, + "Discriminator '%s' is not a member of base"
scripts/qapi.py +2
-2+ "struct '%s'" + % (discriminator, base)) enum_define = find_enum(discriminator_type) allow_metas = ['struct'] # Do not allow string discriminator if not enum_define: - raise QAPIExprError(expr_info, - "Discriminator '%s' must be of enumeration"
scripts/qapi.py +2
-1- "type" % discriminator) + raise QAPISemError(info, + "Discriminator '%s' must be of enumeration"
scripts/qapi.py +2
-2+ "type" % discriminator) # Check every branch; don't allow an empty union if len(members) == 0: - raise QAPIExprError(expr_info, - "Union '%s' cannot have empty 'data'" % name) + raise QAPISemError(info, "Union '%s' cannot have empty 'data'" %name)
for (key, value) inmembers.items():scripts/qapi.py +2
-4- check_name(expr_info, "Member of union '%s'" % name, key) + check_name(info, "Member of union '%s'" % name, key) # Each value must name a known type - check_type(expr_info, "Member '%s' of union '%s'" % (key, name), + check_type(info, "Member '%s' of union '%s'" % (key, name), value, allow_array=not base, allow_metas=allow_metas) # If the discriminator names an enum type, then all members # of 'data' must also be members of the enum type. if enum_define: if key not in enum_define['enum_values']: - raise QAPIExprError(expr_info, - "Discriminator value '%s' is not foundin "
scripts/qapi.py +2
-2- "enum '%s'" % - (key, enum_define["enum_name"])) + raise QAPISemError(info, + "Discriminator value '%s' is not foundin "
scripts/qapi.py +3
-3+ "enum '%s'" + % (key, enum_define["enum_name"])) # If discriminator is user-defined, ensure all values are covered if enum_define: for value in enum_define['enum_values']: if value not in members.keys(): - raise QAPIExprError(expr_info, - "Union '%s' data missing '%s' branch" - % (name, value)) + raise QAPISemError(info, "Union '%s' data missing '%s'branch"
scripts/qapi.py +2
-3+ % (name, value)) -def check_alternate(expr, expr_info): +def check_alternate(expr, info): name = expr['alternate'] members = expr['data'] types_seen = {} # Check every branch; require at least two branches if len(members) < 2: - raise QAPIExprError(expr_info, - "Alternate '%s' should have at least twobranches "
scripts/qapi.py +2
-1- "in 'data'" % name) + raise QAPISemError(info, + "Alternate '%s' should have at least twobranches "
scripts/qapi.py +2
-2+ "in 'data'" % name) for (key, value) in members.items(): - check_name(expr_info, "Member of alternate '%s'" % name, key) + check_name(info, "Member of alternate '%s'" % name, key) # Ensure alternates have no type conflicts. - check_type(expr_info, "Member '%s' of alternate '%s'" % (key,name),
scripts/qapi.py +2
-3+ check_type(info, "Member '%s' of alternate '%s'" % (key, name), value, allow_metas=['built-in', 'union', 'struct', 'enum']) qtype = find_alternate_member_qtype(value) if not qtype: - raise QAPIExprError(expr_info, - "Alternate '%s' member '%s' cannot use " - "type '%s'" % (name, key, value)) + raise QAPISemError(info, "Alternate '%s' member '%s' cannotuse "
scripts/qapi.py +5
-7+ "type '%s'" % (name, key, value)) if qtype in types_seen: - raise QAPIExprError(expr_info, - "Alternate '%s' member '%s' can't " - "be distinguished from member '%s'" - % (name, key, types_seen[qtype])) + raise QAPISemError(info, "Alternate '%s' member '%s' can't " + "be distinguished from member '%s'" + % (name, key, types_seen[qtype])) types_seen[qtype] = key -def check_enum(expr, expr_info): +def check_enum(expr, info): name = expr['enum'] members = expr.get('data') prefix = expr.get('prefix') if not isinstance(members, list): - raise QAPIExprError(expr_info, - "Enum '%s' requires an array for 'data'" %name)
scripts/qapi.py +2
-0+ raise QAPISemError(info, + "Enum '%s' requires an array for 'data'" %name)
if prefix is not None and notisinstance(prefix, str):scripts/qapi.py +0
-2- raise QAPIExprError(expr_info, - "Enum '%s' requires a string for 'prefix'" %name)
scripts/qapi.py +2
-0+ raise QAPISemError(info, + "Enum '%s' requires a string for 'prefix'" %name)
for member in members:scripts/qapi.py +3
-4- check_name(expr_info, "Member of enum '%s'" % name, member, + check_name(info, "Member of enum '%s'" % name, member, enum_member=True) -def check_struct(expr, expr_info): +def check_struct(expr, info): name = expr['struct'] members = expr['data'] - check_type(expr_info, "'data' for struct '%s'" % name, members, + check_type(info, "'data' for struct '%s'" % name, members, allow_dict=True, allow_optional=True) - check_type(expr_info, "'base' for struct '%s'" % name,
expr.get('base'),scripts/qapi.py +1
-0+ check_type(info, "'base' for struct '%s'" % name, expr.get('base'), allow_metas=['struct'])@@ -690,27 +674,24 @@ def check_keys(expr_elem, meta, required,optional=[]):
info = expr_elem['info']
name = expr[meta]
if notisinstance(name, str):scripts/qapi.py +1
-2- raise QAPIExprError(info, - "'%s' key must have a string value" % meta) + raise QAPISemError(info, "'%s' key must have a string value" %meta)
required = required + [meta]
for (key, value) inexpr.items():
if key not in required and key not in optional:scripts/qapi.py +2
-5- raise QAPIExprError(info, - "Unknown key '%s' in %s '%s'" - % (key, meta, name)) + raise QAPISemError(info, "Unknown key '%s' in %s '%s'" + % (key, meta, name)) if (key == 'gen' or key == 'success-response') and value is not False: - raise QAPIExprError(info, - "'%s' of %s '%s' should only use falsevalue"
scripts/qapi.py +2
-1- % (key, meta, name)) + raise QAPISemError(info, + "'%s' of %s '%s' should only use falsevalue"
scripts/qapi.py +1
-2+ % (key, meta, name)) if key == 'boxed' and value is not True: - raise QAPIExprError(info, - "'%s' of %s '%s' should only use truevalue"
scripts/qapi.py +2
-1- % (key, meta, name)) + raise QAPISemError(info, + "'%s' of %s '%s' should only use truevalue"
scripts/qapi.py +11
-12+ % (key, meta, name)) for key in required: if key not in expr: - raise QAPIExprError(info, - "Key '%s' is missing from %s '%s'" - % (key, meta, name)) + raise QAPISemError(info, "Key '%s' is missing from %s '%s'" + % (key, meta, name)) def check_exprs(exprs):@@ -743,8 +724,8 @@ def check_exprs(exprs): check_keys(expr_elem, 'event', [], ['data', 'boxed']) add_name(expr['event'], info, 'event') else: - raise QAPIExprError(expr_elem['info'], - "Expression is missing metatype") + raise QAPISemError(expr_elem['info'], + "Expression is missing metatype") # Try again for hidden UnionKind enum for expr_elem in exprs:@@ -978,8 +959,8 @@ class QAPISchemaObjectType(QAPISchemaType): def check(self, schema): if self.members is False: # check for cycles - raise QAPIExprError(self.info, - "Object %s contains itself" % self.name) + raise QAPISemError(self.info, + "Object %s contains itself" % self.name) if self.members: return self.members = False # mark as being checked@@ -1051,12 +1032,11 @@ class QAPISchemaMember(object): def check_clash(self, info, seen): cname = c_name(self.name) if cname.lower() != cname and self.owner not in case_whitelist: - raise QAPIExprError(info, - "%s should not use uppercase" % self.describe()) + raise QAPISemError(info, + "%s should not use uppercase" % self.describe()) if cname in seen: - raise QAPIExprError(info, - "%s collides with %s" - % (self.describe(), seen[cname].describe())) + raise QAPISemError(info, "%s collides with %s" % + (self.describe(), seen[cname].describe()))seen[cname] = self
def
_pretty_owner(self):scripts/qapi.py +3
-4@@ -1201,14 +1181,13 @@ class QAPISchemaCommand(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, - "Cannot use 'boxed' with empty type") + raise QAPISemError(self.info, + "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, - "Use of 'boxed' requires 'data'") + raise QAPISemError(self.info, "Use of 'boxed' requires'data'")
if self._ret_type_name:
self.ret_type =schema.lookup_type(self._ret_type_name)assertisinstance(self.ret_type, QAPISchemaType)scripts/qapi.py +3
-4@@ -1235,14 +1214,13 @@ class QAPISchemaEvent(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, - "Cannot use 'boxed' with empty type") + raise QAPISemError(self.info, + "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, - "Use of 'boxed' requires 'data'") + raise QAPISemError(self.info, "Use of 'boxed' requires'data'")
def
visit(self, visitor):
visitor.visit_event(self.name, self.info, self.arg_type, self.boxed)scripts/qapi.py +1
-1@@ -1258,7 +1236,7 @@ class QAPISchema(object): self._predefining = False self._def_exprs() self.check() - except (QAPISchemaError, QAPIExprError) as err: + except QAPIError as err: print >>sys.stderr, err exit(1)
Quoted 13 lines
Quoted 11 lines
scripts/qapi.py +1
-2@@ -1557,8 +1535,8 @@ def c_name(name, protect=True): # namespace pollution: polluted_words = set(['unix', 'errno', 'mips', 'sparc']) name = name.translate(c_name_trans) - if protect and (name in c89_words | c99_words | c11_words | gcc_words - | cpp_words | polluted_words): + if protect and (name in c89_words | c99_words | c11_words | gcc_words|
+cpp_words|polluted_words):
return "q_" + name
return nameSpurious hunk. Could drop on commit.
I think I did it to fixscripts/qapi.py:1539:21: W503 line break before binary operator
I'll split it
Quoted 9 lines
The change is mostly mechanical. Would be easier to review if the rename from
expr_infoto info was a separate patch, but I guess it's not worth splitting off now. I'm not sure the rename is an improvement, but backing it out seems not worth it now, either.With the two touch-ups:
Reviewed-by Markus Armbruster <[email protected]>
PATCH v6 7/17 qapi: use a QAPIParseError in parser
In reply to Marc-André Lureau--- scripts/qapi.py | 13 +++++++------ tests/qapi-schema/include-cycle.err | 2 +- tests/qapi-schema/include-format-err.err | 2 +- tests/qapi-schema/include-no-file.err | 2 +- tests/qapi-schema/include-non-file.err | 2 +- tests/qapi-schema/include-self-cycle.err | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-)
scripts/qapi.py +7 -6
@@ -148,19 +148,19 @@ class QAPISchemaParser(object): expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1: - raise QAPISemError(info, "Invalid 'include' directive") + raise QAPIParseError(self, "Invalid 'include' directive") include = expr["include"] if not isinstance(include, str): - raise QAPISemError(info, - "Value of 'include' must be a string") + raise QAPIParseError(self, + "Value of 'include' must be a string") incl_abs_fname = os.path.join(os.path.dirname(abs_fname), include) # catch inclusion cycle inf = info while inf: if incl_abs_fname == os.path.abspath(inf['file']): - raise QAPISemError(info, "Inclusion loop for %s" - % include) + raise QAPIParseError(self, "Inclusion loop for %s" + % include) inf = inf['parent'] # skip multiple include of the same file if incl_abs_fname in previously_included:
@@ -168,7 +168,8 @@ class QAPISchemaParser(object): try: fobj = open(incl_abs_fname, 'r') except IOError as e: - raise QAPISemError(info, '%s: %s' % (e.strerror, include)) + raise QAPIParseError(self, '%s: %s' % + (e.strerror, include)) exprs_include = QAPISchemaParser(fobj, previously_included, info) self.exprs.extend(exprs_include.exprs)
tests/qapi-schema/include-cycle.err +1 -1
@@ -1,3 +1,3 @@ In file included from tests/qapi-schema/include-cycle.json:1: In file included from tests/qapi-schema/include-cycle-b.json:1: -tests/qapi-schema/include-cycle-c.json:1: Inclusion loop for include-cycle.json +tests/qapi-schema/include-cycle-c.json:1:36: Inclusion loop for include-cycle.json
tests/qapi-schema/include-format-err.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/include-format-err.json:1: Invalid 'include' directive +tests/qapi-schema/include-format-err.json:2:17: Invalid 'include' directive
tests/qapi-schema/include-no-file.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/include-no-file.json:1: No such file or directory: include-no-file-sub.json +tests/qapi-schema/include-no-file.json:1:42: No such file or directory: include-no-file-sub.json
tests/qapi-schema/include-non-file.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/include-non-file.json:1: Value of 'include' must be a string +tests/qapi-schema/include-non-file.json:1:18: Value of 'include' must be a string
tests/qapi-schema/include-self-cycle.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/include-self-cycle.json:1: Inclusion loop for include-self-cycle.json +tests/qapi-schema/include-self-cycle.json:1:41: Inclusion loop for include-self-cycle.json
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v6 07/17] qapi: use a QAPIParseError in parser
Quoted 54 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi.py | 13 +++++++------ tests/qapi-schema/include-cycle.err | 2 +- tests/qapi-schema/include-format-err.err | 2 +- tests/qapi-schema/include-no-file.err | 2 +- tests/qapi-schema/include-non-file.err | 2 +- tests/qapi-schema/include-self-cycle.err | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-)scripts/qapi.py +7
-6@@ -148,19 +148,19 @@ class QAPISchemaParser(object): expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1: - raise QAPISemError(info, "Invalid 'include' directive") + raise QAPIParseError(self, "Invalid 'include' directive") include = expr["include"] if not isinstance(include, str): - raise QAPISemError(info, - "Value of 'include' must be a string") + raise QAPIParseError(self, + "Value of 'include' must be a string") incl_abs_fname = os.path.join(os.path.dirname(abs_fname), include) # catch inclusion cycle inf = info while inf: if incl_abs_fname == os.path.abspath(inf['file']): - raise QAPISemError(info, "Inclusion loop for %s" - % include) + raise QAPIParseError(self, "Inclusion loop for %s" + % include) inf = inf['parent'] # skip multiple include of the same file if incl_abs_fname in previously_included:@@ -168,7 +168,8 @@ class QAPISchemaParser(object): try: fobj = open(incl_abs_fname, 'r') except IOError as e: - raise QAPISemError(info, '%s: %s' % (e.strerror, include)) + raise QAPIParseError(self, '%s: %s' % + (e.strerror, include)) exprs_include = QAPISchemaParser(fobj, previously_included, info) self.exprs.extend(exprs_include.exprs)tests/qapi-schema/include-cycle.err +0
-0
tests/qapi-schema/include-cycle.err line 3
Quoted 4 lines
tests/qapi-schema/include-cycle.err +1
-1@@ -1,3 +1,3 @@ In file included from tests/qapi-schema/include-cycle.json:1: In file included from tests/qapi-schema/include-cycle-b.json:1: -tests/qapi-schema/include-cycle-c.json:1: Inclusion loop for include-cycle.json +tests/qapi-schema/include-cycle-c.json:1:36: Inclusion loop for include-cycle.json
Location :1:36 points to end of include expression.
tests/qapi-schema/include-no-file.err
Quoted 8 lines
tests/qapi-schema/include-format-err.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/include-format-err.json:1: Invalid 'include' directive +tests/qapi-schema/include-format-err.json:2:17: Invalid 'include' directivetests/qapi-schema/include-no-file.err +0
-0
Likewise.
tests/qapi-schema/include-non-file.err line 1
Quoted 13 lines
index
d5b9b22d85..de321ac477100644tests/qapi-schema/include-no-file.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/include-no-file.json:1: No such file or directory: include-no-file-sub.json +tests/qapi-schema/include-no-file.json:1:42: No such file or directory: include-no-file-sub.jsontests/qapi-schema/include-non-file.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/include-non-file.json:1: Value of 'include' must be a string +tests/qapi-schema/include-non-file.json:1:18: Value of 'include' must be a string
Likewise.
tests/qapi-schema/include-self-cycle.err line 1
Quoted 7 lines
tests/qapi-schema/include-self-cycle.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/include-self-cycle.json:1: Inclusion loop for include-self-cycle.json +tests/qapi-schema/include-self-cycle.json:1:41: Inclusion loop for include-self-cycle.json
Likewise.
The reason for this location is that the error isn't actually a parse error.
Parse errors happen when the parser runs into a unexpected token, and then the location stored in the parser points exactly there. Good.
The errors above happen while checking an expression the parser accepted, in other words, they're semantic errors. Because the parser already accepted the expression, the location stored in it points beyond the expression. Using it is not so good.
I proposed to use QAPIParseError here. Sorry for misleading you.
Thankfully, you made it its own patch, which should be easy to drop.
PATCH v6 8/17 qapi: add qapi2texi script
In reply to Marc-André LureauAs the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
It parses the following kind of blocks:
Free-form:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:
# | $ echo foo # | -> do this # | <- get that
#
##
Symbol:
##
# @symbol:
#
# Symbol body ditto ergo sum. Foo bar
# baz ding.
#
# @param1: the frob to frobnicate
# @param2: #optional how hard to frobnicate
#
# Returns: the frobnicated frob.
# If frob isn't frobnicatable, GenericError.
#
# Since: version
# Notes: notes, comments can have
# - itemized list
# - like this
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
##That's roughly following the following EBNF grammar:
api_comment = "##\n" comment "##\n"
comment = freeform_comment | symbol_commentfreeform_comment = { "# " text "\n" | "#\n" }symbol_comment = "# @" name ":\n" { member | meta | freeform_comment }
member = "# @" name ':' [ text ] "\n" freeform_comment
meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:", "Examples:" ) [ text ] "\n" freeform_comment text = free text with annotations
See docs/qapi-code-gen.txt for more details.
The documentation is enriched with information from the actual schema.
Deficiencies:
- the generated QMP documentation includes internal types
- union support is lacking
- doc comment error message positions are imprecise, they point to the beginning of the comment.
--- tests/Makefile.include | 19 ++ scripts/qapi.py | 221 +++++++++++++- scripts/qapi2texi.py | 339 +++++++++++++++++++++ docs/qapi-code-gen.txt | 138 ++++++--- tests/qapi-schema/alternate-any.err | 2 +- tests/qapi-schema/alternate-any.json | 4 + tests/qapi-schema/alternate-array.err | 2 +- tests/qapi-schema/alternate-array.json | 7 + tests/qapi-schema/alternate-base.err | 2 +- tests/qapi-schema/alternate-base.json | 7 + tests/qapi-schema/alternate-clash.err | 2 +- tests/qapi-schema/alternate-clash.json | 4 + tests/qapi-schema/alternate-conflict-dict.err | 2 +- tests/qapi-schema/alternate-conflict-dict.json | 10 + tests/qapi-schema/alternate-conflict-string.err | 2 +- tests/qapi-schema/alternate-conflict-string.json | 7 + tests/qapi-schema/alternate-empty.err | 2 +- tests/qapi-schema/alternate-empty.json | 4 + tests/qapi-schema/alternate-nested.err | 2 +- tests/qapi-schema/alternate-nested.json | 7 + tests/qapi-schema/alternate-unknown.err | 2 +- tests/qapi-schema/alternate-unknown.json | 4 + tests/qapi-schema/args-alternate.err | 2 +- tests/qapi-schema/args-alternate.json | 8 + tests/qapi-schema/args-any.err | 2 +- tests/qapi-schema/args-any.json | 4 + tests/qapi-schema/args-array-empty.err | 2 +- tests/qapi-schema/args-array-empty.json | 4 + tests/qapi-schema/args-array-unknown.err | 2 +- tests/qapi-schema/args-array-unknown.json | 4 + tests/qapi-schema/args-bad-boxed.err | 2 +- tests/qapi-schema/args-bad-boxed.json | 4 + tests/qapi-schema/args-boxed-anon.err | 2 +- tests/qapi-schema/args-boxed-anon.json | 4 + tests/qapi-schema/args-boxed-empty.err | 2 +- tests/qapi-schema/args-boxed-empty.json | 8 + tests/qapi-schema/args-boxed-string.err | 2 +- tests/qapi-schema/args-boxed-string.json | 4 + tests/qapi-schema/args-int.err | 2 +- tests/qapi-schema/args-int.json | 4 + tests/qapi-schema/args-invalid.err | 2 +- tests/qapi-schema/args-invalid.json | 3 + tests/qapi-schema/args-member-array-bad.err | 2 +- tests/qapi-schema/args-member-array-bad.json | 4 + tests/qapi-schema/args-member-case.err | 2 +- tests/qapi-schema/args-member-case.json | 4 + tests/qapi-schema/args-member-unknown.err | 2 +- tests/qapi-schema/args-member-unknown.json | 4 + tests/qapi-schema/args-name-clash.err | 2 +- tests/qapi-schema/args-name-clash.json | 4 + tests/qapi-schema/args-union.err | 2 +- tests/qapi-schema/args-union.json | 7 + tests/qapi-schema/args-unknown.err | 2 +- tests/qapi-schema/args-unknown.json | 4 + tests/qapi-schema/bad-base.err | 2 +- tests/qapi-schema/bad-base.json | 7 + tests/qapi-schema/bad-data.err | 2 +- tests/qapi-schema/bad-data.json | 4 + tests/qapi-schema/bad-ident.err | 2 +- tests/qapi-schema/bad-ident.json | 4 + tests/qapi-schema/bad-type-bool.err | 2 +- tests/qapi-schema/bad-type-bool.json | 4 + tests/qapi-schema/bad-type-dict.err | 2 +- tests/qapi-schema/bad-type-dict.json | 4 + tests/qapi-schema/base-cycle-direct.err | 2 +- tests/qapi-schema/base-cycle-direct.json | 4 + tests/qapi-schema/base-cycle-indirect.err | 2 +- tests/qapi-schema/base-cycle-indirect.json | 7 + tests/qapi-schema/command-int.err | 2 +- tests/qapi-schema/command-int.json | 4 + tests/qapi-schema/comments.json | 4 + tests/qapi-schema/comments.out | 3 + tests/qapi-schema/doc-bad-args.err | 1 + tests/qapi-schema/doc-bad-args.exit | 1 + tests/qapi-schema/doc-bad-args.json | 8 + tests/qapi-schema/doc-bad-args.out | 0 tests/qapi-schema/doc-bad-section.err | 1 + tests/qapi-schema/doc-bad-section.exit | 1 + tests/qapi-schema/doc-bad-section.json | 19 ++ tests/qapi-schema/doc-bad-section.out | 0 tests/qapi-schema/doc-bad-symbol.err | 1 + tests/qapi-schema/doc-bad-symbol.exit | 1 + tests/qapi-schema/doc-bad-symbol.json | 6 + tests/qapi-schema/doc-bad-symbol.out | 0 tests/qapi-schema/doc-duplicated-arg.err | 1 + tests/qapi-schema/doc-duplicated-arg.exit | 1 + tests/qapi-schema/doc-duplicated-arg.json | 7 + tests/qapi-schema/doc-duplicated-arg.out | 0 tests/qapi-schema/doc-duplicated-return.err | 1 + tests/qapi-schema/doc-duplicated-return.exit | 1 + tests/qapi-schema/doc-duplicated-return.json | 8 + tests/qapi-schema/doc-duplicated-return.out | 0 tests/qapi-schema/doc-duplicated-since.err | 1 + tests/qapi-schema/doc-duplicated-since.exit | 1 + tests/qapi-schema/doc-duplicated-since.json | 8 + tests/qapi-schema/doc-duplicated-since.out | 0 tests/qapi-schema/doc-empty-arg.err | 1 + tests/qapi-schema/doc-empty-arg.exit | 1 + tests/qapi-schema/doc-empty-arg.json | 6 + tests/qapi-schema/doc-empty-arg.out | 0 tests/qapi-schema/doc-empty-section.err | 1 + tests/qapi-schema/doc-empty-section.exit | 1 + tests/qapi-schema/doc-empty-section.json | 8 + tests/qapi-schema/doc-empty-section.out | 0 tests/qapi-schema/doc-empty-symbol.err | 1 + tests/qapi-schema/doc-empty-symbol.exit | 1 + tests/qapi-schema/doc-empty-symbol.json | 5 + tests/qapi-schema/doc-empty-symbol.out | 0 tests/qapi-schema/doc-invalid-end.err | 1 + tests/qapi-schema/doc-invalid-end.exit | 1 + tests/qapi-schema/doc-invalid-end.json | 5 + tests/qapi-schema/doc-invalid-end.out | 0 tests/qapi-schema/doc-invalid-end2.err | 1 + tests/qapi-schema/doc-invalid-end2.exit | 1 + tests/qapi-schema/doc-invalid-end2.json | 5 + tests/qapi-schema/doc-invalid-end2.out | 0 tests/qapi-schema/doc-invalid-return.err | 1 + tests/qapi-schema/doc-invalid-return.exit | 1 + tests/qapi-schema/doc-invalid-return.json | 7 + tests/qapi-schema/doc-invalid-return.out | 0 tests/qapi-schema/doc-invalid-section.err | 1 + tests/qapi-schema/doc-invalid-section.exit | 1 + tests/qapi-schema/doc-invalid-section.json | 6 + tests/qapi-schema/doc-invalid-section.out | 0 tests/qapi-schema/doc-invalid-start.err | 1 + tests/qapi-schema/doc-invalid-start.exit | 1 + tests/qapi-schema/doc-invalid-start.json | 5 + tests/qapi-schema/doc-invalid-start.out | 0 tests/qapi-schema/doc-missing-colon.err | 1 + tests/qapi-schema/doc-missing-colon.exit | 1 + tests/qapi-schema/doc-missing-colon.json | 5 + tests/qapi-schema/doc-missing-colon.out | 0 tests/qapi-schema/doc-missing-expr.err | 1 + tests/qapi-schema/doc-missing-expr.exit | 1 + tests/qapi-schema/doc-missing-expr.json | 5 + tests/qapi-schema/doc-missing-expr.out | 0 tests/qapi-schema/doc-missing-space.err | 1 + tests/qapi-schema/doc-missing-space.exit | 1 + tests/qapi-schema/doc-missing-space.json | 6 + tests/qapi-schema/doc-missing-space.out | 0 tests/qapi-schema/double-type.err | 2 +- tests/qapi-schema/double-type.json | 4 + tests/qapi-schema/enum-bad-name.err | 2 +- tests/qapi-schema/enum-bad-name.json | 4 + tests/qapi-schema/enum-bad-prefix.err | 2 +- tests/qapi-schema/enum-bad-prefix.json | 4 + tests/qapi-schema/enum-clash-member.err | 2 +- tests/qapi-schema/enum-clash-member.json | 4 + tests/qapi-schema/enum-dict-member.err | 2 +- tests/qapi-schema/enum-dict-member.json | 4 + tests/qapi-schema/enum-member-case.err | 2 +- tests/qapi-schema/enum-member-case.json | 7 + tests/qapi-schema/enum-missing-data.err | 2 +- tests/qapi-schema/enum-missing-data.json | 4 + tests/qapi-schema/enum-wrong-data.err | 2 +- tests/qapi-schema/enum-wrong-data.json | 4 + tests/qapi-schema/event-boxed-empty.err | 2 +- tests/qapi-schema/event-boxed-empty.json | 4 + tests/qapi-schema/event-case.json | 4 + tests/qapi-schema/event-case.out | 3 + tests/qapi-schema/event-nest-struct.err | 2 +- tests/qapi-schema/event-nest-struct.json | 4 + tests/qapi-schema/flat-union-array-branch.err | 2 +- tests/qapi-schema/flat-union-array-branch.json | 12 + tests/qapi-schema/flat-union-bad-base.err | 2 +- tests/qapi-schema/flat-union-bad-base.json | 13 + tests/qapi-schema/flat-union-bad-discriminator.err | 2 +- .../qapi-schema/flat-union-bad-discriminator.json | 16 + tests/qapi-schema/flat-union-base-any.err | 2 +- tests/qapi-schema/flat-union-base-any.json | 13 + tests/qapi-schema/flat-union-base-union.err | 2 +- tests/qapi-schema/flat-union-base-union.json | 16 + tests/qapi-schema/flat-union-clash-member.err | 2 +- tests/qapi-schema/flat-union-clash-member.json | 16 + tests/qapi-schema/flat-union-empty.err | 2 +- tests/qapi-schema/flat-union-empty.json | 10 + tests/qapi-schema/flat-union-incomplete-branch.err | 2 +- .../qapi-schema/flat-union-incomplete-branch.json | 10 + tests/qapi-schema/flat-union-inline.err | 2 +- tests/qapi-schema/flat-union-inline.json | 10 + tests/qapi-schema/flat-union-int-branch.err | 2 +- tests/qapi-schema/flat-union-int-branch.json | 13 + .../qapi-schema/flat-union-invalid-branch-key.err | 2 +- .../qapi-schema/flat-union-invalid-branch-key.json | 15 + .../flat-union-invalid-discriminator.err | 2 +- .../flat-union-invalid-discriminator.json | 15 + tests/qapi-schema/flat-union-no-base.err | 2 +- tests/qapi-schema/flat-union-no-base.json | 13 + .../flat-union-optional-discriminator.err | 2 +- .../flat-union-optional-discriminator.json | 13 + .../flat-union-string-discriminator.err | 2 +- .../flat-union-string-discriminator.json | 15 + tests/qapi-schema/ident-with-escape.json | 4 + tests/qapi-schema/ident-with-escape.out | 3 + tests/qapi-schema/include-relpath-sub.json | 3 + tests/qapi-schema/include-relpath.out | 3 + tests/qapi-schema/include-repetition.out | 3 + tests/qapi-schema/include-simple-sub.json | 3 + tests/qapi-schema/include-simple.out | 3 + tests/qapi-schema/indented-expr.json | 6 + tests/qapi-schema/indented-expr.out | 6 + tests/qapi-schema/missing-type.err | 2 +- tests/qapi-schema/missing-type.json | 4 + tests/qapi-schema/nested-struct-data.err | 2 +- tests/qapi-schema/nested-struct-data.json | 4 + tests/qapi-schema/qapi-schema-test.json | 213 +++++++++++++ tests/qapi-schema/qapi-schema-test.out | 212 +++++++++++++ tests/qapi-schema/redefined-builtin.err | 2 +- tests/qapi-schema/redefined-builtin.json | 4 + tests/qapi-schema/redefined-command.err | 2 +- tests/qapi-schema/redefined-command.json | 7 + tests/qapi-schema/redefined-event.err | 2 +- tests/qapi-schema/redefined-event.json | 7 + tests/qapi-schema/redefined-type.err | 2 +- tests/qapi-schema/redefined-type.json | 7 + tests/qapi-schema/reserved-command-q.err | 2 +- tests/qapi-schema/reserved-command-q.json | 7 + tests/qapi-schema/reserved-enum-q.err | 2 +- tests/qapi-schema/reserved-enum-q.json | 4 + tests/qapi-schema/reserved-member-has.err | 2 +- tests/qapi-schema/reserved-member-has.json | 4 + tests/qapi-schema/reserved-member-q.err | 2 +- tests/qapi-schema/reserved-member-q.json | 4 + tests/qapi-schema/reserved-member-u.err | 2 +- tests/qapi-schema/reserved-member-u.json | 4 + tests/qapi-schema/reserved-member-underscore.err | 2 +- tests/qapi-schema/reserved-member-underscore.json | 4 + tests/qapi-schema/reserved-type-kind.err | 2 +- tests/qapi-schema/reserved-type-kind.json | 4 + tests/qapi-schema/reserved-type-list.err | 2 +- tests/qapi-schema/reserved-type-list.json | 4 + tests/qapi-schema/returns-alternate.err | 2 +- tests/qapi-schema/returns-alternate.json | 7 + tests/qapi-schema/returns-array-bad.err | 2 +- tests/qapi-schema/returns-array-bad.json | 4 + tests/qapi-schema/returns-dict.err | 2 +- tests/qapi-schema/returns-dict.json | 4 + tests/qapi-schema/returns-unknown.err | 2 +- tests/qapi-schema/returns-unknown.json | 4 + tests/qapi-schema/returns-whitelist.err | 2 +- tests/qapi-schema/returns-whitelist.json | 16 + tests/qapi-schema/struct-base-clash-deep.err | 2 +- tests/qapi-schema/struct-base-clash-deep.json | 10 + tests/qapi-schema/struct-base-clash.err | 2 +- tests/qapi-schema/struct-base-clash.json | 7 + tests/qapi-schema/struct-data-invalid.err | 2 +- tests/qapi-schema/struct-data-invalid.json | 3 + tests/qapi-schema/struct-member-invalid.err | 2 +- tests/qapi-schema/struct-member-invalid.json | 3 + tests/qapi-schema/test-qapi.py | 12 + tests/qapi-schema/type-bypass-bad-gen.err | 2 +- tests/qapi-schema/type-bypass-bad-gen.json | 4 + tests/qapi-schema/unicode-str.err | 2 +- tests/qapi-schema/unicode-str.json | 4 + tests/qapi-schema/union-base-no-discriminator.err | 2 +- tests/qapi-schema/union-base-no-discriminator.json | 12 + tests/qapi-schema/union-branch-case.err | 2 +- tests/qapi-schema/union-branch-case.json | 4 + tests/qapi-schema/union-clash-branches.err | 2 +- tests/qapi-schema/union-clash-branches.json | 4 + tests/qapi-schema/union-empty.err | 2 +- tests/qapi-schema/union-empty.json | 4 + tests/qapi-schema/union-invalid-base.err | 2 +- tests/qapi-schema/union-invalid-base.json | 10 + tests/qapi-schema/union-optional-branch.err | 2 +- tests/qapi-schema/union-optional-branch.json | 4 + tests/qapi-schema/union-unknown.err | 2 +- tests/qapi-schema/union-unknown.json | 4 + tests/qapi-schema/unknown-escape.err | 2 +- tests/qapi-schema/unknown-escape.json | 4 + tests/qapi-schema/unknown-expr-key.err | 2 +- tests/qapi-schema/unknown-expr-key.json | 4 + 272 files changed, 2004 insertions(+), 128 deletions(-) create mode 100755 scripts/qapi2texi.py create mode 100644 tests/qapi-schema/doc-bad-args.err create mode 100644 tests/qapi-schema/doc-bad-args.exit create mode 100644 tests/qapi-schema/doc-bad-args.json create mode 100644 tests/qapi-schema/doc-bad-args.out create mode 100644 tests/qapi-schema/doc-bad-section.err create mode 100644 tests/qapi-schema/doc-bad-section.exit create mode 100644 tests/qapi-schema/doc-bad-section.json create mode 100644 tests/qapi-schema/doc-bad-section.out create mode 100644 tests/qapi-schema/doc-bad-symbol.err create mode 100644 tests/qapi-schema/doc-bad-symbol.exit create mode 100644 tests/qapi-schema/doc-bad-symbol.json create mode 100644 tests/qapi-schema/doc-bad-symbol.out create mode 100644 tests/qapi-schema/doc-duplicated-arg.err create mode 100644 tests/qapi-schema/doc-duplicated-arg.exit create mode 100644 tests/qapi-schema/doc-duplicated-arg.json create mode 100644 tests/qapi-schema/doc-duplicated-arg.out create mode 100644 tests/qapi-schema/doc-duplicated-return.err create mode 100644 tests/qapi-schema/doc-duplicated-return.exit create mode 100644 tests/qapi-schema/doc-duplicated-return.json create mode 100644 tests/qapi-schema/doc-duplicated-return.out create mode 100644 tests/qapi-schema/doc-duplicated-since.err create mode 100644 tests/qapi-schema/doc-duplicated-since.exit create mode 100644 tests/qapi-schema/doc-duplicated-since.json create mode 100644 tests/qapi-schema/doc-duplicated-since.out create mode 100644 tests/qapi-schema/doc-empty-arg.err create mode 100644 tests/qapi-schema/doc-empty-arg.exit create mode 100644 tests/qapi-schema/doc-empty-arg.json create mode 100644 tests/qapi-schema/doc-empty-arg.out create mode 100644 tests/qapi-schema/doc-empty-section.err create mode 100644 tests/qapi-schema/doc-empty-section.exit create mode 100644 tests/qapi-schema/doc-empty-section.json create mode 100644 tests/qapi-schema/doc-empty-section.out create mode 100644 tests/qapi-schema/doc-empty-symbol.err create mode 100644 tests/qapi-schema/doc-empty-symbol.exit create mode 100644 tests/qapi-schema/doc-empty-symbol.json create mode 100644 tests/qapi-schema/doc-empty-symbol.out create mode 100644 tests/qapi-schema/doc-invalid-end.err create mode 100644 tests/qapi-schema/doc-invalid-end.exit create mode 100644 tests/qapi-schema/doc-invalid-end.json create mode 100644 tests/qapi-schema/doc-invalid-end.out create mode 100644 tests/qapi-schema/doc-invalid-end2.err create mode 100644 tests/qapi-schema/doc-invalid-end2.exit create mode 100644 tests/qapi-schema/doc-invalid-end2.json create mode 100644 tests/qapi-schema/doc-invalid-end2.out create mode 100644 tests/qapi-schema/doc-invalid-return.err create mode 100644 tests/qapi-schema/doc-invalid-return.exit create mode 100644 tests/qapi-schema/doc-invalid-return.json create mode 100644 tests/qapi-schema/doc-invalid-return.out create mode 100644 tests/qapi-schema/doc-invalid-section.err create mode 100644 tests/qapi-schema/doc-invalid-section.exit create mode 100644 tests/qapi-schema/doc-invalid-section.json create mode 100644 tests/qapi-schema/doc-invalid-section.out create mode 100644 tests/qapi-schema/doc-invalid-start.err create mode 100644 tests/qapi-schema/doc-invalid-start.exit create mode 100644 tests/qapi-schema/doc-invalid-start.json create mode 100644 tests/qapi-schema/doc-invalid-start.out create mode 100644 tests/qapi-schema/doc-missing-colon.err create mode 100644 tests/qapi-schema/doc-missing-colon.exit create mode 100644 tests/qapi-schema/doc-missing-colon.json create mode 100644 tests/qapi-schema/doc-missing-colon.out create mode 100644 tests/qapi-schema/doc-missing-expr.err create mode 100644 tests/qapi-schema/doc-missing-expr.exit create mode 100644 tests/qapi-schema/doc-missing-expr.json create mode 100644 tests/qapi-schema/doc-missing-expr.out create mode 100644 tests/qapi-schema/doc-missing-space.err create mode 100644 tests/qapi-schema/doc-missing-space.exit create mode 100644 tests/qapi-schema/doc-missing-space.json create mode 100644 tests/qapi-schema/doc-missing-space.out
tests/Makefile.include +19 -0
@@ -350,6 +350,23 @@ qapi-schema += base-cycle-direct.json qapi-schema += base-cycle-indirect.json qapi-schema += command-int.json qapi-schema += comments.json +qapi-schema += doc-bad-args.json +qapi-schema += doc-bad-section.json +qapi-schema += doc-bad-symbol.json +qapi-schema += doc-duplicated-arg.json +qapi-schema += doc-duplicated-return.json +qapi-schema += doc-duplicated-since.json +qapi-schema += doc-empty-arg.json +qapi-schema += doc-empty-section.json +qapi-schema += doc-empty-symbol.json +qapi-schema += doc-invalid-end.json +qapi-schema += doc-invalid-end2.json +qapi-schema += doc-invalid-return.json +qapi-schema += doc-invalid-section.json +qapi-schema += doc-invalid-start.json +qapi-schema += doc-missing-colon.json +qapi-schema += doc-missing-expr.json +qapi-schema += doc-missing-space.json qapi-schema += double-data.json qapi-schema += double-type.json qapi-schema += duplicate-key.json
@@ -443,6 +460,8 @@ qapi-schema += union-optional-branch.json qapi-schema += union-unknown.json qapi-schema += unknown-escape.json qapi-schema += unknown-expr-key.json + + check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \
scripts/qapi.py +219 -2
286 lines not on this page · raw message
scripts/qapi2texi.py new file +339 -0
339 lines not on this page · raw message
docs/qapi-code-gen.txt +104 -34
151 lines not on this page · raw message
tests/qapi-schema/alternate-any.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-any.json:2: Alternate 'Alt' member 'one' cannot use type 'any' +tests/qapi-schema/alternate-any.json:6: Alternate 'Alt' member 'one' cannot use type 'any'
tests/qapi-schema/alternate-any.json +4 -0
@@ -1,4 +1,8 @@ # we do not allow the 'any' type as an alternate branch + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'one': 'any', 'two': 'int' } }
tests/qapi-schema/alternate-array.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-array.json:5: Member 'two' of alternate 'Alt' cannot be an array +tests/qapi-schema/alternate-array.json:12: Member 'two' of alternate 'Alt' cannot be an array
tests/qapi-schema/alternate-array.json +7 -0
@@ -1,7 +1,14 @@ # we do not allow array branches in alternates + +## +# @One: +## # TODO: should we support this? { 'struct': 'One', 'data': { 'name': 'str' } } +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'one': 'One', 'two': [ 'int' ] } }
tests/qapi-schema/alternate-base.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-base.json:4: Unknown key 'base' in alternate 'Alt' +tests/qapi-schema/alternate-base.json:11: Unknown key 'base' in alternate 'Alt'
tests/qapi-schema/alternate-base.json +7 -0
@@ -1,6 +1,13 @@ # we reject alternate with base type + +## +# @Base: +## { 'struct': 'Base', 'data': { 'string': 'str' } } +## +# @Alt: +## { 'alternate': 'Alt', 'base': 'Base', 'data': { 'number': 'int' } }
tests/qapi-schema/alternate-clash.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-clash.json:7: 'a_b' (branch of Alt1) collides with 'a-b' (branch of Alt1) +tests/qapi-schema/alternate-clash.json:11: 'a_b' (branch of Alt1) collides with 'a-b' (branch of Alt1)
tests/qapi-schema/alternate-clash.json +4 -0
@@ -4,5 +4,9 @@ # TODO: In the future, if alternates are simplified to not generate # the implicit Alt1Kind enum, we would still have a collision with the # resulting C union trying to have two members named 'a_b'. + +## +# @Alt1: +## { 'alternate': 'Alt1', 'data': { 'a-b': 'str', 'a_b': 'int' } }
tests/qapi-schema/alternate-conflict-dict.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-conflict-dict.json:6: Alternate 'Alt' member 'two' can't be distinguished from member 'one' +tests/qapi-schema/alternate-conflict-dict.json:16: Alternate 'Alt' member 'two' can't be distinguished from member 'one'
tests/qapi-schema/alternate-conflict-dict.json +10 -0
@@ -1,8 +1,18 @@ # we reject alternates with multiple object branches + +## +# @One: +## { 'struct': 'One', 'data': { 'name': 'str' } } +## +# @Two: +## { 'struct': 'Two', 'data': { 'value': 'int' } } +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'one': 'One', 'two': 'Two' } }
tests/qapi-schema/alternate-conflict-string.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-conflict-string.json:4: Alternate 'Alt' member 'two' can't be distinguished from member 'one' +tests/qapi-schema/alternate-conflict-string.json:11: Alternate 'Alt' member 'two' can't be distinguished from member 'one'
tests/qapi-schema/alternate-conflict-string.json +7 -0
@@ -1,6 +1,13 @@ # we reject alternates with multiple string-like branches + +## +# @Enum: +## { 'enum': 'Enum', 'data': [ 'hello', 'world' ] } +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'one': 'str', 'two': 'Enum' } }
tests/qapi-schema/alternate-empty.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-empty.json:2: Alternate 'Alt' should have at least two branches in 'data' +tests/qapi-schema/alternate-empty.json:6: Alternate 'Alt' should have at least two branches in 'data'
tests/qapi-schema/alternate-empty.json +4 -0
@@ -1,2 +1,6 @@ # alternates must list at least two types to be useful + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'i': 'int' } }
tests/qapi-schema/alternate-nested.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-nested.json:4: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1' +tests/qapi-schema/alternate-nested.json:11: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1'
tests/qapi-schema/alternate-nested.json +7 -0
@@ -1,5 +1,12 @@ # we reject a nested alternate branch + +## +# @Alt1: +## { 'alternate': 'Alt1', 'data': { 'name': 'str', 'value': 'int' } } +## +# @Alt2: +## { 'alternate': 'Alt2', 'data': { 'nested': 'Alt1', 'b': 'bool' } }
tests/qapi-schema/alternate-unknown.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/alternate-unknown.json:2: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType' +tests/qapi-schema/alternate-unknown.json:6: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType'
tests/qapi-schema/alternate-unknown.json +4 -0
@@ -1,3 +1,7 @@ # we reject an alternate with unknown type in branch + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'unknown': 'MissingType', 'i': 'int' } }
tests/qapi-schema/args-alternate.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-alternate.json:3: 'data' for command 'oops' cannot use alternate type 'Alt' +tests/qapi-schema/args-alternate.json:11: 'data' for command 'oops' cannot use alternate type 'Alt'
tests/qapi-schema/args-alternate.json +8 -0
@@ -1,3 +1,11 @@ # we do not allow alternate arguments + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'str' } } + +## +# @oops: +## { 'command': 'oops', 'data': 'Alt' }
tests/qapi-schema/args-any.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-any.json:2: 'data' for command 'oops' cannot use built-in type 'any' +tests/qapi-schema/args-any.json:6: 'data' for command 'oops' cannot use built-in type 'any'
tests/qapi-schema/args-any.json +4 -0
@@ -1,2 +1,6 @@ # we do not allow an 'any' argument + +## +# @oops: +## { 'command': 'oops', 'data': 'any' }
tests/qapi-schema/args-array-empty.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-array-empty.json:2: Member 'empty' of 'data' for command 'oops': array type must contain single type name +tests/qapi-schema/args-array-empty.json:6: Member 'empty' of 'data' for command 'oops': array type must contain single type name
tests/qapi-schema/args-array-empty.json +4 -0
@@ -1,2 +1,6 @@ # we reject an array for data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': { 'empty': [ ] } }
tests/qapi-schema/args-array-unknown.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-array-unknown.json:2: Member 'array' of 'data' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-array-unknown.json:6: Member 'array' of 'data' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/args-array-unknown.json +4 -0
@@ -1,2 +1,6 @@ # we reject an array for data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': { 'array': [ 'NoSuchType' ] } }
tests/qapi-schema/args-bad-boxed.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-bad-boxed.json:2: 'boxed' of command 'foo' should only use true value +tests/qapi-schema/args-bad-boxed.json:6: 'boxed' of command 'foo' should only use true value
tests/qapi-schema/args-bad-boxed.json +4 -0
@@ -1,2 +1,6 @@ # 'boxed' should only appear with value true + +## +# @foo: +## { 'command': 'foo', 'boxed': false }
tests/qapi-schema/args-boxed-anon.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-boxed-anon.json:2: 'data' for command 'foo' should be a type name +tests/qapi-schema/args-boxed-anon.json:6: 'data' for command 'foo' should be a type name
tests/qapi-schema/args-boxed-anon.json +4 -0
@@ -1,2 +1,6 @@ # 'boxed' can only be used with named types + +## +# @foo: +## { 'command': 'foo', 'boxed': true, 'data': { 'string': 'str' } }
tests/qapi-schema/args-boxed-empty.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-boxed-empty.json:3: Cannot use 'boxed' with empty type +tests/qapi-schema/args-boxed-empty.json:11: Cannot use 'boxed' with empty type
tests/qapi-schema/args-boxed-empty.json +8 -0
@@ -1,3 +1,11 @@ # 'boxed' requires a non-empty type + +## +# @Empty: +## { 'struct': 'Empty', 'data': {} } + +## +# @foo: +## { 'command': 'foo', 'boxed': true, 'data': 'Empty' }
tests/qapi-schema/args-boxed-string.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-boxed-string.json:2: 'data' for command 'foo' cannot use built-in type 'str' +tests/qapi-schema/args-boxed-string.json:6: 'data' for command 'foo' cannot use built-in type 'str'
tests/qapi-schema/args-boxed-string.json +4 -0
@@ -1,2 +1,6 @@ # 'boxed' requires a complex (not built-in) type + +## +# @foo: +## { 'command': 'foo', 'boxed': true, 'data': 'str' }
tests/qapi-schema/args-int.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-int.json:2: 'data' for command 'oops' cannot use built-in type 'int' +tests/qapi-schema/args-int.json:6: 'data' for command 'oops' cannot use built-in type 'int'
tests/qapi-schema/args-int.json +4 -0
@@ -1,2 +1,6 @@ # we reject commands where data is not an array or complex type + +## +# @oops: +## { 'command': 'oops', 'data': 'int' }
tests/qapi-schema/args-invalid.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-invalid.json:1: 'data' for command 'foo' should be a dictionary or type name +tests/qapi-schema/args-invalid.json:4: 'data' for command 'foo' should be a dictionary or type name
tests/qapi-schema/args-invalid.json +3 -0
@@ -1,2 +1,5 @@ +## +# @foo: +## { 'command': 'foo', 'data': false }
tests/qapi-schema/args-member-array-bad.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-member-array-bad.json:2: Member 'member' of 'data' for command 'oops': array type must contain single type name +tests/qapi-schema/args-member-array-bad.json:6: Member 'member' of 'data' for command 'oops': array type must contain single type name
tests/qapi-schema/args-member-array-bad.json +4 -0
@@ -1,2 +1,6 @@ # we reject data if it does not contain a valid array type + +## +# @oops: +## { 'command': 'oops', 'data': { 'member': [ { 'nested': 'str' } ] } }
tests/qapi-schema/args-member-case.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-member-case.json:2: 'Arg' (parameter of no-way-this-will-get-whitelisted) should not use uppercase +tests/qapi-schema/args-member-case.json:6: 'Arg' (parameter of no-way-this-will-get-whitelisted) should not use uppercase
tests/qapi-schema/args-member-case.json +4 -0
@@ -1,2 +1,6 @@ # Member names should be 'lower-case' unless the struct/command is whitelisted + +## +# @no-way-this-will-get-whitelisted: +## { 'command': 'no-way-this-will-get-whitelisted', 'data': { 'Arg': 'int' } }
tests/qapi-schema/args-member-unknown.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-member-unknown.json:2: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-member-unknown.json:6: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/args-member-unknown.json +4 -0
@@ -1,2 +1,6 @@ # we reject data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': { 'member': 'NoSuchType' } }
tests/qapi-schema/args-name-clash.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-name-clash.json:4: 'a_b' (parameter of oops) collides with 'a-b' (parameter of oops) +tests/qapi-schema/args-name-clash.json:8: 'a_b' (parameter of oops) collides with 'a-b' (parameter of oops)
tests/qapi-schema/args-name-clash.json +4 -0
@@ -1,4 +1,8 @@ # C member name collision # Reject members that clash when mapped to C names (we would have two 'a_b' # members). + +## +# @oops: +## { 'command': 'oops', 'data': { 'a-b': 'str', 'a_b': 'str' } }
tests/qapi-schema/args-union.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-union.json:3: 'data' for command 'oops' cannot use union type 'Uni' +tests/qapi-schema/args-union.json:10: 'data' for command 'oops' cannot use union type 'Uni'
tests/qapi-schema/args-union.json +7 -0
@@ -1,3 +1,10 @@ # use of union arguments requires 'boxed':true + +## +# @Uni: +## { 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } } +## +# oops: +## { 'command': 'oops', 'data': 'Uni' }
tests/qapi-schema/args-unknown.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/args-unknown.json:2: 'data' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-unknown.json:6: 'data' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/args-unknown.json +4 -0
@@ -1,2 +1,6 @@ # we reject data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': 'NoSuchType' }
tests/qapi-schema/bad-base.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/bad-base.json:3: 'base' for struct 'MyType' cannot use union type 'Union' +tests/qapi-schema/bad-base.json:10: 'base' for struct 'MyType' cannot use union type 'Union'
tests/qapi-schema/bad-base.json +7 -0
@@ -1,3 +1,10 @@ # we reject a base that is not a struct + +## +# @Union: +## { 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } } +## +# @MyType: +## { 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
tests/qapi-schema/bad-data.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/bad-data.json:2: 'data' for command 'oops' cannot be an array +tests/qapi-schema/bad-data.json:6: 'data' for command 'oops' cannot be an array
tests/qapi-schema/bad-data.json +4 -0
@@ -1,2 +1,6 @@ # we ensure 'data' is a dictionary for all but enums + +## +# @oops: +## { 'command': 'oops', 'data': [ ] }
tests/qapi-schema/bad-ident.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/bad-ident.json:2: 'struct' does not allow optional name '*oops' +tests/qapi-schema/bad-ident.json:6: 'struct' does not allow optional name '*oops'
tests/qapi-schema/bad-ident.json +4 -0
@@ -1,2 +1,6 @@ # we reject creating a type name with bad name + +## +# @*oops: +## { 'struct': '*oops', 'data': { 'i': 'int' } }
tests/qapi-schema/bad-type-bool.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/bad-type-bool.json:2: 'struct' key must have a string value +tests/qapi-schema/bad-type-bool.json:6: 'struct' key must have a string value
tests/qapi-schema/bad-type-bool.json +4 -0
@@ -1,2 +1,6 @@ # we reject an expression with a metatype that is not a string + +## +# @true: +## { 'struct': true, 'data': { } }
tests/qapi-schema/bad-type-dict.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/bad-type-dict.json:2: 'command' key must have a string value +tests/qapi-schema/bad-type-dict.json:6: 'command' key must have a string value
tests/qapi-schema/bad-type-dict.json +4 -0
@@ -1,2 +1,6 @@ # we reject an expression with a metatype that is not a string + +## +# @foo: +## { 'command': { } }
tests/qapi-schema/base-cycle-direct.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/base-cycle-direct.json:2: Object Loopy contains itself +tests/qapi-schema/base-cycle-direct.json:6: Object Loopy contains itself
tests/qapi-schema/base-cycle-direct.json +4 -0
@@ -1,2 +1,6 @@ # we reject a loop in base classes + +## +# @Loopy: +## { 'struct': 'Loopy', 'base': 'Loopy', 'data': {} }
tests/qapi-schema/base-cycle-indirect.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/base-cycle-indirect.json:2: Object Base1 contains itself +tests/qapi-schema/base-cycle-indirect.json:6: Object Base1 contains itself
tests/qapi-schema/base-cycle-indirect.json +7 -0
@@ -1,3 +1,10 @@ # we reject a loop in base classes + +## +# @Base1: +## { 'struct': 'Base1', 'base': 'Base2', 'data': {} } +## +# @Base2: +## { 'struct': 'Base2', 'base': 'Base1', 'data': {} }
tests/qapi-schema/command-int.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/command-int.json:2: built-in 'int' is already defined +tests/qapi-schema/command-int.json:6: built-in 'int' is already defined
tests/qapi-schema/command-int.json +4 -0
@@ -1,2 +1,6 @@ # we reject collisions between commands and types + +## +# @int: +## { 'command': 'int', 'data': { 'character': 'str' } }
tests/qapi-schema/comments.json +4 -0
@@ -1,4 +1,8 @@ # Unindented comment + +## +# @Status: +## { 'enum': 'Status', # Comment to the right of code # Indented comment 'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/comments.out +3 -0
@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +
tests/qapi-schema/doc-bad-args.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-args.json:3: Members documentation is not a subset of API ['a', 'b'] > ['a']
tests/qapi-schema/doc-bad-args.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-bad-args.json new file +8 -0
@@ -0,0 +1,8 @@ +# Arguments listed in the doc comment must exist in the actual schema + +## +# @foo: +# @a: a +# @b: b +## +{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-bad-args.out new file +0 -0
tests/qapi-schema/doc-bad-section.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-section.json:13:1: Invalid section indentation
tests/qapi-schema/doc-bad-section.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-bad-section.json new file +19 -0
@@ -0,0 +1,19 @@ +# Comment body must be only at the top of the section + +## +# @TestStruct: +# +# body with @var +# +# @integer: foo +# blah +# +# bao +# +# Let's catch this bad comment. +# +# Since: 2.3 +# +## +{ 'struct': 'TestStruct', + 'data': { 'integer': 'int' } }
tests/qapi-schema/doc-bad-section.out new file +0 -0
tests/qapi-schema/doc-bad-symbol.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-symbol.json:3: Definition of 'foo' follows documentation for 'food'
tests/qapi-schema/doc-bad-symbol.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-bad-symbol.json new file +6 -0
@@ -0,0 +1,6 @@ +# Documentation symbol mismatch with expression + +## +# @food: +## +{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-bad-symbol.out new file +0 -0
tests/qapi-schema/doc-duplicated-arg.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-arg.json:6:1: 'a' parameter name duplicated
tests/qapi-schema/doc-duplicated-arg.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-duplicated-arg.json new file +7 -0
@@ -0,0 +1,7 @@ +# Do not allow duplicated argument + +## +# @foo: +# @a: +# @a: +##
tests/qapi-schema/doc-duplicated-arg.out new file +0 -0
tests/qapi-schema/doc-duplicated-return.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-return.json:7:1: Duplicated 'Returns' section
tests/qapi-schema/doc-duplicated-return.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-duplicated-return.json new file +8 -0
@@ -0,0 +1,8 @@ +# Do not allow duplicated Returns section + +## +# @foo: +# +# Returns: 0 +# Returns: 1 +##
tests/qapi-schema/doc-duplicated-return.out new file +0 -0
tests/qapi-schema/doc-duplicated-since.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-since.json:7:1: Duplicated 'Since' section
tests/qapi-schema/doc-duplicated-since.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-duplicated-since.json new file +8 -0
@@ -0,0 +1,8 @@ +# Do not allow duplicated Since section + +## +# @foo: +# +# Since: 0 +# Since: 1 +##
tests/qapi-schema/doc-duplicated-since.out new file +0 -0
tests/qapi-schema/doc-empty-arg.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-arg.json:5:1: Invalid parameter name
tests/qapi-schema/doc-empty-arg.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-empty-arg.json new file +6 -0
@@ -0,0 +1,6 @@ +# An invalid empty argument name + +## +# @foo: +# @: +##
tests/qapi-schema/doc-empty-arg.out new file +0 -0
tests/qapi-schema/doc-empty-section.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-section.json:3: Empty doc section 'Note'
tests/qapi-schema/doc-empty-section.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-empty-section.json new file +8 -0
@@ -0,0 +1,8 @@ +# Tagged-section must not be empty + +## +# @foo: +# +# Note: +## +{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-empty-section.out new file +0 -0
tests/qapi-schema/doc-empty-symbol.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-symbol.json:4:1: Invalid name
tests/qapi-schema/doc-empty-symbol.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-empty-symbol.json new file +5 -0
@@ -0,0 +1,5 @@ +# Invalid documentation symbol + +## +# @: +##
tests/qapi-schema/doc-empty-symbol.out new file +0 -0
tests/qapi-schema/doc-invalid-end.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end.json:5:2: Documentation comment must end with '##'
tests/qapi-schema/doc-invalid-end.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-end.json new file +5 -0
@@ -0,0 +1,5 @@ +# Documentation must end with '##' + +## +# An invalid comment +#
tests/qapi-schema/doc-invalid-end.out new file +0 -0
tests/qapi-schema/doc-invalid-end2.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end2.json:5:1: Junk after '##' at end of documentation comment
tests/qapi-schema/doc-invalid-end2.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-end2.json new file +5 -0
@@ -0,0 +1,5 @@ +# Documentation must end with '##' + +## +# +## invalid
tests/qapi-schema/doc-invalid-end2.out new file +0 -0
tests/qapi-schema/doc-invalid-return.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-return.json:3: 'Returns:' is only valid for commands
tests/qapi-schema/doc-invalid-return.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-return.json new file +7 -0
@@ -0,0 +1,7 @@ +# Events can't have 'Returns' section + +## +# @foo: +# Returns: blah +## +{ 'event': 'foo' }
tests/qapi-schema/doc-invalid-return.out new file +0 -0
tests/qapi-schema/doc-invalid-section.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-section.json:3: Document body cannot contain @NAME: sections
tests/qapi-schema/doc-invalid-section.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-section.json new file +6 -0
@@ -0,0 +1,6 @@ +# Free-form documentation doesn't have tagged-sections + +## +# freeform +# @note: foo +##
tests/qapi-schema/doc-invalid-section.out new file +0 -0
tests/qapi-schema/doc-invalid-start.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-start.json:3:1: Junk after '##' at start of documentation comment
tests/qapi-schema/doc-invalid-start.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-start.json new file +5 -0
@@ -0,0 +1,5 @@ +# Documentation must start with '##' + +## invalid +# +##
tests/qapi-schema/doc-invalid-start.out new file +0 -0
tests/qapi-schema/doc-missing-colon.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-colon.json:4:1: Line should end with :
tests/qapi-schema/doc-missing-colon.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-missing-colon.json new file +5 -0
@@ -0,0 +1,5 @@ +# The symbol section must end with ':' + +## +# @missing-colon +##
tests/qapi-schema/doc-missing-colon.out new file +0 -0
tests/qapi-schema/doc-missing-expr.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-expr.json:3: Documention for 'bar' is not followed by the definition
tests/qapi-schema/doc-missing-expr.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-missing-expr.json new file +5 -0
@@ -0,0 +1,5 @@ +# Expression documentation must be followed by the actual expression + +## +# @bar: +##
tests/qapi-schema/doc-missing-expr.out new file +0 -0
tests/qapi-schema/doc-missing-space.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-space.json:5:1: Missing space after #
tests/qapi-schema/doc-missing-space.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-missing-space.json new file +6 -0
@@ -0,0 +1,6 @@ +# Documentation line must have a leading space + +## +# missing space: +#wef +##
tests/qapi-schema/doc-missing-space.out new file +0 -0
tests/qapi-schema/double-type.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/double-type.json:2: Unknown key 'command' in struct 'bar' +tests/qapi-schema/double-type.json:6: Unknown key 'command' in struct 'bar'
tests/qapi-schema/double-type.json +4 -0
@@ -1,2 +1,6 @@ # we reject an expression with ambiguous metatype + +## +# @foo: +## { 'command': 'foo', 'struct': 'bar', 'data': { } }
tests/qapi-schema/enum-bad-name.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/enum-bad-name.json:2: Member of enum 'MyEnum' uses invalid name 'not^possible' +tests/qapi-schema/enum-bad-name.json:6: Member of enum 'MyEnum' uses invalid name 'not^possible'
tests/qapi-schema/enum-bad-name.json +4 -0
@@ -1,2 +1,6 @@ # we ensure all enum names can map to C + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ 'not^possible' ] }
tests/qapi-schema/enum-bad-prefix.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/enum-bad-prefix.json:2: Enum 'MyEnum' requires a string for 'prefix' +tests/qapi-schema/enum-bad-prefix.json:6: Enum 'MyEnum' requires a string for 'prefix'
tests/qapi-schema/enum-bad-prefix.json +4 -0
@@ -1,2 +1,6 @@ # The prefix must be a string type + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ 'one' ], 'prefix': [ 'fish' ] }
tests/qapi-schema/enum-clash-member.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/enum-clash-member.json:2: 'one_two' (member of MyEnum) collides with 'one-two' (member of MyEnum) +tests/qapi-schema/enum-clash-member.json:6: 'one_two' (member of MyEnum) collides with 'one-two' (member of MyEnum)
tests/qapi-schema/enum-clash-member.json +4 -0
@@ -1,2 +1,6 @@ # we reject enums where members will clash when mapped to C enum + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ 'one-two', 'one_two' ] }
tests/qapi-schema/enum-dict-member.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/enum-dict-member.json:2: Member of enum 'MyEnum' requires a string name +tests/qapi-schema/enum-dict-member.json:6: Member of enum 'MyEnum' requires a string name
tests/qapi-schema/enum-dict-member.json +4 -0
@@ -1,2 +1,6 @@ # we reject any enum member that is not a string + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] }
tests/qapi-schema/enum-member-case.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/enum-member-case.json:3: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase +tests/qapi-schema/enum-member-case.json:10: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase
tests/qapi-schema/enum-member-case.json +7 -0
@@ -1,3 +1,10 @@ # Member names should be 'lower-case' unless the enum is whitelisted + +## +# @UuidInfo: +## { 'enum': 'UuidInfo', 'data': [ 'Value' ] } # UuidInfo is whitelisted +## +# @NoWayThisWillGetWhitelisted: +## { 'enum': 'NoWayThisWillGetWhitelisted', 'data': [ 'Value' ] }
tests/qapi-schema/enum-missing-data.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/enum-missing-data.json:2: Key 'data' is missing from enum 'MyEnum' +tests/qapi-schema/enum-missing-data.json:6: Key 'data' is missing from enum 'MyEnum'
tests/qapi-schema/enum-missing-data.json +4 -0
@@ -1,2 +1,6 @@ # we require that all QAPI enums have a data array + +## +# @MyEnum: +## { 'enum': 'MyEnum' }
tests/qapi-schema/enum-wrong-data.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/enum-wrong-data.json:2: Enum 'MyEnum' requires an array for 'data' +tests/qapi-schema/enum-wrong-data.json:6: Enum 'MyEnum' requires an array for 'data'
tests/qapi-schema/enum-wrong-data.json +4 -0
@@ -1,2 +1,6 @@ # we require that all qapi enums have an array for data + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': { 'value': 'str' } }
tests/qapi-schema/event-boxed-empty.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/event-boxed-empty.json:2: Use of 'boxed' requires 'data' +tests/qapi-schema/event-boxed-empty.json:6: Use of 'boxed' requires 'data'
tests/qapi-schema/event-boxed-empty.json +4 -0
@@ -1,2 +1,6 @@ # 'boxed' requires a non-empty type + +## +# @FOO: +## { 'event': 'FOO', 'boxed': true }
tests/qapi-schema/event-case.json +4 -0
@@ -1,3 +1,7 @@ # TODO: might be nice to enforce naming conventions; but until then this works # even though events should usually be ALL_CAPS + +## +# @oops: +## { 'event': 'oops' }
tests/qapi-schema/event-case.out +3 -0
@@ -3,3 +3,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo event oops None boxed=False object q_empty +doc symbol=oops expr=('event', 'oops') + body= +
tests/qapi-schema/event-nest-struct.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/event-nest-struct.json:1: Member 'a' of 'data' for event 'EVENT_A' should be a type name +tests/qapi-schema/event-nest-struct.json:5: Member 'a' of 'data' for event 'EVENT_A' should be a type name
tests/qapi-schema/event-nest-struct.json +4 -0
@@ -1,2 +1,6 @@ +## +# @EVENT_A: +# event-nest-struct +## { 'event': 'EVENT_A', 'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }
tests/qapi-schema/flat-union-array-branch.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-array-branch.json:8: Member 'value1' of union 'TestUnion' cannot be an array +tests/qapi-schema/flat-union-array-branch.json:20: Member 'value1' of union 'TestUnion' cannot be an array
tests/qapi-schema/flat-union-array-branch.json +12 -0
@@ -1,10 +1,22 @@ +## +# @TestEnum: +## # we require flat union branches to be a struct { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',
tests/qapi-schema/flat-union-bad-base.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-bad-base.json:8: 'string' (member of TestTypeA) collides with 'string' (base of TestUnion) +tests/qapi-schema/flat-union-bad-base.json:21: 'string' (member of TestTypeA) collides with 'string' (base of TestUnion)
tests/qapi-schema/flat-union-bad-base.json +13 -0
@@ -1,10 +1,23 @@ # we allow anonymous base, but enforce no duplicate keys + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': { 'enum1': 'TestEnum', 'string': 'str' }, 'discriminator': 'enum1',
tests/qapi-schema/flat-union-bad-discriminator.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-bad-discriminator.json:11: Discriminator of flat union 'TestUnion' requires a string name +tests/qapi-schema/flat-union-bad-discriminator.json:27: Discriminator of flat union 'TestUnion' requires a string name
tests/qapi-schema/flat-union-bad-discriminator.json +16 -0
@@ -1,13 +1,29 @@ # we require the discriminator to be a string naming a base-type member # this tests the old syntax for anonymous unions before we added alternates + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum', 'kind': 'str' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': {},
tests/qapi-schema/flat-union-base-any.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-base-any.json:8: 'base' for union 'TestUnion' cannot use built-in type 'any' +tests/qapi-schema/flat-union-base-any.json:21: 'base' for union 'TestUnion' cannot use built-in type 'any'
tests/qapi-schema/flat-union-base-any.json +13 -0
@@ -1,10 +1,23 @@ # we require the base to be an existing struct + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'any', 'discriminator': 'enum1',
tests/qapi-schema/flat-union-base-union.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-base-union.json:14: 'base' for union 'TestUnion' cannot use union type 'UnionBase' +tests/qapi-schema/flat-union-base-union.json:30: 'base' for union 'TestUnion' cannot use union type 'UnionBase'
tests/qapi-schema/flat-union-base-union.json +16 -0
@@ -2,15 +2,31 @@ # TODO: It would be possible to allow a union as a base, as long as all # permutations of QMP names exposed by base do not clash with any QMP # member names added by local variants. + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @UnionBase: +## { 'union': 'UnionBase', 'data': { 'kind1': 'TestTypeA', 'kind2': 'TestTypeB' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'UnionBase', 'discriminator': 'type',
tests/qapi-schema/flat-union-clash-member.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-clash-member.json:11: 'name' (member of Branch1) collides with 'name' (member of Base) +tests/qapi-schema/flat-union-clash-member.json:27: 'name' (member of Branch1) collides with 'name' (member of Base)
tests/qapi-schema/flat-union-clash-member.json +16 -0
@@ -1,13 +1,29 @@ # We check for no duplicate keys between branch members and base # base's member 'name' clashes with Branch1's + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum', '*name': 'str' } } +## +# @Branch1: +## { 'struct': 'Branch1', 'data': { 'name': 'str' } } +## +# @Branch2: +## { 'struct': 'Branch2', 'data': { 'value': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',
tests/qapi-schema/flat-union-empty.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-empty.json:4: Union 'Union' cannot have empty 'data' +tests/qapi-schema/flat-union-empty.json:14: Union 'Union' cannot have empty 'data'
tests/qapi-schema/flat-union-empty.json +10 -0
@@ -1,4 +1,14 @@ # flat unions cannot be empty + +## +# @Empty: +## { 'enum': 'Empty', 'data': [ ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'type': 'Empty' } } +## +# @Union: +## { 'union': 'Union', 'base': 'Base', 'discriminator': 'type', 'data': { } }
tests/qapi-schema/flat-union-incomplete-branch.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-incomplete-branch.json:6: Union 'TestUnion' data missing 'value2' branch +tests/qapi-schema/flat-union-incomplete-branch.json:16: Union 'TestUnion' data missing 'value2' branch
tests/qapi-schema/flat-union-incomplete-branch.json +10 -0
@@ -1,8 +1,18 @@ # we require all branches of the union to be covered + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': { 'type': 'TestEnum' }, 'discriminator': 'type',
tests/qapi-schema/flat-union-inline.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-inline.json:7: Member 'value1' of union 'TestUnion' should be a type name +tests/qapi-schema/flat-union-inline.json:17: Member 'value1' of union 'TestUnion' should be a type name
tests/qapi-schema/flat-union-inline.json +10 -0
@@ -1,9 +1,19 @@ # we require branches to be a struct name # TODO: should we allow anonymous inline branch types? + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum', 'kind': 'str' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',
tests/qapi-schema/flat-union-int-branch.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-int-branch.json:8: Member 'value1' of union 'TestUnion' cannot use built-in type 'int' +tests/qapi-schema/flat-union-int-branch.json:21: Member 'value1' of union 'TestUnion' cannot use built-in type 'int'
tests/qapi-schema/flat-union-int-branch.json +13 -0
@@ -1,10 +1,23 @@ # we require flat union branches to be a struct + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',
tests/qapi-schema/flat-union-invalid-branch-key.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-invalid-branch-key.json:13: Discriminator value 'value_wrong' is not found in enum 'TestEnum' +tests/qapi-schema/flat-union-invalid-branch-key.json:28: Discriminator value 'value_wrong' is not found in enum 'TestEnum'
tests/qapi-schema/flat-union-invalid-branch-key.json +15 -0
@@ -1,15 +1,30 @@ +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': 'enum1',
tests/qapi-schema/flat-union-invalid-discriminator.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-invalid-discriminator.json:13: Discriminator 'enum_wrong' is not a member of base struct 'TestBase' +tests/qapi-schema/flat-union-invalid-discriminator.json:28: Discriminator 'enum_wrong' is not a member of base struct 'TestBase'
tests/qapi-schema/flat-union-invalid-discriminator.json +15 -0
@@ -1,15 +1,30 @@ +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': 'enum_wrong',
tests/qapi-schema/flat-union-no-base.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-no-base.json:9: Flat union 'TestUnion' must have a base +tests/qapi-schema/flat-union-no-base.json:22: Flat union 'TestUnion' must have a base
tests/qapi-schema/flat-union-no-base.json +13 -0
@@ -1,11 +1,24 @@ # flat unions require a base # TODO: simple unions should be able to use an enum discriminator + +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @Enum: +## { 'enum': 'Enum', 'data': [ 'value1', 'value2' ] } +## +# @TestUnion: +## { 'union': 'TestUnion', 'discriminator': 'Enum', 'data': { 'value1': 'TestTypeA',
tests/qapi-schema/flat-union-optional-discriminator.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-optional-discriminator.json:6: Discriminator of flat union 'MyUnion' does not allow optional name '*switch' +tests/qapi-schema/flat-union-optional-discriminator.json:19: Discriminator of flat union 'MyUnion' does not allow optional name '*switch'
tests/qapi-schema/flat-union-optional-discriminator.json +13 -0
@@ -1,8 +1,21 @@ # we require the discriminator to be non-optional + +## +# @Enum: +## { 'enum': 'Enum', 'data': [ 'one', 'two' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { '*switch': 'Enum' } } +## +# @Branch: +## { 'struct': 'Branch', 'data': { 'name': 'str' } } +## +# @MyUnion: +## { 'union': 'MyUnion', 'base': 'Base', 'discriminator': '*switch',
tests/qapi-schema/flat-union-string-discriminator.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/flat-union-string-discriminator.json:13: Discriminator 'kind' must be of enumeration type +tests/qapi-schema/flat-union-string-discriminator.json:28: Discriminator 'kind' must be of enumeration type
tests/qapi-schema/flat-union-string-discriminator.json +15 -0
@@ -1,15 +1,30 @@ +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum', 'kind': 'str' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': 'kind',
tests/qapi-schema/ident-with-escape.json +4 -0
@@ -1,4 +1,8 @@ # we allow escape sequences in strings, if they map back to ASCII # { 'command': 'fooA', 'data': { 'bar1': 'str' } } + +## +# @fooA: +## { 'c\u006fmmand': '\u0066\u006f\u006FA', 'd\u0061ta': { '\u0062\u0061\u00721': '\u0073\u0074\u0072' } }
tests/qapi-schema/ident-with-escape.out +3 -0
@@ -5,3 +5,6 @@ command fooA q_obj_fooA-arg -> None object q_empty object q_obj_fooA-arg member bar1: str optional=False +doc symbol=fooA expr=('command', 'fooA') + body= +
tests/qapi-schema/include-relpath-sub.json +3 -0
@@ -1,2 +1,5 @@ +## +# @Status: +## { 'enum': 'Status', 'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/include-relpath.out +3 -0
@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +
tests/qapi-schema/include-repetition.out +3 -0
@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +
tests/qapi-schema/include-simple-sub.json +3 -0
@@ -1,2 +1,5 @@ +## +# @Status: +## { 'enum': 'Status', 'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/include-simple.out +3 -0
@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +
tests/qapi-schema/indented-expr.json +6 -0
@@ -1,2 +1,8 @@ +## +# @eins: +## { 'command' : 'eins' } +## +# @zwei: +## { 'command' : 'zwei' }
tests/qapi-schema/indented-expr.out +6 -0
@@ -5,3 +5,9 @@ command eins None -> None object q_empty command zwei None -> None gen=True success_response=True boxed=False +doc symbol=eins expr=('command', 'eins') + body= + +doc symbol=zwei expr=('command', 'zwei') + body= +
tests/qapi-schema/missing-type.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/missing-type.json:2: Expression is missing metatype +tests/qapi-schema/missing-type.json:6: Expression is missing metatype
tests/qapi-schema/missing-type.json +4 -0
@@ -1,2 +1,6 @@ # we reject an expression with missing metatype + +## +# @foo: +## { 'data': { } }
tests/qapi-schema/nested-struct-data.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/nested-struct-data.json:2: Member 'a' of 'data' for command 'foo' should be a type name +tests/qapi-schema/nested-struct-data.json:6: Member 'a' of 'data' for command 'foo' should be a type name
tests/qapi-schema/nested-struct-data.json +4 -0
@@ -1,3 +1,7 @@ # inline subtypes collide with our desired future use of defaults + +## +# @foo: +## { 'command': 'foo', 'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }
tests/qapi-schema/qapi-schema-test.json +213 -0
375 lines not on this page · raw message
tests/qapi-schema/qapi-schema-test.out +212 -0
215 lines not on this page · raw message
tests/qapi-schema/redefined-builtin.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/redefined-builtin.json:2: built-in 'size' is already defined +tests/qapi-schema/redefined-builtin.json:6: built-in 'size' is already defined
tests/qapi-schema/redefined-builtin.json +4 -0
@@ -1,2 +1,6 @@ # we reject types that duplicate builtin names + +## +# @size: +## { 'struct': 'size', 'data': { 'myint': 'size' } }
tests/qapi-schema/redefined-command.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/redefined-command.json:3: command 'foo' is already defined +tests/qapi-schema/redefined-command.json:10: command 'foo' is already defined
tests/qapi-schema/redefined-command.json +7 -0
@@ -1,3 +1,10 @@ # we reject commands defined more than once + +## +# @foo: +## { 'command': 'foo', 'data': { 'one': 'str' } } +## +# @foo: +## { 'command': 'foo', 'data': { '*two': 'str' } }
tests/qapi-schema/redefined-event.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/redefined-event.json:3: event 'EVENT_A' is already defined +tests/qapi-schema/redefined-event.json:10: event 'EVENT_A' is already defined
tests/qapi-schema/redefined-event.json +7 -0
@@ -1,3 +1,10 @@ # we reject duplicate events + +## +# @EVENT_A: +## { 'event': 'EVENT_A', 'data': { 'myint': 'int' } } +## +# @EVENT_A: +## { 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
tests/qapi-schema/redefined-type.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/redefined-type.json:3: struct 'foo' is already defined +tests/qapi-schema/redefined-type.json:10: struct 'foo' is already defined
tests/qapi-schema/redefined-type.json +7 -0
@@ -1,3 +1,10 @@ # we reject types defined more than once + +## +# @foo: +## { 'struct': 'foo', 'data': { 'one': 'str' } } +## +# @foo: +## { 'enum': 'foo', 'data': [ 'two' ] }
tests/qapi-schema/reserved-command-q.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-command-q.json:5: 'command' uses invalid name 'q-unix' +tests/qapi-schema/reserved-command-q.json:12: 'command' uses invalid name 'q-unix'
tests/qapi-schema/reserved-command-q.json +7 -0
@@ -1,5 +1,12 @@ # C entity name collision # We reject names like 'q-unix', because they can collide with the mangled # name for 'unix' in generated C. + +## +# @unix: +## { 'command': 'unix' } +## +# @q-unix: +## { 'command': 'q-unix' }
tests/qapi-schema/reserved-enum-q.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-enum-q.json:4: Member of enum 'Foo' uses invalid name 'q-Unix' +tests/qapi-schema/reserved-enum-q.json:8: Member of enum 'Foo' uses invalid name 'q-Unix'
tests/qapi-schema/reserved-enum-q.json +4 -0
@@ -1,4 +1,8 @@ # C entity name collision # We reject names like 'q-unix', because they can collide with the mangled # name for 'unix' in generated C. + +## +# @Foo: +## { 'enum': 'Foo', 'data': [ 'unix', 'q-Unix' ] }
tests/qapi-schema/reserved-member-has.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-member-has.json:5: Member of 'data' for command 'oops' uses reserved name 'has-a' +tests/qapi-schema/reserved-member-has.json:9: Member of 'data' for command 'oops' uses reserved name 'has-a'
tests/qapi-schema/reserved-member-has.json +4 -0
@@ -2,4 +2,8 @@ # We reject names like 'has-a', because they can collide with the flag # for an optional 'a' in generated C. # TODO we could munge the optional flag name to avoid the collision. + +## +# @oops: +## { 'command': 'oops', 'data': { '*a': 'str', 'has-a': 'str' } }
tests/qapi-schema/reserved-member-q.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-member-q.json:4: Member of 'data' for struct 'Foo' uses invalid name 'q-unix' +tests/qapi-schema/reserved-member-q.json:8: Member of 'data' for struct 'Foo' uses invalid name 'q-unix'
tests/qapi-schema/reserved-member-q.json +4 -0
@@ -1,4 +1,8 @@ # C member name collision # We reject names like 'q-unix', because they can collide with the mangled # name for 'unix' in generated C. + +## +# @Foo: +## { 'struct': 'Foo', 'data': { 'unix':'int', 'q-unix':'bool' } }
tests/qapi-schema/reserved-member-u.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-member-u.json:7: Member of 'data' for struct 'Oops' uses reserved name 'u' +tests/qapi-schema/reserved-member-u.json:11: Member of 'data' for struct 'Oops' uses reserved name 'u'
tests/qapi-schema/reserved-member-u.json +4 -0
@@ -4,4 +4,8 @@ # This is true even for non-unions, because it is possible to convert a # struct to flat union while remaining backwards compatible in QMP. # TODO - we could munge the member name to 'q_u' to avoid the collision + +## +# @Oops: +## { 'struct': 'Oops', 'data': { 'u': 'str' } }
tests/qapi-schema/reserved-member-underscore.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-member-underscore.json:4: Member of 'data' for struct 'Oops' uses invalid name '_oops' +tests/qapi-schema/reserved-member-underscore.json:8: Member of 'data' for struct 'Oops' uses invalid name '_oops'
tests/qapi-schema/reserved-member-underscore.json +4 -0
@@ -1,4 +1,8 @@ # C member name collision # We reject use of a single leading underscore in all names (names must # begin with a letter or a downstream extension double-underscore prefix). + +## +# @Oops: +## { 'struct': 'Oops', 'data': { '_oops': 'str' } }
tests/qapi-schema/reserved-type-kind.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-type-kind.json:2: enum 'UnionKind' should not end in 'Kind' +tests/qapi-schema/reserved-type-kind.json:6: enum 'UnionKind' should not end in 'Kind'
tests/qapi-schema/reserved-type-kind.json +4 -0
@@ -1,2 +1,6 @@ # we reject types that would conflict with implicit union enum + +## +# @UnionKind: +## { 'enum': 'UnionKind', 'data': [ 'oops' ] }
tests/qapi-schema/reserved-type-list.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/reserved-type-list.json:5: struct 'FooList' should not end in 'List' +tests/qapi-schema/reserved-type-list.json:9: struct 'FooList' should not end in 'List'
tests/qapi-schema/reserved-type-list.json +4 -0
@@ -2,4 +2,8 @@ # We reserve names ending in 'List' for use by array types. # TODO - we could choose array names to avoid collision with user types, # in order to let this compile + +## +# @FooList: +## { 'struct': 'FooList', 'data': { 's': 'str' } }
tests/qapi-schema/returns-alternate.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/returns-alternate.json:3: 'returns' for command 'oops' cannot use alternate type 'Alt' +tests/qapi-schema/returns-alternate.json:10: 'returns' for command 'oops' cannot use alternate type 'Alt'
tests/qapi-schema/returns-alternate.json +7 -0
@@ -1,3 +1,10 @@ # we reject returns if it is an alternate type + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'a': 'int', 'b': 'str' } } +## +# @oops: +## { 'command': 'oops', 'returns': 'Alt' }
tests/qapi-schema/returns-array-bad.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/returns-array-bad.json:2: 'returns' for command 'oops': array type must contain single type name +tests/qapi-schema/returns-array-bad.json:6: 'returns' for command 'oops': array type must contain single type name
tests/qapi-schema/returns-array-bad.json +4 -0
@@ -1,2 +1,6 @@ # we reject an array return that is not a single type + +## +# @oops: +## { 'command': 'oops', 'returns': [ 'str', 'str' ] }
tests/qapi-schema/returns-dict.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/returns-dict.json:2: 'returns' for command 'oops' should be a type name +tests/qapi-schema/returns-dict.json:6: 'returns' for command 'oops' should be a type name
tests/qapi-schema/returns-dict.json +4 -0
@@ -1,2 +1,6 @@ # we reject inline struct return type + +## +# @oops: +## { 'command': 'oops', 'returns': { 'a': 'str' } }
tests/qapi-schema/returns-unknown.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/returns-unknown.json:2: 'returns' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/returns-unknown.json:6: 'returns' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/returns-unknown.json +4 -0
@@ -1,2 +1,6 @@ # we reject returns if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'returns': 'NoSuchType' }
tests/qapi-schema/returns-whitelist.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/returns-whitelist.json:10: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int' +tests/qapi-schema/returns-whitelist.json:26: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int'
tests/qapi-schema/returns-whitelist.json +16 -0
@@ -1,11 +1,27 @@ # we enforce that 'returns' be a dict or array of dict unless whitelisted + +## +# @human-monitor-command: +## { 'command': 'human-monitor-command', 'data': {'command-line': 'str', '*cpu-index': 'int'}, 'returns': 'str' } +## +# @TpmModel: +## { 'enum': 'TpmModel', 'data': [ 'tpm-tis' ] } +## +# @query-tpm-models: +## { 'command': 'query-tpm-models', 'returns': ['TpmModel'] } +## +# @guest-get-time: +## { 'command': 'guest-get-time', 'returns': 'int' } +## +# @no-way-this-will-get-whitelisted: +## { 'command': 'no-way-this-will-get-whitelisted', 'returns': [ 'int' ] }
tests/qapi-schema/struct-base-clash-deep.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/struct-base-clash-deep.json:10: 'name' (member of Sub) collides with 'name' (member of Base) +tests/qapi-schema/struct-base-clash-deep.json:20: 'name' (member of Sub) collides with 'name' (member of Base)
tests/qapi-schema/struct-base-clash-deep.json +10 -0
@@ -2,11 +2,21 @@ # Here, 'name' would have to appear twice on the wire, locally and # indirectly for the grandparent base; the collision doesn't care that # one instance is optional. + +## +# @Base: +## { 'struct': 'Base', 'data': { 'name': 'str' } } +## +# @Mid: +## { 'struct': 'Mid', 'base': 'Base', 'data': { 'value': 'int' } } +## +# @Sub: +## { 'struct': 'Sub', 'base': 'Mid', 'data': { '*name': 'str' } }
tests/qapi-schema/struct-base-clash.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/struct-base-clash.json:5: 'name' (member of Sub) collides with 'name' (member of Base) +tests/qapi-schema/struct-base-clash.json:12: 'name' (member of Sub) collides with 'name' (member of Base)
tests/qapi-schema/struct-base-clash.json +7 -0
@@ -1,7 +1,14 @@ # Reject attempts to duplicate QMP members # Here, 'name' would have to appear twice on the wire, locally and for base. + +## +# @Base: +## { 'struct': 'Base', 'data': { 'name': 'str' } } +## +# @Sub: +## { 'struct': 'Sub', 'base': 'Base', 'data': { 'name': 'str' } }
tests/qapi-schema/struct-data-invalid.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/struct-data-invalid.json:1: 'data' for struct 'foo' should be a dictionary or type name +tests/qapi-schema/struct-data-invalid.json:4: 'data' for struct 'foo' should be a dictionary or type name
tests/qapi-schema/struct-data-invalid.json +3 -0
@@ -1,2 +1,5 @@ +## +# @foo: +## { 'struct': 'foo', 'data': false }
tests/qapi-schema/struct-member-invalid.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/struct-member-invalid.json:1: Member 'a' of 'data' for struct 'foo' should be a type name +tests/qapi-schema/struct-member-invalid.json:4: Member 'a' of 'data' for struct 'foo' should be a type name
tests/qapi-schema/struct-member-invalid.json +3 -0
@@ -1,2 +1,5 @@ +## +# @foo: +## { 'struct': 'foo', 'data': { 'a': false } }
tests/qapi-schema/test-qapi.py +12 -0
@@ -55,3 +55,15 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): schema = QAPISchema(sys.argv[1]) schema.visit(QAPISchemaTestVisitor()) + +for doc in schema.docs: + if doc.symbol: + print 'doc symbol=%s expr=%s' % \ + (doc.symbol, doc.expr.items()[0]) + else: + print 'doc freeform' + for arg, section in doc.args.iteritems(): + print ' arg=%s\n%s' % (arg, section) + for section in doc.sections: + print ' section=%s\n%s' % (section.name, section) + print ' body=\n%s' % doc.body
tests/qapi-schema/type-bypass-bad-gen.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/type-bypass-bad-gen.json:2: 'gen' of command 'foo' should only use false value +tests/qapi-schema/type-bypass-bad-gen.json:6: 'gen' of command 'foo' should only use false value
tests/qapi-schema/type-bypass-bad-gen.json +4 -0
@@ -1,2 +1,6 @@ # 'gen' should only appear with value false + +## +# @foo: +## { 'command': 'foo', 'gen': 'whatever' }
tests/qapi-schema/unicode-str.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/unicode-str.json:2: 'command' uses invalid name 'é' +tests/qapi-schema/unicode-str.json:6: 'command' uses invalid name 'é'
tests/qapi-schema/unicode-str.json +4 -0
@@ -1,2 +1,6 @@ # we don't support full Unicode strings, yet + +## +# @e: +## { 'command': 'é' }
tests/qapi-schema/union-base-no-discriminator.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/union-base-no-discriminator.json:11: Simple union 'TestUnion' must not have a base +tests/qapi-schema/union-base-no-discriminator.json:23: Simple union 'TestUnion' must not have a base
tests/qapi-schema/union-base-no-discriminator.json +12 -0
@@ -1,13 +1,25 @@ +## +# @TestTypeA: +## # we reject simple unions with a base (or flat unions without discriminator) { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @Base: +## { 'struct': 'Base', 'data': { 'string': 'str' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'data': { 'value1': 'TestTypeA',
tests/qapi-schema/union-branch-case.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/union-branch-case.json:2: 'Branch' (branch of NoWayThisWillGetWhitelisted) should not use uppercase +tests/qapi-schema/union-branch-case.json:6: 'Branch' (branch of NoWayThisWillGetWhitelisted) should not use uppercase
tests/qapi-schema/union-branch-case.json +4 -0
@@ -1,2 +1,6 @@ # Branch names should be 'lower-case' unless the union is whitelisted + +## +# @NoWayThisWillGetWhitelisted: +## { 'union': 'NoWayThisWillGetWhitelisted', 'data': { 'Branch': 'int' } }
tests/qapi-schema/union-clash-branches.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/union-clash-branches.json:4: 'a_b' (branch of TestUnion) collides with 'a-b' (branch of TestUnion) +tests/qapi-schema/union-clash-branches.json:8: 'a_b' (branch of TestUnion) collides with 'a-b' (branch of TestUnion)
tests/qapi-schema/union-clash-branches.json +4 -0
@@ -1,5 +1,9 @@ # Union branch name collision # Reject a union that would result in a collision in generated C names (this # would try to generate two members 'a_b'). + +## +# @TestUnion: +## { 'union': 'TestUnion', 'data': { 'a-b': 'int', 'a_b': 'str' } }
tests/qapi-schema/union-empty.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/union-empty.json:2: Union 'Union' cannot have empty 'data' +tests/qapi-schema/union-empty.json:6: Union 'Union' cannot have empty 'data'
tests/qapi-schema/union-empty.json +4 -0
@@ -1,2 +1,6 @@ # unions cannot be empty + +## +# @Union: +## { 'union': 'Union', 'data': { } }
tests/qapi-schema/union-invalid-base.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/union-invalid-base.json:8: 'base' for union 'TestUnion' cannot use built-in type 'int' +tests/qapi-schema/union-invalid-base.json:18: 'base' for union 'TestUnion' cannot use built-in type 'int'
tests/qapi-schema/union-invalid-base.json +10 -0
@@ -1,10 +1,20 @@ # a union base type must be a struct + +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'int', 'discriminator': 'int',
tests/qapi-schema/union-optional-branch.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/union-optional-branch.json:2: Member of union 'Union' does not allow optional name '*a' +tests/qapi-schema/union-optional-branch.json:6: Member of union 'Union' does not allow optional name '*a'
tests/qapi-schema/union-optional-branch.json +4 -0
@@ -1,2 +1,6 @@ # union branches cannot be optional + +## +# @Union: +## { 'union': 'Union', 'data': { '*a': 'int', 'b': 'str' } }
tests/qapi-schema/union-unknown.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/union-unknown.json:2: Member 'unknown' of union 'Union' uses unknown type 'MissingType' +tests/qapi-schema/union-unknown.json:6: Member 'unknown' of union 'Union' uses unknown type 'MissingType'
tests/qapi-schema/union-unknown.json +4 -0
@@ -1,3 +1,7 @@ # we reject a union with unknown type in branch + +## +# @Union: +## { 'union': 'Union', 'data': { 'unknown': 'MissingType' } }
tests/qapi-schema/unknown-escape.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/unknown-escape.json:3:21: Unknown escape \x +tests/qapi-schema/unknown-escape.json:7:21: Unknown escape \x
tests/qapi-schema/unknown-escape.json +4 -0
@@ -1,3 +1,7 @@ # we only recognize JSON escape sequences, plus our \' extension (no \x) + +## +# @foo: +## # { 'command': 'foo', 'data': {} } { 'command': 'foo', 'dat\x61':{} }
tests/qapi-schema/unknown-expr-key.err +1 -1
@@ -1 +1 @@ -tests/qapi-schema/unknown-expr-key.json:2: Unknown key 'bogus' in struct 'bar' +tests/qapi-schema/unknown-expr-key.json:6: Unknown key 'bogus' in struct 'bar'
tests/qapi-schema/unknown-expr-key.json +4 -0
@@ -1,2 +1,6 @@ # we reject an expression with unknown top-level keys + +## +# @bar: +## { 'struct': 'bar', 'data': { 'string': 'str'}, 'bogus': { } }
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v6 08/17] qapi: add qapi2texi script
Quoted 51 lines · Marc-André Lureau
As the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
It parses the following kind of blocks:
Free-form:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:# | $ echo foo # | -> do this # | <- get that#
##Symbol:
##
# @symbol:
#
# Symbol body ditto ergo sum. Foo bar# baz ding. # # @param1: the frob to frobnicate # @param2: #optional how hard to frobnicate # # Returns: the frobnicated frob. # If frob isn't frobnicatable, GenericError. # # Since: version # Notes: notes, comments can have # - itemized list # - like this # # Example: # # -> { "execute": "quit" } # <- { "return": {} } # ##That's roughly following the following EBNF grammar:
Quoted 7 lines
api_comment= "##\n" comment "##\n"
comment =freeform_comment|symbol_commentfreeform_comment= { "# " text "\n" | "#\n" }symbol_comment= "# @" name ":\n" { member | meta |freeform_comment}
member = "# @" name ':' [ text ] "\n"freeform_comment
meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:", "Examples:" ) [ text ] "\n"freeform_commenttext = free text with annotations
Let's add:
Note that the grammar is ambiguous: a line "# @foo:\n" can be parsed both as freeform_comment and as symbol_comment. The actual parser recognizes symbol_comment.
Quoted 9 lines
See
docs/qapi-code-gen.txtfor more details.The documentation is enriched with information from the actual schema.
Deficiencies:
- the generated QMP documentation includes internal types
- union support is lacking
- doc comment error message positions are imprecise, they point to the beginning of the comment.
Acceptable. We need matching FIXME or TODO comments; see below.
Hope we're not missing anything noteworthy here. I should double-check.
Quoted 2 lines
Signed-off-by Marc-André Lureau <[email protected]>
[diffstat snipped...]
Recommend to jump forward to docs/qapi-code-gen.txt, then come back.
Quoted 54 lines
tests/Makefile.include +19
-0@@ -350,6 +350,23 @@ qapi-schema += base-cycle-direct.json qapi-schema += base-cycle-indirect.json qapi-schema += command-int.json qapi-schema += comments.json +qapi-schema += doc-bad-args.json +qapi-schema += doc-bad-section.json +qapi-schema += doc-bad-symbol.json +qapi-schema += doc-duplicated-arg.json +qapi-schema += doc-duplicated-return.json +qapi-schema += doc-duplicated-since.json +qapi-schema += doc-empty-arg.json +qapi-schema += doc-empty-section.json +qapi-schema += doc-empty-symbol.json +qapi-schema += doc-invalid-end.json +qapi-schema += doc-invalid-end2.json +qapi-schema += doc-invalid-return.json +qapi-schema += doc-invalid-section.json +qapi-schema += doc-invalid-start.json +qapi-schema += doc-missing-colon.json +qapi-schema += doc-missing-expr.json +qapi-schema += doc-missing-space.json qapi-schema += double-data.json qapi-schema += double-type.json qapi-schema += duplicate-key.json@@ -443,6 +460,8 @@ qapi-schema += union-optional-branch.json qapi-schema += union-unknown.json qapi-schema += unknown-escape.json qapi-schema += unknown-expr-key.json + + check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \scripts/qapi.py +9
-0@@ -125,6 +125,114 @@ class QAPISemError(QAPIError): info['parent'], msg) +class QAPIDoc(object): + class Section(object): + def __init__(self, name=None): + # optional section name (argument/member or section name) + self.name = name + # the list of lines for this section + self.content = [] + + def append(self, line):
scripts/qapi.py class QAPISemError(QAPIError): · line 146
Quoted 10 lines
scripts/qapi.py +10
-0+ self.content.append(line) + + def __repr__(self): + return "\n".join(self.content).strip() + + class ArgSection(Section): + pass + + def __init__(self, parser, info): + self.parser = parser
Let's document the comment error message position deficiency mentioned in the commit message here:
# self.parser is used to report errors with QAPIParseError. The
# resulting error position depends on the state of the parser.
# It happens to be the beginning of the comment. More or less
# servicable, but action at a distance.Quoted 4 lines
scripts/qapi.py +4
-0+ self.info = info + self.symbol = None + self.body = QAPIDoc.Section() + # dict mapping parameter name to ArgSection
scripts/qapi.py class QAPISemError(QAPIError): · line 160
Quoted 10 lines
scripts/qapi.py +10
-0+ self.args = OrderedDict() + # a list of Section + self.sections = [] + # the current section + self.section = self.body + # associated expression (to be set by expression parser) + self.expr = None + + def has_section(self, name): + """Return True if we have a meta section with this name."""
Pretty much all other uses of "meta" are gone. Can we simply drop it here?
Hmm, there's one more left in the commit message's grammar. Can we come up with a better name there?
Quoted 8 lines
scripts/qapi.py +8
-0+ for i in self.sections: + if i.name == name: + return True + return False + + def append(self, line): + """Parse a comment line and add it to the documentation.""" + line = line[1:]
scripts/qapi.py class QAPISemError(QAPIError): · line 178
Quoted 10 lines
scripts/qapi.py +10
-0+ if not line: + self._append_freeform(line) + return + + if line[0] != ' ': + raise QAPIParseError(self.parser, "Missing space after #") + line = line[1:] + + # FIXME: currently recognizes only '# @foo:' with a single space + # we may want to fail if there are other kind of whitespaces
Actually, also fails when there's crap after ':', including invisible crap (trailing whitespace). Suggest:
# FIXME not nice: things like '# @foo:' and '# @foo: ' aren't # recognized, and get silently treated as ordinary text
Should this be added to the commit message's list of deficiencies? I guess it's not necessary.
scripts/qapi.py class QAPISemError(QAPIError): · line 186
Quoted 8 lines
scripts/qapi.py +8
-0+ if self.symbol: + self._append_symbol_line(line) + elif not self.body.content and line.startswith("@"): + if not line.endswith(":"): + raise QAPIParseError(self.parser, "Line should end with :") + self.symbol = line[1:-1] + if not self.symbol: + raise QAPIParseError(self.parser, "Invalid name")
Let's add:
# FIXME invalid names other than the empty string aren't flagged
Quoted 11 lines
scripts/qapi.py +11
-0+ else: + self._append_freeform(line) + + def _append_symbol_line(self, line): + name = line.split(' ', 1)[0] + + if name.startswith("@") and name.endswith(":"): + line = line[len(name)+1:] + self._start_args_section(name[1:-1]) + elif name in ("Returns:", "Since:", + # those are often singular or plural
scripts/qapi.py class QAPISemError(QAPIError): · line 207
Quoted 10 lines
scripts/qapi.py +10
-0+ "Note:", "Notes:", + "Example:", "Examples:"): + line = line[len(name)+1:] + self._start_section(name[:-1]) + + self._append_freeform(line) + + def _start_args_section(self, name): + if not name: + raise QAPIParseError(self.parser, "Invalid parameter name")
Let's add
# FIXME invalid names other than the empty string aren't flagged
Quoted 8 lines
scripts/qapi.py +8
-0+ if name in self.args: + raise QAPIParseError(self.parser, + "'%s' parameter name duplicated" % name) + self.section = QAPIDoc.ArgSection(name) + self.args[name] = self.section + + def _start_section(self, name): + if name in ("Returns", "Since") and self.has_section(name):
scripts/qapi.py class QAPISemError(QAPIError): · line 225
Quoted 10 lines
scripts/qapi.py +10
-0+ raise QAPIParseError(self.parser, + "Duplicated '%s' section" % name) + self.section = QAPIDoc.Section(name) + self.sections.append(self.section) + + def _append_freeform(self, line): + in_arg = isinstance(self.section, QAPIDoc.ArgSection) + if (in_arg and self.section.content and + not self.section.content[-1] and + line and not line[0].isspace()):
PEP8 recommends breaking lines before operators in new code. Can touch up on commit.
scripts/qapi.py class QAPISemError(QAPIError): · line 227
Quoted 2 lines
scripts/qapi.py +2
-0+ # an empty line followed by a non-indented + # comment is usually meant to ends the section
to end
scripts/qapi.py class QAPISemError(QAPIError): · line 228
Quoted 1 line
scripts/qapi.py +1
-0+ # but we prefer to reject this ambiguous case
I'm afraid this comment confuses more than it helps. Drop it?
scripts/qapi.py class QAPISemError(QAPIError): · line 231
Quoted 3 lines
scripts/qapi.py +3
-0+ raise QAPIParseError(self.parser, "Invalid section indentation") + if (in_arg or not self.section.name or + not self.section.name.startswith("Example")):
Again, break before the operator.
Quoted 34 lines
scripts/qapi.py +11
-0+ line = line.strip() + self.section.append(line) + + class QAPISchemaParser(object): def __init__(self, fp, previously_included=[], incl_info=None):@@ -140,11 +248,17 @@ class QAPISchemaParser(object): self.line = 1 self.line_pos = 0 self.exprs = [] + self.docs = [] self.accept() while self.tok is not None: info = {'file': fname, 'line': self.line, 'parent': self.incl_info} + if self.tok == '#': + doc = self.get_doc(info) + self.docs.append(doc) + continue + expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1:@@ -162,6 +276,7 @@ class QAPISchemaParser(object): raise QAPIParseError(self, "Inclusion loop for %s" % include) inf = inf['parent'] + # skip multiple include of the same file if incl_abs_fname in previously_included: continue
scripts/qapi.py class QAPISchemaParser(object): · line 297
Quoted 10 lines
scripts/qapi.py +4
-0@@ -173,12 +288,19 @@ class QAPISchemaParser(object): exprs_include = QAPISchemaParser(fobj, previously_included, info) self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) else: expr_elem = {'expr': expr, 'info': info} + if (self.docs and + self.docs[-1].info['file'] == fname and + not self.docs[-1].expr):
Again, break before the operator.
Quoted 14 lines
scripts/qapi.py +4
-1+ self.docs[-1].expr = expr + expr_elem['doc'] = self.docs[-1] + self.exprs.append(expr_elem) - def accept(self): + def accept(self, skip_comment=True): while True: self.tok = self.src[self.cursor] self.pos = self.cursor@@ -186,7 +308,13 @@ class QAPISchemaParser(object): self.val = None if self.tok == '#':
scripts/qapi.py class QAPISchemaParser(object): · line 320
Quoted 10 lines
scripts/qapi.py +6
-0+ if self.src[self.cursor] == '#': + # Start of doc comment + skip_comment = False self.cursor = self.src.find('\n', self.cursor) + if not skip_comment: + self.val = self.src[self.pos:self.cursor] + return elif self.tok in "{}:,[]": return elif self.tok == "'":
Copied from review of v3, so I don't forget:
Comment tokens are thrown away as before, except when the parser asks for them by passing skip_comment=False, or when the comment token starts with ##. The parser asks while parsing a doc comment, in get_doc().
This is a backchannel from the parser to the lexer. I'd rather avoid such lexer hacks, but I guess we can address that on top.
A comment starting with ## inside an expression is now a syntax error. For instance, input
{
##yields
/dev/stdin:2:1: Expected string or "}"
Rather unfriendly error message, but we can fix that on top.
Quoted 45 lines
scripts/qapi.py +27
-0@@ -320,6 +448,28 @@ class QAPISchemaParser(object): raise QAPIParseError(self, 'Expected "{", "[" or string') return expr + def get_doc(self, info): + if self.val != '##': + raise QAPIParseError(self, "Junk after '##' at start of " + "documentation comment") + + doc = QAPIDoc(self, info) + self.accept(False) + while self.tok == '#': + if self.val.startswith('##'): + # End of doc comment + if self.val != '##': + raise QAPIParseError(self, "Junk after '##' at end of " + "documentation comment") + self.accept() + return doc + else: + doc.append(self.val) + self.accept(False) + + raise QAPIParseError(self, "Documentation comment must end with '##'") + + # # Semantic analysis of schema expressions # TODO fold into QAPISchema@@ -704,6 +854,11 @@ def check_exprs(exprs): for expr_elem in exprs: expr = expr_elem['expr'] info = expr_elem['info'] + + if 'doc' not in expr_elem: + raise QAPISemError(info, + "Expression missing documentation comment") + if 'enum' in expr: check_keys(expr_elem, 'enum', ['data'], ['prefix']) add_enum(expr['enum'], info, expr['data'])@@ -762,6 +917,66 @@ def check_exprs(exprs): return exprs
scripts/qapi.py def check_exprs(exprs): · line 929
Quoted 10 lines
scripts/qapi.py +10
-0+def check_freeform_doc(doc): + if doc.symbol: + raise QAPISemError(doc.info, + "Documention for '%s' is not followed" + " by the definition" % doc.symbol) + + body = str(doc.body) + if re.search(r'@\S+:', body, re.MULTILINE): + raise QAPISemError(doc.info, + "Document body cannot contain @NAME: sections")
"Free-form documentation block must not contain ..."
Quoted 4 lines
scripts/qapi.py +4
-0+ + +def check_definition_doc(doc, expr, info): + for i in ('enum', 'union', 'alternate', 'struct', 'command', 'event'):
scripts/qapi.py def check_exprs(exprs): · line 943
Quoted 10 lines
scripts/qapi.py +10
-0+ if i in expr: + meta = i + break + + name = expr[meta] + if doc.symbol != name: + raise QAPISemError(info, "Definition of '%s' follows documentation" + " for '%s'" % (name, doc.symbol)) + if doc.has_section('Returns') and 'command' not in expr: + raise QAPISemError(info, "'Returns:' is only valid for commands")
Copied from review of v5, so I don't forget:
We accept 'Returns:' even when the command doesn't return anything, because we currently use it to document errors, too. Can't say I like that, but it's out of scope here.
Quoted 8 lines
scripts/qapi.py +8
-0+ + doc_args = set(doc.args.keys()) + if meta == 'union': + data = expr.get('base', []) + else: + data = expr.get('data', []) + if isinstance(data, dict): + data = data.keys()
scripts/qapi.py def check_exprs(exprs): · line 961
Quoted 10 lines
scripts/qapi.py +10
-0+ if isinstance(data, list): + args = set([name.strip('*') for name in data]) + else: + args = set() + if meta == 'alternate' or \ + (meta == 'union' and not expr.get('discriminator')): + args.add('type') + if not doc_args.issubset(args): + raise QAPISemError(info, "Members documentation is not a subset of" + " API %r > %r" % (list(doc_args), list(args)))
This error message is pretty horrid :) Can be improved on top.
Copied from review of v5, so I don't forget:
As explained in review of v3, this is only a subset of the real set of members. Computing the exact set is impractical when working with the abstract syntax tree. I believe we'll eventually have to rewrite this code to work with the QAPISchemaEntity instead.
Quoted 40 lines
scripts/qapi.py +21
-1+ + +def check_docs(docs): + for doc in docs: + for section in doc.args.values() + doc.sections: + content = str(section) + if not content or content.isspace(): + raise QAPISemError(doc.info, + "Empty doc section '%s'" % section.name) + + if not doc.expr: + check_freeform_doc(doc) + else: + check_definition_doc(doc, doc.expr, doc.info) + + return docs + + # # Schema compiler frontend #@@ -1230,7 +1445,9 @@ class QAPISchemaEvent(QAPISchemaEntity): class QAPISchema(object): def __init__(self, fname): try: - self.exprs = check_exprs(QAPISchemaParser(open(fname, "r")).exprs) + parser = QAPISchemaParser(open(fname, "r")) + self.exprs = check_exprs(parser.exprs) + self.docs = check_docs(parser.docs) self._entity_dict = {} self._predefining = True self._def_predefineds()scripts/qapi2texi.py new file +2
-0@@ -0,0 +1,339 @@ +#!/usr/bin/env python +# QAPI texi generator
scripts/qapi2texi.py line 12
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+# +# This work is licensed under the terms of the GNU LGPL, version 2+. +# See the COPYING file in the top-level directory. +"""This script produces the documentation of a qapi schema in texinfo format""" +import re +import sys + +import qapi + +COMMAND_FMT = """
Got a particular reason for shouting?
scripts/qapi2texi.py line 20
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+@deftypefn {type} {{{ret}}} {name} @ +{{{args}}} + +{body} + +@end deftypefn + +""".format
This .format business is perhaps a bit too clever. But let's move on.
scripts/qapi2texi.py line 31
Quoted 11 lines
scripts/qapi2texi.py new file +11
-0+ +ENUM_FMT = """ +@deftp Enum {name} + +{body} + +@end deftp + +""".format + +STRUCT_FMT = """
This is used for unions and alternates in addition to structs. But okay.
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+@deftp {{{type}}} {name} @ +{{{attrs}}} + +{body} + +@end deftp + +""".format
scripts/qapi2texi.py line 49
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ +EXAMPLE_FMT = """@example +{code} +@end example +""".format + + +def subst_strong(doc): + """Replaces *foo* by @strong{foo}""" + return re.sub(r'\*([^_\n]+)\*', r'@emph{\1}', doc)
Pasto: you want * instead of _ in the [^ ... ].
scripts/qapi2texi.py line 54
Quoted 5 lines
scripts/qapi2texi.py new file +5
-0+ + +def subst_emph(doc): + """Replaces _foo_ by @emph{foo}""" + return re.sub(r'\s_([^_\n]+)_\s', r' @emph{\1} ', doc)
This replaces adjacent whitespace characters by the space character. Would \b work here?
scripts/qapi2texi.py line 59
Quoted 5 lines
scripts/qapi2texi.py new file +5
-0+ + +def subst_vars(doc): + """Replaces @var by @code{var}""" + return re.sub(r'@([\w-]+)', r'@code{\1}', doc)
Note: any @ characters not followed by at least one word character are left alone.
scripts/qapi2texi.py line 70
Quoted 11 lines
scripts/qapi2texi.py new file +11
-0+ + +def subst_braces(doc): + """Replaces {} with @{ @}""" + return doc.replace("{", "@{").replace("}", "@}") + + +def texi_example(doc): + """Format @example""" + doc = subst_braces(doc).strip('\n') + return EXAMPLE_FMT(code=doc)
Neglects to escape @ characters.
We should probably escape them in subst_braces(), and rename the function to subst_special() or subs_texi_special(). If we do that, we need to delay it until after subst_vars() in texi_format().
scripts/qapi2texi.py line 81
Quoted 11 lines
scripts/qapi2texi.py new file +11
-0+ + +def texi_format(doc): + """ + Format documentation + + Lines starting with: + - |: generates an @example + - =: generates @section + - ==: generates @subsection + - 1. or 1): generates an @enumerate @item
Any number works, but I guess this is close enough.
Quoted 9 lines
scripts/qapi2texi.py new file +9
-0+ - o/*/-: generates an @itemize list + """ + lines = [] + doc = subst_braces(doc) + doc = subst_vars(doc) + doc = subst_emph(doc) + doc = subst_strong(doc) + inlist = "" + lastempty = False
scripts/qapi2texi.py line 100
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ for line in doc.split('\n'): + empty = line == "" + + if line.startswith("| "): + line = EXAMPLE_FMT(code=line[2:]) + elif line.startswith("= "): + line = "@section " + line[2:] + elif line.startswith("== "): + line = "@subsection " + line[3:] + elif re.match("^([0-9]*[.)]) ", line):
N) isn't actually used, and not covered by tests. Dropping it is simpler than testing it, so let's do that.
scripts/qapi2texi.py line 110
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ if not inlist: + lines.append("@enumerate") + inlist = "enumerate" + line = line[line.find(" ")+1:] + lines.append("@item") + elif re.match("^[o*-] ", line): + if not inlist: + lines.append("@itemize %s" % {'o': "@bullet", + '*': "@minus", + '-': ""}[line[0]])
Both 'o' and '-' become @bullet, the former explicitly, the latter because @bullet is the default. '*' becomes @minus. This is odd.
Since 'o' isn't actually used, let's drop it, and map '*' to @bullet (or nothing, doesn't matter), '-' to @minus'.
scripts/qapi2texi.py line 113
Quoted 3 lines
scripts/qapi2texi.py new file +3
-0+ inlist = "itemize" + lines.append("@item") + line = line[2:]
Note that the choice of 'o' vs. '*' vs. '-' vs. [0-9]*[.)] matters only in the first item.
scripts/qapi2texi.py line 116
Quoted 3 lines
scripts/qapi2texi.py new file +3
-0+ elif lastempty and inlist: + lines.append("@end %s\n" % inlist) + inlist = ""
Doing this in a single if / elif chain is problematic. For instance, a line without markup terminates a list if it follows a blank line (reaches the final elif), but a line with some *other* markup, such as a title doesn't.
Example:
##
# 1. one
# 2. two
#
# = title
#
# 1. eins
# 2. zwei
# * drei
##happily produces
@enumerate
@item
one
@item
two
@section title
@item
eins
@item
zwei
@item
drei
@end enumerate
Could be filed under deficiencies for now, with a FIXME comment here.
scripts/qapi2texi.py line 129
Quoted 13 lines
scripts/qapi2texi.py new file +13
-0+ + lastempty = empty + lines.append(line) + + if inlist: + lines.append("@end %s\n" % inlist) + return "\n".join(lines) + + +def texi_args(expr, key="data"): + """ + Format the functions/structure/events.. arguments/members + """
PEP257 wants one-liner doc strings in one line, including the """.
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ if key not in expr: + return "" + + args = expr[key] + arg_list = [] + if isinstance(args, str): + arg_list.append(args) + else:
scripts/qapi2texi.py line 147
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ for name, typ in args.iteritems(): + # optional arg + if name.startswith("*"): + name = name[1:] + arg_list.append("['%s': @t{%s}]" % (name, typ)) + # regular arg + else: + arg_list.append("'%s': @t{%s}" % (name, typ)) + + return ", ".join(arg_list)
Generates a formal description of something like struct members in a language you invent. As I showed in review of PATCH 05, the information here is redundant except for types. If we can add the type information elsewhere, and the formal description be dropped. That's what I want us to try in the medium term. For the short term, I propose to drop it, and add a FIXME. This gets rid of code I haven't fully reviewed, yet. More importantly, it gets rid of documentation that is known to be inaccurate and incomplete (see review of PATCH 05), and threatens to delay this series further.
Quoted 18 lines
scripts/qapi2texi.py new file +18
-0+ + +def texi_body(doc): + """ + Format the body of a symbol documentation: + - a table of arguments + - followed by "Returns/Notes/Since/Example" sections + """ + def _section_order(section): + return {"Returns": 0, + "Note": 1, + "Notes": 1, + "Since": 2, + "Example": 3, + "Examples": 3}[section] + + body = "" + if doc.args:
scripts/qapi2texi.py line 175
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ body += "@table @asis\n" + for arg, section in doc.args.iteritems(): + desc = str(section) + opt = '' + if desc.startswith("#optional"): + desc = desc[10:] + opt = ' *' + elif desc.endswith("#optional"): + desc = desc[:-10] + opt = ' *'
Add here:
# TODO Should ensure #optional matches the schema
scripts/qapi2texi.py line 181
Quoted 6 lines
scripts/qapi2texi.py new file +6
-0+ body += "@item @code{'%s'}%s\n%s\n" % (arg, opt, + texi_format(desc)) + body += "@end table\n" + body += texi_format(str(doc.body)) + + sections = sorted(doc.sections, key=lambda i: _section_order(i.name))
Reordering documentation written by humans is unlikely to improve things, so let's not do that. If we want our documentation presented in a certain order, we should enforce that order at the source level.
The doc parser splits doc comments into sections. It should produce a list of sections in source order, for the generator to walk.
If we decide doing that now would delay the series too much, I'm willing to accept it as is with a suitable FIXME comment here, noted in the commit message's list of deficiencies.
scripts/qapi2texi.py line 189
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ for section in sections: + name, doc = (section.name, str(section)) + func = texi_format + if name.startswith("Example"): + func = texi_example + + body += "\n@quotation %s\n%s\n@end quotation" % \ + (name, func(doc))
Are you sure @quotation is a good idea? The extra indentation looks ugly to me, both in .txt and .html. But we can touch that up on top.
Quoted 189 lines
scripts/qapi2texi.py new file +150
-0+ return body + + +def texi_alternate(expr, doc): + """ + Format an alternate to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return STRUCT_FMT(type="Alternate", + name=doc.symbol, + attrs="[ " + args + " ]", + body=body) + + +def texi_union(expr, doc): + """ + Format a union to texi + """ + discriminator = expr.get("discriminator") + if discriminator: + is_flat = True + union = "Flat Union" + else: + is_flat = False + union = "Simple Union" + discriminator = "type" + + attrs = "@{ " + if is_flat: + attrs += texi_args(expr, "base") + ", " + else: + attrs += "'type': @t{str}, 'data': " + attrs += "[ '%s' = " % discriminator + attrs += texi_args(expr, "data") + " ] @}" + body = texi_body(doc) + return STRUCT_FMT(type=union, + name=doc.symbol, + attrs=attrs, + body=body) + + +def texi_enum(expr, doc): + """ + Format an enum to texi + """ + for i in expr['data']: + if i not in doc.args: + doc.args[i] = '' + body = texi_body(doc) + return ENUM_FMT(name=doc.symbol, + body=body) + + +def texi_struct(expr, doc): + """ + Format a struct to texi + """ + args = texi_args(expr) + body = texi_body(doc) + base = expr.get("base") + attrs = "@{ " + if base: + attrs += "%s" % base + if args: + attrs += " + " + attrs += args + " @}" + return STRUCT_FMT(type="Struct", + name=doc.symbol, + attrs=attrs, + body=body) + + +def texi_command(expr, doc): + """ + Format a command to texi + """ + args = texi_args(expr) + ret = expr["returns"] if "returns" in expr else "" + body = texi_body(doc) + return COMMAND_FMT(type="Command", + name=doc.symbol, + ret=ret, + args="(" + args + ")", + body=body) + + +def texi_event(expr, doc): + """ + Format an event to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return COMMAND_FMT(type="Event", + name=doc.symbol, + ret="", + args="(" + args + ")", + body=body) + + +def texi_expr(expr, doc): + """ + Format an expr to texi + """ + (kind, _) = expr.items()[0] + + fmt = {"command": texi_command, + "struct": texi_struct, + "enum": texi_enum, + "union": texi_union, + "alternate": texi_alternate, + "event": texi_event}[kind] + + return fmt(expr, doc) + + +def texi(docs): + """ + Convert QAPI schema expressions to texi documentation + """ + res = [] + for doc in docs: + expr = doc.expr + if not expr: + res.append(texi_body(doc)) + continue + try: + doc = texi_expr(expr, doc) + res.append(doc) + except: + print >>sys.stderr, "error at @%s" % doc.info + raise + + return '\n'.join(res) + + +def main(argv): + """ + Takes schema argument, prints result to stdout + """ + if len(argv) != 2: + print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0] + sys.exit(1) + + schema = qapi.QAPISchema(argv[1]) + print texi(schema.docs) + + +if __name__ == "__main__": + main(sys.argv)docs/qapi-code-gen.txt +3
-27@@ -44,40 +44,110 @@ Input must be ASCII (although QMP supports full Unicode strings, the QAPI parser does not). At present, there is no place where a QAPI schema requires the use of JSON numbers or null. + +=== Comments === + Comments are allowed; anything between an unquoted # and the following -newline is ignored. Although there is not yet a documentation -generator, a form of stylized comments has developed for consistently -documenting details about an expression and when it was added to the -schema. The documentation is delimited between two lines of ##, then -the first line names the expression, an optional overview is provided, -then individual documentation about each member of 'data' is provided, -and finally, a 'Since: x.y.z' tag lists the release that introduced -the expression. Optional members are tagged with the phrase -'#optional', often with their default value; and extensions added -after the expression was first released are also given a '(since -x.y.z)' comment. For example: - - ## - # @BlockStats: - # - # Statistics of a virtual block device or a block backing device. - # - # @device: #optional If the stats are for a virtual block device, the name - # corresponding to the virtual block device. - # - # @stats: A @BlockDeviceStats for the device. - # - # @parent: #optional This describes the file block device if it has one. - # - # @backing: #optional This describes the backing block device if it has one. - # (Since 2.0) - #
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 54
Quoted 10 lines
docs/qapi-code-gen.txt +4
-6- # Since: 0.14.0 - ## - { 'struct': 'BlockStats', - 'data': {'*device': 'str', 'stats': 'BlockDeviceStats', - '*parent': 'BlockStats', - '*backing': 'BlockStats'} } +newline is ignored. + +A documentation block is delimited between two lines of ##, and can be +formatted.
Well, any comment can be "formatted". Suggest:
A multi-line comment that starts and ends with a '##' line is a documentation comment. These are parsed by the documentation generator, which recognizes certain markup detailed below.
Note that I say "markup" instead of "annotations". I think it's a more precise term. If we go with it, the commit message's grammar needs an update, too.
Quoted 7 lines
docs/qapi-code-gen.txt +7
-0+ +Example: + +## +# = Section +# == Subsection +#
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 71
Quoted 10 lines
docs/qapi-code-gen.txt +10
-0+# Some text foo with *strong* and _emphasis_ +# 1. with a list +# 2. like that +# +# And some code: +# | $ echo foo +# | -> do this +# | <- get that +# +##
I'd move this to the end of "Documentation annotations".
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 77
Quoted 6 lines
docs/qapi-code-gen.txt +6
-0+ + +==== Documentation annotations ==== + +Documentation lines starting with the following characters and a +space:
What exactly constitutes a "documentation line"? It's actually whatever line the doc comment machinery gets out of the doc comment parsing & mangling, to be passed on to the doc formatting.
The user doesn't want to know about all that crap. We should talk to him in terms of doc comments, because that's what he writes and reads.
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 79
Quoted 2 lines
docs/qapi-code-gen.txt +2
-0+- = are top section title +- == are subsection title
Grammar demands "titles".
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 80
Quoted 1 line
docs/qapi-code-gen.txt +1
-0+- | are examples
Not spelled out, but perhaps obvious enough: a sequence of such lines is *one* example. Peeking at the generator code... hmm, obvious enough or not, it's wrong: each such line is its own example. Doesn't that suck? Could be filed under "deficiencies", for improvement on top.
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 82
Quoted 2 lines
docs/qapi-code-gen.txt +2
-0+- X. or X) are enumerations (X is any number) +- o/*/- are itemized list
What exactly ends a list? Particularly important for enumerations, because their counter gets reset there. Peeking at the code... looks like blank lines followed by a line without markup does. Not so good, see there.
Can lists be nested? Peeking at the code... no.
The forms "X)" and "o " appear not to be used. Let's get rid of them.
Here's my try:
==== Documentation markup ====
Comment text starting with '=' is a section title:
# = Section title
Double the '=' for a subsection title:
# == Subection title
'|' denotes examples:
# | Text of the example, may span
# | multiple lines
'*' starts an itemized list:
# * First item, may span
# multiple lines
# * Second item
You can also use '-' instead of '*'.
A decimal number followed by '.' starts a numbered list:
# 1. First item, may span
# multiple lines
# 2. Second item
The actual number doesn't matter. You could even use '*' instead of '2.' for the second item.
FIXME what exactly ends a list
Additional whitespace between the initial '#' and the comment text is permitted.
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 85
Quoted 3 lines
docs/qapi-code-gen.txt +3
-0+ +*foo* and _foo_ are for strong and emphasis styles respectively (they +do not work over multiple lines). @foo is used to reference a symbol.
Only occurence of "symbol" in this file. Let's say "to reference a name in the schema".
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 88
Quoted 3 lines
docs/qapi-code-gen.txt +3
-0+ +Note: the 'Example' section is processed verbatim (see 'Expression +documentation' below).
Peeking at the generator code... the section text is enclosed in an @example environment. For true verbatim processing, we'd need a @verbatim environment. The easy fix is to explain the formatting of Example sections by reduction to '# |' formatting instead.
Unecessary forward reference: Example sections are not yet defined. Let's move the explanation how they're formatted to their definition. I'll propose something there.
Taking a step back: there are two ways to mark up examples: as Example/Examples section, or as '# |' lines. Feels like a bad language design idea, but it's probably a good "limit the QAPI schema churn in this series" idea. We can get rid of it later.
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 94
Quoted 6 lines
docs/qapi-code-gen.txt +6
-0+ + +==== Free-form documentation ==== + +A free-form documentation isn't immediately followed by an expression, +and is used to provide some additional text and structuring content.
Suggest to move this below the next section, and say:
==== Free-form documentation blocks ====
A documentation block that isn't expression an documentation block is a free-form documentation block. These may be used to provide additional ...
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 99
Quoted 5 lines
docs/qapi-code-gen.txt +5
-0+ + +==== Expression documentation ==== + +An expression must have a preceding comment block defining it.
What about include expressions?
Suggest:
==== Expression documentation blocks ====
Each expression that isn't an include directive must be preceded by a documentation block. Such blocks are called expression documentation blocks.
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 104
Quoted 5 lines
docs/qapi-code-gen.txt +5
-0+ +The first line of the documentation names the expression, then the +documentation body is provided, then individual documentation about +each member of 'data' is provided. Finally, several tagged sections +can be added.
I'm afraid this is more aspiration than specification: the parser accepts these things in almost any order.
Could be filed under "deficiencies" for now.
Member of 'data' won't remain accurate. Consider:
{ 'union': 'GlusterServer',
'base': { 'type': 'GlusterTransport' },
'discriminator': 'type',
'data': { 'unix': 'UnixSocketAddress',
'tcp': 'InetSocketAddress' } }Its doc comment currently doesn't contain argument sections. It should eventually contain @type:, @unix: and @tcp:. Only the latter two are members of 'data'.
I should propose something better, but I'm getting perilously close to the christmas break already. Later.
I don't like the reuse of "section". We already burned that term on the things that start with # = lines. But I don't have a better idea right now.
Quoted 33 lines
docs/qapi-code-gen.txt +33
-0+ +Optional members are tagged with the phrase '#optional', often with +their default value; and extensions added after the expression was +first released are also given a '(since x.y.z)' comment. + +A tagged section starts with one of the following words: +"Note:"/"Notes:", "Since:", "Example"/"Examples", "Returns:". + +A 'Since: x.y.z' tag lists the release that introduced the expression. + +For example: + +## +# @BlockStats: +# +# Statistics of a virtual block device or a block backing device. +# +# @device: #optional If the stats are for a virtual block device, the name +# corresponding to the virtual block device. +# +# @stats: A @BlockDeviceStats for the device. +# +# @parent: #optional This describes the file block device if it has one. +# +# @backing: #optional This describes the backing block device if it has one. +# (Since 2.0) +# +# Since: 0.14.0 +# +# Notes: You can also make a list: +# - with items +# - like this +#
docs/qapi-code-gen.txt Input must be ASCII (although QMP supports full Unicode strings, the · line 147
Quoted 10 lines
docs/qapi-code-gen.txt +10
-0+# Example: +# +# -> { "execute": ... } +# <- { "return": ... } +# +## +{ 'struct': 'BlockStats', + 'data': {'*device': 'str', 'stats': 'BlockDeviceStats', + '*parent': 'BlockStats', + '*backing': 'BlockStats'} }
I don't like this example. It's a type cribbed from block-core.json, with Notes: and Example: thrown in just to show how they're used. Except you'd never use such an example with a type, only with a command.
Instead of cramming this stuff into @BlockStats, why not add the command that uses it?
##
# @BlockStats:
#
# Statistics of a virtual block device or a block backing device. #
# @device: #optional If the stats are for a virtual block device, the name
# corresponding to the virtual block device.
#
# @node-name: #optional The node name of the device. (Since 2.3) #
# ... more members ...
#
# Since: 0.14.0
##
{ 'struct': 'BlockStats',
'data': {'*device': 'str', '*node-name': 'str',
... more members ... } } ##
# @query-blockstats:
#
# Query the @BlockStats for all virtual block devices.
#
# @query-nodes: #optional If true, the command will query all the block nodes
# ... explain, explain ...
# (Since 2.3)
#
# Returns: A list of @BlockStats for each virtual block devices. #
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "query-blockstats" }
# <- {
# ... lots of output ...
# }
#
##
{ 'command': 'query-blockstats',
'data': { '*query-nodes': 'bool' },
'returns': ['BlockStats'] }Quoted 7 lines
docs/qapi-code-gen.txt +3
-0+ + +=== Schema overview === The schema sets up a series of types, as well as commands and events that will use those types. Forward references are allowed: the parser
docs/qapi-code-gen.txt struct in C or an Object in JSON. Each value of the 'data' dictionary · line 269
Quoted 8 lines
docs/qapi-code-gen.txt +1
-1@@ -193,7 +263,7 @@ struct in C or an Object in JSON. Each value of the 'data' dictionary must be the name of a type, or a one-element array containing a type name. An example of a struct is: - { 'struct': 'MyType', +{ 'struct': 'MyType', 'data': { 'member1': 'str', 'member2': 'int', '*member3': 'str' } } The use of '*' as a prefix to the name means the member is optional in
Spurious hunk. Could be dropped on commit.
Quoted 12 lines
tests/qapi-schema/alternate-any.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-any.json:2: Alternate 'Alt' member 'one' cannot use type 'any' +tests/qapi-schema/alternate-any.json:6: Alternate 'Alt' member 'one' cannot use type 'any'tests/qapi-schema/alternate-any.json +0
-0
tests/qapi-schema/alternate-any.json line 5
Quoted 5 lines
tests/qapi-schema/alternate-any.json +4
-0@@ -1,4 +1,8 @@ # we do not allow the 'any' type as an alternate branch + +## +# @Alt: +##
If you need to respin, please consider splitting these off into their own patch, to make this one a smaller bear to review.
Quoted 3,142 lines
tests/qapi-schema/alternate-any.json +0
-0{ 'alternate': 'Alt', 'data': { 'one': 'any', 'two': 'int' } }tests/qapi-schema/alternate-array.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-array.json:5: Member 'two' of alternate 'Alt' cannot be an array +tests/qapi-schema/alternate-array.json:12: Member 'two' of alternate 'Alt' cannot be an arraytests/qapi-schema/alternate-array.json +7
-0@@ -1,7 +1,14 @@ # we do not allow array branches in alternates + +## +# @One: +## # TODO: should we support this? { 'struct': 'One', 'data': { 'name': 'str' } } +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'one': 'One', 'two': [ 'int' ] } }tests/qapi-schema/alternate-base.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-base.json:4: Unknown key 'base' in alternate 'Alt' +tests/qapi-schema/alternate-base.json:11: Unknown key 'base' in alternate 'Alt'tests/qapi-schema/alternate-base.json +7
-0@@ -1,6 +1,13 @@ # we reject alternate with base type + +## +# @Base: +## { 'struct': 'Base', 'data': { 'string': 'str' } } +## +# @Alt: +## { 'alternate': 'Alt', 'base': 'Base', 'data': { 'number': 'int' } }tests/qapi-schema/alternate-clash.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-clash.json:7: 'a_b' (branch of Alt1) collides with 'a-b' (branch of Alt1) +tests/qapi-schema/alternate-clash.json:11: 'a_b' (branch of Alt1) collides with 'a-b' (branch of Alt1)tests/qapi-schema/alternate-clash.json +4
-0@@ -4,5 +4,9 @@ # TODO: In the future, if alternates are simplified to not generate # the implicit Alt1Kind enum, we would still have a collision with the # resulting C union trying to have two members named 'a_b'. + +## +# @Alt1: +## { 'alternate': 'Alt1', 'data': { 'a-b': 'str', 'a_b': 'int' } }tests/qapi-schema/alternate-conflict-dict.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-conflict-dict.json:6: Alternate 'Alt' member 'two' can't be distinguished from member 'one' +tests/qapi-schema/alternate-conflict-dict.json:16: Alternate 'Alt' member 'two' can't be distinguished from member 'one'tests/qapi-schema/alternate-conflict-dict.json +10
-0@@ -1,8 +1,18 @@ # we reject alternates with multiple object branches + +## +# @One: +## { 'struct': 'One', 'data': { 'name': 'str' } } +## +# @Two: +## { 'struct': 'Two', 'data': { 'value': 'int' } } +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'one': 'One', 'two': 'Two' } }tests/qapi-schema/alternate-conflict-string.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-conflict-string.json:4: Alternate 'Alt' member 'two' can't be distinguished from member 'one' +tests/qapi-schema/alternate-conflict-string.json:11: Alternate 'Alt' member 'two' can't be distinguished from member 'one'tests/qapi-schema/alternate-conflict-string.json +7
-0@@ -1,6 +1,13 @@ # we reject alternates with multiple string-like branches + +## +# @Enum: +## { 'enum': 'Enum', 'data': [ 'hello', 'world' ] } +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'one': 'str', 'two': 'Enum' } }tests/qapi-schema/alternate-empty.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-empty.json:2: Alternate 'Alt' should have at least two branches in 'data' +tests/qapi-schema/alternate-empty.json:6: Alternate 'Alt' should have at least two branches in 'data'tests/qapi-schema/alternate-empty.json +4
-0@@ -1,2 +1,6 @@ # alternates must list at least two types to be useful + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'i': 'int' } }tests/qapi-schema/alternate-nested.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-nested.json:4: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1' +tests/qapi-schema/alternate-nested.json:11: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1'tests/qapi-schema/alternate-nested.json +7
-0@@ -1,5 +1,12 @@ # we reject a nested alternate branch + +## +# @Alt1: +## { 'alternate': 'Alt1', 'data': { 'name': 'str', 'value': 'int' } } +## +# @Alt2: +## { 'alternate': 'Alt2', 'data': { 'nested': 'Alt1', 'b': 'bool' } }tests/qapi-schema/alternate-unknown.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/alternate-unknown.json:2: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType' +tests/qapi-schema/alternate-unknown.json:6: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType'tests/qapi-schema/alternate-unknown.json +4
-0@@ -1,3 +1,7 @@ # we reject an alternate with unknown type in branch + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'unknown': 'MissingType', 'i': 'int' } }tests/qapi-schema/args-alternate.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-alternate.json:3: 'data' for command 'oops' cannot use alternate type 'Alt' +tests/qapi-schema/args-alternate.json:11: 'data' for command 'oops' cannot use alternate type 'Alt'tests/qapi-schema/args-alternate.json +8
-0@@ -1,3 +1,11 @@ # we do not allow alternate arguments + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'str' } } + +## +# @oops: +## { 'command': 'oops', 'data': 'Alt' }tests/qapi-schema/args-any.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-any.json:2: 'data' for command 'oops' cannot use built-in type 'any' +tests/qapi-schema/args-any.json:6: 'data' for command 'oops' cannot use built-in type 'any'tests/qapi-schema/args-any.json +4
-0@@ -1,2 +1,6 @@ # we do not allow an 'any' argument + +## +# @oops: +## { 'command': 'oops', 'data': 'any' }tests/qapi-schema/args-array-empty.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-array-empty.json:2: Member 'empty' of 'data' for command 'oops': array type must contain single type name +tests/qapi-schema/args-array-empty.json:6: Member 'empty' of 'data' for command 'oops': array type must contain single type nametests/qapi-schema/args-array-empty.json +4
-0@@ -1,2 +1,6 @@ # we reject an array for data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': { 'empty': [ ] } }tests/qapi-schema/args-array-unknown.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-array-unknown.json:2: Member 'array' of 'data' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-array-unknown.json:6: Member 'array' of 'data' for command 'oops' uses unknown type 'NoSuchType'tests/qapi-schema/args-array-unknown.json +4
-0@@ -1,2 +1,6 @@ # we reject an array for data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': { 'array': [ 'NoSuchType' ] } }tests/qapi-schema/args-bad-boxed.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-bad-boxed.json:2: 'boxed' of command 'foo' should only use true value +tests/qapi-schema/args-bad-boxed.json:6: 'boxed' of command 'foo' should only use true valuetests/qapi-schema/args-bad-boxed.json +4
-0@@ -1,2 +1,6 @@ # 'boxed' should only appear with value true + +## +# @foo: +## { 'command': 'foo', 'boxed': false }tests/qapi-schema/args-boxed-anon.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-boxed-anon.json:2: 'data' for command 'foo' should be a type name +tests/qapi-schema/args-boxed-anon.json:6: 'data' for command 'foo' should be a type nametests/qapi-schema/args-boxed-anon.json +4
-0@@ -1,2 +1,6 @@ # 'boxed' can only be used with named types + +## +# @foo: +## { 'command': 'foo', 'boxed': true, 'data': { 'string': 'str' } }tests/qapi-schema/args-boxed-empty.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-boxed-empty.json:3: Cannot use 'boxed' with empty type +tests/qapi-schema/args-boxed-empty.json:11: Cannot use 'boxed' with empty typetests/qapi-schema/args-boxed-empty.json +8
-0@@ -1,3 +1,11 @@ # 'boxed' requires a non-empty type + +## +# @Empty: +## { 'struct': 'Empty', 'data': {} } + +## +# @foo: +## { 'command': 'foo', 'boxed': true, 'data': 'Empty' }tests/qapi-schema/args-boxed-string.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-boxed-string.json:2: 'data' for command 'foo' cannot use built-in type 'str' +tests/qapi-schema/args-boxed-string.json:6: 'data' for command 'foo' cannot use built-in type 'str'tests/qapi-schema/args-boxed-string.json +4
-0@@ -1,2 +1,6 @@ # 'boxed' requires a complex (not built-in) type + +## +# @foo: +## { 'command': 'foo', 'boxed': true, 'data': 'str' }tests/qapi-schema/args-int.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-int.json:2: 'data' for command 'oops' cannot use built-in type 'int' +tests/qapi-schema/args-int.json:6: 'data' for command 'oops' cannot use built-in type 'int'tests/qapi-schema/args-int.json +4
-0@@ -1,2 +1,6 @@ # we reject commands where data is not an array or complex type + +## +# @oops: +## { 'command': 'oops', 'data': 'int' }tests/qapi-schema/args-invalid.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-invalid.json:1: 'data' for command 'foo' should be a dictionary or type name +tests/qapi-schema/args-invalid.json:4: 'data' for command 'foo' should be a dictionary or type nametests/qapi-schema/args-invalid.json +3
-0@@ -1,2 +1,5 @@ +## +# @foo: +## { 'command': 'foo', 'data': false }tests/qapi-schema/args-member-array-bad.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-member-array-bad.json:2: Member 'member' of 'data' for command 'oops': array type must contain single type name +tests/qapi-schema/args-member-array-bad.json:6: Member 'member' of 'data' for command 'oops': array type must contain single type nametests/qapi-schema/args-member-array-bad.json +4
-0@@ -1,2 +1,6 @@ # we reject data if it does not contain a valid array type + +## +# @oops: +## { 'command': 'oops', 'data': { 'member': [ { 'nested': 'str' } ] } }tests/qapi-schema/args-member-case.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-member-case.json:2: 'Arg' (parameter of no-way-this-will-get-whitelisted) should not use uppercase +tests/qapi-schema/args-member-case.json:6: 'Arg' (parameter of no-way-this-will-get-whitelisted) should not use uppercasetests/qapi-schema/args-member-case.json +4
-0@@ -1,2 +1,6 @@ # Member names should be 'lower-case' unless the struct/command is whitelisted + +## +# @no-way-this-will-get-whitelisted: +## { 'command': 'no-way-this-will-get-whitelisted', 'data': { 'Arg': 'int' } }tests/qapi-schema/args-member-unknown.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-member-unknown.json:2: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-member-unknown.json:6: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType'tests/qapi-schema/args-member-unknown.json +4
-0@@ -1,2 +1,6 @@ # we reject data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': { 'member': 'NoSuchType' } }tests/qapi-schema/args-name-clash.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-name-clash.json:4: 'a_b' (parameter of oops) collides with 'a-b' (parameter of oops) +tests/qapi-schema/args-name-clash.json:8: 'a_b' (parameter of oops) collides with 'a-b' (parameter of oops)tests/qapi-schema/args-name-clash.json +4
-0@@ -1,4 +1,8 @@ # C member name collision # Reject members that clash when mapped to C names (we would have two 'a_b' # members). + +## +# @oops: +## { 'command': 'oops', 'data': { 'a-b': 'str', 'a_b': 'str' } }tests/qapi-schema/args-union.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-union.json:3: 'data' for command 'oops' cannot use union type 'Uni' +tests/qapi-schema/args-union.json:10: 'data' for command 'oops' cannot use union type 'Uni'tests/qapi-schema/args-union.json +7
-0@@ -1,3 +1,10 @@ # use of union arguments requires 'boxed':true + +## +# @Uni: +## { 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } } +## +# oops: +## { 'command': 'oops', 'data': 'Uni' }tests/qapi-schema/args-unknown.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/args-unknown.json:2: 'data' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-unknown.json:6: 'data' for command 'oops' uses unknown type 'NoSuchType'tests/qapi-schema/args-unknown.json +4
-0@@ -1,2 +1,6 @@ # we reject data if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'data': 'NoSuchType' }tests/qapi-schema/bad-base.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/bad-base.json:3: 'base' for struct 'MyType' cannot use union type 'Union' +tests/qapi-schema/bad-base.json:10: 'base' for struct 'MyType' cannot use union type 'Union'tests/qapi-schema/bad-base.json +7
-0@@ -1,3 +1,10 @@ # we reject a base that is not a struct + +## +# @Union: +## { 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } } +## +# @MyType: +## { 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }tests/qapi-schema/bad-data.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/bad-data.json:2: 'data' for command 'oops' cannot be an array +tests/qapi-schema/bad-data.json:6: 'data' for command 'oops' cannot be an arraytests/qapi-schema/bad-data.json +4
-0@@ -1,2 +1,6 @@ # we ensure 'data' is a dictionary for all but enums + +## +# @oops: +## { 'command': 'oops', 'data': [ ] }tests/qapi-schema/bad-ident.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/bad-ident.json:2: 'struct' does not allow optional name '*oops' +tests/qapi-schema/bad-ident.json:6: 'struct' does not allow optional name '*oops'tests/qapi-schema/bad-ident.json +4
-0@@ -1,2 +1,6 @@ # we reject creating a type name with bad name + +## +# @*oops: +## { 'struct': '*oops', 'data': { 'i': 'int' } }tests/qapi-schema/bad-type-bool.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/bad-type-bool.json:2: 'struct' key must have a string value +tests/qapi-schema/bad-type-bool.json:6: 'struct' key must have a string valuetests/qapi-schema/bad-type-bool.json +4
-0@@ -1,2 +1,6 @@ # we reject an expression with a metatype that is not a string + +## +# @true: +## { 'struct': true, 'data': { } }tests/qapi-schema/bad-type-dict.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/bad-type-dict.json:2: 'command' key must have a string value +tests/qapi-schema/bad-type-dict.json:6: 'command' key must have a string valuetests/qapi-schema/bad-type-dict.json +4
-0@@ -1,2 +1,6 @@ # we reject an expression with a metatype that is not a string + +## +# @foo: +## { 'command': { } }tests/qapi-schema/base-cycle-direct.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/base-cycle-direct.json:2: Object Loopy contains itself +tests/qapi-schema/base-cycle-direct.json:6: Object Loopy contains itselftests/qapi-schema/base-cycle-direct.json +4
-0@@ -1,2 +1,6 @@ # we reject a loop in base classes + +## +# @Loopy: +## { 'struct': 'Loopy', 'base': 'Loopy', 'data': {} }tests/qapi-schema/base-cycle-indirect.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/base-cycle-indirect.json:2: Object Base1 contains itself +tests/qapi-schema/base-cycle-indirect.json:6: Object Base1 contains itselftests/qapi-schema/base-cycle-indirect.json +7
-0@@ -1,3 +1,10 @@ # we reject a loop in base classes + +## +# @Base1: +## { 'struct': 'Base1', 'base': 'Base2', 'data': {} } +## +# @Base2: +## { 'struct': 'Base2', 'base': 'Base1', 'data': {} }tests/qapi-schema/command-int.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/command-int.json:2: built-in 'int' is already defined +tests/qapi-schema/command-int.json:6: built-in 'int' is already definedtests/qapi-schema/command-int.json +4
-0@@ -1,2 +1,6 @@ # we reject collisions between commands and types + +## +# @int: +## { 'command': 'int', 'data': { 'character': 'str' } }tests/qapi-schema/comments.json +4
-0@@ -1,4 +1,8 @@ # Unindented comment + +## +# @Status: +## { 'enum': 'Status', # Comment to the right of code # Indented comment 'data': [ 'good', 'bad', 'ugly' ] }tests/qapi-schema/comments.out +3
-0@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +tests/qapi-schema/doc-bad-args.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-args.json:3: Members documentation is not a subset of API ['a', 'b'] > ['a']tests/qapi-schema/doc-bad-args.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-bad-args.json new file +8
-0@@ -0,0 +1,8 @@ +# Arguments listed in the doc comment must exist in the actual schema + +## +# @foo: +# @a: a +# @b: b +## +{ 'command': 'foo', 'data': {'a': 'int'} }tests/qapi-schema/doc-bad-args.out new file +0
-0tests/qapi-schema/doc-bad-section.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-section.json:13:1: Invalid section indentationtests/qapi-schema/doc-bad-section.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-bad-section.json new file +19
-0@@ -0,0 +1,19 @@ +# Comment body must be only at the top of the section + +## +# @TestStruct: +# +# body with @var +# +# @integer: foo +# blah +# +# bao +# +# Let's catch this bad comment. +# +# Since: 2.3 +# +## +{ 'struct': 'TestStruct', + 'data': { 'integer': 'int' } }tests/qapi-schema/doc-bad-section.out new file +0
-0tests/qapi-schema/doc-bad-symbol.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-symbol.json:3: Definition of 'foo' follows documentation for 'food'tests/qapi-schema/doc-bad-symbol.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-bad-symbol.json new file +6
-0@@ -0,0 +1,6 @@ +# Documentation symbol mismatch with expression + +## +# @food: +## +{ 'command': 'foo', 'data': {'a': 'int'} }tests/qapi-schema/doc-bad-symbol.out new file +0
-0tests/qapi-schema/doc-duplicated-arg.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-arg.json:6:1: 'a' parameter name duplicatedtests/qapi-schema/doc-duplicated-arg.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-duplicated-arg.json new file +7
-0@@ -0,0 +1,7 @@ +# Do not allow duplicated argument + +## +# @foo: +# @a: +# @a: +##tests/qapi-schema/doc-duplicated-arg.out new file +0
-0tests/qapi-schema/doc-duplicated-return.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-return.json:7:1: Duplicated 'Returns' sectiontests/qapi-schema/doc-duplicated-return.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-duplicated-return.json new file +8
-0@@ -0,0 +1,8 @@ +# Do not allow duplicated Returns section + +## +# @foo: +# +# Returns: 0 +# Returns: 1 +##tests/qapi-schema/doc-duplicated-return.out new file +0
-0tests/qapi-schema/doc-duplicated-since.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-since.json:7:1: Duplicated 'Since' sectiontests/qapi-schema/doc-duplicated-since.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-duplicated-since.json new file +8
-0@@ -0,0 +1,8 @@ +# Do not allow duplicated Since section + +## +# @foo: +# +# Since: 0 +# Since: 1 +##tests/qapi-schema/doc-duplicated-since.out new file +0
-0tests/qapi-schema/doc-empty-arg.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-arg.json:5:1: Invalid parameter nametests/qapi-schema/doc-empty-arg.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-empty-arg.json new file +6
-0@@ -0,0 +1,6 @@ +# An invalid empty argument name + +## +# @foo: +# @: +##tests/qapi-schema/doc-empty-arg.out new file +0
-0tests/qapi-schema/doc-empty-section.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-section.json:3: Empty doc section 'Note'tests/qapi-schema/doc-empty-section.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-empty-section.json new file +8
-0@@ -0,0 +1,8 @@ +# Tagged-section must not be empty + +## +# @foo: +# +# Note: +## +{ 'command': 'foo', 'data': {'a': 'int'} }tests/qapi-schema/doc-empty-section.out new file +0
-0tests/qapi-schema/doc-empty-symbol.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-symbol.json:4:1: Invalid nametests/qapi-schema/doc-empty-symbol.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-empty-symbol.json new file +5
-0@@ -0,0 +1,5 @@ +# Invalid documentation symbol + +## +# @: +##tests/qapi-schema/doc-empty-symbol.out new file +0
-0tests/qapi-schema/doc-invalid-end.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end.json:5:2: Documentation comment must end with '##'tests/qapi-schema/doc-invalid-end.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-end.json new file +5
-0@@ -0,0 +1,5 @@ +# Documentation must end with '##' + +## +# An invalid comment +#tests/qapi-schema/doc-invalid-end.out new file +0
-0tests/qapi-schema/doc-invalid-end2.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end2.json:5:1: Junk after '##' at end of documentation commenttests/qapi-schema/doc-invalid-end2.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-end2.json new file +5
-0@@ -0,0 +1,5 @@ +# Documentation must end with '##' + +## +# +## invalidtests/qapi-schema/doc-invalid-end2.out new file +0
-0tests/qapi-schema/doc-invalid-return.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-return.json:3: 'Returns:' is only valid for commandstests/qapi-schema/doc-invalid-return.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-return.json new file +7
-0@@ -0,0 +1,7 @@ +# Events can't have 'Returns' section + +## +# @foo: +# Returns: blah +## +{ 'event': 'foo' }tests/qapi-schema/doc-invalid-return.out new file +0
-0tests/qapi-schema/doc-invalid-section.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-section.json:3: Document body cannot contain @NAME: sectionstests/qapi-schema/doc-invalid-section.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-section.json new file +6
-0@@ -0,0 +1,6 @@ +# Free-form documentation doesn't have tagged-sections + +## +# freeform +# @note: foo +##tests/qapi-schema/doc-invalid-section.out new file +0
-0tests/qapi-schema/doc-invalid-start.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-start.json:3:1: Junk after '##' at start of documentation commenttests/qapi-schema/doc-invalid-start.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-start.json new file +5
-0@@ -0,0 +1,5 @@ +# Documentation must start with '##' + +## invalid +# +##tests/qapi-schema/doc-invalid-start.out new file +0
-0tests/qapi-schema/doc-missing-colon.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-colon.json:4:1: Line should end with :tests/qapi-schema/doc-missing-colon.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-missing-colon.json new file +5
-0@@ -0,0 +1,5 @@ +# The symbol section must end with ':' + +## +# @missing-colon +##tests/qapi-schema/doc-missing-colon.out new file +0
-0tests/qapi-schema/doc-missing-expr.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-expr.json:3: Documention for 'bar' is not followed by the definitiontests/qapi-schema/doc-missing-expr.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-missing-expr.json new file +5
-0@@ -0,0 +1,5 @@ +# Expression documentation must be followed by the actual expression + +## +# @bar: +##tests/qapi-schema/doc-missing-expr.out new file +0
-0tests/qapi-schema/doc-missing-space.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-space.json:5:1: Missing space after #tests/qapi-schema/doc-missing-space.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-missing-space.json new file +6
-0@@ -0,0 +1,6 @@ +# Documentation line must have a leading space + +## +# missing space: +#wef +##tests/qapi-schema/doc-missing-space.out new file +0
-0tests/qapi-schema/double-type.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/double-type.json:2: Unknown key 'command' in struct 'bar' +tests/qapi-schema/double-type.json:6: Unknown key 'command' in struct 'bar'tests/qapi-schema/double-type.json +4
-0@@ -1,2 +1,6 @@ # we reject an expression with ambiguous metatype + +## +# @foo: +## { 'command': 'foo', 'struct': 'bar', 'data': { } }tests/qapi-schema/enum-bad-name.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/enum-bad-name.json:2: Member of enum 'MyEnum' uses invalid name 'not^possible' +tests/qapi-schema/enum-bad-name.json:6: Member of enum 'MyEnum' uses invalid name 'not^possible'tests/qapi-schema/enum-bad-name.json +4
-0@@ -1,2 +1,6 @@ # we ensure all enum names can map to C + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ 'not^possible' ] }tests/qapi-schema/enum-bad-prefix.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/enum-bad-prefix.json:2: Enum 'MyEnum' requires a string for 'prefix' +tests/qapi-schema/enum-bad-prefix.json:6: Enum 'MyEnum' requires a string for 'prefix'tests/qapi-schema/enum-bad-prefix.json +4
-0@@ -1,2 +1,6 @@ # The prefix must be a string type + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ 'one' ], 'prefix': [ 'fish' ] }tests/qapi-schema/enum-clash-member.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/enum-clash-member.json:2: 'one_two' (member of MyEnum) collides with 'one-two' (member of MyEnum) +tests/qapi-schema/enum-clash-member.json:6: 'one_two' (member of MyEnum) collides with 'one-two' (member of MyEnum)tests/qapi-schema/enum-clash-member.json +4
-0@@ -1,2 +1,6 @@ # we reject enums where members will clash when mapped to C enum + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ 'one-two', 'one_two' ] }tests/qapi-schema/enum-dict-member.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/enum-dict-member.json:2: Member of enum 'MyEnum' requires a string name +tests/qapi-schema/enum-dict-member.json:6: Member of enum 'MyEnum' requires a string nametests/qapi-schema/enum-dict-member.json +4
-0@@ -1,2 +1,6 @@ # we reject any enum member that is not a string + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] }tests/qapi-schema/enum-member-case.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/enum-member-case.json:3: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase +tests/qapi-schema/enum-member-case.json:10: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercasetests/qapi-schema/enum-member-case.json +7
-0@@ -1,3 +1,10 @@ # Member names should be 'lower-case' unless the enum is whitelisted + +## +# @UuidInfo: +## { 'enum': 'UuidInfo', 'data': [ 'Value' ] } # UuidInfo is whitelisted +## +# @NoWayThisWillGetWhitelisted: +## { 'enum': 'NoWayThisWillGetWhitelisted', 'data': [ 'Value' ] }tests/qapi-schema/enum-missing-data.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/enum-missing-data.json:2: Key 'data' is missing from enum 'MyEnum' +tests/qapi-schema/enum-missing-data.json:6: Key 'data' is missing from enum 'MyEnum'tests/qapi-schema/enum-missing-data.json +4
-0@@ -1,2 +1,6 @@ # we require that all QAPI enums have a data array + +## +# @MyEnum: +## { 'enum': 'MyEnum' }tests/qapi-schema/enum-wrong-data.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/enum-wrong-data.json:2: Enum 'MyEnum' requires an array for 'data' +tests/qapi-schema/enum-wrong-data.json:6: Enum 'MyEnum' requires an array for 'data'tests/qapi-schema/enum-wrong-data.json +4
-0@@ -1,2 +1,6 @@ # we require that all qapi enums have an array for data + +## +# @MyEnum: +## { 'enum': 'MyEnum', 'data': { 'value': 'str' } }tests/qapi-schema/event-boxed-empty.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/event-boxed-empty.json:2: Use of 'boxed' requires 'data' +tests/qapi-schema/event-boxed-empty.json:6: Use of 'boxed' requires 'data'tests/qapi-schema/event-boxed-empty.json +4
-0@@ -1,2 +1,6 @@ # 'boxed' requires a non-empty type + +## +# @FOO: +## { 'event': 'FOO', 'boxed': true }tests/qapi-schema/event-case.json +4
-0@@ -1,3 +1,7 @@ # TODO: might be nice to enforce naming conventions; but until then this works # even though events should usually be ALL_CAPS + +## +# @oops: +## { 'event': 'oops' }tests/qapi-schema/event-case.out +3
-0@@ -3,3 +3,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo event oops None boxed=False object q_empty +doc symbol=oops expr=('event', 'oops') + body= +tests/qapi-schema/event-nest-struct.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/event-nest-struct.json:1: Member 'a' of 'data' for event 'EVENT_A' should be a type name +tests/qapi-schema/event-nest-struct.json:5: Member 'a' of 'data' for event 'EVENT_A' should be a type nametests/qapi-schema/event-nest-struct.json +4
-0@@ -1,2 +1,6 @@ +## +# @EVENT_A: +# event-nest-struct +## { 'event': 'EVENT_A', 'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }tests/qapi-schema/flat-union-array-branch.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-array-branch.json:8: Member 'value1' of union 'TestUnion' cannot be an array +tests/qapi-schema/flat-union-array-branch.json:20: Member 'value1' of union 'TestUnion' cannot be an arraytests/qapi-schema/flat-union-array-branch.json +12
-0@@ -1,10 +1,22 @@ +## +# @TestEnum: +## # we require flat union branches to be a struct { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',tests/qapi-schema/flat-union-bad-base.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-bad-base.json:8: 'string' (member of TestTypeA) collides with 'string' (base of TestUnion) +tests/qapi-schema/flat-union-bad-base.json:21: 'string' (member of TestTypeA) collides with 'string' (base of TestUnion)tests/qapi-schema/flat-union-bad-base.json +13
-0@@ -1,10 +1,23 @@ # we allow anonymous base, but enforce no duplicate keys + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': { 'enum1': 'TestEnum', 'string': 'str' }, 'discriminator': 'enum1',tests/qapi-schema/flat-union-bad-discriminator.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-bad-discriminator.json:11: Discriminator of flat union 'TestUnion' requires a string name +tests/qapi-schema/flat-union-bad-discriminator.json:27: Discriminator of flat union 'TestUnion' requires a string nametests/qapi-schema/flat-union-bad-discriminator.json +16
-0@@ -1,13 +1,29 @@ # we require the discriminator to be a string naming a base-type member # this tests the old syntax for anonymous unions before we added alternates + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum', 'kind': 'str' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': {},tests/qapi-schema/flat-union-base-any.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-base-any.json:8: 'base' for union 'TestUnion' cannot use built-in type 'any' +tests/qapi-schema/flat-union-base-any.json:21: 'base' for union 'TestUnion' cannot use built-in type 'any'tests/qapi-schema/flat-union-base-any.json +13
-0@@ -1,10 +1,23 @@ # we require the base to be an existing struct + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'any', 'discriminator': 'enum1',tests/qapi-schema/flat-union-base-union.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-base-union.json:14: 'base' for union 'TestUnion' cannot use union type 'UnionBase' +tests/qapi-schema/flat-union-base-union.json:30: 'base' for union 'TestUnion' cannot use union type 'UnionBase'tests/qapi-schema/flat-union-base-union.json +16
-0@@ -2,15 +2,31 @@ # TODO: It would be possible to allow a union as a base, as long as all # permutations of QMP names exposed by base do not clash with any QMP # member names added by local variants. + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @UnionBase: +## { 'union': 'UnionBase', 'data': { 'kind1': 'TestTypeA', 'kind2': 'TestTypeB' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'UnionBase', 'discriminator': 'type',tests/qapi-schema/flat-union-clash-member.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-clash-member.json:11: 'name' (member of Branch1) collides with 'name' (member of Base) +tests/qapi-schema/flat-union-clash-member.json:27: 'name' (member of Branch1) collides with 'name' (member of Base)tests/qapi-schema/flat-union-clash-member.json +16
-0@@ -1,13 +1,29 @@ # We check for no duplicate keys between branch members and base # base's member 'name' clashes with Branch1's + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum', '*name': 'str' } } +## +# @Branch1: +## { 'struct': 'Branch1', 'data': { 'name': 'str' } } +## +# @Branch2: +## { 'struct': 'Branch2', 'data': { 'value': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',tests/qapi-schema/flat-union-empty.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-empty.json:4: Union 'Union' cannot have empty 'data' +tests/qapi-schema/flat-union-empty.json:14: Union 'Union' cannot have empty 'data'tests/qapi-schema/flat-union-empty.json +10
-0@@ -1,4 +1,14 @@ # flat unions cannot be empty + +## +# @Empty: +## { 'enum': 'Empty', 'data': [ ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'type': 'Empty' } } +## +# @Union: +## { 'union': 'Union', 'base': 'Base', 'discriminator': 'type', 'data': { } }tests/qapi-schema/flat-union-incomplete-branch.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-incomplete-branch.json:6: Union 'TestUnion' data missing 'value2' branch +tests/qapi-schema/flat-union-incomplete-branch.json:16: Union 'TestUnion' data missing 'value2' branchtests/qapi-schema/flat-union-incomplete-branch.json +10
-0@@ -1,8 +1,18 @@ # we require all branches of the union to be covered + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': { 'type': 'TestEnum' }, 'discriminator': 'type',tests/qapi-schema/flat-union-inline.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-inline.json:7: Member 'value1' of union 'TestUnion' should be a type name +tests/qapi-schema/flat-union-inline.json:17: Member 'value1' of union 'TestUnion' should be a type nametests/qapi-schema/flat-union-inline.json +10
-0@@ -1,9 +1,19 @@ # we require branches to be a struct name # TODO: should we allow anonymous inline branch types? + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum', 'kind': 'str' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',tests/qapi-schema/flat-union-int-branch.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-int-branch.json:8: Member 'value1' of union 'TestUnion' cannot use built-in type 'int' +tests/qapi-schema/flat-union-int-branch.json:21: Member 'value1' of union 'TestUnion' cannot use built-in type 'int'tests/qapi-schema/flat-union-int-branch.json +13
-0@@ -1,10 +1,23 @@ # we require flat union branches to be a struct + +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'discriminator': 'enum1',tests/qapi-schema/flat-union-invalid-branch-key.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-invalid-branch-key.json:13: Discriminator value 'value_wrong' is not found in enum 'TestEnum' +tests/qapi-schema/flat-union-invalid-branch-key.json:28: Discriminator value 'value_wrong' is not found in enum 'TestEnum'tests/qapi-schema/flat-union-invalid-branch-key.json +15
-0@@ -1,15 +1,30 @@ +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': 'enum1',tests/qapi-schema/flat-union-invalid-discriminator.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-invalid-discriminator.json:13: Discriminator 'enum_wrong' is not a member of base struct 'TestBase' +tests/qapi-schema/flat-union-invalid-discriminator.json:28: Discriminator 'enum_wrong' is not a member of base struct 'TestBase'tests/qapi-schema/flat-union-invalid-discriminator.json +15
-0@@ -1,15 +1,30 @@ +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': 'enum_wrong',tests/qapi-schema/flat-union-no-base.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-no-base.json:9: Flat union 'TestUnion' must have a base +tests/qapi-schema/flat-union-no-base.json:22: Flat union 'TestUnion' must have a basetests/qapi-schema/flat-union-no-base.json +13
-0@@ -1,11 +1,24 @@ # flat unions require a base # TODO: simple unions should be able to use an enum discriminator + +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @Enum: +## { 'enum': 'Enum', 'data': [ 'value1', 'value2' ] } +## +# @TestUnion: +## { 'union': 'TestUnion', 'discriminator': 'Enum', 'data': { 'value1': 'TestTypeA',tests/qapi-schema/flat-union-optional-discriminator.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-optional-discriminator.json:6: Discriminator of flat union 'MyUnion' does not allow optional name '*switch' +tests/qapi-schema/flat-union-optional-discriminator.json:19: Discriminator of flat union 'MyUnion' does not allow optional name '*switch'tests/qapi-schema/flat-union-optional-discriminator.json +13
-0@@ -1,8 +1,21 @@ # we require the discriminator to be non-optional + +## +# @Enum: +## { 'enum': 'Enum', 'data': [ 'one', 'two' ] } +## +# @Base: +## { 'struct': 'Base', 'data': { '*switch': 'Enum' } } +## +# @Branch: +## { 'struct': 'Branch', 'data': { 'name': 'str' } } +## +# @MyUnion: +## { 'union': 'MyUnion', 'base': 'Base', 'discriminator': '*switch',tests/qapi-schema/flat-union-string-discriminator.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/flat-union-string-discriminator.json:13: Discriminator 'kind' must be of enumeration type +tests/qapi-schema/flat-union-string-discriminator.json:28: Discriminator 'kind' must be of enumeration typetests/qapi-schema/flat-union-string-discriminator.json +15
-0@@ -1,15 +1,30 @@ +## +# @TestEnum: +## { 'enum': 'TestEnum', 'data': [ 'value1', 'value2' ] } +## +# @TestBase: +## { 'struct': 'TestBase', 'data': { 'enum1': 'TestEnum', 'kind': 'str' } } +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'TestBase', 'discriminator': 'kind',tests/qapi-schema/ident-with-escape.json +4
-0@@ -1,4 +1,8 @@ # we allow escape sequences in strings, if they map back to ASCII # { 'command': 'fooA', 'data': { 'bar1': 'str' } } + +## +# @fooA: +## { 'c\u006fmmand': '\u0066\u006f\u006FA', 'd\u0061ta': { '\u0062\u0061\u00721': '\u0073\u0074\u0072' } }tests/qapi-schema/ident-with-escape.out +3
-0@@ -5,3 +5,6 @@ command fooA q_obj_fooA-arg -> None object q_empty object q_obj_fooA-arg member bar1: str optional=False +doc symbol=fooA expr=('command', 'fooA') + body= +tests/qapi-schema/include-relpath-sub.json +3
-0@@ -1,2 +1,5 @@ +## +# @Status: +## { 'enum': 'Status', 'data': [ 'good', 'bad', 'ugly' ] }tests/qapi-schema/include-relpath.out +3
-0@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +tests/qapi-schema/include-repetition.out +3
-0@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +tests/qapi-schema/include-simple-sub.json +3
-0@@ -1,2 +1,5 @@ +## +# @Status: +## { 'enum': 'Status', 'data': [ 'good', 'bad', 'ugly' ] }tests/qapi-schema/include-simple.out +3
-0@@ -2,3 +2,6 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty +doc symbol=Status expr=('enum', 'Status') + body= +tests/qapi-schema/indented-expr.json +6
-0@@ -1,2 +1,8 @@ +## +# @eins: +## { 'command' : 'eins' } +## +# @zwei: +## { 'command' : 'zwei' }tests/qapi-schema/indented-expr.out +6
-0@@ -5,3 +5,9 @@ command eins None -> None object q_empty command zwei None -> None gen=True success_response=True boxed=False +doc symbol=eins expr=('command', 'eins') + body= + +doc symbol=zwei expr=('command', 'zwei') + body= +tests/qapi-schema/missing-type.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/missing-type.json:2: Expression is missing metatype +tests/qapi-schema/missing-type.json:6: Expression is missing metatypetests/qapi-schema/missing-type.json +4
-0@@ -1,2 +1,6 @@ # we reject an expression with missing metatype + +## +# @foo: +## { 'data': { } }tests/qapi-schema/nested-struct-data.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/nested-struct-data.json:2: Member 'a' of 'data' for command 'foo' should be a type name +tests/qapi-schema/nested-struct-data.json:6: Member 'a' of 'data' for command 'foo' should be a type nametests/qapi-schema/nested-struct-data.json +4
-0@@ -1,3 +1,7 @@ # inline subtypes collide with our desired future use of defaults + +## +# @foo: +## { 'command': 'foo', 'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }tests/qapi-schema/qapi-schema-test.json +213
-0@@ -3,67 +3,153 @@ # This file is a stress test of supported qapi constructs that must # parse and compile correctly. +## +# = Section +# == subsection +# +# Some text foo with *strong* and _emphasis_ +# 1. with a list +# 2. like that @foo +# +# And some code: +# | $ echo foo +# | -> do this +# | <- get that +# +# Note: is not a meta +## + +## +# @TestStruct: +# +# body with @var +# +# @integer: foo +# blah +# +# bao +# +# @boolean: bar +# @string: baz +# +# Example: +# +# -> { "execute": ... } +# <- { "return": ... } +# +# Since: 2.3 +# Note: a note +# +## { 'struct': 'TestStruct', 'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } } +## +# @NestedEnumsOne: # for testing enums +## { 'struct': 'NestedEnumsOne', 'data': { 'enum1': 'EnumOne', # Intentional forward reference '*enum2': 'EnumOne', 'enum3': 'EnumOne', '*enum4': 'EnumOne' } } +## +# @MyEnum: # An empty enum, although unusual, is currently acceptable +## { 'enum': 'MyEnum', 'data': [ ] } +## +# @Empty1: # Likewise for an empty struct, including an empty base +## { 'struct': 'Empty1', 'data': { } } +## +# @Empty2: +## { 'struct': 'Empty2', 'base': 'Empty1', 'data': { } } +## +# @user_def_cmd0: +## { 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' } +## +# @QEnumTwo: # for testing override of default naming heuristic +## { 'enum': 'QEnumTwo', 'prefix': 'QENUM_TWO', 'data': [ 'value1', 'value2' ] } +## +# @UserDefOne: # for testing nested structs +## { 'struct': 'UserDefOne', 'base': 'UserDefZero', # intentional forward reference 'data': { 'string': 'str', '*enum1': 'EnumOne' } } # intentional forward reference +## +# @EnumOne: +## { 'enum': 'EnumOne', 'data': [ 'value1', 'value2', 'value3' ] } +## +# @UserDefZero: +## { 'struct': 'UserDefZero', 'data': { 'integer': 'int' } } +## +# @UserDefTwoDictDict: +## { 'struct': 'UserDefTwoDictDict', 'data': { 'userdef': 'UserDefOne', 'string': 'str' } } +## +# @UserDefTwoDict: +## { 'struct': 'UserDefTwoDict', 'data': { 'string1': 'str', 'dict2': 'UserDefTwoDictDict', '*dict3': 'UserDefTwoDictDict' } } +## +# @UserDefTwo: +## { 'struct': 'UserDefTwo', 'data': { 'string0': 'str', 'dict1': 'UserDefTwoDict' } } +## +# @ForceArrays: # dummy struct to force generation of array types not otherwise mentioned +## { 'struct': 'ForceArrays', 'data': { 'unused1':['UserDefOne'], 'unused2':['UserDefTwo'], 'unused3':['TestStruct'] } } +## +# @UserDefA: # for testing unions # Among other things, test that a name collision between branches does # not cause any problems (since only one branch can be in use at a time), # by intentionally using two branches that both have a C member 'a_b' +## { 'struct': 'UserDefA', 'data': { 'boolean': 'bool', '*a_b': 'int' } } +## +# @UserDefB: +## { 'struct': 'UserDefB', 'data': { 'intb': 'int', '*a-b': 'bool' } } +## +# @UserDefFlatUnion: +## { 'union': 'UserDefFlatUnion', 'base': 'UserDefUnionBase', # intentional forward reference 'discriminator': 'enum1',@@ -71,35 +157,71 @@ 'value2' : 'UserDefB', 'value3' : 'UserDefB' } } +## +# @UserDefUnionBase: +## { 'struct': 'UserDefUnionBase', 'base': 'UserDefZero', 'data': { 'string': 'str', 'enum1': 'EnumOne' } } +## +# @UserDefFlatUnion2: # this variant of UserDefFlatUnion defaults to a union that uses members with # allocated types to test corner cases in the cleanup/dealloc visitor +## { 'union': 'UserDefFlatUnion2', 'base': { '*integer': 'int', 'string': 'str', 'enum1': 'QEnumTwo' }, 'discriminator': 'enum1', 'data': { 'value1' : 'UserDefC', # intentional forward reference 'value2' : 'UserDefB' } } +## +# @WrapAlternate: +## { 'struct': 'WrapAlternate', 'data': { 'alt': 'UserDefAlternate' } } +## +# @UserDefAlternate: +## { 'alternate': 'UserDefAlternate', 'data': { 'udfu': 'UserDefFlatUnion', 's': 'str', 'i': 'int' } } +## +# @UserDefC: +## { 'struct': 'UserDefC', 'data': { 'string1': 'str', 'string2': 'str' } } # for testing use of 'number' within alternates +## +# @AltStrBool: +## { 'alternate': 'AltStrBool', 'data': { 's': 'str', 'b': 'bool' } } +## +# @AltStrNum: +## { 'alternate': 'AltStrNum', 'data': { 's': 'str', 'n': 'number' } } +## +# @AltNumStr: +## { 'alternate': 'AltNumStr', 'data': { 'n': 'number', 's': 'str' } } +## +# @AltStrInt: +## { 'alternate': 'AltStrInt', 'data': { 's': 'str', 'i': 'int' } } +## +# @AltIntNum: +## { 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } } +## +# @AltNumInt: +## { 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } } +## +# @UserDefNativeListUnion: # for testing native lists +## { 'union': 'UserDefNativeListUnion', 'data': { 'integer': ['int'], 's8': ['int8'],@@ -117,19 +239,61 @@ 'any': ['any'] } } # testing commands +## +# @user_def_cmd: +## { 'command': 'user_def_cmd', 'data': {} } +## +# @user_def_cmd1: +## { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} } +## +# @user_def_cmd2: +## { 'command': 'user_def_cmd2', 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } +## +# Another comment +## + +## +# @guest-get-time: +# +# @guest-get-time body +# +# @a: an integer +# @b: #optional integer +# +# Returns: returns something +# +# Example: +# +# -> { "execute": "guest-get-time", ... } +# <- { "return": "42" } +# +## + # Returning a non-dictionary requires a name from the whitelist { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' }, 'returns': 'int' } +## +# @guest-sync: +## { 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } +## +# @boxed-struct: +## { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' } +## +# @boxed-union: +## { 'command': 'boxed-union', 'data': 'UserDefNativeListUnion', 'boxed': true } +## +# @UserDefOptions: +# # For testing integer range flattening in opts-visitor. The following schema # corresponds to the option format: #@@ -137,6 +301,7 @@ # # For simplicity, this example doesn't use [type=]discriminator nor optargs # specific to discriminator values. +## { 'struct': 'UserDefOptions', 'data': { '*i64' : [ 'int' ],@@ -146,35 +311,83 @@ '*u64x': 'uint64' } } # testing event +## +# @EventStructOne: +## { 'struct': 'EventStructOne', 'data': { 'struct1': 'UserDefOne', 'string': 'str', '*enum2': 'EnumOne' } } +## +# @EVENT_A: +## { 'event': 'EVENT_A' } +## +# @EVENT_B: +## { 'event': 'EVENT_B', 'data': { } } +## +# @EVENT_C: +## { 'event': 'EVENT_C', 'data': { '*a': 'int', '*b': 'UserDefOne', 'c': 'str' } } +## +# @EVENT_D: +## { 'event': 'EVENT_D', 'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } } +## +# @EVENT_E: +## { 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' } +## +# @EVENT_F: +## { 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefAlternate' } # test that we correctly compile downstream extensions, as well as munge # ticklish names +## +# @__org.qemu_x-Enum: +## { 'enum': '__org.qemu_x-Enum', 'data': [ '__org.qemu_x-value' ] } +## +# @__org.qemu_x-Base: +## { 'struct': '__org.qemu_x-Base', 'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } } +## +# @__org.qemu_x-Struct: +## { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base', 'data': { '__org.qemu_x-member2': 'str', '*wchar-t': 'int' } } +## +# @__org.qemu_x-Union1: +## { 'union': '__org.qemu_x-Union1', 'data': { '__org.qemu_x-branch': 'str' } } +## +# @__org.qemu_x-Struct2: +## { 'struct': '__org.qemu_x-Struct2', 'data': { 'array': ['__org.qemu_x-Union1'] } } +## +# @__org.qemu_x-Union2: +## { 'union': '__org.qemu_x-Union2', 'base': '__org.qemu_x-Base', 'discriminator': '__org.qemu_x-member1', 'data': { '__org.qemu_x-value': '__org.qemu_x-Struct2' } } +## +# @__org.qemu_x-Alt: +## { 'alternate': '__org.qemu_x-Alt', 'data': { '__org.qemu_x-branch': 'str', 'b': '__org.qemu_x-Base' } } +## +# @__ORG.QEMU_X-EVENT: +## { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' } +## +# @__org.qemu_x-command: +## { 'command': '__org.qemu_x-command', 'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'], 'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' },tests/qapi-schema/qapi-schema-test.out +212
-0@@ -232,3 +232,215 @@ command user_def_cmd1 q_obj_user_def_cmd1-arg -> None gen=True success_response=True boxed=False command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo gen=True success_response=True boxed=False +doc freeform + body= += Section +== subsection + +Some text foo with *strong* and _emphasis_ +1. with a list +2. like that @foo + +And some code: +| $ echo foo +| -> do this +| <- get that + +Note: is not a meta +doc symbol=TestStruct expr=('struct', 'TestStruct') + arg=integer +foo +blah + +bao + arg=boolean +bar + arg=string +baz + section=Example +-> { "execute": ... } +<- { "return": ... } + section=Since +2.3 + section=Note +a note + body= +body with @var +doc symbol=NestedEnumsOne expr=('struct', 'NestedEnumsOne') + body= +for testing enums +doc symbol=MyEnum expr=('enum', 'MyEnum') + body= +An empty enum, although unusual, is currently acceptable +doc symbol=Empty1 expr=('struct', 'Empty1') + body= +Likewise for an empty struct, including an empty base +doc symbol=Empty2 expr=('struct', 'Empty2') + body= + +doc symbol=user_def_cmd0 expr=('command', 'user_def_cmd0') + body= + +doc symbol=QEnumTwo expr=('enum', 'QEnumTwo') + body= +for testing override of default naming heuristic +doc symbol=UserDefOne expr=('struct', 'UserDefOne') + body= +for testing nested structs +doc symbol=EnumOne expr=('enum', 'EnumOne') + body= + +doc symbol=UserDefZero expr=('struct', 'UserDefZero') + body= + +doc symbol=UserDefTwoDictDict expr=('struct', 'UserDefTwoDictDict') + body= + +doc symbol=UserDefTwoDict expr=('struct', 'UserDefTwoDict') + body= + +doc symbol=UserDefTwo expr=('struct', 'UserDefTwo') + body= + +doc symbol=ForceArrays expr=('struct', 'ForceArrays') + body= +dummy struct to force generation of array types not otherwise mentioned +doc symbol=UserDefA expr=('struct', 'UserDefA') + body= +for testing unions +Among other things, test that a name collision between branches does +not cause any problems (since only one branch can be in use at a time), +by intentionally using two branches that both have a C member 'a_b' +doc symbol=UserDefB expr=('struct', 'UserDefB') + body= + +doc symbol=UserDefFlatUnion expr=('union', 'UserDefFlatUnion') + body= + +doc symbol=UserDefUnionBase expr=('struct', 'UserDefUnionBase') + body= + +doc symbol=UserDefFlatUnion2 expr=('union', 'UserDefFlatUnion2') + body= +this variant of UserDefFlatUnion defaults to a union that uses members with +allocated types to test corner cases in the cleanup/dealloc visitor +doc symbol=WrapAlternate expr=('struct', 'WrapAlternate') + body= + +doc symbol=UserDefAlternate expr=('alternate', 'UserDefAlternate') + body= + +doc symbol=UserDefC expr=('struct', 'UserDefC') + body= + +doc symbol=AltStrBool expr=('alternate', 'AltStrBool') + body= + +doc symbol=AltStrNum expr=('alternate', 'AltStrNum') + body= + +doc symbol=AltNumStr expr=('alternate', 'AltNumStr') + body= + +doc symbol=AltStrInt expr=('alternate', 'AltStrInt') + body= + +doc symbol=AltIntNum expr=('alternate', 'AltIntNum') + body= + +doc symbol=AltNumInt expr=('alternate', 'AltNumInt') + body= + +doc symbol=UserDefNativeListUnion expr=('union', 'UserDefNativeListUnion') + body= +for testing native lists +doc symbol=user_def_cmd expr=('command', 'user_def_cmd') + body= + +doc symbol=user_def_cmd1 expr=('command', 'user_def_cmd1') + body= + +doc symbol=user_def_cmd2 expr=('command', 'user_def_cmd2') + body= + +doc freeform + body= +Another comment +doc symbol=guest-get-time expr=('command', 'guest-get-time') + arg=a +an integer + arg=b +#optional integer + section=Returns +returns something + section=Example +-> { "execute": "guest-get-time", ... } +<- { "return": "42" } + body= +@guest-get-time body +doc symbol=guest-sync expr=('command', 'guest-sync') + body= + +doc symbol=boxed-struct expr=('command', 'boxed-struct') + body= + +doc symbol=boxed-union expr=('command', 'boxed-union') + body= + +doc symbol=UserDefOptions expr=('struct', 'UserDefOptions') + body= +For testing integer range flattening in opts-visitor. The following schema +corresponds to the option format: + +-userdef i64=3-6,i64=-5--1,u64=2,u16=1,u16=7-12 + +For simplicity, this example doesn't use [type=]discriminator nor optargs +specific to discriminator values. +doc symbol=EventStructOne expr=('struct', 'EventStructOne') + body= + +doc symbol=EVENT_A expr=('event', 'EVENT_A') + body= + +doc symbol=EVENT_B expr=('event', 'EVENT_B') + body= + +doc symbol=EVENT_C expr=('event', 'EVENT_C') + body= + +doc symbol=EVENT_D expr=('event', 'EVENT_D') + body= + +doc symbol=EVENT_E expr=('event', 'EVENT_E') + body= + +doc symbol=EVENT_F expr=('event', 'EVENT_F') + body= + +doc symbol=__org.qemu_x-Enum expr=('enum', '__org.qemu_x-Enum') + body= + +doc symbol=__org.qemu_x-Base expr=('struct', '__org.qemu_x-Base') + body= + +doc symbol=__org.qemu_x-Struct expr=('struct', '__org.qemu_x-Struct') + body= + +doc symbol=__org.qemu_x-Union1 expr=('union', '__org.qemu_x-Union1') + body= + +doc symbol=__org.qemu_x-Struct2 expr=('struct', '__org.qemu_x-Struct2') + body= + +doc symbol=__org.qemu_x-Union2 expr=('union', '__org.qemu_x-Union2') + body= + +doc symbol=__org.qemu_x-Alt expr=('alternate', '__org.qemu_x-Alt') + body= + +doc symbol=__ORG.QEMU_X-EVENT expr=('event', '__ORG.QEMU_X-EVENT') + body= + +doc symbol=__org.qemu_x-command expr=('command', '__org.qemu_x-command') + body= +tests/qapi-schema/redefined-builtin.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/redefined-builtin.json:2: built-in 'size' is already defined +tests/qapi-schema/redefined-builtin.json:6: built-in 'size' is already definedtests/qapi-schema/redefined-builtin.json +4
-0@@ -1,2 +1,6 @@ # we reject types that duplicate builtin names + +## +# @size: +## { 'struct': 'size', 'data': { 'myint': 'size' } }tests/qapi-schema/redefined-command.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/redefined-command.json:3: command 'foo' is already defined +tests/qapi-schema/redefined-command.json:10: command 'foo' is already definedtests/qapi-schema/redefined-command.json +7
-0@@ -1,3 +1,10 @@ # we reject commands defined more than once + +## +# @foo: +## { 'command': 'foo', 'data': { 'one': 'str' } } +## +# @foo: +## { 'command': 'foo', 'data': { '*two': 'str' } }tests/qapi-schema/redefined-event.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/redefined-event.json:3: event 'EVENT_A' is already defined +tests/qapi-schema/redefined-event.json:10: event 'EVENT_A' is already definedtests/qapi-schema/redefined-event.json +7
-0@@ -1,3 +1,10 @@ # we reject duplicate events + +## +# @EVENT_A: +## { 'event': 'EVENT_A', 'data': { 'myint': 'int' } } +## +# @EVENT_A: +## { 'event': 'EVENT_A', 'data': { 'myint': 'int' } }tests/qapi-schema/redefined-type.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/redefined-type.json:3: struct 'foo' is already defined +tests/qapi-schema/redefined-type.json:10: struct 'foo' is already definedtests/qapi-schema/redefined-type.json +7
-0@@ -1,3 +1,10 @@ # we reject types defined more than once + +## +# @foo: +## { 'struct': 'foo', 'data': { 'one': 'str' } } +## +# @foo: +## { 'enum': 'foo', 'data': [ 'two' ] }tests/qapi-schema/reserved-command-q.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-command-q.json:5: 'command' uses invalid name 'q-unix' +tests/qapi-schema/reserved-command-q.json:12: 'command' uses invalid name 'q-unix'tests/qapi-schema/reserved-command-q.json +7
-0@@ -1,5 +1,12 @@ # C entity name collision # We reject names like 'q-unix', because they can collide with the mangled # name for 'unix' in generated C. + +## +# @unix: +## { 'command': 'unix' } +## +# @q-unix: +## { 'command': 'q-unix' }tests/qapi-schema/reserved-enum-q.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-enum-q.json:4: Member of enum 'Foo' uses invalid name 'q-Unix' +tests/qapi-schema/reserved-enum-q.json:8: Member of enum 'Foo' uses invalid name 'q-Unix'tests/qapi-schema/reserved-enum-q.json +4
-0@@ -1,4 +1,8 @@ # C entity name collision # We reject names like 'q-unix', because they can collide with the mangled # name for 'unix' in generated C. + +## +# @Foo: +## { 'enum': 'Foo', 'data': [ 'unix', 'q-Unix' ] }tests/qapi-schema/reserved-member-has.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-member-has.json:5: Member of 'data' for command 'oops' uses reserved name 'has-a' +tests/qapi-schema/reserved-member-has.json:9: Member of 'data' for command 'oops' uses reserved name 'has-a'tests/qapi-schema/reserved-member-has.json +4
-0@@ -2,4 +2,8 @@ # We reject names like 'has-a', because they can collide with the flag # for an optional 'a' in generated C. # TODO we could munge the optional flag name to avoid the collision. + +## +# @oops: +## { 'command': 'oops', 'data': { '*a': 'str', 'has-a': 'str' } }tests/qapi-schema/reserved-member-q.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-member-q.json:4: Member of 'data' for struct 'Foo' uses invalid name 'q-unix' +tests/qapi-schema/reserved-member-q.json:8: Member of 'data' for struct 'Foo' uses invalid name 'q-unix'tests/qapi-schema/reserved-member-q.json +4
-0@@ -1,4 +1,8 @@ # C member name collision # We reject names like 'q-unix', because they can collide with the mangled # name for 'unix' in generated C. + +## +# @Foo: +## { 'struct': 'Foo', 'data': { 'unix':'int', 'q-unix':'bool' } }tests/qapi-schema/reserved-member-u.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-member-u.json:7: Member of 'data' for struct 'Oops' uses reserved name 'u' +tests/qapi-schema/reserved-member-u.json:11: Member of 'data' for struct 'Oops' uses reserved name 'u'tests/qapi-schema/reserved-member-u.json +4
-0@@ -4,4 +4,8 @@ # This is true even for non-unions, because it is possible to convert a # struct to flat union while remaining backwards compatible in QMP. # TODO - we could munge the member name to 'q_u' to avoid the collision + +## +# @Oops: +## { 'struct': 'Oops', 'data': { 'u': 'str' } }tests/qapi-schema/reserved-member-underscore.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-member-underscore.json:4: Member of 'data' for struct 'Oops' uses invalid name '_oops' +tests/qapi-schema/reserved-member-underscore.json:8: Member of 'data' for struct 'Oops' uses invalid name '_oops'tests/qapi-schema/reserved-member-underscore.json +4
-0@@ -1,4 +1,8 @@ # C member name collision # We reject use of a single leading underscore in all names (names must # begin with a letter or a downstream extension double-underscore prefix). + +## +# @Oops: +## { 'struct': 'Oops', 'data': { '_oops': 'str' } }tests/qapi-schema/reserved-type-kind.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-type-kind.json:2: enum 'UnionKind' should not end in 'Kind' +tests/qapi-schema/reserved-type-kind.json:6: enum 'UnionKind' should not end in 'Kind'tests/qapi-schema/reserved-type-kind.json +4
-0@@ -1,2 +1,6 @@ # we reject types that would conflict with implicit union enum + +## +# @UnionKind: +## { 'enum': 'UnionKind', 'data': [ 'oops' ] }tests/qapi-schema/reserved-type-list.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/reserved-type-list.json:5: struct 'FooList' should not end in 'List' +tests/qapi-schema/reserved-type-list.json:9: struct 'FooList' should not end in 'List'tests/qapi-schema/reserved-type-list.json +4
-0@@ -2,4 +2,8 @@ # We reserve names ending in 'List' for use by array types. # TODO - we could choose array names to avoid collision with user types, # in order to let this compile + +## +# @FooList: +## { 'struct': 'FooList', 'data': { 's': 'str' } }tests/qapi-schema/returns-alternate.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/returns-alternate.json:3: 'returns' for command 'oops' cannot use alternate type 'Alt' +tests/qapi-schema/returns-alternate.json:10: 'returns' for command 'oops' cannot use alternate type 'Alt'tests/qapi-schema/returns-alternate.json +7
-0@@ -1,3 +1,10 @@ # we reject returns if it is an alternate type + +## +# @Alt: +## { 'alternate': 'Alt', 'data': { 'a': 'int', 'b': 'str' } } +## +# @oops: +## { 'command': 'oops', 'returns': 'Alt' }tests/qapi-schema/returns-array-bad.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/returns-array-bad.json:2: 'returns' for command 'oops': array type must contain single type name +tests/qapi-schema/returns-array-bad.json:6: 'returns' for command 'oops': array type must contain single type nametests/qapi-schema/returns-array-bad.json +4
-0@@ -1,2 +1,6 @@ # we reject an array return that is not a single type + +## +# @oops: +## { 'command': 'oops', 'returns': [ 'str', 'str' ] }tests/qapi-schema/returns-dict.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/returns-dict.json:2: 'returns' for command 'oops' should be a type name +tests/qapi-schema/returns-dict.json:6: 'returns' for command 'oops' should be a type nametests/qapi-schema/returns-dict.json +4
-0@@ -1,2 +1,6 @@ # we reject inline struct return type + +## +# @oops: +## { 'command': 'oops', 'returns': { 'a': 'str' } }tests/qapi-schema/returns-unknown.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/returns-unknown.json:2: 'returns' for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/returns-unknown.json:6: 'returns' for command 'oops' uses unknown type 'NoSuchType'tests/qapi-schema/returns-unknown.json +4
-0@@ -1,2 +1,6 @@ # we reject returns if it does not contain a known type + +## +# @oops: +## { 'command': 'oops', 'returns': 'NoSuchType' }tests/qapi-schema/returns-whitelist.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/returns-whitelist.json:10: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int' +tests/qapi-schema/returns-whitelist.json:26: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int'tests/qapi-schema/returns-whitelist.json +16
-0@@ -1,11 +1,27 @@ # we enforce that 'returns' be a dict or array of dict unless whitelisted + +## +# @human-monitor-command: +## { 'command': 'human-monitor-command', 'data': {'command-line': 'str', '*cpu-index': 'int'}, 'returns': 'str' } +## +# @TpmModel: +## { 'enum': 'TpmModel', 'data': [ 'tpm-tis' ] } +## +# @query-tpm-models: +## { 'command': 'query-tpm-models', 'returns': ['TpmModel'] } +## +# @guest-get-time: +## { 'command': 'guest-get-time', 'returns': 'int' } +## +# @no-way-this-will-get-whitelisted: +## { 'command': 'no-way-this-will-get-whitelisted', 'returns': [ 'int' ] }tests/qapi-schema/struct-base-clash-deep.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/struct-base-clash-deep.json:10: 'name' (member of Sub) collides with 'name' (member of Base) +tests/qapi-schema/struct-base-clash-deep.json:20: 'name' (member of Sub) collides with 'name' (member of Base)tests/qapi-schema/struct-base-clash-deep.json +10
-0@@ -2,11 +2,21 @@ # Here, 'name' would have to appear twice on the wire, locally and # indirectly for the grandparent base; the collision doesn't care that # one instance is optional. + +## +# @Base: +## { 'struct': 'Base', 'data': { 'name': 'str' } } +## +# @Mid: +## { 'struct': 'Mid', 'base': 'Base', 'data': { 'value': 'int' } } +## +# @Sub: +## { 'struct': 'Sub', 'base': 'Mid', 'data': { '*name': 'str' } }tests/qapi-schema/struct-base-clash.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/struct-base-clash.json:5: 'name' (member of Sub) collides with 'name' (member of Base) +tests/qapi-schema/struct-base-clash.json:12: 'name' (member of Sub) collides with 'name' (member of Base)tests/qapi-schema/struct-base-clash.json +7
-0@@ -1,7 +1,14 @@ # Reject attempts to duplicate QMP members # Here, 'name' would have to appear twice on the wire, locally and for base. + +## +# @Base: +## { 'struct': 'Base', 'data': { 'name': 'str' } } +## +# @Sub: +## { 'struct': 'Sub', 'base': 'Base', 'data': { 'name': 'str' } }tests/qapi-schema/struct-data-invalid.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/struct-data-invalid.json:1: 'data' for struct 'foo' should be a dictionary or type name +tests/qapi-schema/struct-data-invalid.json:4: 'data' for struct 'foo' should be a dictionary or type nametests/qapi-schema/struct-data-invalid.json +3
-0@@ -1,2 +1,5 @@ +## +# @foo: +## { 'struct': 'foo', 'data': false }tests/qapi-schema/struct-member-invalid.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/struct-member-invalid.json:1: Member 'a' of 'data' for struct 'foo' should be a type name +tests/qapi-schema/struct-member-invalid.json:4: Member 'a' of 'data' for struct 'foo' should be a type nametests/qapi-schema/struct-member-invalid.json +3
-0@@ -1,2 +1,5 @@ +## +# @foo: +## { 'struct': 'foo', 'data': { 'a': false } }tests/qapi-schema/test-qapi.py +2
-0@@ -55,3 +55,15 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): schema = QAPISchema(sys.argv[1]) schema.visit(QAPISchemaTestVisitor()) + +for doc in schema.docs:
tests/qapi-schema/test-qapi.py class QAPISchemaTestVisitor(QAPISchemaVisitor): · line 69
Quoted 10 lines
tests/qapi-schema/test-qapi.py +10
-0+ if doc.symbol: + print 'doc symbol=%s expr=%s' % \ + (doc.symbol, doc.expr.items()[0]) + else: + print 'doc freeform' + for arg, section in doc.args.iteritems(): + print ' arg=%s\n%s' % (arg, section) + for section in doc.sections: + print ' section=%s\n%s' % (section.name, section) + print ' body=\n%s' % doc.body
This line seems to responsible for trailing blank lines in .out:
Applying: qapi: add qapi2texi script /home/armbru/work/qemu/.git/rebase-apply/patch:1869: new blank line at EOF. +
/home/armbru/work/qemu/.git/rebase-apply/patch:2568: new blank line at EOF. +
/home/armbru/work/qemu/.git/rebase-apply/patch:3156: new blank line at EOF. +
/home/armbru/work/qemu/.git/rebase-apply/patch:3177: new blank line at EOF. +
/home/armbru/work/qemu/.git/rebase-apply/patch:3188: new blank line at EOF. +
warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.
Quoted 236 lines
tests/qapi-schema/type-bypass-bad-gen.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/type-bypass-bad-gen.json:2: 'gen' of command 'foo' should only use false value +tests/qapi-schema/type-bypass-bad-gen.json:6: 'gen' of command 'foo' should only use false valuetests/qapi-schema/type-bypass-bad-gen.json +4
-0@@ -1,2 +1,6 @@ # 'gen' should only appear with value false + +## +# @foo: +## { 'command': 'foo', 'gen': 'whatever' }tests/qapi-schema/unicode-str.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/unicode-str.json:2: 'command' uses invalid name 'é' +tests/qapi-schema/unicode-str.json:6: 'command' uses invalid name 'é'tests/qapi-schema/unicode-str.json +4
-0@@ -1,2 +1,6 @@ # we don't support full Unicode strings, yet + +## +# @e: +## { 'command': 'é' }tests/qapi-schema/union-base-no-discriminator.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/union-base-no-discriminator.json:11: Simple union 'TestUnion' must not have a base +tests/qapi-schema/union-base-no-discriminator.json:23: Simple union 'TestUnion' must not have a basetests/qapi-schema/union-base-no-discriminator.json +12
-0@@ -1,13 +1,25 @@ +## +# @TestTypeA: +## # we reject simple unions with a base (or flat unions without discriminator) { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @Base: +## { 'struct': 'Base', 'data': { 'string': 'str' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'Base', 'data': { 'value1': 'TestTypeA',tests/qapi-schema/union-branch-case.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/union-branch-case.json:2: 'Branch' (branch of NoWayThisWillGetWhitelisted) should not use uppercase +tests/qapi-schema/union-branch-case.json:6: 'Branch' (branch of NoWayThisWillGetWhitelisted) should not use uppercasetests/qapi-schema/union-branch-case.json +4
-0@@ -1,2 +1,6 @@ # Branch names should be 'lower-case' unless the union is whitelisted + +## +# @NoWayThisWillGetWhitelisted: +## { 'union': 'NoWayThisWillGetWhitelisted', 'data': { 'Branch': 'int' } }tests/qapi-schema/union-clash-branches.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/union-clash-branches.json:4: 'a_b' (branch of TestUnion) collides with 'a-b' (branch of TestUnion) +tests/qapi-schema/union-clash-branches.json:8: 'a_b' (branch of TestUnion) collides with 'a-b' (branch of TestUnion)tests/qapi-schema/union-clash-branches.json +4
-0@@ -1,5 +1,9 @@ # Union branch name collision # Reject a union that would result in a collision in generated C names (this # would try to generate two members 'a_b'). + +## +# @TestUnion: +## { 'union': 'TestUnion', 'data': { 'a-b': 'int', 'a_b': 'str' } }tests/qapi-schema/union-empty.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/union-empty.json:2: Union 'Union' cannot have empty 'data' +tests/qapi-schema/union-empty.json:6: Union 'Union' cannot have empty 'data'tests/qapi-schema/union-empty.json +4
-0@@ -1,2 +1,6 @@ # unions cannot be empty + +## +# @Union: +## { 'union': 'Union', 'data': { } }tests/qapi-schema/union-invalid-base.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/union-invalid-base.json:8: 'base' for union 'TestUnion' cannot use built-in type 'int' +tests/qapi-schema/union-invalid-base.json:18: 'base' for union 'TestUnion' cannot use built-in type 'int'tests/qapi-schema/union-invalid-base.json +10
-0@@ -1,10 +1,20 @@ # a union base type must be a struct + +## +# @TestTypeA: +## { 'struct': 'TestTypeA', 'data': { 'string': 'str' } } +## +# @TestTypeB: +## { 'struct': 'TestTypeB', 'data': { 'integer': 'int' } } +## +# @TestUnion: +## { 'union': 'TestUnion', 'base': 'int', 'discriminator': 'int',tests/qapi-schema/union-optional-branch.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/union-optional-branch.json:2: Member of union 'Union' does not allow optional name '*a' +tests/qapi-schema/union-optional-branch.json:6: Member of union 'Union' does not allow optional name '*a'tests/qapi-schema/union-optional-branch.json +4
-0@@ -1,2 +1,6 @@ # union branches cannot be optional + +## +# @Union: +## { 'union': 'Union', 'data': { '*a': 'int', 'b': 'str' } }tests/qapi-schema/union-unknown.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/union-unknown.json:2: Member 'unknown' of union 'Union' uses unknown type 'MissingType' +tests/qapi-schema/union-unknown.json:6: Member 'unknown' of union 'Union' uses unknown type 'MissingType'tests/qapi-schema/union-unknown.json +4
-0@@ -1,3 +1,7 @@ # we reject a union with unknown type in branch + +## +# @Union: +## { 'union': 'Union', 'data': { 'unknown': 'MissingType' } }tests/qapi-schema/unknown-escape.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/unknown-escape.json:3:21: Unknown escape \x +tests/qapi-schema/unknown-escape.json:7:21: Unknown escape \xtests/qapi-schema/unknown-escape.json +4
-0@@ -1,3 +1,7 @@ # we only recognize JSON escape sequences, plus our \' extension (no \x) + +## +# @foo: +## # { 'command': 'foo', 'data': {} } { 'command': 'foo', 'dat\x61':{} }tests/qapi-schema/unknown-expr-key.err +1
-1@@ -1 +1 @@ -tests/qapi-schema/unknown-expr-key.json:2: Unknown key 'bogus' in struct 'bar' +tests/qapi-schema/unknown-expr-key.json:6: Unknown key 'bogus' in struct 'bar'tests/qapi-schema/unknown-expr-key.json +4
-0@@ -1,2 +1,6 @@ # we reject an expression with unknown top-level keys + +## +# @bar: +## { 'struct': 'bar', 'data': { 'string': 'str'}, 'bogus': { } }