qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/3] qom: add unit test for Interfaces
Date: Mon, 18 Jun 2012 15:51:30 +0200	[thread overview]
Message-ID: <4FDF3262.4090400@suse.de> (raw)
In-Reply-To: <CAEgOgz6ErNdJ-A8uFzWX+hVBZGiZQG3DoRDKFYTdWm5WrExjfA@mail.gmail.com>

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.
> 
> 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?
> 
>  They are just classes.  But 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.

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

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2012-06-18 13:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-13 20:54 [Qemu-devel] [PATCH 0/3] qom: refactor Interfaces Anthony Liguori
2012-06-13 20:55 ` [Qemu-devel] [PATCH 1/3] tests: fix dependency inclusion Anthony Liguori
2012-06-14 13:08   ` Andreas Färber
2012-06-14 13:12     ` Paolo Bonzini
2012-06-13 20:55 ` [Qemu-devel] [PATCH 2/3] qom: reimplement Interfaces Anthony Liguori
2012-06-16 10:47   ` Peter Crosthwaite
2012-06-22 11:29     ` Peter Crosthwaite
2012-06-13 20:55 ` [Qemu-devel] [PATCH 3/3] qom: add unit test for Interfaces Anthony Liguori
2012-06-16 10:31   ` Peter Crosthwaite
2012-06-18 13:26     ` Anthony Liguori
2012-06-18 13:46       ` Peter Crosthwaite
2012-06-18 13:51         ` Andreas Färber [this message]
2012-06-18 14:54           ` Anthony Liguori
2012-06-14  9:10 ` [Qemu-devel] [PATCH 0/3] qom: refactor Interfaces Paolo Bonzini
2012-06-15  4:58 ` Peter Crosthwaite

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FDF3262.4090400@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@petalogix.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).