[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.
- Re: [Qemu-devel] [PATCH 04/17] qapi: merge QInt and QFloat in QNum, (continued)
Re: [Qemu-devel] [PATCH 04/17] qapi: merge QInt and QFloat in QNum, Markus Armbruster, 2017/05/12
Re: [Qemu-devel] [PATCH 04/17] qapi: merge QInt and QFloat in QNum, Markus Armbruster, 2017/05/12
[Qemu-devel] [PATCH 05/17] qapi: remove promote_int, Marc-André Lureau, 2017/05/09
- Re: [Qemu-devel] [PATCH 05/17] qapi: remove promote_int,
Markus Armbruster <=
[Qemu-devel] [PATCH 06/17] qnum: add uint type, Marc-André Lureau, 2017/05/09
[Qemu-devel] [PATCH 07/17] json: learn to parse uint64 numbers, Marc-André Lureau, 2017/05/09
[Qemu-devel] [PATCH 08/17] qapi: update the qobject visitor to use QUInt, Marc-André Lureau, 2017/05/09