From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVjTz-0003sn-MQ for qemu-devel@nongnu.org; Tue, 16 Feb 2016 12:32:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVjTv-0005eL-Ll for qemu-devel@nongnu.org; Tue, 16 Feb 2016 12:32:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVjTv-0005eB-Dr for qemu-devel@nongnu.org; Tue, 16 Feb 2016 12:32:11 -0500 References: <1455582057-27565-1-git-send-email-eblake@redhat.com> <1455582057-27565-10-git-send-email-eblake@redhat.com> <87ziv0oadf.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56C35D1A.1020103@redhat.com> Date: Tue, 16 Feb 2016 10:32:10 -0700 MIME-Version: 1.0 In-Reply-To: <87ziv0oadf.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="R5o5FdlkFgdSxGNRdVS98efe7P68pGbit" Subject: Re: [Qemu-devel] [PATCH v10 09/13] qapi: Emit structs used as variants in topological order List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --R5o5FdlkFgdSxGNRdVS98efe7P68pGbit Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/16/2016 10:03 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> 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 =3D '' >> + if variants: >> + for v in variants.variants: >> + if isinstance(v.type, QAPISchemaObjectType) and \ >> + not v.type.is_implicit(): >> + ret +=3D gen_object(v.type.name, v.type.base, >> + v.type.local_members, v.type.varian= ts) >=20 > PEP 8: >=20 > 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. >=20 > In this case: >=20 > 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 +=3D ... 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 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --R5o5FdlkFgdSxGNRdVS98efe7P68pGbit Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWw10aAAoJEKeha0olJ0Nqq8UH/iwaWQQ1KWHWFwZQjwf8EcHu J1W4603h6aYHPw3fnOH3Jgj+HHtAdHwxdS9gFELITUwHms7/n7gQ9R3gQyUufJJp bNOmKfMqcghK4OyiNl4Y7/gDH/I6hDFRYv74NIthNHAGhbxa596eAV9p2WybHlP/ D3fIKVn6rN/+4Jqdv2JrOTkZxzhGZkfIEs3Pxf+aH5qVl9isWr6220aktYGFjVN8 CtE4fcTCBCadnuBePZUStQg1f8bIcGRQHT3CjXjW7i9MIL2U8jFnh4oXUS/7jhd8 mxc8nVTlGs2Ga+Bo1ymob29roGKIigzecKLj2OooCyo4TeLftj/ngdGKXo0RPeE= =3/w3 -----END PGP SIGNATURE----- --R5o5FdlkFgdSxGNRdVS98efe7P68pGbit--