From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgm8q-0005B7-Tw for qemu-devel@nongnu.org; Tue, 29 Sep 2015 00:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgm8l-0002Te-VI for qemu-devel@nongnu.org; Tue, 29 Sep 2015 00:03:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgm8l-0002TR-OW for qemu-devel@nongnu.org; Tue, 29 Sep 2015 00:03:43 -0400 References: <1442872682-6523-1-git-send-email-eblake@redhat.com> <1442872682-6523-13-git-send-email-eblake@redhat.com> <87fv1yhfdm.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <560A0D9D.9000303@redhat.com> Date: Mon, 28 Sep 2015 22:03:41 -0600 MIME-Version: 1.0 In-Reply-To: <87fv1yhfdm.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OWJxrkGeif0gilQX7aTec0Iv4epnX5lpd" Subject: Re: [Qemu-devel] [PATCH v5 12/46] qapi: Track location that created an implicit type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: marcandre.lureau@redhat.com, DirtY.iCE.hu@gmail.com, qemu-devel@nongnu.org, ehabkost@redhat.com, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --OWJxrkGeif0gilQX7aTec0Iv4epnX5lpd Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/28/2015 06:56 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> A future patch will enable error detection in the various >> QapiSchema check() methods. But since all errors have to >> have an associated 'info' location, we need a location to >> be associated with all implicit types. Easiest is to reuse >> the location of the enclosing entity that includes the >> dictionary defining the implicit type. >> >> While at it, we were always passing None as the location of >> array types, making that parameter useless; sharing the >> location (if any) of the underlying element type makes sense. >=20 > The parameter is useless only because all array types are implicit. > Once we change that, it won't be anymore. I guess it depends whether I pass in the existing info when creating the array or determine the info when resolving the string name of the array element during check() (it will ultimately be the same info either way, it's just a question of which approach looks cleaner for getting the information set). >> @@ -917,6 +917,7 @@ class QAPISchemaArrayType(QAPISchemaType): >> def check(self, schema): >> self.element_type =3D schema.lookup_type(self._element_type_n= ame) >> assert self.element_type >> + self._info =3D self.element_type._info >> >> def json_type(self): >> return 'array' >=20 > Implicit array type's info is the element type's info. Okay. >=20 >> @@ -928,6 +929,7 @@ class QAPISchemaArrayType(QAPISchemaType): >> class QAPISchemaObjectType(QAPISchemaType): >> def __init__(self, name, info, base, local_members, variants): >> QAPISchemaType.__init__(self, name, info) >> + assert info or name =3D=3D ':empty' >=20 > I think what we really want to assert is "we got info unless this is a > built-in entity", in QAPISchemaEntity.__init__(). To do that, arrays would have to pass info in to __init__() rather than deferring to check() as I did above. >=20 > Built-in entities are exactly the types defined by > QAPISchema._def_predefineds(), currently the built-in types and > ':empty'. I'm still wondering how best to test that, but agree that hoisting the assert into QAPISchemaEntity instead of just in QAPISchemaObjectType would be nice. Maybe some sort of boolean switch, initially off, then turned on after _def_predefineds() is called, and assuming that no types other than predefineds are initialized prior to that point. >=20 > Missing: implicit enum types' info. I'll add it; should be the info of the containing union type that caused the implicit enum. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --OWJxrkGeif0gilQX7aTec0Iv4epnX5lpd 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/ iQEcBAEBCAAGBQJWCg2dAAoJEKeha0olJ0NqL80IAJYgqhrmd1hAMq//499OeU1m D363/JKIUZaDbkNT5ATakuMyWuABjpzra2pLHxwNPlHatKDa1zeIagfxMnifgCDC IbXGcuIdy5zGfeJ1vvwpJOyozk8FYIuoOpe6XVyf86s/QcqsGExSJcRUsIE37zES 0Ky2ztxGYIhr+vGoAZjomLoYYSKiFqdIDrrQG5Q2EShxctymJkoVmf2E6qdJ9i9b kgYkij6Zvi1tHP4mpDN/IiyfB5eeORz+KNvFN9SaiwytSDlPuKItHli+U/TX8Om4 FlJxLYgkjhmxp0LuJ+9jzGPVO8I4SB+n1fcZqGKeHGchPDY5/rpwZv4AqCYZd/Y= =YP4I -----END PGP SIGNATURE----- --OWJxrkGeif0gilQX7aTec0Iv4epnX5lpd--