diff mbox

[v8,28/40] qapi: Prefer 'struct' over 'type' in generator

Message ID 1430751937-17523-29-git-send-email-eblake@redhat.com
State New
Headers show

Commit Message

Eric Blake May 4, 2015, 3:05 p.m. UTC
Referring to "type" as both a meta-type (built-in, enum, union,
alternate, or struct) and a specific type (the name that the
schema uses for declaring structs) is confusing.  The confusion
is only made worse by the fact that the generator mostly already
refers to struct even when dealing with expr['type'].  This
commit changes the generator to consistently refer to it as
struct everywhere, plus a single back-compat tweak that allows
accepting the existing .json files as-is, so that the meat of
this change is separate from the mindless churn of that change.

Fix the testsuite fallout for error messages that change, and
in some cases, become more legible.  Improve comments to better
match our intentions where a struct (rather than any complex
type) is required.  Note that in some cases, an error message
now refers to 'struct' while the schema still refers to 'type';
that will be cleaned up in the later commit to the schema.

Signed-off-by: Eric Blake <eblake@redhat.com>

---

v7: enhance commit message; change check_struct() to refer to 'struct'
rather than 'type'; update a few more comments at this point (enough
fallout that I dropped Markus' R-b)
---
 scripts/qapi-types.py                              | 16 ++++----
 scripts/qapi-visit.py                              |  8 ++--
 scripts/qapi.py                                    | 46 ++++++++++++++--------
 tests/qapi-schema/alternate-good.out               |  4 +-
 tests/qapi-schema/bad-base.err                     |  2 +-
 tests/qapi-schema/bad-ident.err                    |  2 +-
 tests/qapi-schema/bad-type-bool.err                |  2 +-
 tests/qapi-schema/data-member-array.out            |  4 +-
 tests/qapi-schema/double-type.err                  |  2 +-
 tests/qapi-schema/flat-union-bad-base.json         |  2 +-
 tests/qapi-schema/flat-union-base-star.err         |  2 +-
 tests/qapi-schema/flat-union-base-star.json        |  2 +-
 tests/qapi-schema/flat-union-base-union.err        |  2 +-
 tests/qapi-schema/flat-union-base-union.json       |  2 +-
 tests/qapi-schema/flat-union-branch-clash.out      | 12 +++---
 tests/qapi-schema/flat-union-inline.json           |  2 +-
 tests/qapi-schema/flat-union-int-branch.json       |  2 +-
 .../flat-union-invalid-discriminator.err           |  2 +-
 tests/qapi-schema/flat-union-reverse-define.out    | 12 +++---
 tests/qapi-schema/qapi-schema-test.out             | 44 ++++++++++-----------
 tests/qapi-schema/union-invalid-base.err           |  2 +-
 tests/qapi-schema/unknown-expr-key.err             |  2 +-
 22 files changed, 93 insertions(+), 81 deletions(-)

Comments

Markus Armbruster May 4, 2015, 5:46 p.m. UTC | #1
Eric Blake <eblake@redhat.com> writes:

> Referring to "type" as both a meta-type (built-in, enum, union,
> alternate, or struct) and a specific type (the name that the
> schema uses for declaring structs) is confusing.  The confusion
> is only made worse by the fact that the generator mostly already
> refers to struct even when dealing with expr['type'].  This
> commit changes the generator to consistently refer to it as
> struct everywhere, plus a single back-compat tweak that allows
> accepting the existing .json files as-is, so that the meat of
> this change is separate from the mindless churn of that change.
>
> Fix the testsuite fallout for error messages that change, and
> in some cases, become more legible.  Improve comments to better
> match our intentions where a struct (rather than any complex
> type) is required.  Note that in some cases, an error message
> now refers to 'struct' while the schema still refers to 'type';
> that will be cleaned up in the later commit to the schema.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox

Patch

diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 9c8d68c..a429d9e 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -83,7 +83,7 @@  def generate_struct_fields(members):

 def generate_struct(expr):

-    structname = expr.get('type', "")
+    structname = expr.get('struct', "")
     fieldname = expr.get('field', "")
     members = expr['data']
     base = expr.get('base')
@@ -394,8 +394,8 @@  fdecl.write(guardend("QAPI_TYPES_BUILTIN_STRUCT_DECL"))

 for expr in exprs:
     ret = "\n"
-    if expr.has_key('type'):
-        ret += generate_fwd_struct(expr['type'], expr['data'])
+    if expr.has_key('struct'):
+        ret += generate_fwd_struct(expr['struct'], expr['data'])
     elif expr.has_key('enum'):
         ret += generate_enum(expr['enum'], expr['data']) + "\n"
         ret += generate_fwd_enum_struct(expr['enum'], expr['data'])
@@ -435,12 +435,12 @@  if do_builtins:

 for expr in exprs:
     ret = "\n"
-    if expr.has_key('type'):
+    if expr.has_key('struct'):
         ret += generate_struct(expr) + "\n"
-        ret += generate_type_cleanup_decl(expr['type'] + "List")
-        fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n")
-        ret += generate_type_cleanup_decl(expr['type'])
-        fdef.write(generate_type_cleanup(expr['type']) + "\n")
+        ret += generate_type_cleanup_decl(expr['struct'] + "List")
+        fdef.write(generate_type_cleanup(expr['struct'] + "List") + "\n")
+        ret += generate_type_cleanup_decl(expr['struct'])
+        fdef.write(generate_type_cleanup(expr['struct']) + "\n")
     elif expr.has_key('union'):
         ret += generate_union(expr, 'union')
         ret += generate_type_cleanup_decl(expr['union'] + "List")
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 9222671..c739a95 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -178,7 +178,7 @@  def generate_visit_struct_body(field_prefix, name, members):

 def generate_visit_struct(expr):

-    name = expr['type']
+    name = expr['struct']
     members = expr['data']
     base = expr.get('base')

@@ -545,12 +545,12 @@  if do_builtins:
         fdef.write(generate_visit_list(typename, None))

 for expr in exprs:
-    if expr.has_key('type'):
+    if expr.has_key('struct'):
         ret = generate_visit_struct(expr)
-        ret += generate_visit_list(expr['type'], expr['data'])
+        ret += generate_visit_list(expr['struct'], expr['data'])
         fdef.write(ret)

-        ret = generate_declaration(expr['type'], expr['data'])
+        ret = generate_declaration(expr['struct'], expr['data'])
         fdecl.write(ret)
     elif expr.has_key('union'):
         ret = generate_visit_union(expr)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 07ae141..ff337c2 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -419,7 +419,7 @@  def check_union(expr, expr_info):
     members = expr['data']
     values = { 'MAX': '(automatic)' }

-    # If the object has a member 'base', its value must name a complex type,
+    # If the object has a member 'base', its value must name a struct,
     # and there must be a discriminator.
     if base is not None:
         if discriminator is None:
@@ -448,18 +448,18 @@  def check_union(expr, expr_info):
         base_fields = find_base_fields(base)
         if not base_fields:
             raise QAPIExprError(expr_info,
-                                "Base '%s' is not a valid type"
+                                "Base '%s' is not a valid struct"
                                 % base)

         # The value of member 'discriminator' must name a non-optional
-        # member of the base type.
+        # member of the base struct.
         check_name(expr_info, "Discriminator of flat union '%s'" % name,
                    discriminator)
         discriminator_type = base_fields.get(discriminator)
         if not discriminator_type:
             raise QAPIExprError(expr_info,
                                 "Discriminator '%s' is not a member of base "
-                                "type '%s'"
+                                "struct '%s'"
                                 % (discriminator, base))
         enum_define = find_enum(discriminator_type)
         allow_metas=['struct']
@@ -546,12 +546,12 @@  def check_enum(expr, expr_info):
         values[key] = member

 def check_struct(expr, expr_info):
-    name = expr['type']
+    name = expr['struct']
     members = expr['data']

-    check_type(expr_info, "'data' for type '%s'" % name, members,
+    check_type(expr_info, "'data' for struct '%s'" % name, members,
                allow_dict=True, allow_optional=True)
-    check_type(expr_info, "'base' for type '%s'" % name, expr.get('base'),
+    check_type(expr_info, "'base' for struct '%s'" % name, expr.get('base'),
                allow_metas=['struct'])

 def check_exprs(schema):
@@ -565,7 +565,7 @@  def check_exprs(schema):
             check_union(expr, info)
         elif expr.has_key('alternate'):
             check_alternate(expr, info)
-        elif expr.has_key('type'):
+        elif expr.has_key('struct'):
             check_struct(expr, info)
         elif expr.has_key('command'):
             check_command(expr, info)
@@ -617,6 +617,20 @@  def parse_schema(input_file):
         for expr_elem in schema.exprs:
             expr = expr_elem['expr']
             info = expr_elem['info']
+
+            # back-compat hack until all schemas have been converted;
+            # preserve the ordering of the original expression
+            if expr.has_key('type'):
+                seen_type = False
+                for (key, value) in expr.items():
+                    if key == 'type':
+                        seen_type = True
+                        del expr['type']
+                        expr['struct'] = value
+                    elif seen_type:
+                        del expr[key]
+                        expr[key] = value
+
             if expr.has_key('enum'):
                 check_keys(expr_elem, 'enum', ['data'])
                 add_enum(expr['enum'], info, expr['data'])
@@ -627,8 +641,8 @@  def parse_schema(input_file):
             elif expr.has_key('alternate'):
                 check_keys(expr_elem, 'alternate', ['data'])
                 add_name(expr['alternate'], info, 'alternate')
-            elif expr.has_key('type'):
-                check_keys(expr_elem, 'type', ['data'], ['base'])
+            elif expr.has_key('struct'):
+                check_keys(expr_elem, 'struct', ['data'], ['base'])
                 add_struct(expr, info)
             elif expr.has_key('command'):
                 check_keys(expr_elem, 'command', [],
@@ -745,11 +759,9 @@  def type_name(name):
         return c_list_type(name[0])
     return name

-def add_name(name, info, meta, implicit = False, source = None):
+def add_name(name, info, meta, implicit = False):
     global all_names
-    if not source:
-        source = "'%s'" % meta
-    check_name(info, source, name)
+    check_name(info, "'%s'" % meta, name)
     if name in all_names:
         raise QAPIExprError(info,
                             "%s '%s' is already defined"
@@ -762,14 +774,14 @@  def add_name(name, info, meta, implicit = False, source = None):

 def add_struct(definition, info):
     global struct_types
-    name = definition['type']
-    add_name(name, info, 'struct', source="'type'")
+    name = definition['struct']
+    add_name(name, info, 'struct')
     struct_types.append(definition)

 def find_struct(name):
     global struct_types
     for struct in struct_types:
-        if struct['type'] == name:
+        if struct['struct'] == name:
             return struct
     return None

diff --git a/tests/qapi-schema/alternate-good.out b/tests/qapi-schema/alternate-good.out
index c3a6b77..99848ee 100644
--- a/tests/qapi-schema/alternate-good.out
+++ b/tests/qapi-schema/alternate-good.out
@@ -1,6 +1,6 @@ 
-[OrderedDict([('type', 'Data'), ('data', OrderedDict([('*number', 'int'), ('*name', 'str')]))]),
+[OrderedDict([('struct', 'Data'), ('data', OrderedDict([('*number', 'int'), ('*name', 'str')]))]),
  OrderedDict([('enum', 'Enum'), ('data', ['hello', 'world'])]),
  OrderedDict([('alternate', 'Alt'), ('data', OrderedDict([('value', 'int'), ('string', 'Enum'), ('struct', 'Data')]))])]
 [{'enum_name': 'Enum', 'enum_values': ['hello', 'world']},
  {'enum_name': 'AltKind', 'enum_values': None}]
-[OrderedDict([('type', 'Data'), ('data', OrderedDict([('*number', 'int'), ('*name', 'str')]))])]
+[OrderedDict([('struct', 'Data'), ('data', OrderedDict([('*number', 'int'), ('*name', 'str')]))])]
diff --git a/tests/qapi-schema/bad-base.err b/tests/qapi-schema/bad-base.err
index f398bbb..154274b 100644
--- a/tests/qapi-schema/bad-base.err
+++ b/tests/qapi-schema/bad-base.err
@@ -1 +1 @@ 
-tests/qapi-schema/bad-base.json:3: 'base' for type 'MyType' cannot use union type 'Union'
+tests/qapi-schema/bad-base.json:3: 'base' for struct 'MyType' cannot use union type 'Union'
diff --git a/tests/qapi-schema/bad-ident.err b/tests/qapi-schema/bad-ident.err
index 42b490c..c419060 100644
--- a/tests/qapi-schema/bad-ident.err
+++ b/tests/qapi-schema/bad-ident.err
@@ -1 +1 @@ 
-tests/qapi-schema/bad-ident.json:2: 'type' does not allow optional name '*oops'
+tests/qapi-schema/bad-ident.json:2: 'struct' does not allow optional name '*oops'
diff --git a/tests/qapi-schema/bad-type-bool.err b/tests/qapi-schema/bad-type-bool.err
index de6168c..62fd70b 100644
--- a/tests/qapi-schema/bad-type-bool.err
+++ b/tests/qapi-schema/bad-type-bool.err
@@ -1 +1 @@ 
-tests/qapi-schema/bad-type-bool.json:2: 'type' key must have a string value
+tests/qapi-schema/bad-type-bool.json:2: 'struct' key must have a string value
diff --git a/tests/qapi-schema/data-member-array.out b/tests/qapi-schema/data-member-array.out
index 8287120..c39fa25 100644
--- a/tests/qapi-schema/data-member-array.out
+++ b/tests/qapi-schema/data-member-array.out
@@ -1,5 +1,5 @@ 
 [OrderedDict([('enum', 'abc'), ('data', ['a', 'b', 'c'])]),
- OrderedDict([('type', 'def'), ('data', OrderedDict([('array', ['abc'])]))]),
+ OrderedDict([('struct', 'def'), ('data', OrderedDict([('array', ['abc'])]))]),
  OrderedDict([('command', 'okay'), ('data', OrderedDict([('member1', ['int']), ('member2', ['def'])]))])]
 [{'enum_name': 'abc', 'enum_values': ['a', 'b', 'c']}]
-[OrderedDict([('type', 'def'), ('data', OrderedDict([('array', ['abc'])]))])]
+[OrderedDict([('struct', 'def'), ('data', OrderedDict([('array', ['abc'])]))])]
diff --git a/tests/qapi-schema/double-type.err b/tests/qapi-schema/double-type.err
index ceb6e46..f9613c6 100644
--- a/tests/qapi-schema/double-type.err
+++ b/tests/qapi-schema/double-type.err
@@ -1 +1 @@ 
-tests/qapi-schema/double-type.json:2: Unknown key 'command' in type 'bar'
+tests/qapi-schema/double-type.json:2: Unknown key 'command' in struct 'bar'
diff --git a/tests/qapi-schema/flat-union-bad-base.json b/tests/qapi-schema/flat-union-bad-base.json
index bb0f02d..d41c80c 100644
--- a/tests/qapi-schema/flat-union-bad-base.json
+++ b/tests/qapi-schema/flat-union-bad-base.json
@@ -1,4 +1,4 @@ 
-# we require the base to be an existing complex type
+# we require the base to be an existing struct
 # TODO: should we allow an anonymous inline base type?
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
diff --git a/tests/qapi-schema/flat-union-base-star.err b/tests/qapi-schema/flat-union-base-star.err
index 60e47ef..b7748f0 100644
--- a/tests/qapi-schema/flat-union-base-star.err
+++ b/tests/qapi-schema/flat-union-base-star.err
@@ -1 +1 @@ 
-tests/qapi-schema/flat-union-base-star.json:8: Base '**' is not a valid type
+tests/qapi-schema/flat-union-base-star.json:8: Base '**' is not a valid struct
diff --git a/tests/qapi-schema/flat-union-base-star.json b/tests/qapi-schema/flat-union-base-star.json
index 994533a..7672407 100644
--- a/tests/qapi-schema/flat-union-base-star.json
+++ b/tests/qapi-schema/flat-union-base-star.json
@@ -1,4 +1,4 @@ 
-# we require the base to be an existing complex type
+# we require the base to be an existing struct
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 { 'type': 'TestTypeA',
diff --git a/tests/qapi-schema/flat-union-base-union.err b/tests/qapi-schema/flat-union-base-union.err
index 185bf51..ede9859 100644
--- a/tests/qapi-schema/flat-union-base-union.err
+++ b/tests/qapi-schema/flat-union-base-union.err
@@ -1 +1 @@ 
-tests/qapi-schema/flat-union-base-union.json:11: Base 'UnionBase' is not a valid type
+tests/qapi-schema/flat-union-base-union.json:11: Base 'UnionBase' is not a valid struct
diff --git a/tests/qapi-schema/flat-union-base-union.json b/tests/qapi-schema/flat-union-base-union.json
index 838986c..0ba6e28 100644
--- a/tests/qapi-schema/flat-union-base-union.json
+++ b/tests/qapi-schema/flat-union-base-union.json
@@ -1,4 +1,4 @@ 
-# FIXME: the error message needs help: we require the base to be a struct
+# we require the base to be a struct
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 { 'type': 'TestTypeA',
diff --git a/tests/qapi-schema/flat-union-branch-clash.out b/tests/qapi-schema/flat-union-branch-clash.out
index 5d54113..04c2395 100644
--- a/tests/qapi-schema/flat-union-branch-clash.out
+++ b/tests/qapi-schema/flat-union-branch-clash.out
@@ -1,9 +1,9 @@ 
 [OrderedDict([('enum', 'TestEnum'), ('data', ['value1', 'value2'])]),
- OrderedDict([('type', 'Base'), ('data', OrderedDict([('enum1', 'TestEnum'), ('name', 'str')]))]),
- OrderedDict([('type', 'Branch1'), ('data', OrderedDict([('name', 'str')]))]),
- OrderedDict([('type', 'Branch2'), ('data', OrderedDict([('value', 'int')]))]),
+ OrderedDict([('struct', 'Base'), ('data', OrderedDict([('enum1', 'TestEnum'), ('name', 'str')]))]),
+ OrderedDict([('struct', 'Branch1'), ('data', OrderedDict([('name', 'str')]))]),
+ OrderedDict([('struct', 'Branch2'), ('data', OrderedDict([('value', 'int')]))]),
  OrderedDict([('union', 'TestUnion'), ('base', 'Base'), ('discriminator', 'enum1'), ('data', OrderedDict([('value1', 'Branch1'), ('value2', 'Branch2')]))])]
 [{'enum_name': 'TestEnum', 'enum_values': ['value1', 'value2']}]
-[OrderedDict([('type', 'Base'), ('data', OrderedDict([('enum1', 'TestEnum'), ('name', 'str')]))]),
- OrderedDict([('type', 'Branch1'), ('data', OrderedDict([('name', 'str')]))]),
- OrderedDict([('type', 'Branch2'), ('data', OrderedDict([('value', 'int')]))])]
+[OrderedDict([('struct', 'Base'), ('data', OrderedDict([('enum1', 'TestEnum'), ('name', 'str')]))]),
+ OrderedDict([('struct', 'Branch1'), ('data', OrderedDict([('name', 'str')]))]),
+ OrderedDict([('struct', 'Branch2'), ('data', OrderedDict([('value', 'int')]))])]
diff --git a/tests/qapi-schema/flat-union-inline.json b/tests/qapi-schema/flat-union-inline.json
index f3da117..65c15d0 100644
--- a/tests/qapi-schema/flat-union-inline.json
+++ b/tests/qapi-schema/flat-union-inline.json
@@ -1,4 +1,4 @@ 
-# we require branches to be a complex type name
+# we require branches to be a struct name
 # TODO: should we allow anonymous inline types?
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
diff --git a/tests/qapi-schema/flat-union-int-branch.json b/tests/qapi-schema/flat-union-int-branch.json
index d373131..ee93cf8 100644
--- a/tests/qapi-schema/flat-union-int-branch.json
+++ b/tests/qapi-schema/flat-union-int-branch.json
@@ -1,4 +1,4 @@ 
-# we require flat union branches to be a complex type
+# we require flat union branches to be a struct
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 { 'type': 'Base',
diff --git a/tests/qapi-schema/flat-union-invalid-discriminator.err b/tests/qapi-schema/flat-union-invalid-discriminator.err
index 790b675..5f40556 100644
--- a/tests/qapi-schema/flat-union-invalid-discriminator.err
+++ b/tests/qapi-schema/flat-union-invalid-discriminator.err
@@ -1 +1 @@ 
-tests/qapi-schema/flat-union-invalid-discriminator.json:13: Discriminator 'enum_wrong' is not a member of base type 'TestBase'
+tests/qapi-schema/flat-union-invalid-discriminator.json:13: Discriminator 'enum_wrong' is not a member of base struct 'TestBase'
diff --git a/tests/qapi-schema/flat-union-reverse-define.out b/tests/qapi-schema/flat-union-reverse-define.out
index 03c952e..1ed7b8a 100644
--- a/tests/qapi-schema/flat-union-reverse-define.out
+++ b/tests/qapi-schema/flat-union-reverse-define.out
@@ -1,9 +1,9 @@ 
 [OrderedDict([('union', 'TestUnion'), ('base', 'TestBase'), ('discriminator', 'enum1'), ('data', OrderedDict([('value1', 'TestTypeA'), ('value2', 'TestTypeB')]))]),
- OrderedDict([('type', 'TestBase'), ('data', OrderedDict([('enum1', 'TestEnum')]))]),
+ OrderedDict([('struct', 'TestBase'), ('data', OrderedDict([('enum1', 'TestEnum')]))]),
  OrderedDict([('enum', 'TestEnum'), ('data', ['value1', 'value2'])]),
- OrderedDict([('type', 'TestTypeA'), ('data', OrderedDict([('string', 'str')]))]),
- OrderedDict([('type', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))])]
+ OrderedDict([('struct', 'TestTypeA'), ('data', OrderedDict([('string', 'str')]))]),
+ OrderedDict([('struct', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))])]
 [{'enum_name': 'TestEnum', 'enum_values': ['value1', 'value2']}]
-[OrderedDict([('type', 'TestBase'), ('data', OrderedDict([('enum1', 'TestEnum')]))]),
- OrderedDict([('type', 'TestTypeA'), ('data', OrderedDict([('string', 'str')]))]),
- OrderedDict([('type', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))])]
+[OrderedDict([('struct', 'TestBase'), ('data', OrderedDict([('enum1', 'TestEnum')]))]),
+ OrderedDict([('struct', 'TestTypeA'), ('data', OrderedDict([('string', 'str')]))]),
+ OrderedDict([('struct', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))])]
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 313ecf3..83ab1a5 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -1,13 +1,13 @@ 
 [OrderedDict([('enum', 'EnumOne'), ('data', ['value1', 'value2', 'value3'])]),
- OrderedDict([('type', 'NestedEnumsOne'), ('data', OrderedDict([('enum1', 'EnumOne'), ('*enum2', 'EnumOne'), ('enum3', 'EnumOne'), ('*enum4', 'EnumOne')]))]),
- OrderedDict([('type', 'UserDefZero'), ('data', OrderedDict([('integer', 'int')]))]),
- OrderedDict([('type', 'UserDefOne'), ('base', 'UserDefZero'), ('data', OrderedDict([('string', 'str'), ('*enum1', 'EnumOne')]))]),
- OrderedDict([('type', 'UserDefTwo'), ('data', OrderedDict([('string', 'str'), ('dict', OrderedDict([('string', 'str'), ('dict', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')])), ('*dict2', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')]))]))]))]),
- OrderedDict([('type', 'UserDefNested'), ('data', OrderedDict([('string0', 'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2', OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3', OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
- OrderedDict([('type', 'UserDefA'), ('data', OrderedDict([('boolean', 'bool')]))]),
- OrderedDict([('type', 'UserDefB'), ('data', OrderedDict([('integer', 'int')]))]),
- OrderedDict([('type', 'UserDefC'), ('data', OrderedDict([('string1', 'str'), ('string2', 'str')]))]),
- OrderedDict([('type', 'UserDefUnionBase'), ('data', OrderedDict([('string', 'str'), ('enum1', 'EnumOne')]))]),
+ OrderedDict([('struct', 'NestedEnumsOne'), ('data', OrderedDict([('enum1', 'EnumOne'), ('*enum2', 'EnumOne'), ('enum3', 'EnumOne'), ('*enum4', 'EnumOne')]))]),
+ OrderedDict([('struct', 'UserDefZero'), ('data', OrderedDict([('integer', 'int')]))]),
+ OrderedDict([('struct', 'UserDefOne'), ('base', 'UserDefZero'), ('data', OrderedDict([('string', 'str'), ('*enum1', 'EnumOne')]))]),
+ OrderedDict([('struct', 'UserDefTwo'), ('data', OrderedDict([('string', 'str'), ('dict', OrderedDict([('string', 'str'), ('dict', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')])), ('*dict2', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')]))]))]))]),
+ OrderedDict([('struct', 'UserDefNested'), ('data', OrderedDict([('string0', 'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2', OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3', OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
+ OrderedDict([('struct', 'UserDefA'), ('data', OrderedDict([('boolean', 'bool')]))]),
+ OrderedDict([('struct', 'UserDefB'), ('data', OrderedDict([('integer', 'int')]))]),
+ OrderedDict([('struct', 'UserDefC'), ('data', OrderedDict([('string1', 'str'), ('string2', 'str')]))]),
+ OrderedDict([('struct', 'UserDefUnionBase'), ('data', OrderedDict([('string', 'str'), ('enum1', 'EnumOne')]))]),
  OrderedDict([('union', 'UserDefFlatUnion'), ('base', 'UserDefUnionBase'), ('discriminator', 'enum1'), ('data', OrderedDict([('value1', 'UserDefA'), ('value2', 'UserDefB'), ('value3', 'UserDefB')]))]),
  OrderedDict([('union', 'UserDefFlatUnion2'), ('base', 'UserDefUnionBase'), ('discriminator', 'enum1'), ('data', OrderedDict([('value1', 'UserDefC'), ('value2', 'UserDefB'), ('value3', 'UserDefA')]))]),
  OrderedDict([('alternate', 'UserDefAlternate'), ('data', OrderedDict([('uda', 'UserDefA'), ('s', 'str'), ('i', 'int')]))]),
@@ -16,8 +16,8 @@ 
  OrderedDict([('command', 'user_def_cmd1'), ('data', OrderedDict([('ud1a', 'UserDefOne')]))]),
  OrderedDict([('command', 'user_def_cmd2'), ('data', OrderedDict([('ud1a', 'UserDefOne'), ('*ud1b', 'UserDefOne')])), ('returns', 'UserDefTwo')]),
  OrderedDict([('command', 'user_def_cmd3'), ('data', OrderedDict([('a', 'int'), ('*b', 'int')])), ('returns', 'int')]),
- OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))]),
- OrderedDict([('type', 'EventStructOne'), ('data', OrderedDict([('struct1', 'UserDefOne'), ('string', 'str'), ('*enum2', 'EnumOne')]))]),
+ OrderedDict([('struct', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))]),
+ OrderedDict([('struct', 'EventStructOne'), ('data', OrderedDict([('struct1', 'UserDefOne'), ('string', 'str'), ('*enum2', 'EnumOne')]))]),
  OrderedDict([('event', 'EVENT_A')]),
  OrderedDict([('event', 'EVENT_B'), ('data', OrderedDict())]),
  OrderedDict([('event', 'EVENT_C'), ('data', OrderedDict([('*a', 'int'), ('*b', 'UserDefOne'), ('c', 'str')]))]),
@@ -25,14 +25,14 @@ 
 [{'enum_name': 'EnumOne', 'enum_values': ['value1', 'value2', 'value3']},
  {'enum_name': 'UserDefAlternateKind', 'enum_values': None},
  {'enum_name': 'UserDefNativeListUnionKind', 'enum_values': None}]
-[OrderedDict([('type', 'NestedEnumsOne'), ('data', OrderedDict([('enum1', 'EnumOne'), ('*enum2', 'EnumOne'), ('enum3', 'EnumOne'), ('*enum4', 'EnumOne')]))]),
- OrderedDict([('type', 'UserDefZero'), ('data', OrderedDict([('integer', 'int')]))]),
- OrderedDict([('type', 'UserDefOne'), ('base', 'UserDefZero'), ('data', OrderedDict([('string', 'str'), ('*enum1', 'EnumOne')]))]),
- OrderedDict([('type', 'UserDefTwo'), ('data', OrderedDict([('string', 'str'), ('dict', OrderedDict([('string', 'str'), ('dict', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')])), ('*dict2', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')]))]))]))]),
- OrderedDict([('type', 'UserDefNested'), ('data', OrderedDict([('string0', 'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2', OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3', OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
- OrderedDict([('type', 'UserDefA'), ('data', OrderedDict([('boolean', 'bool')]))]),
- OrderedDict([('type', 'UserDefB'), ('data', OrderedDict([('integer', 'int')]))]),
- OrderedDict([('type', 'UserDefC'), ('data', OrderedDict([('string1', 'str'), ('string2', 'str')]))]),
- OrderedDict([('type', 'UserDefUnionBase'), ('data', OrderedDict([('string', 'str'), ('enum1', 'EnumOne')]))]),
- OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))]),
- OrderedDict([('type', 'EventStructOne'), ('data', OrderedDict([('struct1', 'UserDefOne'), ('string', 'str'), ('*enum2', 'EnumOne')]))])]
+[OrderedDict([('struct', 'NestedEnumsOne'), ('data', OrderedDict([('enum1', 'EnumOne'), ('*enum2', 'EnumOne'), ('enum3', 'EnumOne'), ('*enum4', 'EnumOne')]))]),
+ OrderedDict([('struct', 'UserDefZero'), ('data', OrderedDict([('integer', 'int')]))]),
+ OrderedDict([('struct', 'UserDefOne'), ('base', 'UserDefZero'), ('data', OrderedDict([('string', 'str'), ('*enum1', 'EnumOne')]))]),
+ OrderedDict([('struct', 'UserDefTwo'), ('data', OrderedDict([('string', 'str'), ('dict', OrderedDict([('string', 'str'), ('dict', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')])), ('*dict2', OrderedDict([('userdef', 'UserDefOne'), ('string', 'str')]))]))]))]),
+ OrderedDict([('struct', 'UserDefNested'), ('data', OrderedDict([('string0', 'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2', OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3', OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
+ OrderedDict([('struct', 'UserDefA'), ('data', OrderedDict([('boolean', 'bool')]))]),
+ OrderedDict([('struct', 'UserDefB'), ('data', OrderedDict([('integer', 'int')]))]),
+ OrderedDict([('struct', 'UserDefC'), ('data', OrderedDict([('string1', 'str'), ('string2', 'str')]))]),
+ OrderedDict([('struct', 'UserDefUnionBase'), ('data', OrderedDict([('string', 'str'), ('enum1', 'EnumOne')]))]),
+ OrderedDict([('struct', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))]),
+ OrderedDict([('struct', 'EventStructOne'), ('data', OrderedDict([('struct1', 'UserDefOne'), ('string', 'str'), ('*enum2', 'EnumOne')]))])]
diff --git a/tests/qapi-schema/union-invalid-base.err b/tests/qapi-schema/union-invalid-base.err
index 3cc82c0..9f63796 100644
--- a/tests/qapi-schema/union-invalid-base.err
+++ b/tests/qapi-schema/union-invalid-base.err
@@ -1 +1 @@ 
-tests/qapi-schema/union-invalid-base.json:8: Base 'int' is not a valid type
+tests/qapi-schema/union-invalid-base.json:8: Base 'int' is not a valid struct
diff --git a/tests/qapi-schema/unknown-expr-key.err b/tests/qapi-schema/unknown-expr-key.err
index 0a35bfd..12f5ed5 100644
--- a/tests/qapi-schema/unknown-expr-key.err
+++ b/tests/qapi-schema/unknown-expr-key.err
@@ -1 +1 @@ 
-tests/qapi-schema/unknown-expr-key.json:2: Unknown key 'bogus' in type 'bar'
+tests/qapi-schema/unknown-expr-key.json:2: Unknown key 'bogus' in struct 'bar'