Eric Blake <ebl...@redhat.com> 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 <arm...@redhat.com>
>> ---
>>  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 <ebl...@redhat.com>

Thanks!

Reply via email to