| 3bef3aae | 20-Nov-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Simplify QAPISchemaModularCVisitor
Since the previous commit, QAPISchemaVisitor.visit_module() is called just once. Simplify QAPISchemaModularCVisitor accordingly.
Signed-off-by: Markus Armb
qapi: Simplify QAPISchemaModularCVisitor
Since the previous commit, QAPISchemaVisitor.visit_module() is called just once. Simplify QAPISchemaModularCVisitor accordingly.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-7-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 3e7fb581 | 20-Nov-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix code generation for empty modules
When a sub-module doesn't contain any definitions, we don't generate code for it, but we do generate the #include.
We generate code only for modules that
qapi: Fix code generation for empty modules
When a sub-module doesn't contain any definitions, we don't generate code for it, but we do generate the #include.
We generate code only for modules that get visited. QAPISchema.visit() visits only modules that have definitions. It can visit modules multiple times.
Clean this up as follows. Collect entities in their QAPISchemaModule. Have QAPISchema.visit() call QAPISchemaModule.visit() for each module. Have QAPISchemaModule.visit() call .visit_module() for itself, and QAPISchemaEntity.visit() for each of its entities. This way, we visit each module exactly once.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-6-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| a9f1dd7e | 20-Nov-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Proper intermediate representation for modules
Modules are represented only by their names so far. Introduce class QAPISchemaModule. So far, it merely wraps the name. The next patch will pu
qapi: Proper intermediate representation for modules
Modules are represented only by their names so far. Introduce class QAPISchemaModule. So far, it merely wraps the name. The next patch will put it to more interesting use.
Once again, arrays spice up the patch a bit. For any other type, @info points to the definition, which lets us map from @info to module. For arrays, there is no definition, and @info points to the first use instead. We have to use the element type's module instead, which is only available after .check().
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-5-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 00ca24ff | 20-Nov-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Generate command registration stuff into separate files
Having to include qapi-commands.h just for qmp_init_marshal() is suboptimal. Generate it into separate files. This lets monitor/misc.c
qapi: Generate command registration stuff into separate files
Having to include qapi-commands.h just for qmp_init_marshal() is suboptimal. Generate it into separate files. This lets monitor/misc.c, qga/main.c, and the generated qapi-commands-FOO.h include less.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-4-armbru@redhat.com> [Typos in docs/devel/qapi-code-gen.txt fixed] Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| b3cdff10 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Lift features into QAPISchemaEntity
Commit 6a8c0b5102 "qapi: Add feature flags to struct types" added features to QAPISchemaObjectType. Commit a95daa5093 "qapi: Add feature flags to commands
qapi: Lift features into QAPISchemaEntity
Commit 6a8c0b5102 "qapi: Add feature flags to struct types" added features to QAPISchemaObjectType. Commit a95daa5093 "qapi: Add feature flags to commands in qapi" added them to QAPISchemaCommand, duplicating the code. Tolerable, but the duplication will only get worse as we add features to more definitions.
To de-duplicate, lift features from QAPISchemaObjectType and QAPISchemaCommand into QAPISchemaEntity.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-18-armbru@redhat.com>
show more ...
|
| ad1ecfc6 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fold normalize_enum() into check_enum()
check_features() is always called together with normalize_features(). Fold the latter into the former.
Signed-off-by: Markus Armbruster <armbru@redhat.
qapi: Fold normalize_enum() into check_enum()
check_features() is always called together with normalize_features(). Fold the latter into the former.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-17-armbru@redhat.com>
show more ...
|
| 2ce51ef6 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fold normalize_features() into check_features()
check_features() is always called together with normalize_features(): the former in check_struct() and check_command(), the latter in their call
qapi: Fold normalize_features() into check_features()
check_features() is always called together with normalize_features(): the former in check_struct() and check_command(), the latter in their caller check_exprs(). Fold the latter into the former.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-16-armbru@redhat.com>
show more ...
|
| c145bfda | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fold normalize_if() into check_if()
check_if() is always called together with normalize_if(). Fold the latter into the former.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id
qapi: Fold normalize_if() into check_if()
check_if() is always called together with normalize_if(). Fold the latter into the former.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-15-armbru@redhat.com>
show more ...
|
| 1192a486 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Eliminate .check_doc() overrides
All sub-classes of QAPISchemaEntity now override .check_doc() the same way, except for QAPISchemaType and and QAPISchemaArrayType.
Put the overrides' code in
qapi: Eliminate .check_doc() overrides
All sub-classes of QAPISchemaEntity now override .check_doc() the same way, except for QAPISchemaType and and QAPISchemaArrayType.
Put the overrides' code in QAPISchemaEntity.check_doc(), and drop the overrides. QAPISchemaType doesn't care because it's abstract. QAPISchemaArrayType doesn't care because its .doc is always None.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-14-armbru@redhat.com>
show more ...
|
| a710e1c8 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Simplify ._make_implicit_object_type()
All callers now pass doc=None. Drop the argument.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-13-armbru@redh
qapi: Simplify ._make_implicit_object_type()
All callers now pass doc=None. Drop the argument.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-13-armbru@redhat.com>
show more ...
|
| bf83f04e | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix doc comment checking for commands and events
When a command's 'data' is an object, its doc comment describes the arguments defined there. When 'data' names a type, the doc comment does no
qapi: Fix doc comment checking for commands and events
When a command's 'data' is an object, its doc comment describes the arguments defined there. When 'data' names a type, the doc comment does not describe arguments. Instead, the doc generator inserts a pointer to the named type.
An event's doc comment works the same.
We don't actually check doc comments for commands and events. Instead, QAPISchema._def_command() forwards the doc comment to the implicit argument type, where it gets checked. Works because the check only cares for the implicit argument type's members.
Not only is this needlessly hard to understand, it actually falls apart in two cases:
* When 'data' is empty, there is nothing to forward to, and the doc comment remains unchecked. Demonstrated by test doc-bad-event-arg.
* When 'data' names a type, we can't forward, as the type has its own doc comment. The command or event's doc comment remains unchecked. Demonstrated by test doc-bad-boxed-command-arg.
The forwarding goes back to commit 069fb5b250 "qapi: Prepare for requiring more complete documentation", put to use in commit 816a57cd6e "qapi: Fix detection of bogus member documentation". That fix was incomplete.
To fix this, make QAPISchemaCommand and QAPISchemaEvent check doc comments, and drop the forwarding of doc comments to implicit argument types.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-12-armbru@redhat.com>
show more ...
|
| 7faefad1 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Clean up doc comment checking for implicit union base
An object type's doc comment describes the type's members, less the ones defined in a named base type. Cases:
* Struct: the members are
qapi: Clean up doc comment checking for implicit union base
An object type's doc comment describes the type's members, less the ones defined in a named base type. Cases:
* Struct: the members are defined in 'data' and inherited from 'base'. Since the base type cannot be implicit, the doc comment describes just 'data'.
* Simple union: the only member is the implicit tag member @type, and the doc comment describes it.
* Flat union with implicit base type: the members are defined in 'base', and the doc comment describes it.
* Flat union with named base type: the members are inherited from 'base'. The doc comment describes no members.
Before we can check a doc comment with .check_doc(), we need .connect_doc() connect each of its "argument sections" to the member it documents.
For structs and simple unions, this is straightforward: the members in question are in .local_members, and .connect_doc() connects them.
For flat unions with a named base type, it's trivial: .local_members is empty, and .connect_doc() does nothing.
For flat unions with an implicit base type, it's tricky. We have QAPISchema._make_implicit_object_type() forward the union's doc comment to the implicit base type, so that the base type's .connect_doc() connects the members. The union's .connect_doc() does nothing, as .local_members is empty.
Dirt effect: we check the doc comment twice, once for the union type, and once for the implicit base type.
This is needlessly brittle and hard to understand. Clean up as follows. Make the union's .connect_doc() connect an implicit base's members itself. Do not forward the union's doc comment to its implicit base type.
Requires extending .connect_doc() so it can work with a doc comment other than self.doc. Add an optional argument for that.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-11-armbru@redhat.com>
show more ...
|
| 36a43905 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix enum doc comment checking
Enumeration type documentation comments are not checked, as demonstrated by test doc-bad-enum-member. This is because we neglect to call self.doc.check() for enu
qapi: Fix enum doc comment checking
Enumeration type documentation comments are not checked, as demonstrated by test doc-bad-enum-member. This is because we neglect to call self.doc.check() for enumeration types. Messed up in 816a57cd6e "qapi: Fix detection of bogus member documentation". Fix it.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-10-armbru@redhat.com>
show more ...
|
| ee1e6a1f | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Split .connect_doc(), .check_doc() off .check()
Splitting documentation checking off the .check() methods makes them a bit more focused, which is welcome, as some of them are pretty big. It al
qapi: Split .connect_doc(), .check_doc() off .check()
Splitting documentation checking off the .check() methods makes them a bit more focused, which is welcome, as some of them are pretty big. It also prepares the ground for the following commits.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-9-armbru@redhat.com>
show more ...
|
| a4bd91d3 | 24-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: De-duplicate entity documentation generation code
QAPISchemaGenDocVisitor.visit_command() duplicates texi_entity() for its boxed arguments case. The previous commit added another copy in .vis
qapi: De-duplicate entity documentation generation code
QAPISchemaGenDocVisitor.visit_command() duplicates texi_entity() for its boxed arguments case. The previous commit added another copy in .visit_event().
Replace texi_entity() by texi_type() and texi_msg(). Use texi_msg() for the boxed arguments case as well.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-8-armbru@redhat.com>
show more ...
|