summaryrefslogtreecommitdiff
path: root/docs/qapi-code-gen.txt
AgeCommit message (Collapse)AuthorFilesLines
2014-03-11qapi script: do not allow string discriminatorWenchao Xia1-4/+1
Since enum based discriminators provide better type-safety and ensure that future qapi additions do not forget to adjust dependent unions, forbid using string as discriminator from now on. Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-03-11qapi script: support enum type as discriminator in unionWenchao Xia1-2/+6
By default, any union will automatically generate a enum type as "[UnionName]Kind" in C code, and it is duplicated when the discriminator is specified as a pre-defined enum type in schema. After this patch, the pre-defined enum type will be really used as the switch case condition in generated C code, if discriminator is an enum field. Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-10-26qapi: fix documentation exampleEric Blake1-1/+1
The QMP wire format uses "", not '', around strings. * docs/qapi-code-gen.txt: Fix typo. Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-10-11qapi-types/visit.py: Inheritance for structsKevin Wolf1-0/+17
This introduces a new 'base' key for struct definitions that refers to another struct type. On the JSON level, the fields of the base type are included directly into the same namespace as the fields of the defined type, like with unions. On the C level, a pointer to a struct of the base type is included. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-07-26qapi: Anonymous unionsKevin Wolf1-0/+25
The discriminator for anonymous unions is the data type. This allows to have a union type that allows both of these: { 'file': 'my_existing_block_device_id' } { 'file': { 'filename': '/tmp/mydisk.qcow2', 'read-only': true } } Unions like this are specified in the schema with an empty dict as discriminator. For this example you could take: { 'union': 'BlockRef', 'discriminator': {}, 'data': { 'definition': 'BlockOptions', 'reference': 'str' } } { 'type': 'ExampleObject', 'data: { 'file': 'BlockRef' } } Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-07-26qapi: Flat unions with arbitrary discriminatorKevin Wolf1-0/+22
Instead of the rather verbose syntax that distinguishes base and subclass fields... { "type": "file", "read-only": true, "data": { "filename": "test" } } ...we can now have both in the same namespace, allowing a more direct mapping of the command line, and moving fields between the common base and subclasses without breaking the API: { "driver": "file", "read-only": true, "filename": "test" } Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-07-26docs: Document QAPI union typesKevin Wolf1-7/+55
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2012-07-23qapi: fix error propagationPaolo Bonzini1-0/+2
Don't overwrite / leak previously set errors. Make traversal cope with missing mandatory sub-structs. Don't try to end a container that could not be started. v1->v2: - unchanged v2->v3: - instead of examining, assert that we never overwrite errors with error_set() - allow visitors to set a NULL struct pointer successfully, so traversal of incomplete objects can continue - check for a NULL "obj" before accessing "(*obj)->has_XXX" (this is not a typo, "obj != NULL" implies "*obj != NULL" here) - fix start_struct / end_struct balance for unions as well Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-03-27qapi: untangle next_listPaolo Bonzini1-2/+2
Right now, the semantics of next_list are complicated. The caller must: * call start_list * call next_list for each element *including the first* * on the first call to next_list, the second argument should point to NULL and the result is the head of the list. On subsequent calls, the second argument should point to the last node (last result of next_list) and next_list itself tacks the element at the tail of the list. This works for both input and output visitor, but having the visitor write memory when it is only reading the list is ugly. Plus, relying on *list to detect the first call is tricky and undocumented. We can initialize so->entry in next_list instead of start_list, leaving it NULL in start_list. This way next_list sees clearly whether it is on the first call---as a bonus, it discriminates the cases based on internal state of the visitor rather than external state. We can also pull the assignment of the list head from generated code up to next_list. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-11-17Fix some spelling bugs in documentation and commentsStefan Weil1-1/+1
These errors were detected by codespell: remaing -> remaining soley -> solely virutal -> virtual seperate -> separate libcacard.txt still needs some more patches. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-01qapi: fix typos in documentation JSON examplesStefan Hajnoczi1-2/+2
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-08-29Fix spelling in comments and debug messages (recieve -> receive)Stefan Weil1-1/+1
Signed-off-by: Stefan Weil <weil@mail.berlios.de> Reviewed-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-07-21qapi: add QAPI code generation documentationMichael Roth1-0/+316
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@gmail.com>