[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 13/19] qapi: Normalize 'if' in check_exprs(), li
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 13/19] qapi: Normalize 'if' in check_exprs(), like other sugar |
Date: |
Mon, 23 Sep 2019 13:59:43 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 9/14/19 10:35 AM, Markus Armbruster wrote:
>> We normalize shorthand to longhand forms in check_expr(): enumeration
>> values with normalize_enum(), feature values with
>> normalize_features(), struct members, union branches and alternate
>> branches with normalize_members(). If conditions are an exception: we
>> normalize them in QAPISchemaEntity.check() and
>> QAPISchemaMember.__init(), with listify_cond(). The idea goes back to
>> commit 2cbc94376e "qapi: pass 'if' condition into QAPISchemaEntity
>> objects", v3.0.0.
>>
>> Normalize in check_expr() instead, with new helper normalize_if().
>>
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>> scripts/qapi/common.py | 26 +++++++++++++++-----------
>> 1 file changed, 15 insertions(+), 11 deletions(-)
>>
>
> Definitely more consistent.
>
>
>> @@ -904,6 +905,7 @@ def check_union(expr, info):
>> check_known_keys(info, "member '%s' of union '%s'" % (key, name),
>> value, ['type'], ['if'])
>> check_if(value, info)
>> + normalize_if(value)
>
> Is it worth combining check_if() and normalize_if() into a single helper
> function, since they always seem to be paired?
The normalize_{enum,members,features}() are similarly paired with
check_keys(). I sidestepped the question whether checking and
normalizing should be fused. We can revisit it later.
> Reviewed-by: Eric Blake <address@hidden>
Thanks!
- [Qemu-devel] [PATCH 15/19] qapi: Clean up around check_known_keys(), (continued)
- [Qemu-devel] [PATCH 15/19] qapi: Clean up around check_known_keys(), Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 17/19] qapi: Fix to .check() empty structs just once, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 07/19] qapi: Use quotes more consistently in frontend error messages, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 09/19] qapi: Remove null from schema language, Markus Armbruster, 2019/09/14
- [Qemu-devel] [PATCH 13/19] qapi: Normalize 'if' in check_exprs(), like other sugar, Markus Armbruster, 2019/09/14