Marc-André Lureau <marcandre.lur...@redhat.com> writes: > qnum_to_double() implicity promotes int now. > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
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.