[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 23/50] qapi: add 'if' to struct members and i
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v3 23/50] qapi: add 'if' to struct members and implicit objects members |
Date: |
Sat, 09 Dec 2017 09:18:41 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> check_type() will now accept a DICT { 'type': TYPENAME, 'if': ... }
> instead of a TYPENAME. This is the case in various situations where
> implicit object types are allowed such as commands/events arguments
> and return type, base and branches of union & alternate.
Uh, do you mean where implicit object type are *not* allowed?
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> scripts/qapi.py | 20 ++++++++++++++++----
> tests/qapi-schema/qapi-schema-test.json | 12 +++++++++---
> tests/qapi-schema/qapi-schema-test.out | 4 +++-
> 3 files changed, 28 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index df2a304e8f..15711f96fa 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -696,7 +696,15 @@ def check_type(info, source, value, allow_array=False,
> return
>
> if not allow_dict:
> - raise QAPISemError(info, "%s should be a type name" % source)
> + if isinstance(value, dict) and 'type' in value:
> + check_type(info, source, value['type'], allow_array,
> + allow_dict, allow_optional, allow_metas)
> + if 'if' in value:
> + check_if(value, info)
> + check_unknown_keys(info, value, {'type', 'if'})
> + return
> + else:
> + raise QAPISemError(info, "%s should be a type name" % source)
@allow_dict becomes a misnomer: dictionaries are now always allowed, but
they have different meaning (implicit type vs. named type with
additional attributes).
Rename to @allow_implicit?
>
> if not isinstance(value, OrderedDict):
> raise QAPISemError(info,
[...]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH v3 23/50] qapi: add 'if' to struct members and implicit objects members,
Markus Armbruster <=