From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcHt-0002Oi-He for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:46:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgcHR-0008Mt-IW for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:46:37 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:36499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcHR-0008Mb-AT for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:46:09 -0400 Received: by bkwj10 with SMTP id j10so4278965bkw.4 for ; Mon, 18 Jun 2012 06:46:06 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4FDF2C6B.2010607@us.ibm.com> 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> Date: Mon, 18 Jun 2012 23:46:06 +1000 Message-ID: From: Peter Crosthwaite 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: Anthony Liguori Cc: Paolo Bonzini , Andreas Faerber , qemu-devel@nongnu.org >>> +#define HERBIVORE(obj) \ >>> + =A0 =A0INTERFACE_CHECK(Herbivore, (obj), TYPE_HERBIVORE) >>> + >>> +typedef struct Herbivore >>> +{ >>> + =A0 =A0Object 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. 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? =A0They are just classes. =A0But it's > very handy to be able to have a Herbivore type that you can cast objects = to. > 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. > I probably need to respin this though. =A0INTERFACE_CHECK() asserts that = an > object implements the interface class and then just returns the obj and > casts it to the dummy Interface object type. > > A better approach would be to just teach object_dynamic_cast to do this f= or > anythign that's an interface type. =A0That would fix the link problem you > pointed out too. =A0I'll spin a v2. Please see my patch, I have a little 3 patch series up on the list. that starts with your v1, does the axi-stream stuff then fixes that bug. Regards, Peter > > Regards, > > Anthony Liguori > >> >> ? >> >>> + >>> +typedef struct HerbivoreClass >>> +{ >>> + =A0 =A0InterfaceClass parent; >>> + >>> + =A0 =A0void (*feed_greens)(Herbivore *obj);