qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v11 19/28] qapi: Change munging of CamelCase enu


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v11 19/28] qapi: Change munging of CamelCase enum values
Date: Fri, 13 Nov 2015 14:37:10 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/13/2015 11:13 AM, Markus Armbruster wrote:

> We need c_name() to protect ticklish identifiers only when its result is
> used as identifier.  Not when it's *part* of an identifier,
> e.g. prefixed with qapi_, or camel_to_upper(type_name) + '_'.
> 
> We can protect even when we don't need to, if that helps keeping things
> simple.

As far as I can tell, as soon as we reserve Q_ in addition to q_, and
fix the bug in c_name() applying munging backwards, then we are safe to
state that any comparison between two names for collisions will be
accurate as long as both sides of the comparison picked the same value
of c_name(name, protect), whether or not our later use of that name is
done with protect=True or protect=False.

> 
> The obvious simple way to check for collisions works like this:
> 
> 1. Every QAPI name is mangled in exactly one way, modulo case: always
>    with c_name(), and always with the same value of protect.

That part is easy.  Maybe I could even reuse guardname(name) instead of
c_name(name).upper(), although I don't know that it buys any clarity.

> 
> 2. We require the mangled name to be case-insensitively unique in its
>    name space.

That part is a bit harder: we unfortunately have the existing clash
between the command 'stop' and the event 'STOP'.  I didn't find any
other clashes in existing clients, though (phew), so we can either
whitelist just that one, or more likely, set up separate namespaces for
commands vs. events when doing the case collision tests.

But it's a bummer that it won't be quite as easy as I had hoped (using a
single dictionary for both lookups and case collisions is easier than
having two dictionaries to separate namespaces, while still searching
both dictionaries for lookups).

At any rate, I'm playing with patches along these lines.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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