From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abqri-0006yk-Vm for qemu-devel@nongnu.org; Fri, 04 Mar 2016 09:38:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abqre-0002ew-4R for qemu-devel@nongnu.org; Fri, 04 Mar 2016 09:38:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abqrd-0002ej-Tl for qemu-devel@nongnu.org; Fri, 04 Mar 2016 09:37:58 -0500 References: <1456443528-13901-1-git-send-email-eblake@redhat.com> <1456443528-13901-20-git-send-email-eblake@redhat.com> <87twkn3d1f.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56D99DC4.1060507@redhat.com> Date: Fri, 4 Mar 2016 07:37:56 -0700 MIME-Version: 1.0 In-Reply-To: <87twkn3d1f.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="a4qfqPOMIjF9xh44eg7o7a6e8Tp4tT4fS" Subject: Re: [Qemu-devel] [PATCH v2 19/19] qapi: Make c_type() more OO-like 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) --a4qfqPOMIjF9xh44eg7o7a6e8Tp4tT4fS Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/03/2016 06:29 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> QAPISchemaType.c_type() was a bit awkward. Rather than having two >> optional orthogonal boolean flags that should never both be true, >> and where all callers pass a compile-time constant, provide three >> different method names that can be overridden as needed, and where >> the caller just uses the right variant. It requires slightly more >> Python, but is arguably easier to read. >> >> + >> + # Use of a type in a struct declaration >> + def c_unboxed_type(self): >> + return self.c_type() >=20 > This one I find bit problematic. We only ever box object types, but > those we box almost everywhere. This method gets used in the select > places where we don't box them (currently just one). I'm afraid "used > in a struct declaration" isn't a good definition. >=20 > I initially suggested to define c_unboxed_type() only for > QAPISchemaObjectType because there boxed vs. unboxed makes sense. > However, your code would like to call it for arbitrary types. qapi-types.py is calling it for arbitrary types thanks to QAPI alternates. If I didn't put it here, then the code there needs to special-case for isinstance(type, QAPISchemaObjectType) before calling =2Ec_unboxed_type(), and fall back to .c_type() otherwise. >=20 > Perhaps we can cure my belly-ache with nothing more than carefully > drafted function contracts. Let me try. >=20 > # Return the C type for common use. > # For the types we commonly box, this is a pointer type. > def c_type(self): >=20 > # Return the C type to be used in a parameter list. > def c_param_type(self): >=20 > # Return the C type to be used where we suppress boxing. > def c_unboxed_type(self): Sure, that helps. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --a4qfqPOMIjF9xh44eg7o7a6e8Tp4tT4fS 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/ iQEcBAEBCAAGBQJW2Z3EAAoJEKeha0olJ0NqBp0H/1abpl4a8QHb+KYNdf+s9/zV QLdnaRI1UpI4gXrVOWyh3BH9PcryhzOOei/E8/4nQSNkPphvadoHp+8ir5Os+wT7 nlTBaaXswoaJkKwIi3Wxnvuf/3XUMObzgl7ZdYMAgkbnqnR6sKFbT9yquXPfqrcr DkdUshix57wHrbduN3bwZ276+jOBfbqBZPYD4vBfOk4Cx1PXuZPTzlXLHoZOfppd UWbpYPTX9kOT+jM04qhn1RJWzxzfXHyWhLA6JKjekw86OeItuY49MUiganMe/6u9 YOI2wUgkLmPdAsHNoFyoufkCBVfemd2UE53Juz+5o/mld53SWYloJvl8li/qSNY= =tmLr -----END PGP SIGNATURE----- --a4qfqPOMIjF9xh44eg7o7a6e8Tp4tT4fS--