Browse Source

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>
pull/228/head
Markus Armbruster 3 years ago
parent
commit
94f9bd33ee
  1. 21
      docs/devel/qapi-code-gen.rst

21
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"), },
{}
})),
{}
}));

Loading…
Cancel
Save