[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v7 25/39] qapi: Require valid names
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v7 25/39] qapi: Require valid names |
Date: |
Mon, 04 May 2015 09:26:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 04/29/2015 07:06 AM, Eric Blake wrote:
>> Previous commits demonstrated that the generator overlooked various
>> bad naming situations:
>> - types, commands, and events need a valid name
>> - enum members must be valid names, when combined with prefix
>> - union and alternate branches cannot be marked optional
>>
>
>> regex, this patch just uses a broader combination that allows both
>> upstream and downstream names, as well as a small hack that
>> realizes that any enum name is merely a suffix to an already valid
>> name prefix (that is, any enum name is valid if prepending _ fits
>> the normal rules).
>>
>
>> + # Enum members can start with a digit, because the generated C
>> + # code always prefixes it with the enum name
>> + if enum_member:
>> + membername = "_%s" %membername
>> + if not valid_name.match(membername):
>> + raise QAPIExprError(expr_info,
>
> Python question: Would it be any simpler to write:
>
> membername = '_' + membername
>
> and if so, do I need to squash anything in?
I find + easier to read here, even when compare to a correctly spaced
"_%s" % membername.
I think we have enough squash candidates to justify a quick v8. I'd
prefer that, as I I haven't checked v7 anyway :)