[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes |
Date: |
Wed, 18 Nov 2015 15:22:31 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 11/18/2015 03:09 PM, Eric Blake wrote:
> On 11/18/2015 10:08 AM, Markus Armbruster wrote:
>> Eric Blake <address@hidden> writes:
>>
>>> In general, designing user interfaces that rely on case
>>> distinction is poor practice. Another benefit of enforcing
>>> a restriction against case-insensitive clashes is that we
>>> no longer have to worry about the situation of enum values
>>> that could be distinguished by case if mapped by c_name(),
>>> but which cannot be distinguished when mapped to C as
>>> ALL_CAPS by c_enum_const() [via c_name(name, False).upper()].
>>> Thus, having the generator look for case collisions up front
>>> will prevent developers from worrying whether different
>>> munging rules for member names compared to enum values as a
>>> discriminator will cause any problems in qapi unions.
>>>
>
>> Another possible improvement is hiding the case-folding logic in
>> methods. Have a QAPISchemaEntity.c_namecase() that returns
>> self.c_name().lower(). Overwrite it in QAPISchemaEvent to return
>> .upper() instead. Use it to make _def_entity() less ugly.
>>
>> Probably not worthwhile unless more uses of .c_namecase() pop up.
>
> I kind of like it. I think I'll propose a 26.5 that implements that,
> then redo 27 on top of it (without reposting the entire series).
Actually, it's not worth splitting that into a separate patch (it was
just 6 lines, and I couldn't find any other uses).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v12 28/36] qapi: Simplify QObject, (continued)
[Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes, Eric Blake, 2015/11/18
Re: [Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes, Eric Blake, 2015/11/18
[Qemu-devel] [PATCH] fixup! qapi: Forbid case-insensitive clashes, Eric Blake, 2015/11/18
Re: [Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes, Markus Armbruster, 2015/11/19
[Qemu-devel] [PATCH v12 19/36] blkdebug: Merge hand-rolled and qapi BlkdebugEvent enum, Eric Blake, 2015/11/18