From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhqto-000510-2Y for qemu-devel@nongnu.org; Mon, 02 Jan 2012 18:02:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rhqtn-0004eB-0u for qemu-devel@nongnu.org; Mon, 02 Jan 2012 18:02:36 -0500 Received: from cantor2.suse.de ([195.135.220.15]:40506 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhqtm-0004e3-QU for qemu-devel@nongnu.org; Mon, 02 Jan 2012 18:02:34 -0500 Message-ID: <4F023733.2070700@suse.de> Date: Tue, 03 Jan 2012 00:01:07 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1324399916-21315-1-git-send-email-aliguori@us.ibm.com> <1324399916-21315-2-git-send-email-aliguori@us.ibm.com> <4EF1E094.6080500@redhat.com> <4EF1EEA4.40209@us.ibm.com> <20111222172531.GA24638@morn.localdomain> <4EF36BB4.1070405@codemonkey.ws> <20111222180018.GA29733@morn.localdomain> <4EF38BA0.1090706@codemonkey.ws> In-Reply-To: <4EF38BA0.1090706@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 01/27] qom: add the base Object class List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Paolo Bonzini , Anthony Liguori , Kevin O'Connor , qemu-devel@nongnu.org, Markus Armbruster Am 22.12.2011 20:57, schrieb Anthony Liguori: > On 12/22/2011 12:00 PM, Kevin O'Connor wrote: >> On Thu, Dec 22, 2011 at 11:41:08AM -0600, Anthony Liguori wrote: >>> On 12/22/2011 11:25 AM, Kevin O'Connor wrote: >>>> Why not declare types with something like the following: >>>> >>>> TypeInfo my_device_info =3D { >>>> .name =3D "my-device", >>>> .parentinfo =3D&device_info, >>>> .instance_size =3D sizeof(MyDevice), >>>> }; >>>> >>>> That is, instead of looking up the TypeImpl via a string, lookup the >>>> TypeImpl via the address of the TypeInfo. (Or possibly store a >>>> pointer to TypeImpl in TypeInfo during registration.) [...] > Yes, thinking about it, I think you're correct that .parent could refer > to some sort of type handle. >=20 > But I think it's a bit nicer to have a string identify the parent type > than an extern struct. I guess it's more a matter of taste than > anything else :-) The advantage of using some kind of symbolic name is that the compiler helps us avoid typos. If we use strings, we defer the checking to the actual instantiation at runtime. Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg