qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 16/28] qapi: Better error messages for duplic


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v5 16/28] qapi: Better error messages for duplicated expressions
Date: Fri, 27 Mar 2015 08:52:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

One more...

Eric Blake <address@hidden> 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):
[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]