From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uosso-0008Ql-59 for qemu-devel@nongnu.org; Tue, 18 Jun 2013 06:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uossh-0006bw-Vs for qemu-devel@nongnu.org; Tue, 18 Jun 2013 06:11:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uossh-0006bn-Nc for qemu-devel@nongnu.org; Tue, 18 Jun 2013 06:11:19 -0400 Date: Tue, 18 Jun 2013 13:12:02 +0300 From: "Michael S. Tsirkin" Message-ID: <20130618101201.GB26066@redhat.com> References: <7ddd1c80f6996331c7ff158c858d456cf62170cc.1371548267.git.peter.crosthwaite@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ddd1c80f6996331c7ff158c858d456cf62170cc.1371548267.git.peter.crosthwaite@xilinx.com> Subject: Re: [Qemu-devel] [RFC PATCH v1 3/7] qdev-core: Introduce DEVICE super class cast macros List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 On Tue, Jun 18, 2013 at 07:45:36PM +1000, peter.crosthwaite@xilinx.com wrote: > From: Peter Crosthwaite > > 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 > --- > > 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