qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: peter.crosthwaite@xilinx.com
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com,
	qemu-devel@nongnu.org, pbonzini@redhat.com,
	edgar.iglesias@gmail.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [RFC PATCH v1 3/7] qdev-core: Introduce DEVICE super class cast macros
Date: Tue, 18 Jun 2013 13:12:02 +0300	[thread overview]
Message-ID: <20130618101201.GB26066@redhat.com> (raw)
In-Reply-To: <7ddd1c80f6996331c7ff158c858d456cf62170cc.1371548267.git.peter.crosthwaite@xilinx.com>

On Tue, Jun 18, 2013 at 07:45:36PM +1000, peter.crosthwaite@xilinx.com wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> Add macros DEVICE_SUPER_CLASS and DEVICE_GET_SUPER_CLASS. These are the
> similar to their respective non SUPER versions, except instead of
> returning the class object for the concrete class, they return their
> parent classes implementation (usually some form of abstract class).
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> 
>  include/hw/qdev-core.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 7fbffcb..96647c4 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -16,6 +16,10 @@ enum {
>  #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
>  #define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
>  #define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
> +#define DEVICE_SUPER_CLASS(klass, typename) \
> +    DEVICE_CLASS(object_class_get_super(OBJECT_CLASS(klass), typename))
> +#define DEVICE_GET_SUPER_CLASS(obj, typename) \
> +    DEVICE_SUPER_CLASS(DEVICE_GET_CLASS(obj), typename)

DEVICE_GET_SUPER_CLASS is not a great name. It actually gets you
a device not a class.

I know this mirrors DEVICE_GET_CLASS that's not
a great name too.

Generally in cases where we change the type of object but in fact return
same pointer, it would be better to rename _GET to _CAST I think.

>  
>  typedef int (*qdev_initfn)(DeviceState *dev);
>  typedef int (*qdev_event)(DeviceState *dev);
> -- 
> 1.8.3.rc1.44.gb387c77.dirty

  reply	other threads:[~2013-06-18 10:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18  9:43 [Qemu-devel] [RFC PATCH v1 0/7] QOM Super class access peter.crosthwaite
2013-06-18  9:44 ` [Qemu-devel] [RFC PATCH v1 1/7] target-arm/cpu.c: delete un-needed instance/class sizes peter.crosthwaite
2013-06-18  9:58   ` Andreas Färber
2013-06-18  9:44 ` [Qemu-devel] [RFC PATCH v1 2/7] qom: Add super class accessor peter.crosthwaite
2013-06-18  9:45 ` [Qemu-devel] [RFC PATCH v1 3/7] qdev-core: Introduce DEVICE super class cast macros peter.crosthwaite
2013-06-18 10:12   ` Michael S. Tsirkin [this message]
2013-06-18  9:46 ` [Qemu-devel] [RFC PATCH v1 4/7] qom/cpu: Introduce CPU " peter.crosthwaite
2013-06-18  9:47 ` [Qemu-devel] [RFC PATCH v1 5/7] target-arm: Remove ARMCPUClass peter.crosthwaite
2013-06-18  9:47 ` [Qemu-devel] [RFC PATCH v1 6/7] target-microblaze: Remove MicroblazeCPUClass peter.crosthwaite
2013-06-18  9:48 ` [Qemu-devel] [RFC PATCH v1 7/7] i8254: Remove [KVM]PITClass peter.crosthwaite
2013-06-18 10:12 ` [Qemu-devel] [RFC PATCH v1 0/7] QOM Super class access Andreas Färber
2013-06-18 10:20   ` Peter Crosthwaite
2013-06-18 10:23 ` Michael S. Tsirkin
2013-06-18 10:35   ` Peter Crosthwaite
2013-06-18 10:39     ` Michael S. Tsirkin
2013-06-18 10:44       ` Peter Crosthwaite
2013-06-18 10:48         ` Michael S. Tsirkin
2013-06-18 10:45       ` Andreas Färber
2013-06-18 10:41   ` Andreas Färber
2013-06-18 10:45     ` Michael S. Tsirkin
2013-06-19  1:44     ` Hu Tao

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=20130618101201.GB26066@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --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).