From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcMn-0005W5-0C for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgcMh-0001De-1b for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:51:40 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51103 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcMg-0001DB-O3 for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:51:34 -0400 Message-ID: <4FDF3262.4090400@suse.de> Date: Mon, 18 Jun 2012 15:51:30 +0200 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1339620902-4481-1-git-send-email-aliguori@us.ibm.com> <1339620902-4481-4-git-send-email-aliguori@us.ibm.com> <4FDF2C6B.2010607@us.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/3] qom: add unit test for Interfaces List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: Paolo Bonzini , Anthony Liguori , qemu-devel@nongnu.org Am 18.06.2012 15:46, schrieb Peter Crosthwaite: >>>> +#define HERBIVORE(obj) \ >>>> + INTERFACE_CHECK(Herbivore, (obj), TYPE_HERBIVORE) >>>> + >>>> +typedef struct Herbivore >>>> +{ >>>> + Object obj; >>>> +} Herbivore; >>> >>> >>> All this is doing is saying Herbivores are Objects right? A user cant >>> add anything to this struct given that interfaces are stateless so >>> could this be simplified to >>> >>> typedef Object Herbivore; >> >> >> This is admittedly a little wierd... >> >> Interfaces don't exist as Objects in QOM. >=20 > Not in the sense that they used too, but all objects that implement an > interface are still OBJECTs just through the inheritance path of their > concrete class, which is the point of this struct yes? >=20 > They are just classes. But it's >> very handy to be able to have a Herbivore type that you can cast objec= ts to. >> >=20 > Yes I agree in full, but the typedef definition is functionally > equivalent to what you have there, and removes the temptation to add > fields to the object type. Having a skeletal struct there gives the > illusion to readers that interface objects are in someway extensible. Why have a typedef at all then? You can just use Object directly. If that ever changes it leads to all kinds of problems (well, necessary adjustments), as seen in the pci_host series. 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