One more... Eric Blake <ebl...@redhat.com> writes:
[...] > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 90eb3bc..5d0dc91 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py [...] > @@ -560,12 +585,22 @@ def type_name(name): > return c_list_type(name[0]) > return name > > -enum_types = [] > -struct_types = [] > -union_types = [] > +def add_name(name, info, meta, implicit = False): > + global all_names > + if name in all_names: > + raise QAPIExprError(info, > + "%s '%s' is already defined" > + %(all_names[name], name)) We say "struct 'Foo'", and expect the user to know that 'struct' means 'complex type'. It'll do, it's just a development tool. I'm not really happy with 'complex type', though. Isn't a union type complex, too? Anyway, we can clean up our confused terminology later; this series is long enough. > + if not implicit and name[-4:] == 'Kind': > + raise QAPIExprError(info, > + "%s '%s' should not end in 'Kind'" > + %(meta, name)) > + all_names[name] = meta > > -def add_struct(definition): > +def add_struct(definition, info): > global struct_types > + name = definition['type'] > + add_name(name, info, 'struct') > struct_types.append(definition) > > def find_struct(name): [...]