aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2022-11-04 17:06:45 +0100
committerMarkus Armbruster <armbru@redhat.com>2022-12-13 18:31:37 +0100
commit94f9bd33eece74810aee86de866b3cc86c3b0aec (patch)
treedeca474fceaa6d072f8b6d3cd8177424969c4382
parent7df184613c911c93490ee36eb73f97159ebe728a (diff)
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 <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20221104160712.3005652-4-armbru@redhat.com>
-rw-r--r--docs/devel/qapi-code-gen.rst21
1 files changed, 20 insertions, 1 deletions
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"), },
+ {}
+ })),
{}
}));