mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-17 21:26:13 -07:00
qapi-visit: Convert to QAPISchemaVisitor, fixing bugs
Fixes flat unions to visit the base's base members (the previous
commit merely added them to the struct). Same test case.
Patch's effect on visit_type_UserDefFlatUnion():
static void visit_type_UserDefFlatUnion_fields(Visitor *m, UserDefFlatUnion **obj, Error **errp)
{
Error *err = NULL;
+ visit_type_int(m, &(*obj)->integer, "integer", &err);
+ if (err) {
+ goto out;
+ }
visit_type_str(m, &(*obj)->string, "string", &err);
if (err) {
goto out;
Test cases updated for the bug fix.
Fixes alternates to generate a visitor for their implicit enumeration
type. None of them are currently used, obviously. Example:
block-core.json's BlockdevRef now generates
visit_type_BlockdevRefKind().
Code is generated in a different order now, and therefore has got a
few new forward declarations. Doesn't matter.
The guard QAPI_VISIT_BUILTIN_VISITOR_DECL is renamed to
QAPI_VISIT_BUILTIN.
The previous commit's two ugly special cases exist here, too. Mark
both TODO.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
2b162ccbe8
commit
441cbac0c7
4 changed files with 117 additions and 164 deletions
|
|
@ -307,15 +307,15 @@ static void test_visitor_in_union_flat(TestInputVisitorData *data,
|
|||
|
||||
v = visitor_input_test_init(data,
|
||||
"{ 'enum1': 'value1', "
|
||||
"'integer': 41, "
|
||||
"'string': 'str', "
|
||||
"'boolean': true }");
|
||||
/* TODO when generator bug is fixed, add 'integer': 41 */
|
||||
|
||||
visit_type_UserDefFlatUnion(v, &tmp, NULL, &err);
|
||||
g_assert(err == NULL);
|
||||
g_assert_cmpint(tmp->enum1, ==, ENUM_ONE_VALUE1);
|
||||
g_assert_cmpstr(tmp->string, ==, "str");
|
||||
/* TODO g_assert_cmpint(tmp->integer, ==, 41); */
|
||||
g_assert_cmpint(tmp->integer, ==, 41);
|
||||
g_assert_cmpint(tmp->value1->boolean, ==, true);
|
||||
qapi_free_UserDefFlatUnion(tmp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue