qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 05/17] qapi: remove promote_int


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 05/17] qapi: remove promote_int
Date: Thu, 11 May 2017 19:30:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Marc-André Lureau <address@hidden> writes:

> qnum_to_double() implicity promotes int now.
>
> Signed-off-by: Marc-André Lureau <address@hidden>

qnum_to_double() works for both for integers and doubles.  That's not
really new; it's what we've always done when we need a double, see
qobject_input_type_number() before your patch.

promote_int is about visit_start_alternate().  It's called before the
switch over the alternate object's member type (of type QType).

Input visitors allocate the alternate object, and set member type to a
value determined by the input.  promote_int = true asks the input
visitor to set type to QTYPE_QFLOAT when the input would otherwise call
for QTYPE_QINT.

Non-input visitors leave member type alone.

The generated visitors pass promote_int = true exactly when QTYPE_QINT
isn't a valid type.  Without that, we'd have to monkey-patch QTYPE_QINT
to QTYPE_QFLOAT in every generated visitor, just in case it's used with
an input visitor.  Not exactly elegant, but it works.

The only input visitor that implements alternates right now is the
QObject input visitor.

The previous patch fused QTYPE_QINT and QTYPE_QFLOAT, rendering
promote_int useless and unused.

Here's my attempt at a commit message:

    qapi: Remove visit_start_alternate() parameter promote_int

    Before the previous commit, parameter promote_int = true made
    visit_start_alternate() with an input visitor avoid QTYPE_QINT
    variants and create QTYPE_QFLOAT variants instead.  This was used
    where QTYPE_QINT variants were invalid.

    The previous commit fused QTYPE_QINT with QTYPE_QFLOAT, rendering
    rendering promote_int useless and unused.

Patch looks good to me.



reply via email to

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