qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v10 09/13] qapi: Emit structs used as variants in topological order
Date: Tue, 16 Feb 2016 10:32:10 -0700	[thread overview]
Message-ID: <56C35D1A.1020103@redhat.com> (raw)
In-Reply-To: <87ziv0oadf.fsf@blackfin.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 2884 bytes --]

On 02/16/2016 10:03 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
>> Right now, we emit the branches of union types as a boxed pointer,
>> and it suffices to have a forward declaration of the type.  However,
>> a future patch will swap things to directly use the branch type,
>> instead of hiding it behind a pointer.  For this to work, the
>> compiler needs the full definition of the type, not just a forward
>> declaration, prior to the union that is including the branch type.
>> This patch just adds topological sorting to hoist all types
>> mentioned in a branch of a union to be fully declared before the
>> union itself.  The sort is always possible, because we do not
>> allow circular union types that include themselves as a direct
>> branch (it is, however, still possible to include a branch type
>> that itself has a pointer to the union, for a type that can
>> indirectly recursively nest itself - that remains safe, because
>> that the member of the branch type will remain a pointer, and the
>> QMP representation of such a type adds another {} for each recurring
>> layer of the union type).
>>

>> +    ret = ''
>> +    if variants:
>> +        for v in variants.variants:
>> +            if isinstance(v.type, QAPISchemaObjectType) and \
>> +               not v.type.is_implicit():
>> +                ret += gen_object(v.type.name, v.type.base,
>> +                                  v.type.local_members, v.type.variants)
> 
> PEP 8:
> 
>     The preferred way of wrapping long lines is by using Python's
>     implied line continuation inside parentheses, brackets and
>     braces. Long lines can be broken over multiple lines by wrapping
>     expressions in parentheses. These should be used in preference to
>     using a backslash for line continuation.
> 
> In this case:
> 
>                if (isinstance(v.type, QAPISchemaObjectType) and
>                    not v.type.is_implicit()):

pep8 silently accepted my version, but complains about yours:

scripts/qapi-types.py:65:5: E129 visually indented line with same indent
as next logical line

So the compromise for both of us is added indentation:

        if (isinstance(v.type, QAPISchemaObjectType) and
                not v.type.is_implicit()):
            ret += ...

Or, I could revisit my earlier proposal of:

v.type.is_implicit(QAPISchemaObjectType)

of giving .is_implicit() an optional parameter; if absent, all types are
considered, but if present, the predicate is True only if the type of
the object being queried matches the parameter type name.

Here's the last time we discussed the tradeoffs of the shorter form:
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg02272.html

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-02-16 17:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16  0:20 [Qemu-devel] [PATCH v10 00/13] prune some QAPI visitor cruft (was qapi cleanups subset E) Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 01/13] qapi: Simplify excess input reporting in input visitors Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 02/13] qapi: Forbid empty unions and useless alternates Eric Blake
2016-02-16 16:08   ` Markus Armbruster
2016-02-16 23:18     ` Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 03/13] qapi: Reposition error checks in gen_visit_fields() Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 04/13] qapi: Drop pointless gotos in generated code Eric Blake
2016-02-16 16:27   ` Markus Armbruster
2016-02-16 17:14     ` Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 05/13] qapi-visit: Simplify how we visit common union members Eric Blake
2016-02-16 16:31   ` Markus Armbruster
2016-02-16 17:17     ` Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 06/13] qapi-visit: Unify struct and union visit Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 07/13] qapi-visit: Less indirection in visit_type_Foo_fields() Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 08/13] qapi: Adjust layout of FooList types Eric Blake
2016-02-16 16:55   ` Markus Armbruster
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 09/13] qapi: Emit structs used as variants in topological order Eric Blake
2016-02-16 17:03   ` Markus Armbruster
2016-02-16 17:32     ` Eric Blake [this message]
2016-02-16 21:00       ` Markus Armbruster
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 10/13] qapi: Don't box struct branch of alternate Eric Blake
2016-02-16 19:07   ` Markus Armbruster
2016-02-16 19:53     ` Eric Blake
2016-02-17 14:40       ` Markus Armbruster
2016-02-17 20:34         ` Eric Blake
2016-02-18  8:21           ` Markus Armbruster
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 11/13] qapi: Don't box branches of flat unions Eric Blake
2016-02-17 17:44   ` Markus Armbruster
2016-02-17 20:53     ` Eric Blake
2016-02-18  8:51       ` Markus Armbruster
2016-02-18 16:51         ` Eric Blake
2016-02-18 17:11           ` Markus Armbruster
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 12/13] qapi: Delete unused visit_start_union() Eric Blake
2016-02-17 18:08   ` Markus Armbruster
2016-02-17 21:19     ` Eric Blake
2016-02-18  8:24       ` Markus Armbruster
2016-02-18 16:47         ` Eric Blake
2016-02-16  0:20 ` [Qemu-devel] [PATCH v10 13/13] qapi: Change visit_start_implicit_struct to visit_start_alternate Eric Blake
2016-02-17 18:13   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C35D1A.1020103@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).