qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-next v2 01/22] object: Add OBJECT_GET_PARENT


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH for-next v2 01/22] object: Add OBJECT_GET_PARENT_CLASS() macro
Date: Wed, 07 Aug 2013 07:58:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7

Am 07.08.2013 05:36, schrieb Alexey Kardashevskiy:
> This what I would suggest:
> 
> #define OBJECT_GET_PARENT_CLASS(obj, name) \
>     object_class_get_parent(OBJECT_GET_CLASS(ObjectClass, (obj), (name)))
> 
> @name here is just to make sure we are at the right level of the class
> hierarchy.
> 
> And use it like this:
> 
> static void xics_kvm_cpu_setup(XICSState *icp, PowerPCCPU *cpu)
> {
>     XICSStateClass *xsc = XICS_COMMON_CLASS(
>               OBJECT_GET_PARENT_CLASS(OBJECT(icp), TYPE_KVM_XICS));
> ...
> 
> Here both source and destination classes are checked, everyone must be happy 
> :)

In addition to what Peter has explained, I recommend against using my
macro inline, just like we don't use OBJECT_CHECK() inline. Doing so
keeps the uses of TYPE_KVM_XICS together and lets us exchange the
implementation more easily should the need arise.

Btw COMMON_XICS_CLASS() would be a more specific name. (Yes, ARM GIC is
a counter-example.)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]