From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy Date: Wed, 23 May 2012 14:49:10 +0200 Message-ID: <1337777350.27368.82.camel@Solace> References: <4FB63171.3020102@amd.com> <4FB63EB6.10803@amd.com> <1337351445.16815.19.camel@Solace> <1337351979.22316.123.camel@zakaz.uk.xensource.com> <1337352492.16815.22.camel@Solace> <1337352958.22316.126.camel@zakaz.uk.xensource.com> <20412.49592.945171.764646@mariner.uk.xensource.com> <1337771858.27368.72.camel@Solace> <20412.55808.555103.132979@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1085524624704369550==" Return-path: In-Reply-To: <20412.55808.555103.132979@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Christoph Egger , Ian Campbell , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --===============1085524624704369550== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-5vMTP/8D7KfWpXeW8aRZ" --=-5vMTP/8D7KfWpXeW8aRZ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2012-05-23 at 13:37 +0100, Ian Jackson wrote: > I think that would be best, if you're willing, thanks. >=20 Doing it right now. > I would recommend the use of "case" rather than "default" clauses in > this case. That way if we introduce a new domain type the compiler > will spot all the missing places for us. >=20 That's what I'm doing for any explicit usage of the enum. Problem arises with auto-generated code, e.g., in gentypes.py for build_info related functions. In this case, in fact, the libxl_domain_type enum is the key of the keyed-union. For those cases, I was thinking at something like the below: if isinstance(ty, idl.KeyedUnion): if parent is None: raise Exception("KeyedUnion type must have a parent") s +=3D "switch (%s) {\n" % (parent + ty.keyvar.name) for f in ty.fields: (nparent,fexpr) =3D ty.member(v, f, parent is None) s +=3D "case %s:\n" % f.enumname s +=3D libxl_C_type_dispose(f.type, fexpr, indent + " ", npa= rent) s +=3D " break;\n" + s +=3D "default:\n break;\n"; s +=3D "}\n" Would it make sense? Thanks and Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-5vMTP/8D7KfWpXeW8aRZ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEABECAAYFAk+83MYACgkQk4XaBE3IOsTXwQCfddXbJUtpByXf58Cjkh+8Znma IJEAn0UdpKftRkWKUFNc+pyZDFY1faUa =kTNB -----END PGP SIGNATURE----- --=-5vMTP/8D7KfWpXeW8aRZ-- --===============1085524624704369550== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============1085524624704369550==--