[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/28] docs/devel/qapi-code-gen: Extend example for next commit's
From: |
Markus Armbruster |
Subject: |
[PULL 03/28] docs/devel/qapi-code-gen: Extend example for next commit's change |
Date: |
Tue, 25 Oct 2022 10:05:16 +0200 |
The next commit will change the code generated for some optional
members. The example schema contains an optional member affected by
the change. Add one that is not affected.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20221018062849.3420573-4-armbru@redhat.com>
---
docs/devel/qapi-code-gen.rst | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst
index b56ea4546d..3a817ba498 100644
--- a/docs/devel/qapi-code-gen.rst
+++ b/docs/devel/qapi-code-gen.rst
@@ -1357,7 +1357,7 @@ qmp_my_command(); everything else is produced by the
generator. ::
$ cat example-schema.json
{ 'struct': 'UserDefOne',
- 'data': { 'integer': 'int', '*string': 'str' } }
+ 'data': { 'integer': 'int', '*string': 'str', '*flag': 'bool' } }
{ 'command': 'my-command',
'data': { 'arg1': ['UserDefOne'] },
@@ -1412,6 +1412,8 @@ Example::
int64_t integer;
bool has_string;
char *string;
+ bool has_flag;
+ bool flag;
};
void qapi_free_UserDefOne(UserDefOne *obj);
@@ -1531,6 +1533,11 @@ Example::
return false;
}
}
+ if (visit_optional(v, "flag", &obj->has_flag)) {
+ if (!visit_type_bool(v, "flag", &obj->flag, errp)) {
+ return false;
+ }
+ }
return true;
}
@@ -1916,6 +1923,12 @@ Example::
{ "type", QLIT_QSTR("str"), },
{}
})),
+ QLIT_QDICT(((QLitDictEntry[]) {
+ { "default", QLIT_QNULL, },
+ { "name", QLIT_QSTR("flag"), },
+ { "type", QLIT_QSTR("bool"), },
+ {}
+ })),
{}
})), },
{ "meta-type", QLIT_QSTR("object"), },
@@ -1949,6 +1962,12 @@ Example::
{ "name", QLIT_QSTR("str"), },
{}
})),
+ QLIT_QDICT(((QLitDictEntry[]) {
+ { "json-type", QLIT_QSTR("boolean"), },
+ { "meta-type", QLIT_QSTR("builtin"), },
+ { "name", QLIT_QSTR("bool"), },
+ {}
+ })),
{}
}));
--
2.37.3
- [PULL 05/28] qapi tests: Elide redundant has_FOO in generated C, (continued)
- [PULL 05/28] qapi tests: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 06/28] qapi acpi: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 02/28] qapi: Tidy up whitespace in generated code, Markus Armbruster, 2022/10/25
- [PULL 10/28] qapi crypto: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 12/28] qapi job: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 15/28] qapi misc: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 28/28] qapi: Drop temporary logic to support conversion step by step, Markus Armbruster, 2022/10/25
- [PULL 17/28] qapi pci: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 27/28] qapi qga: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 24/28] qapi transaction: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 03/28] docs/devel/qapi-code-gen: Extend example for next commit's change,
Markus Armbruster <=
- [PULL 09/28] qapi chardev: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 23/28] qapi tpm: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 16/28] qapi net: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 21/28] qapi run-state: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- [PULL 22/28] qapi stats: Elide redundant has_FOO in generated C, Markus Armbruster, 2022/10/25
- Re: [PULL 00/28] QAPI patches patches for 2022-10-25, Stefan Hajnoczi, 2022/10/25
- Re: [PULL 00/28] QAPI patches patches for 2022-10-25, Stefan Hajnoczi, 2022/10/25