qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH RFC v2 30/47] qapi: De-duplicate enum code gener


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH RFC v2 30/47] qapi: De-duplicate enum code generation
Date: Thu, 23 Jul 2015 06:46:30 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

On 07/01/2015 02:22 PM, Markus Armbruster wrote:
> Duplicated in commit 21cd70d.  Yes, we can't import qapi-types, but
> that's no excuse.  Move the helpers from qapi-types.py to qapi.py, and
> replace the duplicates in qapi-event.py.
> 
> The generated event enumeration type gains a _MAX member,

Not quite; the _MAX member was already there, but done by hand [1]
instead of by common code.

> and its
> lookup table becomes const-correct (see commit 2e4450f).

Maybe what you meant instead of gaining _MAX was that it also gains C99
initializers:

-const char *QAPIEvent_lookup[] = {
-    "ACPI_DEVICE_OST",
-    "BALLOON_CHANGE",
...
-    "WATCHDOG",
-    NULL,
+const char *const QAPIEvent_lookup[] = {
+    [QAPI_EVENT_ACPI_DEVICE_OST] = "ACPI_DEVICE_OST",
+    [QAPI_EVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",

Overall, a good change.

> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  scripts/qapi-event.py | 67 
> +++------------------------------------------------
>  scripts/qapi-types.py | 55 ------------------------------------------
>  scripts/qapi.py       | 55 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 59 insertions(+), 118 deletions(-)

Since only the commit message needs tweaking,
Reviewed-by: Eric Blake <address@hidden>

> 
> diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
> index aec2d32..aed45d6 100644
> --- a/scripts/qapi-event.py
> +++ b/scripts/qapi-event.py
> @@ -153,63 +153,6 @@ def generate_event_implement(api_name, event_name, 
> params):

> -    # append automatically generated _MAX value
> -    enum_max_value = c_enum_const(event_enum_name, "MAX")
> -    enum_values = event_enum_values + [ enum_max_value ]

[1]


-- 
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]