From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbaKS-0007Mm-TY for qemu-devel@nongnu.org; Fri, 27 Mar 2015 15:54:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbaKO-000872-7n for qemu-devel@nongnu.org; Fri, 27 Mar 2015 15:54:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbaKN-00086s-W3 for qemu-devel@nongnu.org; Fri, 27 Mar 2015 15:54:00 -0400 Message-ID: <5515B553.2010606@redhat.com> Date: Fri, 27 Mar 2015 13:53:55 -0600 From: Eric Blake MIME-Version: 1.0 References: <1427227433-5030-1-git-send-email-eblake@redhat.com> <1427227433-5030-17-git-send-email-eblake@redhat.com> <87wq22ubb8.fsf@blackfin.pond.sub.org> In-Reply-To: <87wq22ubb8.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rbv4pUq1pKDfOs7AU6KL3KNJAR2bVoJiG" Subject: Re: [Qemu-devel] [PATCH v5 16/28] qapi: Better error messages for duplicated expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, lcapitulino@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, wenchaoqemu@gmail.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rbv4pUq1pKDfOs7AU6KL3KNJAR2bVoJiG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/27/2015 01:52 AM, Markus Armbruster wrote: > One more... >=20 > Eric Blake writes: >=20 > [...] >> diff --git a/scripts/qapi.py b/scripts/qapi.py >> index 90eb3bc..5d0dc91 100644 >> --- a/scripts/qapi.py >> +++ b/scripts/qapi.py > [...] >> @@ -560,12 +585,22 @@ def type_name(name): >> return c_list_type(name[0]) >> return name >> >> -enum_types =3D [] >> -struct_types =3D [] >> -union_types =3D [] >> +def add_name(name, info, meta, implicit =3D False): >> + global all_names >> + if name in all_names: >> + raise QAPIExprError(info, >> + "%s '%s' is already defined" >> + %(all_names[name], name)) >=20 > We say "struct 'Foo'", and expect the user to know that 'struct' means > 'complex type'. It'll do, it's just a development tool. In fact, I considered making it "type 'Foo'", to match that the item is declared with { 'type':'Foo' ...} and not { 'struct':'Foo' ...}. But type is an ambiguous word. I'm half tempted to do a global search-and-replace of s/'type'/'struct'/ in the json files, since 'union' is also a type. Obviously as its own patch. >=20 > I'm not really happy with 'complex type', though. Isn't a union type > complex, too? Anyway, we can clean up our confused terminology later; > this series is long enough. Hmm. If I _do_ the global rename, then we have a nice hierarchy: type - simple type: built-in, enum - alternate - complex type: struct, union --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rbv4pUq1pKDfOs7AU6KL3KNJAR2bVoJiG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVFbVTAAoJEKeha0olJ0NqGYMH/jUwRmZcwd2qRv3qUDZ+a9bl fyQHKhU7oWdIT801s9F5tPxqvnNgB+SXKIQGZucpjxzaz6+0UvIW5NqiQa6+lVmq SQ9BTwyVykhexEFucWSzU0vGBPuvU4xBmNLv2ALFjyekhASM3qwvYDSyMg77BLNf R5qewPYuP2nuo8aFye5GyRj/gzjQwIDHU3wt12alcu6eqhthkIrAMsn3DgVKqtNP Qvzk/oWRRhUY6JrKtsaqf0dVIPKBq7vx+TOz6kHS1q/z9JdadwiDENUfyxl1WUx/ t3VkPCtTE9IWrA+0mE4Vlj8skW7LE+GsNhUfFtM2dhSKUn+LJ/jQeBi0lzW2gks= =HDnW -----END PGP SIGNATURE----- --rbv4pUq1pKDfOs7AU6KL3KNJAR2bVoJiG--