From: Markus Armbruster Date: Fri, 4 Nov 2022 16:06:45 +0000 (+0100) Subject: docs/devel/qapi-code-gen: Extend example for next commit's change X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=94f9bd33eece74810aee86de866b3cc86c3b0aec;p=qemu.git docs/devel/qapi-code-gen: Extend example for next commit's change 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 Reviewed-by: Daniel P. Berrangé Message-Id: <20221104160712.3005652-4-armbru@redhat.com> --- 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"), }, + {} + })), {} }));